Hi,

I have a very simple question, but I'm obviously not able to solve the
problem on my own.


I have a data.frame like


sample(c("A","B","C"),size=20,replace = T)->type

rnorm(20)->value

data.frame(ty=type,val=value)->test


There must be some built in functions, that will do some descriptive
statistics with tabular output, in the end I like to have something like


 number of samples mean sd .............

A 5

B 9

C 6



So I need a function that counts the number of  occurrences of factors in
type and then does something like the *summary* function, but factor
specific.


I tried:


vector()->Median

vector()->SD

vector()->Mean


as.data.frame(table(type))->int


for (count in c(1:(nrow(int))))

 {

subset(test, ty==as.character(int$type[count])) -> subtest

median(subtest$val)->Median[count]

sd(subtest$val)->SD[count]

mean(subtest$val)->Mean[count]

}


cbind(int,Median,SD,Mean)


This works, but: isn't this much too complicated, I bet there is such
functionality embedded in the base packages, but I cannot find it.


Maxim

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

Reply via email to