Re: [R] proc standardize & data frame x and y

2006-08-13 Thread hadley wickham
> 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?

You could try rescaler in the reshape package.  It currently supports
five column wise rescaling/standardisation methods (common range,
common variance, robust equivalent, rank, do nothing), and I could add
more if needed.

Regards,

Hadley

__
R-help@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.


Re: [R] proc standardize & data frame x and y

2006-08-12 Thread Wensui Liu
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 <[EMAIL PROTECTED]> 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@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

__
R-help@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.


Re: [R] proc standardize & data frame x and y

2006-08-12 Thread Wensui Liu
for proc standardzize, check ?scale



On 8/12/06, zubin <[EMAIL PROTECTED]> 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@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

[[alternative HTML version deleted]]

__
R-help@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.