I have a data frame with following structure, dput(scoreDF)
:
scoreDF <- structure(list(ID = c(1, 2), Status = structure(c(2L, 1L),
.Label = c("Fail", "Pass"), class = "factor"), Subject_1_Score = c(100, 25),
Subject_2_Score = c(50, 76)), .Names = c("ID", "Status", "Subject_1_Score",
"Subject_2_Score"), row.names = c(NA, -2L), class = "data.frame")
Now, I need to come up with the % of students who passed and failed, mean of the students who passed and failed, standard error for the same.
For standard error, I have defined a function as follows:
stdErr <- function(x) {sd(x)/ sqrt(length(x))}
where I expect x
to be a vector whose standard error needs to be calculated.
I have seen the doc for ddply
, but I am not able to figure out how to calculate the % i.e. (number of passes)/ (total count) and standard error for the data frame above.