Re: [R] transform dataframe with look-up table

2013-07-26 Thread Juan Antonio Balbuena
Hello First thank you very much to Jean, Bill, Brian and David for the answers and code. I very extremely grateful. I am eventually going to adapt Brian's code with a very minor alteration. If one follows the original syntax End <- merge(merge(Start, transformer, by.x="Left", by.y="

Re: [R] transform dataframe with look-up table

2013-07-25 Thread David Carlson
Here's an approach that seems to work. I added an 11th case to your data since you did not have a case where both Left and Right had multiple values in the lookup table. This creates an id value so that we can merge left and right separately and then merge them back together: # Create test data fr

Re: [R] transform dataframe with look-up table

2013-07-25 Thread Brian Diggs
On 7/25/2013 8:13 AM, Juan Antonio Balbuena wrote: > > Hello > I hope that there is a simple solution to this apparently complex problem. > Any help will be much appreciated: > I have a dataframe with Left and Right readings (that is, elements in each > row are paired). For inst

Re: [R] transform dataframe with look-up table

2013-07-25 Thread William Dunlap
It would be helpful if you included the expected output for your example, but I think the following does what you want by using merge() for each lookup: f0 <- function(inputDF, lookupDF) { tmp1 <- merge(inputDF, lookupDF, by.x="Left", by.y="input",all.x=TRUE) tmp2 <- merge(tmp1, lookupDF,

Re: [R] transform dataframe with look-up table

2013-07-25 Thread Adams, Jean
Perhaps this will help. Jean df <- structure(list(Left = c(9L, 4L, 2L, 6L, 3L, 4L, 3L, 4L, 10L, 9L), Right = c(8L, 3L, 1L, 5L, 1L, 1L, 2L, 2L, 8L, 10L)), .Names = c("Left", "Right"), class = "data.frame", row.names = 1:10) lookup <- structure(list(input = c(5L, 10L, 4L, 8L, 6L, 5L, 7L, 2L, 9L,

Re: [R] Transform dataframe

2012-04-22 Thread Jeff Newmiller
On Sun, 22 Apr 2012, David Studer wrote: Hi everyone! I have to following question: I have three items that had to be ordered (e.g. three persons were rating var1 on the first rank): var1 var2 var3 123 213 132 123 Now I'd like to have the data.frame "the other