Skip to content
Prev 284839 / 398502 Next

Getting codebook data into R

Or, you can do it the lazy way...

Download spss errr... pspp at http://www.gnu.org/software/pspp/ and run 
the spss code in which somebody else already figured all that out,
 to create an spss file. Then use one of the spss importing
libraries. Lately I've become partial to memisc, but there are several 
choices here.

eRic



----- Original message -----
From: "David Winsemius" <dwinsemius at comcast.net>
To: "barny" <garyb.davies at btinternet.com>
Cc: r-help at r-project.org
Date: Thu, 9 Feb 2012 17:50:39 -0500
Subject: Re: [R] Getting codebook data into R
On Feb 9, 2012, at 3:51 PM, barny wrote:

            
That's not the way the read.fwf is set up to accept data. You will  
need to loop over that input stream and apply logic like:
vec<numeric(0);
nams <-character(0)
getwidth = first-last+1
vec=c(vec, getwidth)
nams=c(nams, <whatever>)
getwidblank = last-first.next-1
If( getblank>0) namskip= <junk-name>

Then remove all the zeros and that will be  your vector of widths and  
your string of col.names
David Winsemius, MD
West Hartford, CT

______________________________________________
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.