Hi,
I need to read multiple dta files and exporting the content of a variable
called "name". My idea is to aggregate to the right each "name" from each
dta file. I made a simple loop and I know It works reading the dta files.
However, It can't say the same exporting the data.
Here is what I wrote:
Every time I run the code I received a message with "Error: POIXMLException
(Java): java.lang.reflect.InvocationTargetException".
And when I opened the excel file, It only contained in the first column
infomatio (plop) of the first dta file.
I have no idea what else to do. The error seems related to the intent to
export the data to excel than reading the files.
Thanks for your time and interest.
I need to read multiple dta files and exporting the content of a variable
called "name". My idea is to aggregate to the right each "name" from each
dta file. I made a simple loop and I know It works reading the dta files.
However, It can't say the same exporting the data.
Here is what I wrote:
Code:
library(XLConnect)
options(java.parameters = "-Xmx4096m")
setwd("C://Users//Jce//a")
file = list.files(pattern="\\.dta$")
myFiles <- list.files(pattern = "\\.dta$")
ttt=length(file)
for(i in myFiles){
for (j in 1:length(file)) {
rm(plop)
myDf = read_dta(i)
plop=myDf$name
writeWorksheetToFile("datos.xlsx",data=plop, sheet="variables",startRow=1, startCol=j)
}
}
(Java): java.lang.reflect.InvocationTargetException".
And when I opened the excel file, It only contained in the first column
infomatio (plop) of the first dta file.
I have no idea what else to do. The error seems related to the intent to
export the data to excel than reading the files.
Thanks for your time and interest.