Skip to content
Prev 315138 / 398503 Next

random effects model

HI,

If you want to find out the percentage of missing values in the whole dataset in females and males:
?set.seed(51)
?dat1<-data.frame(Gender=rep(c("M","F"),each=10),V1=sample(c(1:3,NA),20,replace=TRUE),V2=sample(c(21:24,NA),20,replace=TRUE))
?unlist(lapply(lapply(split(dat1,dat1$Gender),function(x) (nrow(x[!complete.cases(x[,-1]),])/nrow(x))*100),function(x) paste(x,"%",sep="")))
#??? F???? M 
#"20%" "70%" 

#If it is to find the percentage of missing values for each variable in females and males:
?res<-do.call(rbind,lapply(split(dat1,dat1$Gender),function(x) paste((colSums(is.na(x[,-1]))/nrow(x))*100,"%",sep="")))
?colnames(res)<-colnames(dat1)[-1]
?res
#? V1??? V2?? 
#F "0%"? "20%"
#M "50%" "20%"
A.K.





----- Original Message -----
From: rex2013 <usha.nathan at gmail.com>
To: r-help at r-project.org
Cc: 
Sent: Friday, January 11, 2013 2:16 AM
Subject: Re: [R] random effects model

Hi AK

Regarding the missing values, I would like to find out the patterns of
missing values in my data set. I know the overall values for each variable.

using

colSums(is.na(df))

? ? ? ? ? ? ? ? ? ? ? but what I wanted is? to find out the percentages
with each level of the variable with my dataset, as in if there is more
missing data in females or males etc?.

I installed "mi" package, but unable to produce a plot with it( i would
also like to produce a plot). I searched the responses in the relevant
sections in r but could n't find an answer.

Thanks,





On Wed, Jan 9, 2013 at 12:31 PM, arun kirshna [via R] <
ml-node+s789695n4654996h3 at n4.nabble.com> wrote:

            
--
View this message in context: http://r.789695.n4.nabble.com/random-effects-model-tp4654346p4655206.html
Sent from the R help mailing list archive at Nabble.com.
??? [[alternative HTML version deleted]]

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