Hello,

Try

scale(test[, c("temp", "oxy")])

Hope this helps,

Rui Barradas

Em 28-06-2012 20:11, Kristi Glover escreveu:

Hi R User,
Would you give me your hand to standardize some columns in a matrix?

I have included the example table.

dput(test)
structure(list(X = c(1, 2, 3, 4, 5, 6), Y = c(4, 5, 6, 7, 8,
9), temp = c(0.818, 0.113, 0.256, 0.587, 0.955, 0.207), oxy = c(0.797,
0.487, 0.727, 0.128, 0.514, 0.031)), .Names = c("X", "Y", "temp",
"oxy"), row.names = c(NA, -6L), class = "data.frame")

here I wanted to standardize the variable "temp" and "oxy". I have more than 75 
variables so that I need to apply 'loop'.

Could you help me to make a loop?

I wrote following but, it did not work.

for (i in 1:n(test)){
for (t in 1:T (test)) x.z[i] = (x[i,t] - mean(x(i,]/sd)x[i,])
}

Thanks for your help.

Kristi

                                        
        [[alternative HTML version deleted]]

______________________________________________
R-help@r-project.org mailing list
https://stat.ethz.ch/mailman/listinfo/r-help
PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
and provide commented, minimal, self-contained, reproducible code.


______________________________________________
R-help@r-project.org mailing list
https://stat.ethz.ch/mailman/listinfo/r-help
PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
and provide commented, minimal, self-contained, reproducible code.

Reply via email to