0

I have two databases, one with several observations such as df1 = (size, weight, year) and one with just df2= (year, price). I need to add the price for that year to every observation in df1.

Ive tried merge which wont let me because df2 is much smaller and I need to repeat the values. I've tried right_join which throws the

Error in UseMethod("right_join") : no applicable method for 'right_join' applied to an object of class c('double','numeric')"

When I've tried df3 <- left_join(df1, df2, by= "year" ) the result is:

Error in UseMethod("left_join") : no applicable method for 'left_join' applied to an object of class c('double', numeric')"

Jaap
  • 77,147
  • 31
  • 174
  • 185
  • Possible duplicate of [Merge dataframes, different lengths](https://stackoverflow.com/questions/14102498/merge-dataframes-different-lengths) – Hunaidkhan Nov 27 '18 at 04:43
  • 1
    Welcome to StackOverflow! Please read the info about [how to ask a good question](http://stackoverflow.com/help/how-to-ask) and how to give a [reproducible example](http://stackoverflow.com/questions/5963269). This will make it much easier for others to help you. – Ronak Shah Nov 27 '18 at 04:45
  • please include the `dput(df1)` and `dput(df2)` outputs so we can help you – morgan121 Nov 27 '18 at 05:20
  • Have you tried the `plyr::join()` function? Specify that `type=left` or `type=full` (hard for me to tell without seeing any data) and see if it gives you what you want? – morgan121 Nov 27 '18 at 05:24
  • It looks like you have major syntax errors and are trying to apply `dplyr::left_join` on a numeric vector? – Konrad Nov 27 '18 at 08:02

0 Answers0