AW: [R] summary with names

Christoph Bier christoph.bier at web.de
Thu Oct 16 19:02:25 CEST 2003


As I read this, my answers to the other guys don't seem to be 
delievered to the list, although I sent them nearly 4 hours 
ago. I fear, I only sent them to the posters and not to the 
list ... I try to correct this! Sorry!

Axel Benz schrieb:
> Which name do you want?
> varA1

This one resp. the corresponding one in this way (varA2 etc.).

> or
> fb.12.unt[varA1]
> or even then value of varA1????

This question tells me, that you know more than me ;-). Who 
wonders ...? There are 98 values for varA1. Did I use wrong 
terms, that 98 values are surprisingly?

> Your question looks like you made a mistake in your code (just a
> suggestion, of course I can be wrong (that's on thing why I don't like R
> too much: You can more or less write what you want, It's allway correct,
> even if it makes no semantical sense at all)).

Hm, how can I enlighten this? There's a data.frame (fb.12.unt) 
with 302 variables (columns) and 98 values for each (rows). 
Sorry, if I use the wrong terms!! The data.frame was imported 
from SPSS-Data. Some of these variables belong together 
(altogether ~250) and for those I want summaries in extra files.

> What is: fb.12.unt[varA1:varZ9]
> You treat it like a vector, but it is already indexed by a vector, which
> is a sequence from the 
> value of varA1 to the value of varZ9.

Ok, here I has to capitulate ;-/.
    A vector is a datastructure, that concatenates several 
objects of the same kind to one object, e.g. a variable?!?
A data frame allows the combination of different data types in 
a matrix, right? Whereas a matrix has a rectangular structure 
with vectors resp. variables in columns?!
    With this understanding "fb.12.unt" is a data frame and 
"varA1:varZ9" is a sequence of vectors resp. variables. These 
vectors consist of 98 single values resulting in 98 rows of 
the data frame.
    So, "fb.12.unt[varA1]" is a vector, that I want to be 
summarised. And I want "fb.12.unt[varA2]" etc. summarised, too.
    Hoo, I hope I could clarify a little bit =).

> This is really complicated and hard to follow! That's why I believe it's
> not what you want.

After some investigation, I have to say, that you may be right 
(but don't give too much on this statement, because I'm quite 
confused at the moment). What I want is a summary of each of 
the variables/columns. I could also do

 > attach(fb.12.unt)
 > summary(varA1)    # varA1 is a variable from fb.12.unt

for each variable (varA2 etc.) or

 > detach(fb.12.unt)
 > summary(fb.12.unt["varA1"])

for each variable.

> What ist fb.12.unt?
> If it is a data.frame:
> for (i in colnames(fb.12.unt)){print i;...}

I couldn't check this code, because I don't know how to 
replace the ellipsis ("...").

> If it is a vector:
> for (i in 1:length(fb.12.unt)){print i;...}
> If it is a matrix, it could be:
> for (i in 1:ncol(fb.12.unt)){print i;...}
> (or nrow instead of ncol)
> 
> By the way: The only reason NOT to use this relatively easy-to-read
> iterations is performance and with 250 loops this reason does not count.

Ok. I thought, it wasn't "elegant", too =).

[...]

Thanks for your answer, that was first confusing and then 
therefore clarifying. I hope /my/ answer isn't too confusing.

Best regards,

Christoph
-- 
Christoph Bier, Dipl.Oecotroph., Email: bier at wiz.uni-kassel.de
Universitaet Kassel, FG Oekologische Lebensmittelqualitaet und
Ernaehrungskultur \\ Postfach 12 52 \\ 37202 Witzenhausen
Tel.: +49 (0) 55 42 / 98 -17 21, Fax: -17 13




More information about the R-help mailing list