[R] exporting data to stata

Ista Zahn istazahn at gmail.com
Thu Mar 22 13:32:48 CET 2018


On Thu, Mar 22, 2018 at 4:52 AM, Raja, Dr. Edwin Amalraj
<amalraj.raja at abdn.ac.uk> wrote:
> Hi ,
>
> library(foreign)
> write.dta(data1,  "data1.dta")
>
> should work.


I don't think so:

> library(foreign)
> example(svydesign)
> write.dta(dstrat, "~/Downloads/foo.dta")
Error in write.dta(dstrat, "~/Downloads/foo.dta") :
  The object "dataframe" must have class data.frame


The file will be saved in the working directory.
> Use
> getwd()
> to know the working directory.
>
> Best wishes
> Amalraj Raja
>
> -----Original Message-----
> From: R-help [mailto:r-help-bounces at r-project.org] On Behalf Of rosario scandurra
> Sent: 22 March 2018 07:47
> To: r-help at r-project.org
> Subject: [R] exporting data to stata
>
> Hi,
>
> I am new to R and I want to export data into Stata. Could somebody help with that? Thanks a lot.
>
> This is the code I am using:
>
>
>> setwd("D:/datasets/Seg-bcn/ESBD")
>> data1 <- readRDS("r17045_ESDB_Habitatges_BDD_V_1_0.rds")
>> library(foreign)
>> write.dta(data="data1", file = "D:/datasets/data1.dta")
> Error in write.dta(data = "data1", file = "D:/datasets/data1.dta") :
>   The object "dataframe" must have class data.frame
>> class (data1)
> [1] "survey.design2" "survey.design"
>
>
> [[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.
>
>
> The University of Aberdeen is a charity registered in Scotland, No SC013683.
> Tha Oilthigh Obar Dheathain na charthannas clàraichte ann an Alba, Àir. SC013683.
> ______________________________________________
> 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.



More information about the R-help mailing list