[R] Getting codebook data into R

barny garyb.davies at btinternet.com
Thu Feb 9 21:51:29 CET 2012


I've been trying to get some data from the National Survey for Family Growth
into R - however, the data is in a .dat file and the data I need doesn't
have any spaces or commas separating fields - rather you have to look into
the codebook and what number of digits along the line the data you need is. 
The data I want are the following, where 1,12,int means that the data I'm
interested starts in column 1 and finishes in column 12 and is an integer. 

            ('caseid', 1, 12, int),
             ('nbrnaliv', 22, 22, int),
            ('babysex', 56, 56, int),
            ('birthwgt_lb', 57, 58, int),
            ('birthwgt_oz', 59, 60, int),
            ('prglength', 275, 276, int),
            ('outcome', 277, 277, int),
            ('birthord', 278, 279, int),
            ('agepreg', 284, 287, int),
            ('finalwgt', 423, 440, float)

How can I do this using R? I've written a python programme which basically
does it but it'd be nicer if I could skip the Python bit and just do it
using R. Cheers for any help. 
            

--
View this message in context: http://r.789695.n4.nabble.com/Getting-codebook-data-into-R-tp4374329p4374329.html
Sent from the R help mailing list archive at Nabble.com.



More information about the R-help mailing list