Skip to content
Prev 350403 / 398503 Next

knittr: non-numeric argument to binary operator

knittr is giving me the above error. The code it is failing on is
multiplying two numeric features of a data frame. I can run the code
by hand and it works fine, but when I try to knit my document, knittr
chokes on the same line.

When kitting:

Quitting from lines 161-175 (RepData_PeerAssessment2.Rmd)
Error in storm_data$PROPDMG * storm_data$property_damage_cost_factor :
  non-numeric argument to binary operator
Calls: <Anonymous> ... handle -> withCallingHandlers -> withVisible ->
eval -> eval
Execution halted

Running the same lines manually (CTRL+Enter) from the .Rmd file:
+ (storm_data$PROPDMG * storm_data$property_damage_cost_factor) +
+ (storm_data$CROPDMG * storm_data$crop_damage_cost_factor)
num [1:902297] 25 2.5 25 2.5 2.5 2.5 2.5 2.5 25 25 ...
Call me baffled. Any pointers are greatly appreciated at this point.