Hello, i'm newbie of R and think it is a really good alternative to SPSS. But i have more problems using elementary things comparable with using advanced methods. (1) How can i value label i.e the variable X in data.frame DATA with the labels ( 1=very good ) (2=good). spss syntax when DATA is in Spreadsheet is: value labels X 1 'very good'. 2 'good'. execute. (2) How can i split the data set dependent from one variable and give a special output i.e. frequencies. spss syntax: SORT CASES BY countryg . SPLIT FILE LAYERED BY countryg . FREQUENCIES VARIABLES=X Y Z /ORDER ANALYSIS . Thanks in advance regards,christian _______________________________________________________________________ -.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.- r-help mailing list -- Read http://www.ci.tuwien.ac.at/~hornik/R/R-FAQ.html Send "info", "help", or "[un]subscribe" (in the "body", not the subject !) To: r-help-request at stat.math.ethz.ch _._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._
Basic SPSS commands in R ?
3 messages · Christian Schulz, Ben Bolker, Thomas Lumley
On Sat, 8 Sep 2001, C. Schulz wrote:
Hello, i'm newbie of R and think it is a really good alternative to SPSS. But i have more problems using elementary things comparable with using advanced methods.
1. make your variable into a factor, then set the levels (see ?factor, ?levels)
(1) How can i value label i.e the variable X in data.frame DATA with the labels ( 1=very good ) (2=good). spss syntax when DATA is in Spreadsheet is: value labels X 1 'very good'. 2 'good'. execute.
2. Look at ?split, ?tapply, ?table
(2) How can i split the data set dependent from one variable and give a special output i.e. frequencies. spss syntax: SORT CASES BY countryg . SPLIT FILE LAYERED BY countryg . FREQUENCIES VARIABLES=X Y Z /ORDER ANALYSIS . Thanks in advance regards,christian
_______________________________________________________________________ -.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.- r-help mailing list -- Read http://www.ci.tuwien.ac.at/~hornik/R/R-FAQ.html Send "info", "help", or "[un]subscribe" (in the "body", not the subject !) To: r-help-request at stat.math.ethz.ch _._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._
318 Carr Hall bolker at zoo.ufl.edu Zoology Department, University of Florida http://www.zoo.ufl.edu/bolker Box 118525 (ph) 352-392-5697 Gainesville, FL 32611-8525 (fax) 352-392-3704 -.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.- r-help mailing list -- Read http://www.ci.tuwien.ac.at/~hornik/R/R-FAQ.html Send "info", "help", or "[un]subscribe" (in the "body", not the subject !) To: r-help-request at stat.math.ethz.ch _._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._
2 days later
On Sat, 8 Sep 2001, C. Schulz wrote:
Hello, i'm newbie of R and think it is a really good alternative to SPSS. But i have more problems using elementary things comparable with using advanced methods. (1) How can i value label i.e the variable X in data.frame DATA with the labels ( 1=very good ) (2=good). spss syntax when DATA is in Spreadsheet is: value labels X 1 'very good'. 2 'good'. execute.
x<-factor(x,labels=c("very good","good"))
(2) How can i split the data set dependent from one variable and give a special output i.e. frequencies. spss syntax: SORT CASES BY countryg . SPLIT FILE LAYERED BY countryg . FREQUENCIES VARIABLES=X Y Z /ORDER ANALYSIS .
Various commands. The easiest is by(), tapply is more general
For example, looking at the Cars93 dataset in the MASS package:
library(MASS) #load the package
data(Cars93) #load the dataset
#summaries of all variables by type of car
by(Cars93,Cars93$Type,summary)
##summaries of weight, horsepower and engine size by US/Foreign origin
by(Cars93[,c("Weight","Horsepower","EngineSize")],Cars93$Origin,summary)
## table of no. of cylinders by type for US and Foreign cars.
by(Cars93[,c("Cylinders","Type")], Cars93$Origin, table)
This also gives some more examples of factors (aka VALUE LABELS)
-thomas
Thomas Lumley Asst. Professor, Biostatistics
tlumley at u.washington.edu University of Washington, Seattle
-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-
r-help mailing list -- Read http://www.ci.tuwien.ac.at/~hornik/R/R-FAQ.html
Send "info", "help", or "[un]subscribe"
(in the "body", not the subject !) To: r-help-request at stat.math.ethz.ch
_._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._