- here the link to the discussion;
- and here my short suggestion for R Code:
I do not know, whether this is the simples solution in R, but here is the shortest solution I came up with (without thinking about that too deeply):
#create a data matrix (not part of the process -- usually you have that already...)
a<-c(1,2,3,4,5)
b<-c(6,7,8,9,10)
test<-data.frame(cbind(a,b))
#Calculate mean of column a and place it as a new variable in the data frame:
test$meana<-mean(test$a)
#Or, if this is really about centering:
test$meana<-(test$a-mean(test$a))
The solution can spare some letters by attaching "test", but mostly I think, that's it.
0 Kommentare:
Kommentar veröffentlichen