Skip to content
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 with reprex() function: Failed to connect to api.imgur.com port 443: Timed out #336

Closed
lizhiwei1994 opened this issue Oct 13, 2020 · 2 comments

Comments

@lizhiwei1994
Copy link

Same with the title.

I want to show some code and result on StackOverflow with reprex() function from reprex package.

The code as below:

library(tidyverse)
set.seed(20201011)

metal <- c("Al", "As", "Cd", "Co")
site <- paste('City', LETTERS[1:5], sep = '_')
season <- c('spring', 'summer', 'autumn', 'winter')

frames <- expand.grid(metal = metal,
                       site = site,
                       season = season)
dat.avg <- frames %>% cbind(Average = rnorm(nrow(frames)),
                            STDV = rnorm(nrow(frames)))

dat.avg.0 <- dat.avg %>% filter(metal == 'Al')

# ERROR BAR PLOT
ggplot(dat.avg.0, aes(x = season, group = site, color = site))+
  geom_errorbar(
    aes(ymin=Average-STDV,
        ymax=Average+STDV),
    position = position_dodge(.4), width = .3) +
  geom_point(aes(y = Average),  position = position_dodge(.4))

ggplot(dat.avg, aes(x = season, group = site, color = site))+
  geom_errorbar(
    aes(ymin=Average-STDV,
        ymax=Average+STDV),
    position = position_dodge(.4), width = .3) +
  geom_point(aes(y = Average),  position = position_dodge(.4)) +
  facet_grid(metal ~.) +
  labs(
    title = 'Variation in Metals Conentration along Israeli Mediterranean Coastline, by Season and Site',
    subtitle  = 'North to South',
    caption = 'Field Smapling 2019-2020, \n *Outliers omited for better visualization'
  ) +
  theme(
    plot.title = element_text(color = 'Darkblue'),
    plot.subtitle = element_text(color = 'blue'),
    plot.caption = element_text(color = 'green', face = 'bold')
    
  ) + 
  guides(color = F)


# BOXPLOT
metal <- c("Al", "As", "Cd", "Co")
site <- paste('City', LETTERS[1:5], sep = '_')
season <- c('spring', 'summer', 'autumn', 'winter')
day <- 1:10

frames <- expand.grid(metal = metal,
                      site = site,
                      season = season,
                      day = day)

dat.avg <- frames %>% cbind(Value = rnorm(nrow(frames)))


ggplot(dat.avg, aes(x = season, color = site))+
  geom_boxplot(aes(y = Value)) + 
  facet_grid(metal ~.) +
  labs(
    title = 'Variation in Metals Conentration along Israeli Mediterranean Coastline, by Season and Site',
    subtitle  = 'North to South',
    caption = 'Field Smapling 2019-2020, \n *Outliers omited for better visualization'
  ) +
  theme(
    plot.title = element_text(color = 'Darkblue'),
    plot.subtitle = element_text(color = 'blue'),
    plot.caption = element_text(color = 'green', face = 'bold')
    
  ) + 
  guides(color = F)

I want to put all the code and result on StackOverflow, Then I copy the code and run:

library(reprex)
reprex()

Then error occur:

Error: callr subprocess failed: Failed to connect to api.imgur.com port 443: Timed out

I do not know how to solve it.

Any help will be highly appreciated!

My sessionInfo like this:

R version 3.6.3 (2020-02-29)
Platform: x86_64-w64-mingw32/x64 (64-bit)
Running under: Windows 10 x64 (build 18363)

Matrix products: default

locale:
[1] LC_COLLATE=Chinese (Simplified)_China.936 
[2] LC_CTYPE=Chinese (Simplified)_China.936   
[3] LC_MONETARY=Chinese (Simplified)_China.936
[4] LC_NUMERIC=C                              
[5] LC_TIME=Chinese (Simplified)_China.936    

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

other attached packages:
 [1] reprex_0.3.0     ggnewscale_0.4.3 geosphere_1.5-10
 [4] scatterpie_0.1.5 lubridate_1.7.9  forcats_0.5.0   
 [7] stringr_1.4.0    dplyr_1.0.2      purrr_0.3.4     
[10] readr_1.3.1      tidyr_1.1.2      tibble_3.0.3    
[13] ggplot2_3.3.2    tidyverse_1.3.0  readxl_1.3.1    
[16] feather_0.3.5   

loaded via a namespace (and not attached):
 [1] Rcpp_1.0.5          lattice_0.20-38     ps_1.3.4           
 [4] assertthat_0.2.1    digest_0.6.25       ggforce_0.3.2      
 [7] R6_2.4.1            cellranger_1.1.0    backports_1.1.6    
[10] evaluate_0.14       httr_1.4.2          pillar_1.4.6       
[13] rlang_0.4.7         rstudioapi_0.11     callr_3.4.4        
[16] whisker_0.4         blob_1.2.1          rmarkdown_2.3      
[19] labeling_0.3        polyclip_1.10-0     munsell_0.5.0      
[22] broom_0.7.0         compiler_3.6.3      modelr_0.1.8       
[25] xfun_0.17           pkgconfig_2.0.3     clipr_0.7.0        
[28] htmltools_0.5.0     tidyselect_1.1.0    fansi_0.4.1        
[31] crayon_1.3.4        dbplyr_1.4.4        withr_2.3.0        
[34] MASS_7.3-51.5       grid_3.6.3          jsonlite_1.7.1     
[37] gtable_0.3.0        lifecycle_0.2.0     DBI_1.1.0          
[40] magrittr_1.5        scales_1.1.1        cli_2.0.2          
[43] stringi_1.4.6       farver_2.0.3        fs_1.4.0           
[46] sp_1.4-2            xml2_1.3.2          ellipsis_0.3.1     
[49] rvcheck_0.1.8       generics_0.0.2      vctrs_0.3.4        
[52] tools_3.6.3         glue_1.4.0          tweenr_1.0.1       
[55] maps_3.3.0          hms_0.5.3           processx_3.4.3     
[58] colorspace_1.4-1    BiocManager_1.30.10 rvest_0.3.6        
[61] knitr_1.30          haven_2.3.1   
@jennybc
Copy link
Member

jennybc commented Jan 13, 2021

This sounds like some intermittent problem with imgur or perhaps a more persistent problem between your computer/network and imgur. But I think it's not due to or solvable by reprex itself.

@jennybc jennybc closed this as completed Jan 13, 2021
@francisbarton
Copy link

francisbarton commented Mar 25, 2024

@lizhiwei1994 I had this issue (or a very similar one) recently, after I had been creating a lot of reprexes (20+?), all creating multiple plot images. Currently knitr::imgur_upload() uses a default API key for imgur if you don't have your own. And I think it's possible to overload the API limit for this key.

#' @param key Client ID for Imgur. It can be set via either the global option
#' \code{knitr.imgur.key} or the environment variable \code{R_KNITR_IMGUR_KEY}
#' (see [xfun::env_option()]). If neither is set, this uses a client ID
#' registered by Yihui Xie.

(Code here)

I got round this error by creating my own imgur API key, which I did not find a very straightforward process!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants