[R] Using Function
Silvano
silvano at uel.br
Tue Aug 2 13:53:06 CEST 2011
Hi,
I have some simple statistics to calculate for a large
number of variables.
I created a simple function to apply to variables.
I would like the variable name to be placed automatically.
I tried the following function but is not working.
desc = function(x){
media = mean(x, na.rm=T)
desvio = sd(x, na.rm=T)
cv = desvio/media*100
saida = cbind(media, desvio, cv)
colnames(saida) = c(NULL, 'Média',
'Desvio', 'CV')
rownames(saida) = c(x)
saida
}
desc(Idade)
Média Desvio CV
Idade 44.04961 16.9388 38.4539
How do you get the variable name is placed as the first
element?
My objective is get something like:
rbind(
desc(Altura),
desc(Idade),
desc(IMC),
desc(FC),
desc(CIRCABD),
desc(GLICOSE),
desc(UREIA),
desc(CREATINA),
desc(CTOTAL),
desc(CHDL),
desc(CLDL),
desc(CVLDL),
desc(TRIG),
desc(URICO),
desc(SAQRS),
desc(SOKOLOW_LYON),
desc(CORNELL),
desc(QRS_dur),
desc(Interv_QT)
)
Thanks a lot,
--------------------------------------
Silvano Cesar da Costa
Departamento de Estatística
Universidade Estadual de Londrina
Fone: 3371-4346
More information about the R-help
mailing list