[R] Data manipulation

Stephen Tucker brown_emu at yahoo.com
Mon Oct 15 09:33:26 CEST 2007


Hi Klaus,

I am not exactly sure what you are asking for, but something like this? This
would be option (2) from your list - I don't know that it would be too
difficult in R that you would want to use another tool.

filt <- function(x)
  with(x,which(Hole > 1))

normalize <- function(x,y)
{
  x$Feature <- x$Feature - with(y,Nominel[match(x$Hole,Hole)])
  return(x)
}

# from CSV import
mydata <- read.csv(...)

# answer
normalizedData <- normalize(filt(mydata))




--- Klaus Friis Østergaard <farremosen at gmail.com> wrote:

> Hi,
> 
> I have a data set which is like this I write as the CSV I import:
> 
> Sample;Hole;Feature;Value
> 1;5;x;4,2334
> 1;5;y;3,3434
> 1;5;r;0,1080
> 1;10;x;5,2526
> 1;10;y;4,3434
> 1;10;r;0,1080
> ....
> 
> with 98 sample and 10 different holes. These are measured values.
> 
> Now I also have a list of nominel values:
> 
> Hole;Feature;Nominel;LSL;USL
> 5;x;4,25,4,20;4,30
> 5;y;3,35;3,30;3,40
> 5;r;0,10;0,07;0,13
> 10;x;5,25;5,20;5,30
> ...
> 
> If I want to "normalize" the measured values. The results are to be used in
> a Sweave file that I plan to reuse for several similar data sets in the
> furture.
> 
> I have been looking at different approache:
> 1. do it in a script out side R
> 2. do it the long and hard way by filtering out all the single holes and
> Feature, the on this list subtract the nominel values, and then combine it
> back.
> 3. ?
> 
> Any help and guidence apriciated
> -- 
> Klaus F. Østergaard, <farremosen(at)gmail dot com>
> 
> 	[[alternative HTML version deleted]]
> 
> > ______________________________________________
> R-help at 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.
>



More information about the R-help mailing list