Folks, Updating values in a table is simple in SAS or SQL, but I've wracked my brain looking for an elegant solution in R to no avail thus far. Certainly this is a common need that's been solved in dozens of different ways.
Given an initial dataframe nn and a smaller dataframe of updates uu, I'd like to replace the values in nn <- expand.grid('a'=1:4, 'b'=1:3) nn$x <- runif(nrow(nn)) nn$y <- runif(nrow(nn)) uu <- rbind(data.frame('a'=1, 'b'=1, 'x'=100, 'y'=-100) ,data.frame('a'=2, 'b'=2, 'x'=200, 'y'=-100) ,data.frame('a'=4, 'b'=1, 'x'=400, 'y'=-100) ,data.frame('a'=3, 'b'=3, 'x'=300, 'y'=-100) ) I'd like the result <- f(nn, uu) to look like a b x y 1 1 1 100 -100 2 2 1 0.8310890 0.2516533 3 3 1 0.4304501 0.3004313 4 4 1 400 -100 5 1 2 0.9546661 0.2935739 6 2 2 200 -100 7 3 2 0.6941463 0.9356967 8 4 2 0.9642832 0.9253482 9 1 3 0.8735154 0.6055080 10 2 3 0.6665369 0.2938112 11 3 3 300 -100 12 4 3 0.7268327 0.4536969 Anyone spare a clue about what f() might look like? Thanks, cur -- Curt Seeliger, Data Ranger Raytheon Information Services - Contractor to ORD seeliger.c...@epa.gov 541/754-4638 [[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.