When I use Greek letters in a plot label in R on Fedora 31, the expression will not be properly rendered. Instead of the Greek letter, a missing glyph box appears in the label. The same code works properly on rstudio.cloud. The same behavior can also be observed in ggplot. See the reprex below for an example.
As I understand it, R takes an OS default font for text in plots. This seems to be Liberation Sans in my case. I do not get the problem here, as Liberation has glyphs for the Greek alphabet.
Any help would be appreciated.
Edit
Further investigation resulted in some weird things. I ran the code from terminal and the same thing happens. But within RStudio, when I execute x11() before running plot, then the output is rendered properly in the x11 window.
The strange thing about this is, that x11 appears to be the default graphics device when running the code from the terminal. However, even if I run x11() beforehand in the terminal, it returns a plot with the missing glyph box.
After learning that this has something to do with the graphics device, I tried various graphics devices with ggsave(). With all the formats I tried, the expression was rendered properly.
What is not yet clear to me is the source of the problem. Is this a bug in the R binary from dnf? Or where could the issue lie? I do remember that it work with Fedora 30 a couple of months ago.
plot(Sepal.Length ~ Sepal.Width,
iris,
xlab = expression(beta))
Created on 2020-03-06 by the reprex package (v0.3.0)
devtools::session_info()
#> ─ Session info ───────────────────────────────────────────────────────────────
#> setting value
#> version R version 3.6.2 (2019-12-12)
#> os Fedora 31 (Workstation Edition)
#> system x86_64, linux-gnu
#> ui X11
#> language (EN)
#> collate en_US.UTF-8
#> ctype en_US.UTF-8
#> tz Europe/Berlin
#> date 2020-03-06
#>
#> ─ Packages ───────────────────────────────────────────────────────────────────
#> package * version date lib source
#> assertthat 0.2.1 2019-03-21 [1] CRAN (R 3.6.1)
#> backports 1.1.5 2019-10-02 [1] CRAN (R 3.6.1)
#> callr 3.4.2 2020-02-12 [1] CRAN (R 3.6.2)
#> cli 2.0.1 2020-01-08 [1] CRAN (R 3.6.2)
#> crayon 1.3.4 2017-09-16 [1] CRAN (R 3.6.1)
#> curl 4.3 2019-12-02 [1] CRAN (R 3.6.1)
#> desc 1.2.0 2018-05-01 [1] CRAN (R 3.6.2)
#> devtools 2.2.2 2020-02-17 [1] CRAN (R 3.6.2)
#> digest 0.6.25 2020-02-23 [1] CRAN (R 3.6.2)
#> ellipsis 0.3.0 2019-09-20 [1] CRAN (R 3.6.1)
#> evaluate 0.14 2019-05-28 [1] CRAN (R 3.6.1)
#> fansi 0.4.1 2020-01-08 [1] CRAN (R 3.6.2)
#> fs 1.3.1 2019-05-06 [1] CRAN (R 3.6.1)
#> glue 1.3.1 2019-03-12 [1] CRAN (R 3.6.1)
#> highr 0.8 2019-03-20 [1] CRAN (R 3.6.1)
#> htmltools 0.4.0 2019-10-04 [1] CRAN (R 3.6.1)
#> httr 1.4.1 2019-08-05 [1] CRAN (R 3.6.1)
#> knitr 1.28 2020-02-06 [1] CRAN (R 3.6.2)
#> magrittr 1.5 2014-11-22 [1] CRAN (R 3.6.1)
#> memoise 1.1.0 2017-04-21 [1] CRAN (R 3.6.2)
#> mime 0.9 2020-02-04 [1] CRAN (R 3.6.2)
#> pkgbuild 1.0.6 2019-10-09 [1] CRAN (R 3.6.2)
#> pkgload 1.0.2 2018-10-29 [1] CRAN (R 3.6.2)
#> prettyunits 1.1.1 2020-01-24 [1] CRAN (R 3.6.2)
#> processx 3.4.2 2020-02-09 [1] CRAN (R 3.6.2)
#> ps 1.3.2 2020-02-13 [1] CRAN (R 3.6.2)
#> R6 2.4.1 2019-11-12 [1] CRAN (R 3.6.1)
#> Rcpp 1.0.3 2019-11-08 [1] CRAN (R 3.6.1)
#> remotes 2.1.1 2020-02-15 [1] CRAN (R 3.6.2)
#> rlang 0.4.4 2020-01-28 [1] CRAN (R 3.6.2)
#> rmarkdown 2.1 2020-01-20 [1] CRAN (R 3.6.2)
#> rprojroot 1.3-2 2018-01-03 [1] CRAN (R 3.6.2)
#> sessioninfo 1.1.1 2018-11-05 [1] CRAN (R 3.6.2)
#> stringi 1.4.6 2020-02-17 [1] CRAN (R 3.6.2)
#> stringr 1.4.0 2019-02-10 [1] CRAN (R 3.6.1)
#> testthat 2.3.1 2019-12-01 [1] CRAN (R 3.6.2)
#> usethis 1.5.1 2019-07-04 [1] CRAN (R 3.6.2)
#> withr 2.1.2 2018-03-15 [1] CRAN (R 3.6.1)
#> xfun 0.12 2020-01-13 [1] CRAN (R 3.6.2)
#> xml2 1.2.2 2019-08-09 [1] CRAN (R 3.6.1)
#> yaml 2.2.1 2020-02-01 [1] CRAN (R 3.6.2)
#>
#> [1] /home/steffen/R/x86_64-redhat-linux-gnu-library/3.6
#> [2] /usr/lib64/R/library
#> [3] /usr/share/R/library
Related
Is there a way to prevent a command from printing any output?
I was using the nnet function from the package with the same name and it printed some information that I didn't need, making noise in the output of my own program. I found out that with the parameter trace=FALSE the function would run quietly, but now I'm wondering what would happen if a function didn't accept such an argument.
In other words, would it be possible to temporarily disable the output in R?
Edit
To be more specific, I mean the standard output, the one you have with print. For example, something like this:
print("a")
disable_output()
print("b")
enable_output()
print("c")
with the following output:
[1] "a"
[1] "c"
I think you can divert output globally only to a file (I do not know if you can completely disable it). You can look at ?sink as a starting point.
On the other hand, you can use:
?capture.output: Evaluates its arguments with the output being returned as a character string or sent to a file.
and
?invisible: Return a (temporarily) invisible copy of an object.
To write a function which evaluates its arguments without throwing any (standard) output (note, it could be useful to include ?force in the function's body to force the evaluation of its argument):
invisible(capture.output(print("foo")))
without_output <- function(x) {
invisible(capture.output(force(x)))
}
without_output(print("foo"))
Created on 2020-09-07 by the reprex package (v0.3.0)
devtools::session_info()
#> ─ Session info ───────────────────────────────────────────────────────────────
#> setting value
#> version R version 4.0.2 (2020-06-22)
#> os Ubuntu 20.04.1 LTS
#> system x86_64, linux-gnu
#> ui X11
#> language (EN)
#> collate en_US.UTF-8
#> ctype en_US.UTF-8
#> tz Europe/Rome
#> date 2020-09-07
#>
#> ─ Packages ───────────────────────────────────────────────────────────────────
#> package * version date lib source
#> assertthat 0.2.1 2019-03-21 [1] CRAN (R 4.0.2)
#> backports 1.1.9 2020-08-24 [1] CRAN (R 4.0.2)
#> callr 3.4.3 2020-03-28 [1] CRAN (R 4.0.2)
#> cli 2.0.2 2020-02-28 [1] CRAN (R 4.0.2)
#> crayon 1.3.4 2017-09-16 [1] CRAN (R 4.0.2)
#> desc 1.2.0 2018-05-01 [1] CRAN (R 4.0.2)
#> devtools 2.3.1 2020-07-21 [1] CRAN (R 4.0.2)
#> digest 0.6.25 2020-02-23 [1] CRAN (R 4.0.2)
#> ellipsis 0.3.1 2020-05-15 [1] CRAN (R 4.0.2)
#> evaluate 0.14 2019-05-28 [1] CRAN (R 4.0.2)
#> fansi 0.4.1 2020-01-08 [1] CRAN (R 4.0.2)
#> fs 1.5.0 2020-07-31 [1] CRAN (R 4.0.2)
#> glue 1.4.2 2020-08-27 [1] CRAN (R 4.0.2)
#> highr 0.8 2019-03-20 [1] CRAN (R 4.0.2)
#> htmltools 0.5.0 2020-06-16 [1] CRAN (R 4.0.2)
#> knitr 1.29 2020-06-23 [1] CRAN (R 4.0.2)
#> magrittr 1.5 2014-11-22 [1] CRAN (R 4.0.2)
#> memoise 1.1.0 2017-04-21 [1] CRAN (R 4.0.2)
#> pkgbuild 1.1.0 2020-07-13 [1] CRAN (R 4.0.2)
#> pkgload 1.1.0 2020-05-29 [1] CRAN (R 4.0.2)
#> prettyunits 1.1.1 2020-01-24 [1] CRAN (R 4.0.2)
#> processx 3.4.3 2020-07-05 [1] CRAN (R 4.0.2)
#> ps 1.3.4 2020-08-11 [1] CRAN (R 4.0.2)
#> R6 2.4.1 2019-11-12 [1] CRAN (R 4.0.2)
#> remotes 2.2.0 2020-07-21 [1] CRAN (R 4.0.2)
#> rlang 0.4.7 2020-07-09 [1] CRAN (R 4.0.2)
#> rmarkdown 2.3 2020-06-18 [1] CRAN (R 4.0.2)
#> rprojroot 1.3-2 2018-01-03 [1] CRAN (R 4.0.2)
#> sessioninfo 1.1.1 2018-11-05 [1] CRAN (R 4.0.2)
#> stringi 1.4.6 2020-02-17 [1] CRAN (R 4.0.2)
#> stringr 1.4.0 2019-02-10 [1] CRAN (R 4.0.2)
#> testthat 2.3.2 2020-03-02 [1] CRAN (R 4.0.2)
#> usethis 1.6.1 2020-04-29 [1] CRAN (R 4.0.2)
#> withr 2.2.0 2020-04-20 [1] CRAN (R 4.0.2)
#> xfun 0.16 2020-07-24 [1] CRAN (R 4.0.2)
#> yaml 2.2.1 2020-02-01 [1] CRAN (R 4.0.2)
#>
#> [1] /home/cl/R/x86_64-pc-linux-gnu-library/4.0
#> [2] /usr/local/lib/R/site-library
#> [3] /usr/lib/R/site-library
#> [4] /usr/lib/R/library
I'm reading over some R code, and I've come across a line that where the function prototype doesn't seem to match what I've seen in the library's api (fabletools).
fitted_model = a_time_series %>%
filter(date <= tsibble::year(someyear)) %>%
fabletools::model(arima = ARIMA(time)
...Where time is a column from a a_time_series. How do I tell what arima model this is using?
(e.g. arima(1,1,1) or arima(0,1,1) ,etc)
I've checked this documentation however, the function prototypes don't seem to match.
You can identify the ARIMA output by looking at the formatted output in the console. If you need to obtain this display as text, you can use the format() function.
library(fable)
#> Loading required package: fabletools
library(tsibble)
library(dplyr)
tourism %>%
group_by(Purpose) %>%
summarise(Trips = sum(Trips)) %>%
model(auto_arima = ARIMA(Trips)) %>%
mutate(format(auto_arima))
#> # A mable: 4 x 3
#> # Key: Purpose [4]
#> Purpose auto_arima `format(auto_arima)`
#> <chr> <model> <chr>
#> 1 Business <ARIMA(0,1,1)(0,1,1)[4]> <ARIMA(0,1,1)(0,1,1)[4]>
#> 2 Holiday <ARIMA(0,1,1)(0,1,1)[4]> <ARIMA(0,1,1)(0,1,1)[4]>
#> 3 Other <ARIMA(0,1,1)(1,0,0)[4]> <ARIMA(0,1,1)(1,0,0)[4]>
#> 4 Visiting <ARIMA(1,0,1)(2,1,0)[4]> <ARIMA(1,0,1)(2,1,0)[4]>
Created on 2020-06-12 by the reprex package (v0.3.0)
Session info
devtools::session_info()
#> ─ Session info ───────────────────────────────────────────────────────────────
#> setting value
#> version R version 3.6.2 (2019-12-12)
#> os Ubuntu 18.04.4 LTS
#> system x86_64, linux-gnu
#> ui X11
#> language en_AU:en
#> collate en_AU.UTF-8
#> ctype en_AU.UTF-8
#> tz Australia/Melbourne
#> date 2020-06-12
#>
#> ─ Packages ───────────────────────────────────────────────────────────────────
#> package * version date lib source
#> anytime 0.3.7 2020-01-20 [1] CRAN (R 3.6.1)
#> assertthat 0.2.1 2019-03-21 [1] CRAN (R 3.6.1)
#> backports 1.1.7 2020-05-13 [1] RSPM (R 3.6.3)
#> callr 3.4.3 2020-03-28 [1] CRAN (R 3.6.2)
#> cli 2.0.2 2020-02-28 [1] RSPM (R 3.6.2)
#> colorspace 1.4-1 2019-03-18 [1] CRAN (R 3.6.1)
#> crayon 1.3.4 2017-09-16 [1] CRAN (R 3.6.1)
#> desc 1.2.0 2018-05-01 [1] CRAN (R 3.6.1)
#> devtools 2.2.2 2020-02-17 [1] RSPM (R 3.6.2)
#> digest 0.6.25 2020-02-23 [1] RSPM (R 3.6.2)
#> distributional 0.1.0.9000 2020-06-10 [1] local
#> dplyr * 1.0.0 2020-05-29 [1] CRAN (R 3.6.2)
#> ellipsis 0.3.1 2020-05-15 [1] CRAN (R 3.6.2)
#> evaluate 0.14 2019-05-28 [1] CRAN (R 3.6.1)
#> fable * 0.2.1 2020-06-11 [1] local
#> fabletools * 0.2.0 2020-06-11 [1] local
#> fansi 0.4.1 2020-01-08 [1] RSPM (R 3.6.2)
#> farver 2.0.3 2020-01-16 [1] CRAN (R 3.6.1)
#> feasts 0.1.4 2020-06-04 [1] local
#> fs 1.4.1 2020-04-04 [1] RSPM (R 3.6.3)
#> generics 0.0.2 2018-11-29 [1] CRAN (R 3.6.1)
#> ggplot2 3.3.1 2020-05-28 [1] CRAN (R 3.6.2)
#> glue 1.4.1.9000 2020-05-26 [1] Github (tidyverse/glue#a605000)
#> gtable 0.3.0 2019-03-25 [1] CRAN (R 3.6.1)
#> highr 0.8 2019-03-20 [1] CRAN (R 3.6.1)
#> htmltools 0.4.0 2019-10-04 [1] CRAN (R 3.6.1)
#> knitr 1.28 2020-02-06 [1] RSPM (R 3.6.2)
#> lattice 0.20-38 2018-11-04 [2] CRAN (R 3.6.2)
#> lifecycle 0.2.0.9000 2020-03-19 [1] Github (r-lib/lifecycle#355dcba)
#> lubridate 1.7.8 2020-04-06 [1] RSPM (R 3.6.3)
#> magrittr 1.5 2014-11-22 [1] CRAN (R 3.6.1)
#> memoise 1.1.0 2017-04-21 [1] CRAN (R 3.6.1)
#> munsell 0.5.0 2018-06-12 [1] CRAN (R 3.6.1)
#> nlme 3.1-142 2019-11-07 [2] CRAN (R 3.6.2)
#> pillar 1.4.4 2020-05-25 [1] Github (r-lib/pillar#2f5ad11)
#> pkgbuild 1.0.8 2020-05-07 [1] RSPM (R 3.6.3)
#> pkgconfig 2.0.3 2019-09-22 [1] CRAN (R 3.6.1)
#> pkgload 1.1.0 2020-05-29 [1] CRAN (R 3.6.2)
#> prettyunits 1.1.1 2020-01-24 [1] CRAN (R 3.6.2)
#> processx 3.4.2 2020-02-09 [1] RSPM (R 3.6.2)
#> progressr 0.6.0 2020-05-19 [1] CRAN (R 3.6.2)
#> ps 1.3.3 2020-05-08 [1] RSPM (R 3.6.3)
#> purrr 0.3.4 2020-04-17 [1] RSPM (R 3.6.3)
#> R6 2.4.1 2019-11-12 [1] CRAN (R 3.6.1)
#> Rcpp 1.0.4.6 2020-04-09 [1] CRAN (R 3.6.2)
#> remotes 2.1.1 2020-02-15 [1] RSPM (R 3.6.2)
#> rlang 0.4.6.9000 2020-05-20 [1] Github (r-lib/rlang#691b5a8)
#> rmarkdown 2.1 2020-01-20 [1] CRAN (R 3.6.2)
#> rprojroot 1.3-2 2018-01-03 [1] CRAN (R 3.6.1)
#> scales 1.1.1 2020-05-11 [1] RSPM (R 3.6.3)
#> sessioninfo 1.1.1 2018-11-05 [1] CRAN (R 3.6.1)
#> stringi 1.4.6 2020-02-17 [1] CRAN (R 3.6.2)
#> stringr 1.4.0 2019-02-10 [1] CRAN (R 3.6.1)
#> testthat 2.3.2 2020-03-02 [1] RSPM (R 3.6.3)
#> tibble 3.0.1 2020-04-20 [1] RSPM (R 3.6.3)
#> tidyr 1.1.0 2020-05-20 [1] RSPM (R 3.6.3)
#> tidyselect 1.1.0 2020-05-11 [1] RSPM (R 3.6.3)
#> tsibble * 0.9.0 2020-06-02 [1] Github (tidyverts/tsibble#c837e83)
#> urca 1.3-0 2016-09-06 [1] CRAN (R 3.6.1)
#> usethis 1.5.1.9000 2020-01-31 [1] Github (r-lib/usethis#7d8b066)
#> utf8 1.1.4 2018-05-24 [1] CRAN (R 3.6.1)
#> vctrs 0.3.0.9000 2020-05-28 [1] Github (r-lib/vctrs#373e1ce)
#> withr 2.2.0 2020-04-20 [1] RSPM (R 3.6.3)
#> xfun 0.13 2020-04-13 [1] RSPM (R 3.6.3)
#> yaml 2.2.1 2020-02-01 [1] RSPM (R 3.6.2)
#>
#> [1] /home/mitchell/R/x86_64-pc-linux-gnu-library/3.6
#> [2] /opt/R/3.6.2/lib/R/library
I am successfully modifying multiple Excel files using library(RDCOMClient).
However, setting a cell value to a non-ascii string results in å becoming Ã¥ etc.
I also cannot pass an UTF-8 filename to Excel's Open() and Save() methods.
Hopefully there is a single solution to both problems.
Here's a simple reproducible example using Save():
Creating an empty workbook and trying to save it as å.xlsx results in Ã¥.xlsx.
The same operation works fine for a.xlsx.
# install.packages("RDCOMServer", repos = "http://www.omegahat.net/R")
library(RDCOMClient)
xlApp <- COMCreate("Excel.Application")
wb <- xlApp$Workbooks()$Add()
path1 <- normalizePath("a.xlsx", mustWork = FALSE)
path2 <- normalizePath("å.xlsx", mustWork = FALSE)
wb$SaveAs(path1)
#> [1] TRUE
wb$SaveAs(path2)
#> [1] TRUE
wb$Close()
#> [1] TRUE
xlApp$Quit()
#> NULL
dir(pattern = "xlsx")
#> [1] "a.xlsx" "Ã¥.xlsx"
devtools::session_info()
#> - Session info ---------------------------------------------------------------
#> setting value
#> version R version 4.0.0 (2020-04-24)
#> os Windows 10 x64
#> system x86_64, mingw32
#> ui RTerm
#> language (EN)
#> collate English_United States.1252
#> ctype English_United States.1252
#> tz Europe/Berlin
#> date 2020-05-10
#>
#> - Packages -------------------------------------------------------------------
#> package * version date lib source
#> assertthat 0.2.1 2019-03-21 [1] CRAN (R 4.0.0)
#> backports 1.1.6 2020-04-05 [1] CRAN (R 4.0.0)
#> callr 3.4.3 2020-03-28 [1] CRAN (R 4.0.0)
#> cli 2.0.2 2020-02-28 [1] CRAN (R 4.0.0)
#> crayon 1.3.4 2017-09-16 [1] CRAN (R 4.0.0)
#> desc 1.2.0 2018-05-01 [1] CRAN (R 4.0.0)
#> devtools 2.3.0 2020-04-10 [1] CRAN (R 4.0.0)
#> digest 0.6.25 2020-02-23 [1] CRAN (R 4.0.0)
#> ellipsis 0.3.0 2019-09-20 [1] CRAN (R 4.0.0)
#> evaluate 0.14 2019-05-28 [1] CRAN (R 4.0.0)
#> fansi 0.4.1 2020-01-08 [1] CRAN (R 4.0.0)
#> fs 1.4.1 2020-04-04 [1] CRAN (R 4.0.0)
#> glue 1.4.0 2020-04-03 [1] CRAN (R 4.0.0)
#> highr 0.8 2019-03-20 [1] CRAN (R 4.0.0)
#> htmltools 0.4.0 2019-10-04 [1] CRAN (R 4.0.0)
#> knitr 1.28 2020-02-06 [1] CRAN (R 4.0.0)
#> magrittr 1.5 2014-11-22 [1] CRAN (R 4.0.0)
#> memoise 1.1.0 2017-04-21 [1] CRAN (R 4.0.0)
#> pkgbuild 1.0.7 2020-04-25 [1] CRAN (R 4.0.0)
#> pkgload 1.0.2 2018-10-29 [1] CRAN (R 4.0.0)
#> prettyunits 1.1.1 2020-01-24 [1] CRAN (R 4.0.0)
#> processx 3.4.2 2020-02-09 [1] CRAN (R 4.0.0)
#> ps 1.3.2 2020-02-13 [1] CRAN (R 4.0.0)
#> R6 2.4.1 2019-11-12 [1] CRAN (R 4.0.0)
#> Rcpp 1.0.4.6 2020-04-09 [1] CRAN (R 4.0.0)
#> RDCOMClient * 0.94-0 2020-04-13 [1] local
#> remotes 2.1.1 2020-02-15 [1] CRAN (R 4.0.0)
#> rlang 0.4.5 2020-03-01 [1] CRAN (R 4.0.0)
#> rmarkdown 2.1 2020-01-20 [1] CRAN (R 4.0.0)
#> rprojroot 1.3-2 2018-01-03 [1] CRAN (R 4.0.0)
#> sessioninfo 1.1.1 2018-11-05 [1] CRAN (R 4.0.0)
#> stringi 1.4.6 2020-02-17 [1] CRAN (R 4.0.0)
#> stringr 1.4.0 2019-02-10 [1] CRAN (R 4.0.0)
#> testthat 2.3.2 2020-03-02 [1] CRAN (R 4.0.0)
#> usethis 1.6.1 2020-04-29 [1] CRAN (R 4.0.0)
#> withr 2.2.0 2020-04-20 [1] CRAN (R 4.0.0)
#> xfun 0.13 2020-04-13 [1] CRAN (R 4.0.0)
#> yaml 2.2.1 2020-02-01 [1] CRAN (R 4.0.0)
#>
#> [1] C:/R-library
#> [2] C:/Program Files/R/R-4.0.0/library
Created on 2020-05-10 by the reprex package (v0.3.0)
Neither Encoding(path2) <- "UTF-8" nor Sys.setlocale(category = "LC_ALL", locale = "en_US.UTF-8") seem to have any effect. ("OS reports request to set locale to "en_US.UTF-8" cannot be honored".)
I couldn't figure out how Excel COM handles Unicode from the docs.
This Visual Basic-related question may perhaps be relevant, but I can't figure out how to apply it to my issue.
EDIT: I worked around the filename issue by opening/saving a temporary copy, sheetname issues by referring to them by number instead of name, and cell values by rephrasing things. Still interested in a proper solution 8-)
stringi::stri_enc_tonative() was what I needed.
I had UTF-8 strings text and sheets returned by readxl::read_excel() and readxl::excel_sheets(), so that Encoding(text) was "UTF-8" whereas Excel evidently requires "latin1" on my system.
Replacing text with stringi::stri_enc_tonative(text) solved all my issues: filenames for xlApp$Open(), sheetnames for wb$Open(), and values for rng[["Value"]] <-.
One can use stringi::stri_enc_toutf8() to convert to UTF-8.
I am using hrbrthemes::theme_ipsum() with most of my plots, but now I'm encountering odd behaviour while using ggupset: An extra "at" above the x-axis label that I can neither find the origin of nor can get rid of.
If anyone could try to explain what's going on here (and how to get rid of it), that'd be great.
Note that I tried both the current CRAN and GitHub versions of hrbrthemes.
Demonstration:
library(ggplot2)
library(dplyr, warn.conflicts = FALSE)
library(ggupset) # https://github.com/const-ae/ggupset
library(hrbrthemes) # https://github.com/hrbrmstr/hrbrthemes
# starting with a perfectly normal upset plot from ggupset's README
p <- tidy_movies %>%
distinct(title, year, length, .keep_all = TRUE) %>%
head(100) %>% # smaller dataset for faster(ish) plotting
ggplot(aes(x=Genres)) +
geom_bar() +
scale_x_upset(order_by = "degree") +
labs(x = "x-label for demonstration purposes")
looks fine:
p
#> Warning: Removed 30 rows containing non-finite values (stat_count).
Now with theme_ipsum() the easy way
p_hrbr <- p + hrbrthemes::theme_ipsum()
But nope, something seems to conflict here.
p_hrbr
#> Warning: Removed 30 rows containing non-finite values (stat_count).
#> Error: Insufficient values in manual scale. 2 needed but only 0 provided.
But in my actual usecase I set the theme globally, like so:
theme_set(hrbrthemes::theme_ipsum())
The original plot, now with theme_ipsum. Notice the x-axis on the bottom right.
p
#> Warning: Removed 30 rows containing non-finite values (stat_count).
I can't find any label set to "at". at what?
p$labels
#> $x
#> [1] "x-label for demonstration purposes"
#>
#> $y
#> [1] "count"
#>
#> $weight
#> [1] "weight"
Resetting to the default theme:
theme_set(theme_gray())
It's gone
p
#> Warning: Removed 30 rows containing non-finite values (stat_count).
Session info
devtools::session_info(pkgs = c("ggplot2", "hrbrthemes", "ggupset"))
#> ─ Session info ───────────────────────────────────────────────────────────────
#> setting value
#> version R version 3.6.3 (2020-02-29)
#> os macOS Catalina 10.15.3
#> system x86_64, darwin15.6.0
#> ui X11
#> language (EN)
#> collate en_US.UTF-8
#> ctype en_US.UTF-8
#> tz Europe/Berlin
#> date 2020-03-24
#>
#> ─ Packages ───────────────────────────────────────────────────────────────────
#> package * version date lib source
#> assertthat 0.2.1 2019-03-21 [1] CRAN (R 3.6.0)
#> backports 1.1.5 2019-10-02 [1] CRAN (R 3.6.0)
#> base64enc 0.1-3 2015-07-28 [1] CRAN (R 3.6.0)
#> callr 3.4.2 2020-02-12 [1] CRAN (R 3.6.2)
#> cli 2.0.2 2020-02-28 [1] CRAN (R 3.6.2)
#> colorspace 1.4-1 2019-03-18 [1] CRAN (R 3.6.0)
#> crayon 1.3.4 2017-09-16 [1] CRAN (R 3.6.0)
#> desc 1.2.0 2018-05-01 [1] CRAN (R 3.6.0)
#> digest 0.6.25 2020-02-23 [1] CRAN (R 3.6.0)
#> ellipsis 0.3.0 2019-09-20 [1] CRAN (R 3.6.0)
#> evaluate 0.14 2019-05-28 [1] CRAN (R 3.6.0)
#> extrafont 0.17 2014-12-08 [1] CRAN (R 3.6.0)
#> extrafontdb 1.0 2012-06-11 [1] CRAN (R 3.6.0)
#> fansi 0.4.1 2020-01-08 [1] CRAN (R 3.6.0)
#> farver 2.0.3 2020-01-16 [1] CRAN (R 3.6.0)
#> gdtools 0.2.1 2019-10-14 [1] CRAN (R 3.6.0)
#> ggplot2 * 3.3.0 2020-03-05 [1] CRAN (R 3.6.2)
#> ggupset * 0.1.0 2019-03-06 [1] CRAN (R 3.6.0)
#> glue 1.3.2 2020-03-12 [1] CRAN (R 3.6.0)
#> gtable 0.3.0 2019-03-25 [1] CRAN (R 3.6.0)
#> highr 0.8 2019-03-20 [1] CRAN (R 3.6.0)
#> hrbrthemes * 0.8.0 2020-03-24 [1] Github (hrbrmstr/hrbrthemes#a599f17)
#> htmltools 0.4.0 2019-10-04 [1] CRAN (R 3.6.0)
#> isoband 0.2.0 2019-04-06 [1] CRAN (R 3.6.0)
#> jsonlite 1.6.1 2020-02-02 [1] CRAN (R 3.6.0)
#> knitr 1.28 2020-02-06 [1] CRAN (R 3.6.2)
#> labeling 0.3 2014-08-23 [1] CRAN (R 3.6.0)
#> lattice 0.20-38 2018-11-04 [2] CRAN (R 3.6.3)
#> lifecycle 0.2.0 2020-03-06 [1] CRAN (R 3.6.2)
#> magrittr 1.5 2014-11-22 [1] CRAN (R 3.6.0)
#> markdown 1.1 2019-08-07 [1] CRAN (R 3.6.0)
#> MASS 7.3-51.5 2019-12-20 [2] CRAN (R 3.6.3)
#> Matrix 1.2-18 2019-11-27 [2] CRAN (R 3.6.3)
#> mgcv 1.8-31 2019-11-09 [2] CRAN (R 3.6.3)
#> mime 0.9 2020-02-04 [1] CRAN (R 3.6.0)
#> munsell 0.5.0 2018-06-12 [1] CRAN (R 3.6.0)
#> nlme 3.1-144 2020-02-06 [2] CRAN (R 3.6.3)
#> pillar 1.4.3 2019-12-20 [1] CRAN (R 3.6.0)
#> pkgbuild 1.0.6 2019-10-09 [1] CRAN (R 3.6.0)
#> pkgconfig 2.0.3 2019-09-22 [1] CRAN (R 3.6.0)
#> pkgload 1.0.2 2018-10-29 [1] CRAN (R 3.6.0)
#> praise 1.0.0 2015-08-11 [1] CRAN (R 3.6.0)
#> prettyunits 1.1.1 2020-01-24 [1] CRAN (R 3.6.0)
#> processx 3.4.2 2020-02-09 [1] CRAN (R 3.6.0)
#> ps 1.3.2 2020-02-13 [1] CRAN (R 3.6.0)
#> R6 2.4.1 2019-11-12 [1] CRAN (R 3.6.0)
#> RColorBrewer 1.1-2 2014-12-07 [1] CRAN (R 3.6.0)
#> Rcpp 1.0.4 2020-03-17 [1] CRAN (R 3.6.0)
#> rlang 0.4.5 2020-03-01 [1] CRAN (R 3.6.0)
#> rmarkdown 2.1 2020-01-20 [1] CRAN (R 3.6.0)
#> rprojroot 1.3-2 2018-01-03 [1] CRAN (R 3.6.0)
#> rstudioapi 0.11 2020-02-07 [1] CRAN (R 3.6.0)
#> Rttf2pt1 1.3.8 2020-01-10 [1] CRAN (R 3.6.0)
#> scales 1.1.0 2019-11-18 [1] CRAN (R 3.6.0)
#> stringi 1.4.6 2020-02-17 [1] CRAN (R 3.6.0)
#> stringr 1.4.0 2019-02-10 [1] CRAN (R 3.6.0)
#> systemfonts 0.1.1 2019-07-01 [1] CRAN (R 3.6.0)
#> testthat 2.3.2 2020-03-02 [1] CRAN (R 3.6.0)
#> tibble 2.1.3 2019-06-06 [1] CRAN (R 3.6.0)
#> tinytex 0.20 2020-02-25 [1] CRAN (R 3.6.0)
#> utf8 1.1.4 2018-05-24 [1] CRAN (R 3.6.0)
#> vctrs 0.2.4 2020-03-10 [1] CRAN (R 3.6.0)
#> viridisLite 0.3.0 2018-02-01 [1] CRAN (R 3.6.0)
#> withr 2.1.2 2018-03-15 [1] CRAN (R 3.6.0)
#> xfun 0.12 2020-01-13 [1] CRAN (R 3.6.0)
#> yaml 2.2.1 2020-02-01 [1] CRAN (R 3.6.0)
#>
#> [1] /Users/Lukas/Library/R/3.6
#> [2] /Library/Frameworks/R.framework/Versions/3.6/Resources/library
Created on 2020-03-24 by the reprex package (v0.3.0)
Update 2020-03-24: The author of ggupset has responded on GitHub and is taking a look.
The issue was caused by ggupset, and has since been fixed.
If anyone else has encountered this, you can use the current development version: remotes::install_github("const-ae/ggupset"), or wait for the CRAN release in the near future.
Using the R package xaringan, I was trying to create a new presentation in RStudio. I wanted to use the very useful feature inifinite moon reader to get live preview of my tweaking of the presentation. While worked nicely previously, currently for me the presentation is not rendering anymore. What changed in between is probably regular updates in software, operating system and R packages.
Now whenever I press the infinite moon reader addin in RStudio, it spits the error as shown in the image. But when I press the knit to moonreader button in RStudio it renders the document just fine but there is not live preview.
I tried to run R in a console and then used the inf_mr() function to render the document. It spits out the same error. But rmarkdown::render() function works just fine but again with no live preview. I searched for this error but I do not seem to find anything as such related to xaringan package in R. Then I ran a more generalized search and found that the error statement most often comes in the case of XML parsing. I updated the XML and XML2 packages in R but with no luck. Then I updated and upgraded my Arch Linux also to no avail.
Created on 2019-08-13 by the reprex package (v0.3.0)
devtools::session_info()
#> ─ Session info ──────────────────────────────────────────────────────────
#> setting value
#> version R version 3.6.1 (2019-07-05)
#> os Arch Linux
#> system x86_64, linux-gnu
#> ui X11
#> language (EN)
#> collate en_US.UTF-8
#> ctype en_US.UTF-8
#> tz Asia/Dhaka
#> date 2019-08-13
#>
#> ─ Packages ──────────────────────────────────────────────────────────────
#> package * version date lib source
#> assertthat 0.2.1 2019-03-21 [1] CRAN (R 3.5.3)
#> backports 1.1.4 2019-04-10 [1] CRAN (R 3.5.3)
#> callr 2.0.4 2018-05-15 [1] CRAN (R 3.5.1)
#> cli 1.1.0 2019-03-19 [1] CRAN (R 3.5.3)
#> crayon 1.3.4 2017-09-16 [1] CRAN (R 3.5.1)
#> curl 3.3 2019-01-10 [1] CRAN (R 3.5.3)
#> desc 1.2.0 2018-05-01 [1] CRAN (R 3.5.3)
#> devtools 2.0.2 2019-04-08 [1] CRAN (R 3.5.3)
#> digest 0.6.20 2019-07-04 [1] CRAN (R 3.6.0)
#> evaluate 0.14 2019-05-28 [1] CRAN (R 3.6.0)
#> fs 1.3.1 2019-05-06 [1] CRAN (R 3.5.3)
#> glue 1.3.1 2019-03-12 [1] CRAN (R 3.5.3)
#> highr 0.8 2019-03-20 [1] CRAN (R 3.6.0)
#> htmltools 0.3.6 2017-04-28 [1] CRAN (R 3.5.1)
#> httr 1.4.0 2018-12-11 [1] CRAN (R 3.5.3)
#> knitr 1.24 2019-08-08 [1] CRAN (R 3.6.0)
#> magrittr 1.5 2014-11-22 [1] CRAN (R 3.5.1)
#> memoise 1.1.0 2017-04-21 [1] CRAN (R 3.5.1)
#> mime 0.7 2019-06-11 [1] CRAN (R 3.6.0)
#> nvimcom * 0.9-75 2019-08-13 [1] local
#> pkgbuild 1.0.3 2019-03-20 [1] CRAN (R 3.5.3)
#> pkgload 1.0.2 2018-10-29 [1] CRAN (R 3.5.3)
#> png 0.1-7 2013-12-03 [1] CRAN (R 3.5.3)
#> prettyunits 1.0.2 2015-07-13 [1] CRAN (R 3.5.3)
#> processx 3.2.0 2018-08-16 [1] CRAN (R 3.5.1)
#> ps 1.1.0 2018-08-10 [1] CRAN (R 3.5.1)
#> R6 2.4.0 2019-02-14 [1] CRAN (R 3.5.3)
#> Rcpp 1.0.2 2019-07-25 [1] CRAN (R 3.6.0)
#> remotes 2.0.4 2019-04-10 [1] CRAN (R 3.5.3)
#> rlang 0.4.0 2019-06-25 [1] CRAN (R 3.6.0)
#> rmarkdown 1.14 2019-07-12 [1] CRAN (R 3.6.0)
#> rprojroot 1.3-2 2018-01-03 [1] CRAN (R 3.5.1)
#> sessioninfo 1.1.1 2018-11-05 [1] CRAN (R 3.5.3)
#> stringi 1.4.3 2019-03-12 [1] CRAN (R 3.6.0)
#> stringr 1.4.0 2019-02-10 [1] CRAN (R 3.6.0)
#> testthat 2.1.1 2019-04-23 [1] CRAN (R 3.6.0)
#> usethis 1.5.1 2019-07-04 [1] CRAN (R 3.6.0)
#> withr 2.1.2 2018-03-15 [1] CRAN (R 3.5.1)
#> xfun 0.8 2019-06-25 [1] CRAN (R 3.6.0)
#> xml2 1.2.2 2019-08-09 [1] CRAN (R 3.6.0)
#> yaml 2.2.0 2018-07-25 [1] CRAN (R 3.5.1)
#>
#> [1] /home/arch/R/x86_64-pc-linux-gnu-library/3.6
#> [2] /usr/lib/R/library
When I encountered this same error it was because I had the .Rmd file for the presentation open in a separate window. Once I returned it to the main window, xaringan::inf_mr() displayed the presentation in the Viewer tab with no problem.