[R] Loop over folder files

David Winsemius dwinsemius at comcast.net
Mon Aug 22 21:51:53 CEST 2016


> On Aug 22, 2016, at 10:40 AM, Juan Ceccarelli Arias <jfca283 at gmail.com> wrote:
> 
> I removed the data,frame=True...
> I obtain this warnings...
> Error in read.dta(fuente[i]) : not a Stata version 5-12 .dta file

Well, that seems fairly self-explanatory. What version of Stata are you using and does it have capacity to write to one of hte versions that are supported by read.dta?

-- 
David.


> In addition: There were 50 or more warnings (use warnings() to see the
> first 50)
> 
> the warnings() throws this
> Warning messages:
> 1: In `levels<-`(`*tmp*`, value = if (nl == nL) as.character(labels) else
> paste0(labels,  ... :
>  duplicated levels in factors are deprecated
> 2: In `levels<-`(`*tmp*`, value = if (nl == nL) as.character(labels) else
> paste0(labels,  ... :
>  duplicated levels in factors are deprecated
> 3: In `levels<-`(`*tmp*`, value = if (nl == nL) as.character(labels) else
> paste0(labels,  ... :
>  duplicated levels in factors are deprecated
> 4: In `levels<-`(`*tmp*`, value = if (nl == nL) as.character(labels) else
> paste0(labels,  ... :
>  duplicated levels in factors are deprecated
> 5: In `levels<-`(`*tmp*`, value = if (nl == nL) as.character(labels) else
> paste0(labels,  ... :
>  duplicated levels in factors are deprecated
> 
> 
> 
> On Mon, Aug 22, 2016 at 2:32 PM, <ruipbarradas at sapo.pt> wrote:
> 
>> Hello,
>> 
>> That argument doesn't exist, hence the error.
>> Read the help page ?read.dta more carefully. You will see that already
>> read.dta reads into a data.frame.
>> 
>> Hope this helps,
>> 
>> Rui Barradas
>> 
>> 
>> Citando Juan Ceccarelli Arias <jfca283 at gmail.com>:
>> 
>> Hi
>> I need to apply some code over some stata files that are in folder.
>> I've wrote this
>> 
>> library(foreign)
>> 
>> fuente=list.files("C:/Users/Jceccarelli/Bases/Stata", pattern="dta$",
>> full.names=FALSE)
>> 
>> for (i in 1:length(fuente)){
>> 
>> xxx=read.dta(fuente[i], to.data.frame=TRUE)
>> 
>> 
>> }
>> 
>> But i get this error
>> 
>> Error in read.dta(fuente[i], to.data.frame = TRUE) :
>> unused argument (to.data.frame = TRUE)
>> 
>> What am i doing wrong?
>> 
>>        [[alternative HTML version deleted]]
>> 
>> ______________________________________________
>> R-help at r-project.org mailing list -- To UNSUBSCRIBE and more, see
>> https://stat.ethz.ch/mailman/listinfo/r-help
>> PLEASE do read the posting guide http://www.R-project.org/
>> posting-guide.htmland provide commented, minimal, self-contained,
>> reproducible code.
>> 
>> 
>> 
>> 
> 
> 	[[alternative HTML version deleted]]
> 
> ______________________________________________
> R-help at r-project.org mailing list -- To UNSUBSCRIBE and more, see
> https://stat.ethz.ch/mailman/listinfo/r-help
> PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
> and provide commented, minimal, self-contained, reproducible code.

David Winsemius
Alameda, CA, USA



More information about the R-help mailing list