On Mon, 10 May 2004, Christophe Pallier wrote:
The use of tapply(x,f,mean)[match(f,unique(f))] assumes a particular
order in the result of tapply, no? It seems a bit dangerous to me.
My original code for the group means problem used rowsum(,reorder=FALSE)
rather than tapply(), and we do know
Liaw, Andy wrote:
Suppose I
define the function:
fun - function(x, f) {
m - tapply(x, f, mean)
ans - x - m[match(f, unique(f))]
names(ans) - names(x)
ans
}
May I ask what is the purpose of match(f,unique(f)) ?
To remove the group means, I have be using:
x-tapply(x,f,mean)[f]
Both of you might have missed my question from Friday: For very long `x'
(e.g., length=5), indexing by names can take a long time. See that
thread for detail. (For small data, you can hardly tell the difference.)
Also, I'm trying to write the function in a way that one can pass in more
On Mon, 10 May 2004, Liaw, Andy wrote:
Both of you might have missed my question from Friday: For very long `x'
(e.g., length=5), indexing by names can take a long time. See that
thread for detail. (For small data, you can hardly tell the difference.)
That's solved in R-devel as of
On Sat, 8 May 2004, Gabor Grothendieck wrote:
predict(lm(AV~as.factor(GROUP)))
If Felix actually has a huge data frame this will be slow. Instead
try
groupmeans-rowsum(AV,GROUP,reorder=FALSE)
individual.means- groupmeans[match(GROUP, unique(GROUP)]
It uses hashing and takes roughly
Hello list !
I have a huge data.frame with several variables observed on about 3000
persons. For every person (row) there is variable called GROUP which indices
the group the person belongs to. There is also another variable AV for each
person. Now i want to create a new variable which holds
predict(lm(AV~as.factor(GROUP)))
Felix Eschenburg Atropin75 at t-online.de writes:
:
: Hello list !
:
: I have a huge data.frame with several variables observed on about 3000
: persons. For every person (row) there is variable called GROUP which indices
: the group the person belongs to.