[R] conditional filter resulting in 2 new dataframes

2011-08-14 Thread andrewjt
This is what I am starting with: initial<- matrix(c(1,5,4,8,4,4,8,6,4,2,7,5,4,5,3,2,4,6), nrow=6, ncol=3,dimnames=list(c("1900","1901","1902","1903","1904","1905"), c("sample1","sample2","sample3"))) And I need to apply a filter (in this case, any value <5) to give me one dataframe with only the

[R] conditional replacement of contiguous values

2010-10-08 Thread andrewjt
Hello, I need help getting from data$HAVE to data$NEED (see below). This requires replacing every TRUE in data$HAVE with 4 TRUE(s) in data$NEED. Any ideas? It seems straight forward but I can't figure it out! Thanks in advance HAVE NEED 1 FALSE FALSE 2 FALSE