[R] proc standardize & data frame x and y

Wensui Liu liuwensui at gmail.com
Sun Aug 13 07:31:21 CEST 2006


zubin,

for your second question:

supposed you have x1 and x2 and want to combine them in a matrix X in
a data frame called data, try the following code:

X<-matrix(1:10, ncol = 2, dimnames = list(NULL, c("x1", "x2")));
class(X)
class(X)<-"AsIs";
class(X)
data<-data.frame(X);
summary(data);



On 8/12/06, zubin <binabina at bellsouth.net> wrote:
> Hello!  i know these are basic but i cannot seem to find the answer thru
> my searches..
>
> 1) Can someone recommend an equivalent to SAS PROC Standardize in R?  I
> am in need to frequently standardize a data frame, with z-scores, or
> squash to 0-1 scale - is there a slick function or package someone can
> recommend?
>
> 2) Also, have data sets with a lot of predictor variables.  in the
> diabetes data frame i see that fields have been grouped to X and Y
> variables, making it very easy to identify X and Y in the regression
> techniques.  How is this done, how do you group lets say a group of
> columns into 1 matrix, within a data frame.  example: the AsIs group is
> a matrix of X variables:
>
>  > str(diabetes)
> `data.frame':   442 obs. of  3 variables:
>  $ x : AsIs [1:442, 1:10] 0.038075.... -0.00188.... 0.085298....
> -0.08906.... 0.005383.... ...
>   ..- attr(*, "dimnames")=List of 2
>   .. ..$ : NULL
>   .. ..$ : chr  "age" "sex" "bmi" "map" ...
>   ..- attr(*, "class")= chr "AsIs"
>  $ y : num  151 75 141 206 135 97 138 63 110 310 ...
>  $ x2: AsIs [1:442, 1:64] 0.038075.... -0.00188.... 0.085298....
> -0.08906.... 0.005383.... ...
>   ..- attr(*, ".Names")= chr  "age" "age" "age" "age" ...
>   ..- attr(*, "dimnames")=List of 2
>   .. ..$ : chr  "1" "2" "3" "4" ...
>   .. ..$ : chr  "age" "sex" "bmi" "map" ...
>   ..- attr(*, "class")= chr "AsIs"
>
> ______________________________________________
> R-help at stat.math.ethz.ch 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.
>


-- 
WenSui Liu
(http://spaces.msn.com/statcompute/blog)
Senior Decision Support Analyst
Health Policy and Clinical Effectiveness
Cincinnati Children Hospital Medical Center



More information about the R-help mailing list