I have a set of labels arranged along a timeframe in a. Each label has a timestamp and marks a state until the next label. The dataframe a contains 5 such timestamps and 5 associated labels. This means, on a continious scale between 1-100, there are 5 markers. E.g. 'abc' marks the timestampls between 10 and 19, 'def' marks the timestamps between 20 and 32, and so on.
a <- data.frame(timestamp=c(3,5,8), mylabel=c("abc","def","ghi")) b <- data.frame(timestamp=c(1:10)) I would like to assign these labels as an extra collumn 'label' to the data.frame b which currently only consists of a the timestamp. The output would then look like this: timestamp label 1 1 NA 2 2 NA 3 3 "abc" 4 4 "abc" 5 5 "def" 6 6 "def" 7 7 "def" 8 8 "ghi" 9 9 "ghi" 10 10 "ghi" What is the simplest way to assign these labels based on timestamps to get this output. The real dataset is several millions of rows... Thanks, Ralf ______________________________________________ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.