Re: [R] Loop over folder files

2016-08-24 Thread Juan Ceccarelli Arias
Ok. Please, declare this issue as solved. And thanks again for your help. On Wed, Aug 24, 2016 at 2:18 PM, wrote: > Maybe it's better to open a new thread. > > Rui Barradas > > > Citando Juan Ceccarelli Arias : > > The error wasn't in the loop. It was in the file list. > It's running now because

Re: [R] Loop over folder files

2016-08-24 Thread Juan Ceccarelli Arias
The error wasn't in the loop. It was in the file list. It's running now because i added full.names option to TRUE fuente=list.files("C:/Users/Jceccarelli/Bases/Stata", pattern="dta$", full.names=T) Now R can proccess the data. Now it callapses or stops because other kind of error. ¿Should i open an

Re: [R] Loop over folder files

2016-08-24 Thread ruipbarradas
Maybe it's better to open a new thread. Rui Barradas   Citando Juan Ceccarelli Arias : > The error wasn't in the loop. It was in the file list. > It's running now because i added full.names option to TRUE > fuente=list.files("C:/Users/Jceccarelli/Bases/Stata", > pattern="dta$", full.names=T) >

Re: [R] Loop over folder files

2016-08-24 Thread Juan Ceccarelli Arias
I just doesn't work... Im loading the read,dta13 package already. When i try to perform a simple table(sex), i received the "File not found" message. However, if i load the data using the file.choose() option inside read.dta13, i can open the stata file. I don't know what am i doing wrong... On Tu

Re: [R] Loop over folder files

2016-08-24 Thread ruipbarradas
Hello, That means that probably the files are in a different folder/directory. Use getwd() to see what is your current directory and setwd("path/to/files") to set the right place where the files can be found. Rui Barradas   Citando Juan Ceccarelli Arias : > I just doesn't work... > Im loading t

Re: [R] Loop over folder files

2016-08-23 Thread ruipbarradas
Or maybe a print() statement on the table() in the loop. print(table(...)) Rui Barradas   Citando David Winsemius : >> On Aug 23, 2016, at 10:01 AM, Juan Ceccarelli Arias >> wrote: >> >> Im running this but the code doesn't seem work. >> It just hangs out but doesn't show any error. >> >> fo

Re: [R] Loop over folder files

2016-08-23 Thread MacQueen, Don
Compare what happens with these two command: for (i in 1:3) { table(letters[1:4]) } for (i in 1:3) { print(table(letters[1:4])) } Then try modifying your loop similarly. -- Don MacQueen Lawrence Livermore National Laboratory 7000 East Ave., L-627 Livermore, CA 94550 925-423-1062 On 8/2

Re: [R] Loop over folder files

2016-08-23 Thread ruipbarradas
Hello, Where does read_dta come from? You should also post the library() instruction. Try to run the code without the loop, with just one file and inspect xxx to see what's happening. xxx <- read_dta(fuente[1]) str(xxx) table(xxx$cise, xxx$sexo) Rui Barradas   Citando Juan Ceccarelli Arias :

Re: [R] Loop over folder files

2016-08-23 Thread David Winsemius
> On Aug 23, 2016, at 10:01 AM, Juan Ceccarelli Arias wrote: > > Im running this but the code doesn't seem work. > It just hangs out but doesn't show any error. > > > for (i in 1:length(fuente)){ > > xxx=read_dta(fuente[i]) > > table(xxx$cise, xxx$sexo) > > rm(xxx) > > } I still find the

Re: [R] Loop over folder files

2016-08-23 Thread Juan Ceccarelli Arias
Im running this but the code doesn't seem work. It just hangs out but doesn't show any error. for (i in 1:length(fuente)){ xxx=read_dta(fuente[i]) table(xxx$cise, xxx$sexo) rm(xxx) } On Tue, Aug 23, 2016 at 6:31 AM, wrote: > Hello, > > The op could also use package sos to find that and oth

Re: [R] Loop over folder files

2016-08-23 Thread ruipbarradas
Hello, The op could also use package sos to find that and other packages to read stata files. install.packages("sos") library(sos) findFn("stata") found 374 matches;  retrieving 19 pages 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 Downloaded 258 links in 121 packages The first package is re

Re: [R] Loop over folder files

2016-08-23 Thread Michael Dewey
Dear Juan If this is a Stata 13 file the package readstata13 available from CRAN may be of assistance. On 22/08/2016 18:40, Juan Ceccarelli Arias 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 In addition: Th

Re: [R] Loop over folder files

2016-08-22 Thread David Winsemius
> On Aug 22, 2016, at 10:40 AM, Juan Ceccarelli Arias 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 capac

Re: [R] Loop over folder files

2016-08-22 Thread Juan Ceccarelli Arias
I removed the data,frame=True... I obtain this warnings... Error in read.dta(fuente[i]) : not a Stata version 5-12 .dta file 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)

Re: [R] Loop over folder files

2016-08-22 Thread ruipbarradas
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 : > Hi > I need to apply some code over some stata files that are in fol

[R] Loop over folder files

2016-08-22 Thread Juan Ceccarelli Arias
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 Err