Displaying 2 results from an estimated 2 matches for "some_factor".
2009 Jun 24
1
"by" question
Hello all
I have a big data frame and I regularly want to break it down into subsets,
calculate some new data, and add it back to the data frame.
At the moment my technique seems a bit ugly and embarrassing. Something
like:
result <- by(mydata, mydata$some_factor, function (x) {
# do something to create a vector v with length(v) == nrow(x)
return(v)
})
# now result has a big list, argh... how do I put it neatly back into the
mydata data frame?
for (i in unique(mydata$some_factor) {
mydata$newvar[mydata$somefactor ==i] <- result[[i]]
}
What should I b...
2004 May 24
3
error in make.names docs (PR#6912)
...nd.b.1"
when it is actually
"a.and.b" "a_and_b"
The docs do not reflect this very major change in behavior from 1.8.x to 1.9.0.
This change causes numerous R codes to fail in senarios like the following.
Suppose I have a data file, example.dat, like this:
a b x some_factor
1 1 0.4 orange
2 1 0.3 blue
1 1 0.2 dog
2 1 0.1 orange
1 2 0.4 blue
2 2 0.3 dog
1 2 0.2 orange
2 2 0.1 blue
To read and use this in a version independent way, I've tried to write
version-aware code, but this is difficult as '_' is not syntactically valid
prior to R 1.9.0. If it were,...