Dear R users,

I have two datasets:

id1 <- c(rep(1,10), rep(2,10), rep(3,10))
value1 <- sample(1:100, 30, replace=TRUE)
dataset1 <- cbind(id1,value1)

id2 <- c(1,2,3)
subtract.value <- c(1,3,5)
dataset2 <- cbind(id2, subtract.value)

I want to subtract the number of rows in the subtract.value that  
corresponds to the id value in dataset1.  So for the 1 in id1, I want  
to remove the first row, for 2 in id1 I want to remove the first 3  
rows, for 3 in id1 I want to remove the first 5 rows, finally creating  
a new dataframe with the remaining values.

I am having trouble structuring a loop that can do this by the unique  
ids in the first dataset while matching the ids in the datasets.

Any thoughts would be greatly appreciated.

Thank you,
Sara


        [[alternative HTML version deleted]]

______________________________________________
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.

Reply via email to