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")
3
  • 3
    You misspelled restuarantType.
    – joran
    Nov 25, 2013 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.
    – joran
    Nov 25, 2013 at 22:58
  • 1
    Unfortunately, I need a reputation of 15 to vote a response up :(
    – SJSU2013
    Nov 26, 2013 at 7:11

0

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge that you have read and understand our privacy policy and code of conduct.

Browse other questions tagged or ask your own question.