On Mar 7, 2011, at 10:13 PM, Darcy Webber wrote:
Dear R users,
I am working on allocating the rows within a dataframe into some
factor levels.Consider the following dataframe:
Start.action Start.time
1Start.setting2010-12-30 17:58:00
2
Here is a version that should work for any number of values for Start.action
The only requirement is that your data frame is sorted correctly, ie
that subgroups are well defined.
Quite longer but I used it as an exercice to try an approch 'think generic"
I guess there are a lot of better ways...
K
Hi:
Here's one way to piece it together. All we need is the first variable, so
I'll manufacture a vector of Start.action's and go from there.
w <- data.frame(Start.action = c(rep('Start.setting', 3),
rep('Start.hauling', 4),
rep('Start.setting', 4),
rep('Start.hau
Maybe clumsy but shows the activity. The idea is to use a numeric
index to separate cases where Start.action is the same.
(untested)
my.data$action <- rep("set.or.haul ",20)
my.data$recnums <- c(1:20)
my.data$action[my.data$Start.action=="Start.setting" & my.data
$recnums < 7] <- "set1"
my.d
Dear R users,
I am working on allocating the rows within a dataframe into some
factor levels.Consider the following dataframe:
Start.action Start.time
1Start.setting2010-12-30 17:58:00
2Start.setting2010-12-30 18:40:00
3S
5 matches
Mail list logo