Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

read_dta() reads byte variables as character strings #45

huftis opened this issue Mar 12, 2015 · 1 comment


Copy link

commented Mar 12, 2015

read_dta() seems to convert Stata byte variables to character strings, instead of to integers. If I create a simple Stata file, with variables of type float, double, long, int and byte, here is the result of importing it using read_dta:

> d = read_dta("stata-datatypes.dta")
> sapply(d, class)
     vfloat     vdouble       vlong        vint       vbyte 
  "numeric"   "numeric"   "integer"   "integer" "character"

Version info:

> sessionInfo()
R version 3.1.1 (2014-07-10)
Platform: i386-w64-mingw32/i386 (32-bit)

[1] LC_COLLATE=Norwegian-Nynorsk_Norway.1252  LC_CTYPE=Norwegian-Nynorsk_Norway.1252   
[3] LC_MONETARY=Norwegian-Nynorsk_Norway.1252 LC_NUMERIC=C                             
[5] LC_TIME=Norwegian-Nynorsk_Norway.1252    

attached base packages:
[1] stats     graphics  grDevices utils     datasets  methods   base     

other attached packages:
[1] haven_0.1.1

loaded via a namespace (and not attached):
[1] Rcpp_0.11.4 tools_3.1.1

This comment has been minimized.

Copy link
Contributor Author

commented Mar 12, 2015

Here is the example Stata file I used:

And here’s some information on Stata data types:
It says:

byte, int, and long are said to be of integer type in that they can hold only integers.

@hadley hadley closed this in cab0306 Apr 7, 2015

@lock lock bot locked and limited conversation to collaborators Jun 27, 2018

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
None yet
1 participant
You can’t perform that action at this time.