[R] Getting codebook data into R

Peter Alspach Peter.Alspach at plantandfood.co.nz
Thu Feb 9 22:31:35 CET 2012


Tena koe

?read.fwf

HTH ....

Peter Alspach

-----Original Message-----
From: r-help-bounces at r-project.org [mailto:r-help-bounces at r-project.org] On Behalf Of barny
Sent: Friday, 10 February 2012 9:52 a.m.
To: r-help at r-project.org
Subject: [R] Getting codebook data into R

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-tp4374331p4374331.html
Sent from the R help mailing list archive at Nabble.com.

______________________________________________
R-help at r-project.org mailing list
https://stat.ethz.ch/mailman/listinfo/r-help
PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
and provide commented, minimal, self-contained, reproducible code.

The contents of this e-mail are confidential and may be subject to legal privilege.
 If you are not the intended recipient you must not use, disseminate, distribute or
 reproduce all or any part of this e-mail or attachments.  If you have received this
 e-mail in error, please notify the sender and delete all material pertaining to this
 e-mail.  Any opinion or views expressed in this e-mail are those of the individual
 sender and may not represent those of The New Zealand Institute for Plant and
 Food Research Limited.



More information about the R-help mailing list