Re: [R] Aligning names with variable values

2014-02-15 Thread Barry King
Thank you, Arun. Your first suggestion works perfectly and I will use that. - Barry On Sat, Feb 15, 2014 at 12:45 PM, arun wrote: > Also, you could try: > > library(plyr) > indx <- ddply(Prices.df,.(rowID),summarise, > !findInterval(Price,unique(upperLimit[match(rowID,names(upperLimit))])))[,

Re: [R] Aligning names with variable values

2014-02-15 Thread arun
Also, you could try: library(plyr)  indx <- ddply(Prices.df,.(rowID),summarise, !findInterval(Price,unique(upperLimit[match(rowID,names(upperLimit))])))[,2] Prices.df[indx,]  Prices.df[!indx,] #or indx1 <- !with(Prices.df,ave(seq_along(Price),rowID,FUN=function(x) findInterval(Price[x],unique(

Re: [R] Aligning names with variable values

2014-02-15 Thread arun
May be this helps: Prices.df <- read.table(text="rowID  Price 1 'Full Season' 417.95 2 'Full Season' 679.43 3 'Full Season' 839.79 4 'Half Season' 159.39 5 'Half Season' 256.93",sep="",header=TRUE,stringsAsFactors=FALSE) upperLimit <- c(`Full Season`=779.12, `Half Season`=231.11) rejectdf <- do.c

[R] Aligning names with variable values

2014-02-15 Thread Barry King
I wish to compare prices in a dataframe to calculated upper limits and then reject (collect in a reject dataframe) those rows with prices that are above the upper limit but I am having trouble aligning the variable value in the Prices dataframe with the names in the upper limit file. > upperLimit