THIS USES DISPLAYR INSTRUCTIONS AND NEEDS TO BE UPDATED
This article describes how to import Stata DTA data sets into Q. You will need a Stata (*.dta) data set made available as a publicly accessible URL. This example uses a 2017 face-to-face post-election survey data set.
Method
- Select Data Sets > Plus (+) > R.
- Enter a name for the data set under Name.
- Paste the below R code where it states "Enter your R code here":
library(haven)
# Import data
df = read_dta("http://www.britishelectionstudy.com/wp-content/uploads/2018/01/bes_f2f_2017_v1.2.dta")
# Convert as labels
df = as_factor(df)
Here, we read in the data set using haven's read_dta function. Next, we convert the data set so that it displays the labels rather than the values.
- Note this will import using the variable names. Variable labels will need to be updated directly in your Data Sets tree.
Next
Comments
0 comments
Article is closed for comments.