Regarding the script I sent to you earlier, it should be modified a bit according to your dataset. For example, the variable "Sex" was in column 2. Also, your data had some missing values for the "Sex" column, which I removed before running the code.Â
With respect to the Errors that you showed here, you were using different package and I don't have a clue what you were trying to do.
I applied the same code to your dataset. The results are as follows:
BP_2b<-read.csv("BP_2b.csv",sep="\t")
nrow(BP_2b)
#[1] 6898
BP_2bSexNoMV<-BP_2b[!is.na(BP_2b$Sex),]
 nrow(BP_2bSexNoMV)
#[1] 6260
 unique(BP_2bSexNoMV$Sex)
#[1] 2 1
library(car)
BP_2bSexNoMV$Sex<-recode(BP_2bSexNoMV$Sex,"1='Male';2='Female'") #assuming that 1=Male and 2=Female
 unique(BP_2bSexNoMV$Sex)
#[1] "Female" "Male"Â
#whole dataset
 unlist(lapply(lapply(split(BP_2bSexNoMV,BP_2bSexNoMV$Sex),function(x) (nrow(x[!complete.cases(x[,-2]),])/nrow(x))*100),function(x) paste(x,"%",sep="")))
 #           Female               Male
#"72.6552179656539%" "74.4740099009901%"
#splitting the above into components:
 lapply(split(BP_2bSexNoMV,BP_2bSexNoMV$Sex),function(x) head(x,2))
#$Female
#Â CODEAÂ Â Â Sex MaternalAge Education Birthplace AggScore IntScore Obese14
#2    3 Female          3        3         1       0       0      0
#3    4 Female          3        6         1      NA      NA     NA
#Â Overweight14 Overweight21 Obese21 hibp14 hibp21
#2Â Â Â Â Â Â Â Â Â Â Â 0Â Â Â Â Â Â Â Â Â Â Â 1Â Â Â Â Â Â 0Â Â Â Â Â 0Â Â Â Â Â 0
#3Â Â Â Â Â Â Â Â Â Â NAÂ Â Â Â Â Â Â Â Â Â NAÂ Â Â Â Â NAÂ Â Â Â NAÂ Â Â Â NA
#$Male
#Â CODEAÂ Sex MaternalAge Education Birthplace AggScore IntScore Obese14
#6    9 Male          3        6         2       0       0      0
#8   11 Male          3        4         1       0       0     NA
 # Overweight14 Overweight21 Obese21 hibp14 hibp21
#6Â Â Â Â Â Â Â Â Â Â Â 0Â Â Â Â Â Â Â Â Â Â Â 0Â Â Â Â Â Â 0Â Â Â Â Â 0Â Â Â Â Â 0
#8Â Â Â Â Â Â Â Â Â Â NAÂ Â Â Â Â Â Â Â Â Â Â 0Â Â Â Â Â Â 0Â Â Â Â NAÂ Â Â Â Â 0
 lapply(split(BP_2bSexNoMV,BP_2bSexNoMV$Sex),function(x)nrow(x))
#$Female
#[1] 3028
#
#$Male
#[1] 3232
lapply(split(BP_2bSexNoMV,BP_2bSexNoMV$Sex),function(x) nrow(x[!complete.cases(x[,-2]),])) #rows which have at least one NA
#$Female
#[1] 2200
#
#$Male
#[1] 2407
 lapply(split(BP_2bSexNoMV,BP_2bSexNoMV$Sex),function(x) head(x[!complete.cases(x[,-2]),],2))
#$Female
#Â Â CODEAÂ Â Â Sex MaternalAge Education Birthplace AggScore IntScore Obese14
#3     4 Female          3        6         1      NA      NA     NA
#10   13 Female          3        4         2      NA      NA     NA
 # Overweight14 Overweight21 Obese21 hibp14 hibp21
#3Â Â Â Â Â Â Â Â Â Â Â NAÂ Â Â Â Â Â Â Â Â Â NAÂ Â Â Â Â NAÂ Â Â Â NAÂ Â Â Â NA
#10Â Â Â Â Â Â Â Â Â Â NAÂ Â Â Â Â Â Â Â Â Â NAÂ Â Â Â Â NAÂ Â Â Â NAÂ Â Â Â NA
#$Male
#Â CODEAÂ Sex MaternalAge Education Birthplace AggScore IntScore Obese14
#8   11 Male          3        4         1       0       0     NA
#9   12 Male          3        4         2      NA      NA     NA
#Â Overweight14 Overweight21 Obese21 hibp14 hibp21
#8Â Â Â Â Â Â Â Â Â Â NAÂ Â Â Â Â Â Â Â Â Â Â 0Â Â Â Â Â Â 0Â Â Â Â NAÂ Â Â Â Â 0
#9Â Â Â Â Â Â Â Â Â Â NAÂ Â Â Â Â Â Â Â Â Â NAÂ Â Â Â Â NAÂ Â Â Â NAÂ Â Â Â NA
lapply(split(BP_2bSexNoMV,BP_2bSexNoMV$Sex),function(x) (nrow(x[!complete.cases(x[,-2]),])/nrow(x))*100) #gives the percentage of rows of missing #values from the overall rows for Males and Females
#$Female
#[1] 72.65522
#
#$Male
#[1] 74.47401
#iF you want the percentage from the total number rows in Males and Females (without NA's in the the Sex column)
 lapply(split(BP_2bSexNoMV,BP_2bSexNoMV$Sex),function(x) (nrow(x[!complete.cases(x[,-2]),])/nrow(BP_2bSexNoMV))*100)
