When I try to render an rmarkdown file with a ggplot image, all the chunks work that do not contain a ggplot image and it fails without an error when it tries to run said chunk.
The output I get in my terminal is
Killed
It runs fine on my local machine with the latest version of R and all the packages updated.
Below is the environment I am using in docker to try to run the same thing (when it fails).
R version 3.4.1 (2017-06-30)
Platform: x86_64-redhat-linux-gnu (64-bit)
Running under: Amazon Linux AMI 2017.09
Matrix products: default
BLAS/LAPACK: /usr/lib64/R/lib/libRblas.so
locale:
[1] C
attached base packages:
[1] stats graphics grDevices utils datasets methods base
other attached packages:
[1] bindrcpp_0.2.2 blogdown_0.10 rmarkdown_1.11 here_0.1
[5] PRROC_1.3.1 DT_0.5 forcats_0.3.0
stringr_1.3.1
[9] dplyr_0.7.8 purrr_0.2.5 readr_1.3.1
tidyr_0.8.2
[13] tibble_2.0.1 ggplot2_3.1.0 tidyverse_1.2.1
data.table_1.12.0
loaded via a namespace (and not attached):
[1] Rcpp_1.0.0 lubridate_1.7.4 lattice_0.20-35
assertthat_0.2.0
[5] rprojroot_1.3-2 digest_0.6.18 mime_0.6 R6_2.3.0
[9] cellranger_1.1.0 plyr_1.8.4 backports_1.1.3 evaluate_0.12
[13] httr_1.4.0 pillar_1.3.1 rlang_0.3.1
lazyeval_0.2.1
[17] readxl_1.2.0 rstudioapi_0.9.0 Matrix_1.2-10
reticulate_1.10
[21] htmlwidgets_1.3 munsell_0.5.0 shiny_1.2.0 broom_0.5.1
[25] compiler_3.4.1 httpuv_1.4.5.1 modelr_0.1.2 xfun_0.4
[29] pkgconfig_2.0.2 htmltools_0.3.6 tidyselect_0.2.5 crayon_1.3.4
[33] withr_2.1.2 later_0.7.5 grid_3.4.1 nlme_3.1-131
[37] jsonlite_1.6 xtable_1.8-3 gtable_0.2.0 magrittr_1.5
[41] scales_1.0.0 cli_1.0.1 stringi_1.2.4
promises_1.0.1
[45] xml2_1.2.0 generics_0.0.2 tools_3.4.1 glue_1.3.0
[49] hms_0.4.2 crosstalk_1.0.0 yaml_2.2.0
colorspace_1.4-0
[53] rvest_0.3.2 knitr_1.21 bindr_0.1.1 haven_2.0.0
Related
I'm trying to use the waterfall R package to create a waterfall chart, like this, per the example at this link:
category <- c("Sales", "Services", "Fixed Costs",
"Variable Costs", "Taxes")
amount <- c(101000, 52000, -23000, -15000, -10000)
income <- data.frame(category, amount)
library(ggplot2)
library(waterfalls)
waterfall(income)
But getting this error:
Error in unit(rep(just$hjust, n), "npc") : 'x' and 'units' must have length > 0
How can I make it work?
This is the output from my sessionInfo()
R version 3.6.0 (2019-04-26)
Platform: x86_64-apple-darwin15.6.0 (64-bit)
Running under: macOS Mojave 10.14.5
Matrix products: default
BLAS: /System/Library/Frameworks/Accelerate.framework/Versions/A/Frameworks/vecLib.framework/Versions/A/libBLAS.dylib
LAPACK: /Library/Frameworks/R.framework/Versions/3.6/Resources/lib/libRlapack.dylib
locale:
[1] en_US.UTF-8/en_US.UTF-8/en_US.UTF-8/C/en_US.UTF-8/en_US.UTF-8
attached base packages:
[1] stats graphics grDevices utils datasets methods base
other attached packages:
[1] waterfalls_0.1.2 DBI_1.0.0 ggpubr_0.2 patchwork_0.0.1 forcats_0.4.0 stringr_1.4.0 dplyr_0.8.0.1 purrr_0.3.2
[10] readr_1.3.1 tidyr_0.8.3 tibble_2.1.1 ggplot2_3.1.1 tidyverse_1.2.1 scales_1.0.0 lubridate_1.7.4 magrittr_1.5 RPresto_1.3.2
[19] knitr_1.22 extrafont_0.17 bigrquery_1.1.1
loaded via a namespace (and not attached):
[1] nlme_3.1-139 sf_0.7-4 bit64_0.9-7 httr_1.4.0 tools_3.6.0 backports_1.1.4 rgdal_1.4-3 R6_2.4.0
[9] KernSmooth_2.23-15 rgeos_0.4-3 lazyeval_0.2.2 colorspace_1.4-1 raster_2.8-19 withr_2.1.2 sp_1.3-1 tidyselect_0.2.5
[17] bit_1.1-14 curl_3.3 compiler_3.6.0 extrafontdb_1.0 cli_1.1.0 rvest_0.3.3 formatR_1.6 xml2_1.2.0
[25] labeling_0.3 dygraphs_1.1.1.6 classInt_0.3-3 digest_0.6.18 foreign_0.8-71 rmarkdown_1.12 base64enc_0.1-3 pkgconfig_2.0.2
[33] htmltools_0.3.6 jsonvalidate_1.0.0 htmlwidgets_1.3 rlang_0.3.4 readxl_1.3.1 rstudioapi_0.10 httpcode_0.2.0 shiny_1.3.2
[41] generics_0.0.2 zoo_1.8-5 jsonlite_1.6 futile.logger_1.4.3 Rcpp_1.0.1 munsell_0.5.0 yaml_2.2.0 stringi_1.4.3
[49] jqr_1.1.0 plyr_1.8.4 grid_3.6.0 settings_0.2.4 maptools_0.9-5 parallel_3.6.0 listenv_0.7.0 promises_1.0.1
[57] crayon_1.3.4 geojsonio_0.7.0 miniUI_0.1.1.1 lattice_0.20-38 haven_2.1.0 geojson_0.3.2 hms_0.4.2 pillar_1.3.1
[65] geojsonlint_0.3.0 codetools_0.2-16 futile.options_1.0.1 crul_0.7.4 glue_1.3.1 infuser_0.2.8 evaluate_0.13 V8_2.2
[73] lambda.r_1.2.3 modelr_0.1.4 png_0.1-7 httpuv_1.5.1 Rttf2pt1_1.3.7 cellranger_1.1.0 gtable_0.3.0 future_1.12.0
[81] RDruid_0.2.3 assertthat_0.2.1 xfun_0.6 mime_0.6 xtable_1.8-4 broom_0.5.2 e1071_1.7-1 later_0.8.0
[89] class_7.3-15 units_0.6-2 globals_0.12.4
I just found that not loading my company's internal package actually fixes this issue. There must be a function in my company's package that's breaking this package.
When I preview my R Notebook, the HTML output contains strange characters.
This chunk code and output
gets rendered in HTML as
How should I fix this?
SessionInfo:
R version 3.6.0 (2019-04-26)
Platform: x86_64-w64-mingw32/x64 (64-bit)
Running under: Windows 10 x64 (build 17763)
Matrix products: default
locale:
1 LC_COLLATE=Dutch_Netherlands.1252 LC_CTYPE=Dutch_Netherlands.1252 LC_MONETARY=Dutch_Netherlands.1252 LC_NUMERIC=C
[5] LC_TIME=Dutch_Netherlands.1252
other attached packages:
1 plotly_4.9.0 DT_0.6 shinydashboard_0.7.1 shiny_1.3.2 lubridate_1.7.4 forcats_0.4.0
[7] stringr_1.4.0 dplyr_0.8.1 purrr_0.3.2 readr_1.3.1 tidyr_0.8.3 tibble_2.1.1
[13] ggplot2_3.1.1 tidyverse_1.2.1
loaded via a namespace (and not attached):
1 tidyselect_0.2.5 xfun_0.7 haven_2.1.0 lattice_0.20-38 colorspace_1.4-1 generics_0.0.2 viridisLite_0.3.0 htmltools_0.3.6
[9] base64enc_0.1-3 yaml_2.2.0 rlang_0.3.4 pillar_1.4.0 later_0.8.0 glue_1.3.1 withr_2.1.2 modelr_0.1.4
[17] readxl_1.3.1 plyr_1.8.4 munsell_0.5.0 gtable_0.3.0 cellranger_1.1.0 rvest_0.3.4 htmlwidgets_1.3 evaluate_0.14
[25] knitr_1.23 httpuv_1.5.1 crosstalk_1.0.0 broom_0.5.2 Rcpp_1.0.1 xtable_1.8-4 scales_1.0.0 backports_1.1.4
[33] promises_1.0.1 jsonlite_1.6 mime_0.6 hms_0.4.2 digest_0.6.19 stringi_1.4.3 grid_3.6.0 cli_1.1.0
[41] tools_3.6.0 magrittr_1.5 lazyeval_0.2.2 crayon_1.3.4 pkgconfig_2.0.2 data.table_1.12.2 xml2_1.2.0 rmarkdown_1.13
[49] assertthat_0.2.1 httr_1.4.0 rstudioapi_0.10 R6_2.4.0 nlme_3.1-139 compiler_3.6.0
I want to read a bunch of files in from a directory using a loop, with a set naming convention (e.g., File_a_1.Rds, File_a_2.Rds, File_b_1.Rds, etc.). There might be gaps in the file names (e.g., File_a_2.Rds might be missing), but gaps themselves aren't a problem. To account for gaps, I've tried using file.exists(): if (file.exists(fname)) readRDS(fname) else NULL, but I then get an error message indicating that R tried to do readRDS(fname) even though fname doesn't exist: Error in readRDS(fname) : error reading from connection. What's going on here?
Other means of testing this if-statement indicate that it works when I'm not trying to use readRDS(). For example, if (file.exists(fname)) "apple" else "banana" gives me apples and bananas where I expect them, so it's weird that the same logic isn't applied to if (file.exists(fname)) readRDS(fname) else NULL. Likewise, using ifTRUE() doesn't help things, contra an earlier post.
N.B. The type of loop shouldn't matter, but in this case I'm using mclapply() to vectorize the operation. And normally I'd just do something like dir() %>% do.call(readRDS), but then the files would be in the wrong order and without the nested structure I'm looking for.
Session info:
Platform: x86_64-pc-linux-gnu (64-bit)
Running under: Ubuntu 16.04.6 LTS
Matrix products: default
BLAS: /usr/lib/atlas-base/atlas/libblas.so.3.0
LAPACK: /usr/lib/atlas-base/atlas/liblapack.so.3.0
locale:
[1] LC_CTYPE=en_NZ.UTF-8 LC_NUMERIC=C LC_TIME=en_NZ.UTF-8 LC_COLLATE=en_NZ.UTF-8
[5] LC_MONETARY=en_NZ.UTF-8 LC_MESSAGES=en_NZ.UTF-8 LC_PAPER=en_NZ.UTF-8 LC_NAME=C
[9] LC_ADDRESS=C LC_TELEPHONE=C LC_MEASUREMENT=en_NZ.UTF-8 LC_IDENTIFICATION=C
attached base packages:
[1] grid parallel stats graphics grDevices utils datasets methods base
other attached packages:
[1] DMwR_0.4.1 ROCR_1.0-7 gplots_3.0.1.1 caret_6.0-81 lattice_0.20-38 ranger_0.11.1
[7] lmerTest_3.1-0 lme4_1.1-20 Matrix_1.2-15 magrittr_1.5 forcats_0.4.0 stringr_1.4.0
[13] dplyr_0.8.0.1 purrr_0.3.0 readr_1.3.1 tidyr_0.8.2 tibble_2.0.1 ggplot2_3.1.0
[19] tidyverse_1.2.1
loaded via a namespace (and not attached):
[1] nlme_3.1-137 bitops_1.0-6 xts_0.11-2 lubridate_1.7.4 httr_1.4.0
[6] numDeriv_2016.8-1 tools_3.5.2 backports_1.1.3 R6_2.4.0 rpart_4.1-13
[11] KernSmooth_2.23-15 lazyeval_0.2.1 colorspace_1.4-0 nnet_7.3-12 withr_2.1.2
[16] tidyselect_0.2.5 curl_3.3 compiler_3.5.2 cli_1.0.1 rvest_0.3.2
[21] xml2_1.2.0 caTools_1.17.1.1 scales_1.0.0 digest_0.6.18 minqa_1.2.4
[26] rmarkdown_1.11 base64enc_0.1-3 pkgconfig_2.0.2 htmltools_0.3.6 TTR_0.23-4
[31] rlang_0.3.1 readxl_1.3.0 rstudioapi_0.9.0 quantmod_0.4-13 generics_0.0.2
[36] zoo_1.8-4 jsonlite_1.6 gtools_3.8.1 ModelMetrics_1.2.2 Rcpp_1.0.0
[41] munsell_0.5.0 abind_1.4-5 stringi_1.3.1 yaml_2.2.0 MASS_7.3-51.1
[46] plyr_1.8.4 recipes_0.1.4 gdata_2.18.0 crayon_1.3.4 haven_2.1.0
[51] splines_3.5.2 hms_0.4.2 knitr_1.21 pillar_1.3.1 reshape2_1.4.3
[56] codetools_0.2-16 stats4_3.5.2 glue_1.3.0 evaluate_0.13 data.table_1.12.0
[61] modelr_0.1.4 nloptr_1.2.1 foreach_1.4.4 cellranger_1.1.0 gtable_0.2.0
[66] assertthat_0.2.0 xfun_0.5 gower_0.1.2 prodlim_2018.04.18 broom_0.5.1
[71] class_7.3-15 survival_2.43-3 timeDate_3043.102 iterators_1.0.10 lava_1.6.5
[76] ipred_0.9-8 ```
I didn't find any results on my internet calls. How to fix this error is caused?
library(ggplot2)
ggplot(data = mtcars, aes(x=disp , y=wt)) +
geom_point(stat = "identity")
result;
Error: Can't find stat called "identity"
My sessionInfo()
R version 3.5.1 (2018-07-02)
Platform: x86_64-pc-linux-gnu (64-bit)
Running under: Ubuntu 18.04.1 LTS
Matrix products: default
BLAS: /usr/lib/x86_64-linux-gnu/blas/libblas.so.3.7.1
LAPACK: /usr/lib/x86_64-linux-gnu/lapack/liblapack.so.3.7.1
locale:
[1] LC_CTYPE=tr_TR.UTF-8 LC_NUMERIC=C
[3] LC_TIME=tr_TR.UTF-8 LC_COLLATE=tr_TR.UTF-8
[5] LC_MONETARY=tr_TR.UTF-8 LC_MESSAGES=tr_TR.UTF-8
[7] LC_PAPER=tr_TR.UTF-8 LC_NAME=C
[9] LC_ADDRESS=C LC_TELEPHONE=C
[11] LC_MEASUREMENT=tr_TR.UTF-8 LC_IDENTIFICATION=C
attached base packages:
[1] stats graphics grDevices utils datasets methods base
other attached packages:
[1] ggplot2_3.1.0 shiny_1.2.0
loaded via a namespace (and not attached):
[1] Rcpp_1.0.0 pillar_1.3.0 compiler_3.5.1
[4] cellranger_1.1.0 RColorBrewer_1.1-2 later_0.7.5
[7] plyr_1.8.4 bindr_0.1.1 forcats_0.3.0
[10] tools_3.5.1 digest_0.6.18 viridisLite_0.3.0
[13] jsonlite_1.5 tibble_1.4.2 gtable_0.2.0
[16] pkgconfig_2.0.2 rlang_0.3.0.1 ggplotgui_1.0.0
[19] rstudioapi_0.8 yaml_2.2.0 haven_1.1.2
[22] bindrcpp_0.2.2 withr_2.1.2 stringr_1.3.1
[25] httr_1.3.1 dplyr_0.7.8 htmlwidgets_1.3
[28] hms_0.4.2 grid_3.5.1 tidyselect_0.2.5
[31] data.table_1.11.8 glue_1.3.0 R6_2.3.0
[34] plotly_4.8.0 readxl_1.1.0 readr_1.1.1
[37] tidyr_0.8.2 purrr_0.2.5 magrittr_1.5
[40] scales_1.0.0 promises_1.0.1 htmltools_0.3.6
[43] assertthat_0.2.0 xtable_1.8-3 mime_0.6
[46] colorspace_1.3-2 httpuv_1.4.5 stringi_1.2.4
[49] lazyeval_0.2.1 munsell_0.5.0 crayon_1.3.4
I want to print a plus minus sign of the form ± into a string in R, so that I can place that string a table with kableextra
Here is the structure of the string :
x = paste0("first_string", 2, "±", 3, "second_string", collapse = "")
However I get the following output:
"first_string2\302\2613second_string"
what should I do to have the output:
"first_string2±3second_string"
I found that \302\261 is the encoding for ± in Octal Escape Sequence according to this website or this website
EDIT Here is the output of sessionInfo():
R version 3.5.0 (2018-04-23)
Platform: x86_64-apple-darwin15.6.0 (64-bit)
Running under: macOS 10.14
Matrix products: default
BLAS: /System/Library/Frameworks/Accelerate.framework/Versions/A/Frameworks/vecLib.framework/Versions/A/libBLAS.dylib
LAPACK: /Library/Frameworks/R.framework/Versions/3.5/Resources/lib/libRlapack.dylib
locale:
[1] C
attached base packages:
[1] splines stats graphics grDevices utils datasets methods base
other attached packages:
[1] bindrcpp_0.2.2 rms_5.1-2 SparseM_1.77 Hmisc_4.1-1 Formula_1.2-3
[6] lattice_0.20-35 blme_1.0-4 emmeans_1.2.4 lme4_1.1-18-1 Matrix_1.2-14
[11] multcomp_1.4-8 TH.data_1.0-8 MASS_7.3-49 mvtnorm_1.0-8 survminer_0.4.3
[16] survival_2.41-3 latex2exp_0.4.0 magick_1.9 cowplot_0.9.3 ggpubr_0.1.7
[21] magrittr_1.5 gridExtra_2.3 rcompanion_2.0.0 ggsignif_0.4.0 ggplot2_3.1.0
[26] chron_2.3-52 lubridate_1.7.4 dplyr_0.7.5 kableExtra_0.9.0 knitr_1.20
[31] broom_0.4.5
loaded via a namespace (and not attached):
[1] minqa_1.2.4 colorspace_1.3-2 class_7.3-14 modeltools_0.2-22
[5] rprojroot_1.3-2 estimability_1.3 htmlTable_1.12 base64enc_0.1-3
[9] rstudioapi_0.7 MatrixModels_0.4-1 manipulate_1.0.1 coin_1.2-2
[13] xml2_1.2.0 codetools_0.2-15 mnormt_1.5-5 nloptr_1.0.4
[17] km.ci_0.5-2 cluster_2.0.7-1 readr_1.1.1 compiler_3.5.0
[21] httr_1.3.1 backports_1.1.2 assertthat_0.2.0 lazyeval_0.2.1
[25] quantreg_5.36 acepack_1.4.1 htmltools_0.3.6 tools_3.5.0
[29] coda_0.19-1 gtable_0.2.0 glue_1.3.0 reshape2_1.4.3
[33] Rcpp_1.0.0 nlme_3.1-137 psych_1.8.4 lmtest_0.9-36
[37] stringr_1.3.1 rvest_0.3.2 polspline_1.1.13 zoo_1.8-2
[41] scales_1.0.0 hms_0.4.2 parallel_3.5.0 sandwich_2.4-0
[45] expm_0.999-2 RColorBrewer_1.1-2 yaml_2.1.19 BSDA_1.2.0
[49] KMsurv_0.1-5 EMT_1.1 rpart_4.1-13 latticeExtra_0.6-28
[53] stringi_1.2.4 nortest_1.0-4 e1071_1.6-8 checkmate_1.8.5
[57] boot_1.3-20 rlang_0.3.0.1 pkgconfig_2.0.1 evaluate_0.10.1
[61] purrr_0.2.5 bindr_0.1.1 labeling_0.3 htmlwidgets_1.2
[65] cmprsk_2.2-7 tidyselect_0.2.4 plyr_1.8.4 R6_2.3.0
[69] DescTools_0.99.25 multcompView_0.1-7 pillar_1.2.3 foreign_0.8-70
[73] withr_2.1.2 nnet_7.3-12 tibble_1.4.2 survMisc_0.5.5
[77] rmarkdown_1.10 grid_3.5.0 data.table_1.11.4 digest_0.6.18
[81] xtable_1.8-2 tidyr_0.8.1 stats4_3.5.0 munsell_0.5.0
[85] viridisLite_0.3.0
Locale settings control character sets for input and output. You have
locale:
[1] C
but if you want to print non-ASCII characters such as ±, you'll need something such as UTF-8. One example of how to accomplish this (which seems to have solved your issue per the comments) is
Sys.setlocale("LC_ALL","en_US.UTF-8")
paste0("first_string", 2, "±", 3, "second_string", collapse = "")
which should output
[1] "first_string2±3second_string"
For further information, I'd check out the following sources as a starting point:
R help page for getting or setting the locale
RStudio support on character encoding
readr's locale vignette