*Dear R community* * *
*I have two questions on data subsample manipulation. I am starting to use R again after a long brake and feel a bit rusty.* * * *I want to select a subsample of data for males and females separately* * * library(foreign) Datatemp <- read.spss("H:/Skjol/Data/HL/t1and2b.sav", use.value.labels = F) > table(Datatemp$sex) 1 2 3049 3702 > attributes(Datatemp) $names [1] "nomiss" "Bin" "rad09" "year" "sex" "income" "adults" [8] "children" "student" "retired" "disabled" "homemaker" "unemployed" "employed" [15] "occupation" "residencysize" "educ" "agemean" "age" "marital" $codepage [1] 1252 > MalesData <- Datatemp[Datatemp $sex==1] > MalesData named list() > attributes(MalesData) $names character(0) Females.Data <- Datatemp[Datatemp $sex==2] *This subset extraction is not working. Is there anyone who can tell me what I did wrong?* * * * * *A different but related question is the use of the function paste or if I need another function to do the following: * * * * * *Rather than this*: > m2 <- gee( Bin ~ agemean + year, id = rad09 , data = datause , subset=kyn== 1 , family = binomial, corstr ="exchangeable" ) *I want to do this (modified in a loop). * > subsampl <- "kyn== 1 " > m2 <- gee( Bin ~ agemean + year, id = rad09 , data = datause , subset=paste(subsampl) , family = binomial, corstr ="exchangeable" ) Beginning Cgee S-function, @(#) geeformula.q 4.13 98/01/27 Error in gee(Bin ~ agemean + year, id = rad09, data = datause, subset = paste(subsampl), : rank-deficient model matrix *I hope you can see what I want to do, but I think I may need other function than paste()* * * *I appreciate a lot any help. * * Stefan Hrafn* [[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.