3

I am having a problem mergin my datasets together. I get the above error message after I run the last line of code. However, both data sets have the same column name.

The head of avgRev2 is:

  avgRev         restaurantType
 1       33                 Afghan
 2       22                African
 3 56.84211         American (New)
 4 28.69203 American (Traditional)
 5        7              Argentine
 6 51.40909   Arts & Entertainment

The last two rows in expandedDataframe are:

isRestaurant restaurantType
X5          TRUE         Bagels
X10         TRUE     Sandwiches
X12         TRUE        Mexican
X14         TRUE          Pizza
X18         TRUE        Burgers
X23         TRUE        Buffets

I wrote the below code but it won't let me merge the data. I get the error :

Error in fix.by(by.x, x) : 'by' must specify a uniquely valid column

avgRev <- tapply(expandedDataFrame$review_count,expandedDataFrame$restaurantType,mean,simplify=FALSE)

avgRev2 <- as.data.frame(avgRev,)
avgRev2$category<-row.names(avgRev2)
row.names(avgRev2)=NULL

avgRev2 <- rename(avgRev2, c(category="restaurantType"))

expandedDataFrame2<- merge(expandedDataFrame, avgRev2, by="restuarantType")
Brian Tompsett - 汤莱恩
  • 5,195
  • 62
  • 50
  • 120
SJSU2013
  • 525
  • 3
  • 7
  • 17
  • 3
    You misspelled `restuarantType`. – joran Nov 25 '13 at 22:54
  • 5
    By the way, you appear to be new, and may not understand how to use this site correctly. Please spend some time reviewing the site's help, in particular you should read [this](http://stackoverflow.com/help/someone-answers). – joran Nov 25 '13 at 22:58
  • 1
    Unfortunately, I need a reputation of 15 to vote a response up :( – SJSU2013 Nov 26 '13 at 07:11

0 Answers0