From the course: R Programming in Data Science: High Variety Data

Unlock the full course today

Join today to access over 22,600 courses taught by industry experts or purchase this course individually.

Read from and write to Stata

Read from and write to Stata

From the course: R Programming in Data Science: High Variety Data

Start my 1-month free trial

Read from and write to Stata

- [Instructor] Stata is an enormously popular tool for statistics and data analysis and you can bring those files into R using the read.dta command found in the foreign package. So let's look at how to do that. First of all, foreign is probably already installed in your version of R, but be sure to use the library command to bring it into use. At this point, it's also good to make sure that you have selected chapter zero three as your current working directory. Once you've accomplished both of those tasks, we're ready to use read.dta. And here's how to do that. I'm going to create a vector called dtaReadSample and into that vector I'm going to place the results of read.dta and I need to tell it what file I want to bring in. So I'm going to select from the sample files, a file called statasample.dta and when I hit command return and I get dtaReadSample in the global environment. And if we look at dtaReadSample, you'll see that it's a standard data frame. To write an R data frame out to…

Contents