In this video, Mark Niemann-Ross demonstrates the use of functions from the foreign package to import Stata data files. Learn how to use read.dta and write.foreign.
- [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 a Stata file,…you'll use write.foreign and here's what that looks like,…
- Name the three types of big data.
- List three considerations used to determine the appropriate R package for Excel.
- Determine the best package used to import entire Excel workbooks.
- Explain how to import standard text files using base R and tidyverse.
- Define the purpose of the foreign language package for R.
- Recognize restrictions when working on SAS files in the foreign language package.
- Identify the problems involved with extracting data from a PDF in R.
Skill Level Intermediate
R Programming in Data Science: High Volume Datawith Mark Niemann-Ross1h 25m Intermediate
1. Use R with Excel
2. Importing Text Files
3. Understanding the Foreign Package
4. Use R with Popular Data Formats
- Mark as unwatched
- Mark all as unwatched
Are you sure you want to mark all the videos in this course as unwatched?
This will not affect your course history, your reports, or your certificates of completion for this course.Cancel
Take notes with your new membership!
Type in the entry box, then click Enter to save your note.
1:30Press on any video thumbnail to jump immediately to the timecode shown.
Notes are saved with you account but can also be exported as plain text, MS Word, PDF, Google Doc, or Evernote.