0

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.

  • may be more a question for Tex – Timo Kvamme Aug 25 '15 at 00:23
  • 1
    This is not a [reproducible example](http://stackoverflow.com/questions/5963269/how-to-make-a-great-r-reproducible-example) – alexwhitworth Aug 25 '15 at 00:27
  • 1
    This looks like the data set used in the Coursera/Johns Hopkins Reproducible Research course. When I load the stormData file into R and run your code in either the console or in an `rmd` file with `knitr` it runs with no errors. We may be able to provide more help if you show exactly what's in your `rmarkdown` file. – eipi10 Aug 25 '15 at 05:17
  • Maybe you loaded packages in your interactive session and forgot to add the `library` calls to your `knitr` file? – CL. Aug 25 '15 at 07:58

0 Answers0