daudi / Epidata-XML-to-R

3 stars 1 forks source link

Error in xmlChildren(these.data)[[i]] : subscript out of bounds #6

Open LauraMarch opened 8 years ago

LauraMarch commented 8 years ago

Hello, Thank you for your code. I am a statistician and a R beginner. I need to import multiple files .epx from Epidata and your code would be very usefull. Unfortunatly, error "Error in xmlChildren(these.data)[[i]] : subscript out of bounds" is generated when I run your code. Any idea to help me? Thank you again for your code and your help, Laura

daudi commented 8 years ago

Hi Laura,

Wow, it's been a long time since I thought about this code. IIRC they changed the file format soon after I did this and I never got around to updating my code. I think your best bet might be to go with using the epidata export tool to convert the files to another format and then use either the foreign package or haven package to convert/read that into R. I think the epidata command line tool needs windows, but presumably you could do it with dosbox if you are using linux (and perhaps also mac).

The export tool can be found near the bottom of this page: http://www.epidata.dk/download.php and the haven package can be found here: https://cran.r-project.org/web/packages/haven/index.html

You could write a little R function to call the tool to make the conversion if you have lots of files to process.

Any good?

LauraMarch commented 8 years ago

Hello David,Thank you for your quick answer. Unfortunately the 'export tool' is only for .rec files and does not work with .epx files. The only way to convert epx files seems to use the export menu throughout EpidataManager. I keep you in touch if I find a solution. Have a nice day,Laura