Re: [R] Code Book from SPSS Data

2013-10-28 Thread Frank Harrell

Not certain about .por but this works with ordinary SPSS files:

require(Hmisc)
dat <- spss.get(...)  # gets variable labels, etc.
contents(dat)
html(contents(dat), ...)

The last command produces a hyperlinked data dictionary, e.g., for each 
variable the number of levels is given and you click on that number to 
see the levels.  Variables having the same levels are combined in the 
latter part.


Frank

--
Frank E Harrell Jr Professor and Chairman  School of Medicine
   Department of Biostatistics Vanderbilt University

__
R-help@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.


Re: [R] Code Book from SPSS Data

2013-10-28 Thread Gesmann, Markus
Peter,

There is a function called codebook as part of the memisc package that probably 
does what you want.
See also the package vignette: 
http://cran.r-project.org/web/packages/memisc/vignettes/anes48.pdf

library(memisc)
fn <- "NILT12w2.por"
dat <- spss.portable.file(fn)
codebook(dat)
names(dat)
description(dat)

I hope this helps.

Markus



-Original Message-
From: r-help-boun...@r-project.org [mailto:r-help-boun...@r-project.org] On 
Behalf Of Peter Maclean
Sent: 26 October 2013 21:37
To: r-help@r-project.org
Subject: Re: [R] Code Book from SPSS Data

I do not have SPSS and I would like to create a code book in a data frame 
format using R. I am reading the SPSS file using "memisc package". The script 
is:
#Data for 2012 available at 
https://urldefense.proofpoint.com/v1/url?u=http://www.ark.ac.uk/nilt/datasets/&k=VTIXiGvdT7U4yPSpeHcrHQ%3D%3D%0A&r=dUkLGPeM%2BYkyyiRRq50yGs%2BmEf8kG%2FyCNQPwZn%2FaQD0%3D%0A&m=GVKjmjUiiJIiVcY%2FZ%2B35UGhRSRtdr9OJQhLQUx7Ax7Q%3D%0A&s=4dfa4233895c7e2f635380b0f8392a989a28848049001908965f058667a15143
#Also attached
ibrary(memisc)
## change the working directory
getwd()
setwd('')
data <- spss.portable.file("NILT12w2.por")
Get names
names(data) 
#Get Variable Lebels
des <- as.data.frame(description(data))
#Descriptive Statistics & Code Book
#Results are very long for printing
codebook(data)
#How could I extract a codebook (without Summary statistics for printing)?



Peter Maclean
Department of Economics
UDSM

--
The information in this E-Mail and in any attachments is...{{dropped:19}}

__
R-help@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.


Re: [R] Code Book from SPSS Data

2013-10-27 Thread jwd
On Sun, 27 Oct 2013 14:37:27 -0700 (PDT)
Peter Maclean  wrote:

It's not fully clear what you need, but, as I very vaguely recall, the
code book in SPSS provided labels for what are called levels in
"factors" in R, which are categorical variables. 

Try: "??categorical" at the prompt for starters.

Then ?factor

JWDougherty

__
R-help@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.


Re: [R] Code Book from SPSS Data

2013-10-27 Thread Peter Maclean
I am trying again. I do not have SPSS and I would like to create a code book in 
a data frame format using R. I am reading the SPSS file using "memisc package". 
The script is:
#Data for 2012 available at http://www.ark.ac.uk/nilt/datasets/
#Also attached
ibrary(memisc)
## change the working directory
getwd()
setwd('')
data <- spss.portable.file("NILT12w2.por")
Get names
names(data) 
#Get Variable Lebels
des <- as.data.frame(description(data))
#Descriptive Statistics & Code Book
#Results are very long for printing
codebook(data)
#How could I extract a codebook (without Summary statistics for printing)?

The code book will have label value of label and description of labeld
For example, for gender

Variable  Code    Description
Gender  1=Male    Gender of respondent
  2=Female
Status    1=Married    Marital status
   2=Widow
   3=Others

Peter Maclean
Department of Economics
UDSM



On Sunday, October 27, 2013 3:32 AM, Barry Rowlingson 
 wrote:
  
On Sat, Oct 26, 2013 at 9:37 PM, Peter Maclean  wrote:
> I do not have SPSS and I would like to create a code book in a data frame 
> format using R.

> #How could I extract a codebook (without Summary statistics for printing)?

This isn't that clear because I don't think 'codebook' is something
well-defined. Describe the rows and columns of the data frame you want
to create.

Barry
[[alternative HTML version deleted]]

__
R-help@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.


Re: [R] Code Book from SPSS Data

2013-10-27 Thread Barry Rowlingson
On Sat, Oct 26, 2013 at 9:37 PM, Peter Maclean  wrote:
> I do not have SPSS and I would like to create a code book in a data frame 
> format using R.

> #How could I extract a codebook (without Summary statistics for printing)?

 This isn't that clear because I don't think 'codebook' is something
well-defined. Describe the rows and columns of the data frame you want
to create.

Barry

__
R-help@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.