0

I have an automated report that i produce using knitr. i'm running across the oddest problem. I wrote a function that sums the data by month for several locations. when i run this function in R i get the following result (which is correct):

NAME MONTH VOL

1: TOTAL 1 13.00872

2: TOTAL 2 11.62527

3: TOTAL 3 12.71313

4: TOTAL 4 12.67269

5: TOTAL 5 15.05127

6: TOTAL 6 14.61002

7: TOTAL 7 15.43827

8: TOTAL 8 15.22400

9: TOTAL 9 14.91259

10: TOTAL 10 15.83505

11: TOTAL 11 14.97242

12: TOTAL 12 16.34950

when i run this same function (no changes) through knitr to produce the report i get the following result:

NAME MONTH VOL

1: TOTAL 1 14.00872

2: TOTAL 2 13.62527

3: TOTAL 3 15.71313

4: TOTAL 4 16.11338

5: TOTAL 5 17.61269

6: TOTAL 6 18.46945

7: TOTAL 7 20.18851

8: TOTAL 8 21.04382

9: TOTAL 9 21.72287

10: TOTAL 10 23.54272

11: TOTAL 11 23.72971

12: TOTAL 12 26.03293

i also have another table where knitr just prints non-sense even though the table has actual values in it.

Here is my session info:

R version 3.1.2 (2014-10-31) Platform: x86_64-w64-mingw32/x64 (64-bit)

locale: [1] LC_COLLATE=English_United States.1252 LC_CTYPE=English_United States.1252
[3] LC_MONETARY=English_United States.1252 LC_NUMERIC=C
[5] LC_TIME=English_United States.1252

attached base packages: [1] stats graphics grDevices utils datasets methods base

other attached packages: [1] lubridate_1.3.3 xtable_1.7-4 shape_1.4.2 reshape2_1.4.1 rgdal_0.9-2 raster_2.2-12
[7] sp_1.0-17 png_0.1-7 data.table_1.9.2

loaded via a namespace (and not attached): [1] digest_0.6.8 evaluate_0.5.5 formatR_1.1 grid_3.1.2 knitr_1.9 lattice_0.20-29 memoise_0.2.1
[8] packrat_0.4.3 plyr_1.8.1 Rcpp_0.11.5 stringr_0.6.2 tools_3.1.2

  • 1
    This is really an R question and would be better answered at stackoverflow.com/questions/tagged/r. But you need to check that the same packages are loaded when you run knitr. Try running the knit function inside a R session both before and after you run your function in the R session. – R. Schumacher Apr 7 '15 at 15:28
  • i will post there then. – Erica D Apr 7 '15 at 16:40
  • 1
    An MWE as a full .rnw file would help – Boris Apr 7 '15 at 17:37
  • i posted in the R section of stacked exchange. – Erica D Apr 8 '15 at 15:42

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Browse other questions tagged or ask your own question.