The DHS Program User Forum
Discussions regarding The DHS Program data and results
Home » Data » Dataset use (other programs) » Opening databases in RStudio
Opening databases in RStudio [message #11747] Mon, 06 February 2017 11:59 Go to next message
dasanchezp is currently offline  dasanchezp
Messages: 11
Registered: February 2017
Location: San Sebastian
Member
Dear DHS Program User Forum,

I downloaded many databases, but I realized RStudio does not get all the information (variables). Or maybe I am doing something wrong. I am reading the DHS Survey Manual and the Model Woman's Questionnaire and I found sections: 2 (Reproduction), 3 (Contraception), 4 (Pregnancy), 7 (Marriage and Sexual Activity) and 8 (Fertility Preferences), being these the sections of my interest. These sections should be in the women databases but I cannot find them.

For example, I downloaded Albania's database. Then, I opened ALIR50FL.SAV using R. In this file, I only have variables from V000 to V191, ML101 and from BIDX.01 to BIDX.05. Nothing else. I followed this code:

library(foreign)
df=read.spss("ALIR50FL.SAV", to.data.frame = TRUE)

Indeed, I mainly need the sections described above.

May you help me, please?

Thanks in advance.


Best regards,

David A. Sanchez P.
Re: Opening databases in RStudio [message #11802 is a reply to message #11747] Fri, 10 February 2017 11:16 Go to previous messageGo to next message
Trevor-DHS is currently offline  Trevor-DHS
Messages: 802
Registered: January 2013
Senior Member
I just tested this myself and it imports all of the data. In the environment window it states that I have
7584 obs. of 4375 variables
It only shows the variables down to BIDX.05 in that window, and notes below that [list output truncated], but they are all there.
Re: Opening databases in RStudio [message #11806 is a reply to message #11802] Fri, 10 February 2017 15:57 Go to previous messageGo to next message
dasanchezp is currently offline  dasanchezp
Messages: 11
Registered: February 2017
Location: San Sebastian
Member
Thank you. Do you know how may I "untruncated" them?

Best regards,

David A. Sanchez P.
Re: Opening databases in RStudio [message #11807 is a reply to message #11806] Fri, 10 February 2017 16:34 Go to previous messageGo to next message
Trevor-DHS is currently offline  Trevor-DHS
Messages: 802
Registered: January 2013
Senior Member
If you are using View() to see the data, I've no idea how to increase the view. I'm not sure you can
You can try the following to see all of the variable names:
options(max.print=5000)
names(df)

Also to see the variable labels you can use:
attr(df, "variable.labels")

Will show you all of the value labels

[Updated on: Fri, 10 February 2017 16:34]

Report message to a moderator

Re: Opening databases in RStudio [message #11817 is a reply to message #11807] Mon, 13 February 2017 12:25 Go to previous messageGo to next message
dasanchezp is currently offline  dasanchezp
Messages: 11
Registered: February 2017
Location: San Sebastian
Member
Thank you! It worked!

Best regards,

David A. Sanchez P.
Re: Opening databases in RStudio [message #29390 is a reply to message #11817] Tue, 11 June 2024 11:01 Go to previous message
26tanishabanik is currently offline  26tanishabanik
Messages: 4
Registered: June 2024
Member
I have tried the same code but I get below error:

> library(foreign)
> df=read.spss("Downloads/IAIR7ESV/IAIR7EFL.SAV", to.data.frame = TRUE)

Error: vector memory limit of 16.0 Gb reached, see mem.maxVSize()
Previous Topic: Disability prevalence question
Goto Forum:
  


Current Time: Thu Oct 3 10:27:51 Coordinated Universal Time 2024