-
Notifications
You must be signed in to change notification settings - Fork 81
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Error in doc_parse_raw when running reprex
#220
Comments
This comment has been minimized.
This comment has been minimized.
I can't reproduce this at all. What type of input are you specifying with the addin? I've tried and succeeded with "on the clipboard", "current selection", and "current file". Can anyone provide session info? |
When I was able to reproduce it (which only happened once) here was the error info:
I can't reproduce it now, which means I can render it with sessionInfo (from reprex) library(tidyverse)
library(data.table)
#>
#> Attaching package: 'data.table'
#> The following objects are masked from 'package:dplyr':
#>
#> between, first, last
#> The following object is masked from 'package:purrr':
#>
#> transpose
library(lubridate)
#>
#> Attaching package: 'lubridate'
#> The following objects are masked from 'package:data.table':
#>
#> hour, isoweek, mday, minute, month, quarter, second, wday,
#> week, yday, year
#> The following object is masked from 'package:base':
#>
#> date
set.seed(123)
data.table(
date = today() + 1:1000
,value = rnorm(1000,0,10)
# sim stock price
) %>%
mutate(
date = floor_date(date, unit = 'halfyear')
# I suggest you maintain the date in yyyy-mm-dd type
) %>%
group_by(date) %>%
summarise(value = mean(value)) %>%
ggplot(aes(date,value)) +
geom_line() +
scale_x_date(breaks = '6 month') Created on 2018-11-01 by the reprex package (v0.2.1.9000) Session infodevtools::session_info()
#> ─ Session info ──────────────────────────────────────────────────────────
#> setting value
#> version R version 3.5.1 (2018-07-02)
#> os macOS Sierra 10.12.6
#> system x86_64, darwin15.6.0
#> ui X11
#> language (EN)
#> collate en_US.UTF-8
#> ctype en_US.UTF-8
#> tz America/New_York
#> date 2018-11-01
#>
#> ─ Packages ──────────────────────────────────────────────────────────────
#> package * version date lib
#> assertthat 0.2.0 2017-04-11 [1]
#> backports 1.1.2 2017-12-13 [1]
#> base64enc 0.1-3 2015-07-28 [1]
#> broom 0.5.0 2018-07-17 [1]
#> callr 3.0.0 2018-08-24 [1]
#> cellranger 1.1.0 2016-07-27 [1]
#> cli 1.0.1 2018-09-25 [1]
#> colorspace 1.3-2 2016-12-14 [1]
#> crayon 1.3.4 2018-10-31 [1]
#> curl 3.2 2018-03-28 [1]
#> data.table * 1.11.8 2018-09-30 [1]
#> debugme 1.1.0 2017-10-22 [1]
#> desc 1.2.0 2018-05-01 [1]
#> devtools 2.0.1 2018-10-26 [1]
#> digest 0.6.18 2018-10-10 [1]
#> dplyr * 0.7.99.9000 2018-10-31 [1]
#> evaluate 0.12 2018-10-09 [1]
#> forcats * 0.3.0 2018-02-19 [1]
#> fs 1.2.6 2018-08-23 [1]
#> ggplot2 * 3.1.0.9000 2018-10-30 [1]
#> glue 1.3.0 2018-10-29 [1]
#> gtable 0.2.0.9000 2018-11-01 [1]
#> haven 1.1.2 2018-06-27 [1]
#> highr 0.7 2018-06-09 [1]
#> hms 0.4.2.9001 2018-08-22 [1]
#> htmltools 0.3.6 2017-04-28 [1]
#> httr 1.3.1 2017-08-20 [1]
#> jsonlite 1.5 2017-06-01 [1]
#> knitr 1.20.21 2018-10-23 [1]
#> labeling 0.3 2014-08-23 [1]
#> lattice 0.20-35 2017-03-25 [1]
#> lazyeval 0.2.1 2017-10-29 [1]
#> lubridate * 1.7.4 2018-04-11 [1]
#> magrittr 1.5 2014-11-22 [1]
#> memoise 1.1.0 2017-04-21 [1]
#> mime 0.6 2018-10-05 [1]
#> modelr 0.1.2 2018-05-11 [1]
#> munsell 0.5.0 2018-06-12 [1]
#> nlme 3.1-137 2018-04-07 [1]
#> pillar 1.3.0.9001 2018-10-17 [1]
#> pkgbuild 1.0.2 2018-10-16 [1]
#> pkgconfig 2.0.2 2018-08-16 [1]
#> pkgload 1.0.2 2018-10-29 [1]
#> plyr 1.8.4 2016-06-08 [1]
#> prettyunits 1.0.2 2015-07-13 [1]
#> processx 3.2.0 2018-08-16 [1]
#> ps 1.2.0 2018-10-16 [1]
#> purrr * 0.2.5 2018-05-29 [1]
#> R6 2.3.0 2018-10-04 [1]
#> Rcpp 0.12.19.3 2018-10-15 [1]
#> readr * 1.2.0 2018-10-25 [1]
#> readxl 1.1.0.9000 2018-10-24 [1]
#> remotes 2.0.2 2018-10-30 [1]
#> rlang 0.3.0.9000 2018-10-29 [1]
#> rmarkdown 1.10 2018-06-11 [1]
#> rprojroot 1.3-2 2018-01-03 [1]
#> rvest 0.3.2 2016-06-17 [1]
#> scales 1.0.0.9000 2018-10-30 [1]
#> sessioninfo 1.1.0.9001 2018-11-01 [1]
#> stringi 1.2.4 2018-07-20 [1]
#> stringr * 1.3.1 2018-05-10 [1]
#> testthat 2.0.1 2018-10-13 [1]
#> tibble * 1.4.2 2018-01-22 [1]
#> tidyr * 0.8.2.9000 2018-10-31 [1]
#> tidyselect 0.2.5 2018-10-11 [1]
#> tidyverse * 1.2.1.9000 2018-08-21 [1]
#> usethis 1.4.0.9000 2018-10-29 [1]
#> withr 2.1.2 2018-03-15 [1]
#> xfun 0.4 2018-10-23 [1]
#> xml2 1.2.0 2018-01-24 [1]
#> yaml 2.2.0 2018-07-25 [1]
#> source
#> CRAN (R 3.5.0)
#> CRAN (R 3.5.0)
#> CRAN (R 3.5.0)
#> CRAN (R 3.5.0)
#> CRAN (R 3.5.0)
#> CRAN (R 3.5.0)
#> CRAN (R 3.5.0)
#> CRAN (R 3.5.0)
#> Github (r-lib/crayon@0398b12)
#> CRAN (R 3.5.0)
#> CRAN (R 3.5.0)
#> CRAN (R 3.5.0)
#> CRAN (R 3.5.0)
#> CRAN (R 3.5.1)
#> CRAN (R 3.5.0)
#> Github (tidyverse/dplyr@78dd867)
#> CRAN (R 3.5.0)
#> CRAN (R 3.5.0)
#> CRAN (R 3.5.0)
#> Github (tidyverse/ggplot2@765f4de)
#> Github (tidyverse/glue@35c61e9)
#> Github (r-lib/gtable@6af591d)
#> CRAN (R 3.5.0)
#> CRAN (R 3.5.0)
#> Github (tidyverse/hms@979286f)
#> CRAN (R 3.5.0)
#> CRAN (R 3.5.0)
#> CRAN (R 3.5.0)
#> Github (yihui/knitr@6c61415)
#> CRAN (R 3.5.0)
#> CRAN (R 3.5.1)
#> CRAN (R 3.5.0)
#> CRAN (R 3.5.0)
#> CRAN (R 3.5.0)
#> CRAN (R 3.5.0)
#> CRAN (R 3.5.0)
#> CRAN (R 3.5.0)
#> CRAN (R 3.5.0)
#> CRAN (R 3.5.1)
#> Github (r-lib/pillar@c5bf622)
#> CRAN (R 3.5.0)
#> CRAN (R 3.5.0)
#> CRAN (R 3.5.1)
#> CRAN (R 3.5.0)
#> CRAN (R 3.5.0)
#> CRAN (R 3.5.0)
#> CRAN (R 3.5.0)
#> CRAN (R 3.5.0)
#> CRAN (R 3.5.0)
#> Github (RcppCore/Rcpp@a669a19)
#> Github (tidyverse/readr@69c9fd3)
#> Github (tidyverse/readxl@763ca6d)
#> CRAN (R 3.5.1)
#> Github (r-lib/rlang@eb17969)
#> CRAN (R 3.5.0)
#> CRAN (R 3.5.0)
#> CRAN (R 3.5.0)
#> Github (r-lib/scales@b5c43b4)
#> Github (r-lib/sessioninfo@5b02efa)
#> CRAN (R 3.5.0)
#> CRAN (R 3.5.0)
#> CRAN (R 3.5.0)
#> CRAN (R 3.5.0)
#> Github (tidyverse/tidyr@6c0e510)
#> CRAN (R 3.5.1)
#> Github (tidyverse/tidyverse@66e8bbd)
#> Github (r-lib/usethis@44dd72c)
#> CRAN (R 3.5.0)
#> CRAN (R 3.5.0)
#> CRAN (R 3.5.0)
#> CRAN (R 3.5.0)
#>
#> [1] /Library/Frameworks/R.framework/Versions/3.5/Resources/library |
No obvious explanation leaps out from @batpigandme's session info. |
@JiaxiangBU, if you could share yours, that might help. 🙂 Thanks |
Also, your exact usage of the addin. |
Hi @jennybc @batpigandme , Thanks for your replies. I try this code from my two computer, one Mac and one Win. Same error happens on Both. I will share the session infos both here. Mac
'show session info'
#> [1] "show session info" Created on 2018-11-02 by the reprex Session infodevtools::session_info()
#> Session info -------------------------------------------------------------
#> setting value
#> version R version 3.5.1 (2018-07-02)
#> system x86_64, darwin15.6.0
#> ui X11
#> language (EN)
#> collate zh_CN.UTF-8
#> tz Asia/Shanghai
#> date 2018-11-02
#> Packages -----------------------------------------------------------------
#> package * version date source
#> backports 1.1.2 2017-12-13 CRAN (R 3.5.0)
#> base * 3.5.1 2018-07-05 local
#> compiler 3.5.1 2018-07-05 local
#> datasets * 3.5.1 2018-07-05 local
#> devtools 1.13.6 2018-06-27 CRAN (R 3.5.0)
#> digest 0.6.16 2018-08-22 cran (@0.6.16)
#> evaluate 0.11 2018-07-17 CRAN (R 3.5.0)
#> graphics * 3.5.1 2018-07-05 local
#> grDevices * 3.5.1 2018-07-05 local
#> htmltools 0.3.6 2017-04-28 CRAN (R 3.5.0)
#> knitr 1.20 2018-02-20 CRAN (R 3.5.0)
#> magrittr 1.5 2014-11-22 CRAN (R 3.5.0)
#> memoise 1.1.0 2017-04-21 CRAN (R 3.5.0)
#> methods * 3.5.1 2018-07-05 local
#> Rcpp 0.12.19 2018-10-01 cran (@0.12.19)
#> rmarkdown 1.10 2018-06-11 CRAN (R 3.5.0)
#> rprojroot 1.3-2 2018-01-03 CRAN (R 3.5.0)
#> stats * 3.5.1 2018-07-05 local
#> stringi 1.2.4 2018-07-20 CRAN (R 3.5.0)
#> stringr 1.3.1 2018-05-10 CRAN (R 3.5.0)
#> tools 3.5.1 2018-07-05 local
#> utils * 3.5.1 2018-07-05 local
#> withr 2.1.2 2018-03-15 CRAN (R 3.5.0)
#> yaml 2.2.0 2018-07-25 CRAN (R 3.5.0) Win
'show session info'
#> [1] "show session info" Created on 2018-11-02 by the reprex package (v0.2.1) Session infodevtools::session_info()
#> Session info -------------------------------------------------------------
#> setting value
#> version R version 3.4.4 (2018-03-15)
#> system x86_64, mingw32
#> ui RTerm
#> language (EN)
#> collate Chinese (Simplified)_People's Republic of China.936
#> tz Asia/Taipei
#> date 2018-11-02
#> Packages -----------------------------------------------------------------
#> package * version date source
#> backports 1.1.2 2017-12-13 CRAN (R 3.4.3)
#> base * 3.4.4 2018-03-15 local
#> compiler 3.4.4 2018-03-15 local
#> datasets * 3.4.4 2018-03-15 local
#> devtools 1.13.5 2018-02-18 CRAN (R 3.4.3)
#> digest 0.6.18 2018-10-10 CRAN (R 3.4.4)
#> evaluate 0.10.1 2017-06-24 CRAN (R 3.4.3)
#> graphics * 3.4.4 2018-03-15 local
#> grDevices * 3.4.4 2018-03-15 local
#> htmltools 0.3.6 2017-04-28 CRAN (R 3.4.3)
#> knitr 1.20 2018-02-20 CRAN (R 3.4.3)
#> magrittr 1.5 2014-11-22 CRAN (R 3.4.3)
#> memoise 1.1.0 2017-04-21 CRAN (R 3.4.4)
#> methods * 3.4.4 2018-03-15 local
#> Rcpp 0.12.18 2018-07-23 CRAN (R 3.4.4)
#> rmarkdown 1.10 2018-06-11 CRAN (R 3.4.4)
#> rprojroot 1.3-2 2018-01-03 CRAN (R 3.4.3)
#> stats * 3.4.4 2018-03-15 local
#> stringi 1.1.7 2018-03-12 CRAN (R 3.4.4)
#> stringr 1.3.1 2018-05-10 CRAN (R 3.4.4)
#> tools 3.4.4 2018-03-15 local
#> utils * 3.4.4 2018-03-15 local
#> withr 2.1.2 2018-03-15 CRAN (R 3.4.4)
#> yaml 2.2.0 2018-07-25 CRAN (R 3.4.4) |
And I find the bug from the Here are results I test. library(tidyverse)
library(data.table)
#>
#> 载入程辑包:'data.table'
#> The following objects are masked from 'package:dplyr':
#>
#> between, first, last
#> The following object is masked from 'package:purrr':
#>
#> transpose
library(lubridate)
#>
#> 载入程辑包:'lubridate'
#> The following objects are masked from 'package:data.table':
#>
#> hour, isoweek, mday, minute, month, quarter, second, wday,
#> week, yday, year
#> The following object is masked from 'package:base':
#>
#> date
set.seed(123)
data.table(
date = today() + 1:1000
,value = rnorm(1000,0,10)
# sim stock price
) %>%
mutate(
date = floor_date(date, unit = 'halfyear')
# I suggest you maintain the date in yyyy-mm-dd type
) %>%
group_by(date) %>%
summarise(value = mean(value))
#> # A tibble: 7 x 2
#> date value
#> <date> <dbl>
#> 1 2018-07-01 0.631
#> 2 2019-01-01 -0.277
#> 3 2019-07-01 0.393
#> 4 2020-01-01 0.396
#> 5 2020-07-01 -0.360
#> 6 2021-01-01 0.769
#> 7 2021-07-01 -1.48 Created on 2018-11-02 by the reprex package (v0.2.1) Session infodevtools::session_info()
#> Session info -------------------------------------------------------------
#> setting value
#> version R version 3.4.4 (2018-03-15)
#> system x86_64, mingw32
#> ui RTerm
#> language (EN)
#> collate Chinese (Simplified)_People's Republic of China.936
#> tz Asia/Taipei
#> date 2018-11-02
#> Packages -----------------------------------------------------------------
#> package * version date source
#> assertthat 0.2.0 2017-04-11 CRAN (R 3.4.3)
#> backports 1.1.2 2017-12-13 CRAN (R 3.4.3)
#> base * 3.4.4 2018-03-15 local
#> bindr 0.1.1 2018-03-13 CRAN (R 3.4.4)
#> bindrcpp * 0.2.2 2018-03-29 CRAN (R 3.4.4)
#> broom 0.5.0 2018-07-17 CRAN (R 3.4.4)
#> cellranger 1.1.0 2016-07-27 CRAN (R 3.4.3)
#> cli 1.0.0 2017-11-05 CRAN (R 3.4.3)
#> colorspace 1.3-2 2016-12-14 CRAN (R 3.4.3)
#> compiler 3.4.4 2018-03-15 local
#> crayon 1.3.4 2017-09-16 CRAN (R 3.4.3)
#> data.table * 1.11.8 2018-09-30 CRAN (R 3.4.4)
#> datasets * 3.4.4 2018-03-15 local
#> devtools 1.13.5 2018-02-18 CRAN (R 3.4.3)
#> digest 0.6.18 2018-10-10 CRAN (R 3.4.4)
#> dplyr * 0.7.7 2018-10-16 CRAN (R 3.4.4)
#> evaluate 0.10.1 2017-06-24 CRAN (R 3.4.3)
#> fansi 0.2.3 2018-05-06 CRAN (R 3.4.4)
#> forcats * 0.3.0 2018-02-19 CRAN (R 3.4.3)
#> ggplot2 * 3.1.0 2018-10-30 Github (tidyverse/ggplot2@0e29a19)
#> glue 1.3.0 2018-07-17 CRAN (R 3.4.4)
#> graphics * 3.4.4 2018-03-15 local
#> grDevices * 3.4.4 2018-03-15 local
#> grid 3.4.4 2018-03-15 local
#> gtable 0.2.0 2016-02-26 CRAN (R 3.4.3)
#> haven 1.1.1 2018-01-18 CRAN (R 3.4.3)
#> hms 0.4.2 2018-03-10 CRAN (R 3.4.4)
#> htmltools 0.3.6 2017-04-28 CRAN (R 3.4.3)
#> httr 1.3.1 2017-08-20 CRAN (R 3.4.3)
#> jsonlite 1.5 2017-06-01 CRAN (R 3.4.3)
#> knitr 1.20 2018-02-20 CRAN (R 3.4.3)
#> lattice 0.20-35 2017-03-25 CRAN (R 3.4.4)
#> lazyeval 0.2.1 2017-10-29 CRAN (R 3.4.3)
#> lubridate * 1.7.4 2018-04-11 CRAN (R 3.4.4)
#> magrittr 1.5 2014-11-22 CRAN (R 3.4.3)
#> memoise 1.1.0 2017-04-21 CRAN (R 3.4.4)
#> methods * 3.4.4 2018-03-15 local
#> modelr 0.1.2 2018-05-11 CRAN (R 3.4.4)
#> munsell 0.5.0 2018-06-12 CRAN (R 3.4.4)
#> nlme 3.1-137 2018-04-07 CRAN (R 3.4.4)
#> pillar 1.3.0.9000 2018-07-30 Github (r-lib/pillar@7582a75)
#> pkgconfig 2.0.1 2017-03-21 CRAN (R 3.4.3)
#> plyr 1.8.4 2016-06-08 CRAN (R 3.4.3)
#> purrr * 0.2.5 2018-05-29 CRAN (R 3.4.4)
#> R6 2.3.0 2018-10-04 CRAN (R 3.4.4)
#> Rcpp 0.12.18 2018-07-23 CRAN (R 3.4.4)
#> readr * 1.1.1 2017-05-16 CRAN (R 3.4.3)
#> readxl 1.1.0 2018-04-20 CRAN (R 3.4.4)
#> rlang 0.3.0.1 2018-10-25 CRAN (R 3.4.4)
#> rmarkdown 1.10 2018-06-11 CRAN (R 3.4.4)
#> rprojroot 1.3-2 2018-01-03 CRAN (R 3.4.3)
#> rvest 0.3.2 2016-06-17 CRAN (R 3.4.3)
#> scales 1.0.0 2018-08-09 CRAN (R 3.4.4)
#> stats * 3.4.4 2018-03-15 local
#> stringi 1.1.7 2018-03-12 CRAN (R 3.4.4)
#> stringr * 1.3.1 2018-05-10 CRAN (R 3.4.4)
#> tibble * 1.4.2 2018-01-22 CRAN (R 3.4.3)
#> tidyr * 0.8.0 2018-01-29 CRAN (R 3.4.3)
#> tidyselect 0.2.4 2018-02-26 CRAN (R 3.4.3)
#> tidyverse * 1.2.1 2017-11-14 CRAN (R 3.4.4)
#> tools 3.4.4 2018-03-15 local
#> utf8 1.1.4 2018-05-24 CRAN (R 3.4.4)
#> utils * 3.4.4 2018-03-15 local
#> withr 2.1.2 2018-03-15 CRAN (R 3.4.4)
#> xml2 1.2.0 2018-01-24 CRAN (R 3.4.3)
#> yaml 2.2.0 2018-07-25 CRAN (R 3.4.4) When I add the ggplot code line.
The error message happens.
|
FYI you have an outdated version of reprex installed on Mac: v0.2.0. The current version is 0.2.1, which you have on the Windows machine. That is not our problem here, but you might as well update that. When you use the addin, can you please tell me what you have selected for Where is reprex source? What happens when you copy this code to your clipboard and just call What output do you see for this code when you run it in the Console? The problem appears to be the result of some combination of an (error?) message from ggplot2, your locale (zh_CN.UTF-8 on macOS, Chinese (Simplified)_People's Republic of China.936 on Windows), and reprex (maybe just the addin?). |
@jennybc In the picture, I click the default option (the first one).
I am sure the error results from
Thus, I will update the Thank you for your reply. |
OK I repeat this request:
If I could see the exact Console output from the ggplot2 call, it might shed light on why it breaks reprex. I cannot solve this problem with information, as I cannot reproduce it myself, as I don't have your Chinese locale. |
@jennybc Hi, I don't know how to show this bug well. You can check it in these screenshots below. |
When you run this code snippet "live" in RStudio, does ggplot produce any errors or messages in the Console? I don't get any errors or messages. I get this:
and the desired plot. Do you get any errors, messages, or warnings? Do you get the plot? |
@jennybc No, there is no any message from ggplot. And the screenshots are step by step ... |
OK thanks. Hmm, not clear where to start here. |
@JiaxiangBU Can you show me your session info? You can just do Also, can you run the following modified version of your original code? Note I have added some lines at the top.
|
@jennybc OK, I test this code and feedback the session information from both Mac and Win. Mac"hello!"
#> [1] "hello!" Created on 2018-11-05 by the reprex package (v0.2.1) Session infodevtools::session_info()
#> Session info -------------------------------------------------------------
#> setting value
#> version R version 3.5.1 (2018-07-02)
#> system x86_64, darwin15.6.0
#> ui X11
#> language (EN)
#> collate zh_CN.UTF-8
#> tz Asia/Shanghai
#> date 2018-11-05
#> Packages -----------------------------------------------------------------
#> package * version date source
#> backports 1.1.2 2017-12-13 CRAN (R 3.5.0)
#> base * 3.5.1 2018-07-05 local
#> compiler 3.5.1 2018-07-05 local
#> datasets * 3.5.1 2018-07-05 local
#> devtools 1.13.6 2018-06-27 CRAN (R 3.5.0)
#> digest 0.6.16 2018-08-22 cran (@0.6.16)
#> evaluate 0.11 2018-07-17 CRAN (R 3.5.0)
#> graphics * 3.5.1 2018-07-05 local
#> grDevices * 3.5.1 2018-07-05 local
#> htmltools 0.3.6 2017-04-28 CRAN (R 3.5.0)
#> knitr 1.20 2018-02-20 CRAN (R 3.5.0)
#> magrittr 1.5 2014-11-22 CRAN (R 3.5.0)
#> memoise 1.1.0 2017-04-21 CRAN (R 3.5.0)
#> methods * 3.5.1 2018-07-05 local
#> Rcpp 0.12.19 2018-10-01 cran (@0.12.19)
#> rmarkdown 1.10 2018-06-11 CRAN (R 3.5.0)
#> rprojroot 1.3-2 2018-01-03 CRAN (R 3.5.0)
#> stats * 3.5.1 2018-07-05 local
#> stringi 1.2.4 2018-07-20 CRAN (R 3.5.0)
#> stringr 1.3.1 2018-05-10 CRAN (R 3.5.0)
#> tools 3.5.1 2018-07-05 local
#> utils * 3.5.1 2018-07-05 local
#> withr 2.1.2 2018-03-15 CRAN (R 3.5.0)
#> yaml 2.2.0 2018-07-25 CRAN (R 3.5.0) Here is test code result.library(tidyverse)
library(data.table)
#>
#> 载入程辑包:'data.table'
#> The following objects are masked from 'package:dplyr':
#>
#> between, first, last
#> The following object is masked from 'package:purrr':
#>
#> transpose
library(lubridate)
#>
#> 载入程辑包:'lubridate'
#> The following objects are masked from 'package:data.table':
#>
#> hour, isoweek, mday, minute, month, quarter, second, wday,
#> week, yday, year
#> The following object is masked from 'package:base':
#>
#> date
set.seed(123)
data.table(
date = today() + 1:1000
,value = rnorm(1000,0,10)
# sim stock price
) %>%
mutate(
date = floor_date(date, unit = 'halfyear')
# I suggest you maintain the date in yyyy-mm-dd type
) %>%
group_by(date) %>%
summarise(value = mean(value)) %>%
ggplot(aes(date,value)) +
geom_line() +
scale_x_date(breaks = '6 month') Created on 2018-11-05 by the reprex package (v0.2.1) I find it works without any bug. I compare the code you send me and my original code.
Maybe is this the cause. Win"hello!"
#> [1] "hello!" Created on 2018-11-05 by the reprex package (v0.2.1) Session infodevtools::session_info()
#> Session info -------------------------------------------------------------
#> setting value
#> version R version 3.4.4 (2018-03-15)
#> system x86_64, mingw32
#> ui RTerm
#> language (EN)
#> collate Chinese (Simplified)_People's Republic of China.936
#> tz Asia/Taipei
#> date 2018-11-05
#> Packages -----------------------------------------------------------------
#> package * version date source
#> backports 1.1.2 2017-12-13 CRAN (R 3.4.3)
#> base * 3.4.4 2018-03-15 local
#> compiler 3.4.4 2018-03-15 local
#> datasets * 3.4.4 2018-03-15 local
#> devtools 1.13.5 2018-02-18 CRAN (R 3.4.3)
#> digest 0.6.18 2018-10-10 CRAN (R 3.4.4)
#> evaluate 0.10.1 2017-06-24 CRAN (R 3.4.3)
#> graphics * 3.4.4 2018-03-15 local
#> grDevices * 3.4.4 2018-03-15 local
#> htmltools 0.3.6 2017-04-28 CRAN (R 3.4.3)
#> knitr 1.20 2018-02-20 CRAN (R 3.4.3)
#> magrittr 1.5 2014-11-22 CRAN (R 3.4.3)
#> memoise 1.1.0 2017-04-21 CRAN (R 3.4.4)
#> methods * 3.4.4 2018-03-15 local
#> Rcpp 0.12.18 2018-07-23 CRAN (R 3.4.4)
#> rmarkdown 1.10 2018-06-11 CRAN (R 3.4.4)
#> rprojroot 1.3-2 2018-01-03 CRAN (R 3.4.3)
#> stats * 3.4.4 2018-03-15 local
#> stringi 1.1.7 2018-03-12 CRAN (R 3.4.4)
#> stringr 1.3.1 2018-05-10 CRAN (R 3.4.4)
#> tools 3.4.4 2018-03-15 local
#> utils * 3.4.4 2018-03-15 local
#> withr 2.1.2 2018-03-15 CRAN (R 3.4.4)
#> yaml 2.2.0 2018-07-25 CRAN (R 3.4.4) Here is test code result.library(tidyverse)
library(data.table)
#>
#> 载入程辑包:'data.table'
#> The following objects are masked from 'package:dplyr':
#>
#> between, first, last
#> The following object is masked from 'package:purrr':
#>
#> transpose
library(lubridate)
#>
#> 载入程辑包:'lubridate'
#> The following objects are masked from 'package:data.table':
#>
#> hour, isoweek, mday, minute, month, quarter, second, wday,
#> week, yday, year
#> The following object is masked from 'package:base':
#>
#> date
set.seed(123)
data.table(
date = today() + 1:1000
,value = rnorm(1000,0,10)
# sim stock price
) %>%
mutate(
date = floor_date(date, unit = 'halfyear')
# I suggest you maintain the date in yyyy-mm-dd type
) %>%
group_by(date) %>%
summarise(value = mean(value)) %>%
ggplot(aes(date,value)) +
geom_line() +
scale_x_date(breaks = '6 month') Created on 2018-11-05 by the reprex package (v0.2.1) I find it works without any bug on Win too. |
OK we are getting some where!
Well, no, I also added code to suppress the upload of your figure to imgur, which, under the hood, uses the xml2 package. I think it's barfing on some encoding problem. What version of xml2 do you have? |
devtools:::package_info("xml2")
#> package * version date source
#> xml2 1.2.0 2018-01-24 CRAN (R 3.4.3) Created on 2018-11-05 by the reprex package (v0.2.1) |
Thanks for sticking with this. I have two lines of inquiry now. Does your original example work if you direct reprex to save things in current working directory, instead of below session temp dir? Copy your original code snippet to the clipboard (NOT the modified one I gave you that alters the figure upload function). Do I'd like you write a figure to file and then upload it to imgur using the exact code that knitr / reprex use to do this. Maybe we'll see a more exact cause-effect re: your error. This code should do it. Don't run this with reprex, just execute it line by line in RStudio.
|
Ane the code in the second parts runs and faces errors I comments in the code chunk by
|
What happens if you run that last example again, but specify the encoding here:
|
library(ggplot2)
file <- "iris.png"
key <- "9f3460e67f308f6"
p <- ggplot(iris, aes(Sepal.Length, Sepal.Width)) + geom_point()
ggsave(file, p)
#> Saving 7 x 5 in image
resp <- httr::POST(
"https://api.imgur.com/3/image.xml",
config = httr::add_headers(Authorization = paste("Client-ID", key)),
body = list(image = httr::upload_file(file))
)
res <- httr::content(resp, as = "raw")
res <- if (length(res)) xml2::as_list(xml2::read_xml(res), encoding = "UTF-8")
#> Error in doc_parse_raw(x, encoding = encoding, base_url = base_url, as_html = as_html, : Start tag expected, '<' not found [4]
if (packageVersion('xml2') >= '1.2.0') res <- res[[1L]]
if (is.null(res$link[[1]])) stop('failed to upload ', file)
#> Error in res$link: $ operator is invalid for atomic vectors
res$link[[1]]
#> Error in res$link: $ operator is invalid for atomic vectors Created on 2018-11-07 by the reprex package (v0.2.1) Session infodevtools::session_info()
#> Session info -------------------------------------------------------------
#> setting value
#> version R version 3.5.1 (2018-07-02)
#> system x86_64, darwin15.6.0
#> ui X11
#> language (EN)
#> collate zh_CN.UTF-8
#> tz Asia/Shanghai
#> date 2018-11-07
#> Packages -----------------------------------------------------------------
#> package * version date source
#> assertthat 0.2.0 2017-04-11 CRAN (R 3.5.0)
#> backports 1.1.2 2017-12-13 CRAN (R 3.5.0)
#> base * 3.5.1 2018-07-05 local
#> bindr 0.1.1 2018-03-13 CRAN (R 3.5.0)
#> bindrcpp 0.2.2 2018-03-29 CRAN (R 3.5.0)
#> colorspace 1.3-2 2016-12-14 CRAN (R 3.5.0)
#> compiler 3.5.1 2018-07-05 local
#> crayon 1.3.4 2017-09-16 CRAN (R 3.5.0)
#> curl 3.2 2018-03-28 CRAN (R 3.5.0)
#> datasets * 3.5.1 2018-07-05 local
#> devtools 1.13.6 2018-06-27 CRAN (R 3.5.0)
#> digest 0.6.16 2018-08-22 cran (@0.6.16)
#> dplyr 0.7.6 2018-06-29 CRAN (R 3.5.1)
#> evaluate 0.11 2018-07-17 CRAN (R 3.5.0)
#> ggplot2 * 3.0.0 2018-07-03 CRAN (R 3.5.0)
#> glue 1.3.0 2018-07-17 CRAN (R 3.5.0)
#> graphics * 3.5.1 2018-07-05 local
#> grDevices * 3.5.1 2018-07-05 local
#> grid 3.5.1 2018-07-05 local
#> gtable 0.2.0 2016-02-26 CRAN (R 3.5.0)
#> htmltools 0.3.6 2017-04-28 CRAN (R 3.5.0)
#> httr 1.3.1 2017-08-20 CRAN (R 3.5.0)
#> knitr 1.20 2018-02-20 CRAN (R 3.5.0)
#> labeling 0.3 2014-08-23 CRAN (R 3.5.0)
#> lazyeval 0.2.1 2017-10-29 CRAN (R 3.5.0)
#> magrittr 1.5 2014-11-22 CRAN (R 3.5.0)
#> memoise 1.1.0 2017-04-21 CRAN (R 3.5.0)
#> methods * 3.5.1 2018-07-05 local
#> mime 0.5 2016-07-07 CRAN (R 3.5.0)
#> munsell 0.5.0 2018-06-12 CRAN (R 3.5.0)
#> pillar 1.3.0 2018-07-14 CRAN (R 3.5.0)
#> pkgconfig 2.0.1 2017-03-21 CRAN (R 3.5.0)
#> plyr 1.8.4 2016-06-08 CRAN (R 3.5.0)
#> purrr 0.2.5 2018-05-29 CRAN (R 3.5.0)
#> R6 2.3.0 2018-10-04 cran (@2.3.0)
#> Rcpp 0.12.19 2018-10-01 cran (@0.12.19)
#> rlang 0.2.2 2018-08-16 cran (@0.2.2)
#> rmarkdown 1.10 2018-06-11 CRAN (R 3.5.0)
#> rprojroot 1.3-2 2018-01-03 CRAN (R 3.5.0)
#> scales 1.0.0 2018-08-09 CRAN (R 3.5.0)
#> stats * 3.5.1 2018-07-05 local
#> stringi 1.2.4 2018-07-20 CRAN (R 3.5.0)
#> stringr 1.3.1 2018-05-10 CRAN (R 3.5.0)
#> tibble 1.4.2 2018-01-22 CRAN (R 3.5.0)
#> tidyselect 0.2.5 2018-10-11 cran (@0.2.5)
#> tools 3.5.1 2018-07-05 local
#> utils * 3.5.1 2018-07-05 local
#> withr 2.1.2 2018-03-15 CRAN (R 3.5.0)
#> xml2 1.2.0 2018-01-24 CRAN (R 3.5.0)
#> yaml 2.2.0 2018-07-25 CRAN (R 3.5.0) |
Bummer. We have narrowed this down to a problem in knitr or xml2, though. It's not a problem in reprex itself. I suggest that you open an issue on knitr, demonstrating your problem with This code snippet from the help for f = tempfile(fileext = ".png")
png(f)
plot(rnorm(100), main = R.version.string)
dev.off()
res = imgur_upload(f) |
@JiaxiangBU Not sure if you are aware of it, but imgur.com has been blocked in China for years, so you cannot really use this function without tools to deal with GFW. |
@yihui Should knitr check for, e.g. a response status of 200, before trying to parse the response from imgur? A better error message here would have saved a lot of time. |
Yes, it definitely should. A PR would be welcome! :) |
Is there any alternative to imgur.com that works despite the GFW? This appears to be a very handy feature of knitr and, by extension, reprex. |
I'm not aware of other image hosts as convenient as imgur. The problem is when some services are too convenient and provide too much freedom, they are likely to be GFW'ed because people will upload and share "sensitive" stuff there. Github may be the only exception these years and it is surprising that it has survived for so long. We could actually upload images to Github (gist?) and I feel it sounds like abusing Github. |
I was thinking of making reprex's |
When I use
reprex
function, there is an error happening.Here is the code I run and the error happen.
The text was updated successfully, but these errors were encountered: