Skip to content
Prev 131864 / 398503 Next

Odp: Book: The New S Language

Hi

r-help-bounces at r-project.org napsal dne 12.12.2007 07:45:54:
going
DF$A,
-
Maybe you misunderstand what split does:
a data frame with 2 columns
a character vector (which is internally turned into factor). And split 
splits your data frame DF into groups according to levels of "g". It does 
not at all lookup into columns of your data frame (and the help page does 
not even give you a suspicion that it shall behave like that).

first sentence in help page tells you
split divides the data in the vector x into the groups defined by f.

compare your result with
Factor w/ 4 levels "A 1","A 2","B 2",..: 1 1 2 3 4
[1] 1 1 2 3 4

split(DF, g.f)
split(DF, g.n)

And try to explain with your idea how split works this
DF$A<-rnorm(5)
s <- split(DF, g)

Regards
Petr
on
referenced
http://www.R-project.org/posting-guide.html