I have the following R code:
cleanData <- aggregate(x = stormData[c("FATALITIES", "INJURIES")],
by = list(tolower(stormData$EVTYPE)), sum)
It runs fine in the R Studio console, but when I copy/paste this in a chunk in knitr
it generates an error:
Error in `$<-.data.frame`(`*tmp*`, "HARM", value = c(15, 0, 2, 2, 2, 6, :
replacement has 902297 rows, data has 898
Calls: <Anonymous> ... withVisible -> eval -> eval -> $<- -> $<-.data.frame
I'm not sure why this is happening.