I have this dataframe :
> head(merged.tables)
  Store DayOfWeek       Date Sales Customers Open Promo StateHoliday SchoolHoliday StoreType
1     1         5 2015-07-31  5263       555    1     1            0             1         c
2     1         6 2013-01-12  4952       646    1     0            0             0         c
3     1         5 2014-01-03  4190       552    1     0            0             1         c
4     1         3 2014-12-03  6454       695    1     1            0             0         c
5     1         3 2013-11-13  3310       464    1     0            0             0         c
6     1         7 2013-10-27     0         0    0     0            0             0         c
  Assortment CompetitionDistance CompetitionOpenSinceMonth CompetitionOpenSinceYear Promo2
1          a                1270                         9                     2008      0
2          a                1270                         9                     2008      0
3          a                1270                         9                     2008      0
4          a                1270                         9                     2008      0
5          a                1270                         9                     2008      0
6          a                1270                         9                     2008      0
  Promo2SinceWeek Promo2SinceYear PromoInterval
1              NA              NA              
2              NA              NA              
3              NA              NA              
4              NA              NA              
5              NA              NA              
6              NA              NA       
Then I want to extract a dataframe showing the average of Sales vector when Open equal to 1 and by StoreType. I used this command because it's the fatest I think:
merged.tables[StateHoliday==1,mean(na.omit(Sales)),by=StoreType]
But I got this error:
Error in [.data.frame(merged.tables, StateHoliday == 0, mean(na.omit(Sales)), : unused argument (by = StoreType)
I search but I didn't get an answer to this error. Thanks for your help!
 
     
     
    