Skip to content
Prev 299990 / 398503 Next

remove loop which compares row i to row i-1

Hello,

I've not been following this thread but this seems ndependent from 
previous posts. Try the following.



url <- "http://r.789695.n4.nabble.com/file/n4636337/BR3_2011_New.csv"
tUnitsort <- read.csv(url, header=TRUE)

cols <- sapply(c("Date", "Hour", "BlockNumber", "MyTo"), function(x)
         grep(x, names(tUnitsort)))

# This does it
# Use full data.frame 'tUnitsort' if you want
data.tmp <- aggregate(MyTo ~ Date + Hour, data = tUnitsort[, cols], max)
data.tmp <- merge(tUnitsort[, cols], data.tmp, by=c("Date", "Hour"))

# Make it pretty
idx <- grep("MyTo", names(data.tmp))
names(data.tmp)[idx] <- c("MyTo", "NewColumn")

# See it
head(data.tmp, 20)
tail(data.tmp, 20)


Also, you should quote the context. Many, almost all of us do NOT read 
the posts on Nabble. And Nabble does have a "quote" button.

Hope this helps,

Rui Barradas

Em 12-07-2012 18:55, jcrosbie escreveu: