?ave

-- 
Gregory (Greg) L. Snow Ph.D.
Statistical Data Center
Intermountain Healthcare
[EMAIL PROTECTED]
(801) 408-8111
 
 

> -----Original Message-----
> From: [EMAIL PROTECTED] 
> [mailto:[EMAIL PROTECTED] On Behalf Of john seers (IFR)
> Sent: Friday, November 16, 2007 7:21 AM
> To: r-help@r-project.org
> Subject: [R] Scaling a column in groups
> 
> 
>  
> Hello R people
> 
> I have a column of numeric values that are grouped in blocks 
> of 25 and to be centered and scaled within each block. (That 
> is subtract the mean and divide by the standard deviation.) 
> 
> Is there a neater way to do this? i.e not using a loop?
> 
> Example looped code:
> 
> testdata<-1:100
> csvalues<-NULL
> for (i in 1:(length(testdata)/25)) {
>     st<-(i-1) * 25 + 1
>     sel<-st:(st+24)
>     selvals<-testdata[sel]
>     csvalues<-c(csvalues, scale(selvals, scale=sd(selvals))) }
> 
> Thanks for any help.
> 
> 
> John Seers
> 
> 
> 
>  
> ---
> 
> John Seers
> Institute of Food Research
> Norwich Research Park
> Colney
> Norwich
> NR4 7UA
>  
> 
> tel +44 (0)1603 251497
> fax +44 (0)1603 507723
> e-mail [EMAIL PROTECTED]                         
> e-disclaimer at http://www.ifr.ac.uk/edisclaimer/ 
>  
> Web sites:
> 
> www.ifr.ac.uk   
> www.foodandhealthnetwork.com
> 
> ______________________________________________
> 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