Re: [R] data.frame: adding a column that is based on ranges of values in another column

2010-07-05 Thread Bill.Venables
lhakim Sent: Tuesday, 6 July 2010 6:01 AM To: r-help@r-project.org Subject: [R] data.frame: adding a column that is based on ranges of values in another column Dear List, I've been looking tirelessly for a solution to this dilemma but without success. Perhaps someone has an idea that will gui

Re: [R] data.frame: adding a column that is based on ranges of values in another column

2010-07-05 Thread Dennis Murphy
Hi: Since you've been looking tirelessly :) For your stated problem, the following will work: DF$Fortnight <- with(DF, ifelse(Date %in% f.n1, 'FN1', ifelse(Date %in% f.n2, 'FN2', 'FN3'))) However, if you have a number of fortnights (perhaps stretching over several year

Re: [R] data.frame: adding a column that is based on ranges of values in another column

2010-07-05 Thread jim holtman
use 'merge': > DF = data.frame(X = c(114.5508, 114.6468, 114.6596, 114.6957, 114.6828, > 114.8903, 114.9519, 114.8842, + 114.8579, 114.8489), Y = c(47.14094, 46.98874, 46.91235, 46.88265, 46.80584, 46.67022, 46.53264, 46.47727, + 46.46457, 46.47032), Date = as.Date(c('2009-01-01', '2009-01-03', '

[R] data.frame: adding a column that is based on ranges of values in another column

2010-07-05 Thread Abdi, Abdulhakim
Dear List, I've been looking tirelessly for a solution to this dilemma but without success. Perhaps someone has an idea that will guide me in the right direction. Suppose I have the following data.frame: DF = data.frame(X = c(114.5508, 114.6468, 114.6596, 114.6957, 114.6828, 114.8903, 114.9519