[R] Help with write.foreign (exporting data to Stata)
Thomas Lumley
tlumley at u.washington.edu
Tue Jul 10 21:57:56 CEST 2007
On Tue, 10 Jul 2007, Stefan Grosse wrote:
> I am not sure what you are doing there but what you need is
> library(foreign)
> and
> write.dta()
write.foreign should also work, though.
My guess is that Kate used tempfile() to specify the filenames, and that the data file would then have been deleted on leaving R. This is only a guess, of course.
The syntax for write.dta is
write.dta(the.data.set, file="dataset.dta")
and for write.foreign is
write.foreign(the.data.set,codefile="dataset.do", datafile="dataset.raw",
package="Stata")
-thomas
> see
> ?write.dta once you have loaded the foreign package
>
> Stefan
>
> -------- Original Message --------
> Subject: [R] Help with write.foreign (exporting data to Stata)
> From: kdestler <kdestler at u.washington.edu>
> To: r-help at stat.math.ethz.ch
> Date: Tue Jul 10 2007 19:37:54 GMT+0200
>> Hi. I'm trying to export a dataframe from R into Stata to use a statistical
>> function I have there. I attached library write.foreign and renamed my
>> variables to get them to match Stata's required format, and now have the
>> following error: "file /tmp/Rtmps7rmrM/file1c06dac8.raw not found" Other
>> than typing write.foreign, do I need to do something in R to get it to save
>> the file on my hard drive? When I search for the file name on my computer
>> nothing comes up. I'm using a Mac in case that makes a difference.
>>
>> Thanks,
>> Kate
>>
>
> ______________________________________________
> R-help at stat.math.ethz.ch mailing list
> 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.
>
Thomas Lumley Assoc. Professor, Biostatistics
tlumley at u.washington.edu University of Washington, Seattle
More information about the R-help
mailing list