#$Female
#[1] 35.14377
#
#$Male
#[1] 38.45048
unlist(lapply(lapply(split(BP_2bSexNoMV,BP_2bSexNoMV$Sex),function(x) (nrow(x[!complete.cases(x[,-2]),])/nrow(BP_2bSexNoMV))*100),function(x) paste(x,"%",sep="")))#paste the "%" to the numbers
#            Female               Male
#"35.1437699680511%" "38.4504792332268%"
#If it is to find the percentage of missing values for each variable in females and males:
res<-do.call(rbind,lapply(split(BP_2bSexNoMV,BP_2bSexNoMV$Sex),function(x) paste((colSums(is.na(x[,-2]))/nrow(BP_2bSexNoMV))*100,"%",sep=""))) #If #you want percentage of missing values per category, replace by nrow(x)
 colnames(res)<-colnames(BP_2bSexNoMV)[-2]
res
#      CODEA MaternalAge Education          Birthplace       Â
#Female "0%"Â "0%"Â Â Â Â Â Â Â "1.03833865814696%" "1.18210862619808%"
#Male  "0%" "0%"       "1.10223642172524%" "1.3258785942492%"
 #     AggScore           IntScore           Obese14          Â
#Female "15.2076677316294%" "15.2076677316294%" "24.0894568690096%"
#Male  "16.5015974440895%" "16.5015974440895%" "25.814696485623%"
#Â Â Â Â Â Â Overweight14Â Â Â Â Â Â Â Overweight21Â Â Â Â Â Â Â Obese21Â Â Â Â Â Â Â Â Â Â Â
#Female "24.0894568690096%" "23.3865814696486%" "23.3865814696486%"
#Male  "25.814696485623%" "29.1533546325879%" "29.1533546325879%"
#Â Â Â Â Â Â hibp14Â Â Â Â Â Â Â Â Â Â Â Â Â hibp21Â Â Â Â Â Â Â Â Â Â Â Â
#Female "24.1693290734824%" "31.3418530351438%"
#Male  "25.8466453674121%" "35.223642172524%"
A.K.
________________________________
From: Usha Gurunathan <usha....@gmail.com>
To: arun <smartp...@yahoo.com>
Cc: R help <r-h...@r-project.org>
Sent: Saturday, January 12, 2013 1:42 AM
Subject: Re: [R] random effects model
 Hi
 I do want percentages of the categories inthe whole data set. But, I am a bit unclear about this syntax. Can you explain please. This is the error message I got with your script?
Error: could not find function "Copy.of.BP_2". Not sure what, because the data frame was already loaded.
Also
I was trying out package: vmv( after installing)
as data(df,package, package="vmv")
In data(Copy.of.BP_2c, package = "vmv") : data set ‘Copy.of.BP_2c’ not foundtablemissing(df, sort by="variable")
Are you sure that you got the error message with#
unlist(lapply(lapply(split(dat1,dat1$Gender),function(x)
(nrow(x[!complete.cases(x[,-1]),])/nrow(x))*100),function(x)
paste(x,"%",sep="")))
#or
do.call(rbind,lapply(split(dat1,dat1$Gender),function(x) paste((colSums(is.na(x[,-1]))/nrow(x))*100,"%",sep="")))
From ur reply, it seemed like you were trying different codes:
as data(df,package, package="vmv")
A.K.
________________________________
From: Usha Gurunathan <usha....@gmail.com>
To: arun <smartp...@yahoo.com>
Cc: R help <r-h...@r-project.org>
Sent: Saturday, January 12, 2013 1:42 AM
Subject: Re: [R] random effects model
 Hi
 I do want percentages of the categories inthe whole data set. But, I am a bit unclear about this syntax. Can you explain please. This is the error message I got with your script?
Error: could not find function "Copy.of.BP_2". Not sure what, because the data frame was already loaded.
Also
I was trying out package: vmv( after installing)
as data(df,package, package="vmv")
In data(Copy.of.BP_2c, package = "vmv") : data set ‘Copy.of.BP_2c’ not foundtablemissing(df, sort by="variable")
Hi,
I tried ur dataset with vmv.
library(vmv)
tablemissing(BP_2bSexNoMV[BP_2bSexNoMV$Sex=="Male",],sortby="variable")
tablemissing(BP_2bSexNoMV[BP_2bSexNoMV$Sex=="Female",],sortby="variable")
I am attaching the plots i got with it. I didn't look at the details to change the font labels in the plot.
Hope this helps.
A.K.
________________________________
From: Usha Gurunathan <usha....@gmail.com>
To: arun <smartp...@yahoo.com>
Cc: R help <r-h...@r-project.org>
Sent: Saturday, January 12, 2013 1:42 AM
Subject: Re: [R] random effects model
 Hi
 I do want percentages of the categories inthe whole data set. But, I am a bit unclear about this syntax. Can you explain please. This is the error message I got with your script?
Error: could not find function "Copy.of.BP_2". Not sure what, because the data frame was already loaded.
Also
I was trying out package: vmv( after installing)
as data(df,package, package="vmv")
In data(Copy.of.BP_2c, package = "vmv") : data set ‘Copy.of.BP_2c’ not foundtablemissing(df, sort by="variable")