MarkEdmondson1234 / searchConsoleR

R interface with Google Search Console API v3, including Search Analytics.
http://code.markedmondson.me/searchConsoleR/
Other
114 stars 41 forks source link

R 4.3 ends with 'length = 2' in coercion to 'logical(1)' when using c() in dimensions #82

Open neologyc opened 1 year ago

neologyc commented 1 year ago

What goes wrong

R errors on getting data from Search Console

The problem goes from newest R version, according to https://cran.r-project.org/doc/manuals/r-release/NEWS.html changelog:

Calling && or || with LHS or (if evaluated) RHS of length greater than one is now always an error, with a report of the form

'length = 4' in coercion to 'logical(1)'

Steps to reproduce the problem

siteUrl <- "sc-domain:hlavinka.cz"
end <- Sys.Date()
start <- dateTo - 500 # za celou dobu
resultsCount <- 200
download_dimensions <- c('date','query')
type <- c('web')

data <- search_analytics(siteURL = siteUrl, 
                         startDate = start, 
                         endDate = end, 
                         dimensions = download_dimensions, 
                         searchType = type, 
                         rowLimit = 100)

Expected output

Data from GSC in data variable

Actual output

Error in !is.null(dimensions) && !dimensions %in% c("date", "country",  : 
  'length = 2' in coercion to 'logical(1)'

Before you run your code, please run:

options(googleAuthR.verbose=2) and copy-paste the console output here.

no data returned

Session Info

Please run sessionInfo() so we can check what versions of packages you have installed

R version 4.3.0 (2023-04-21)
Platform: aarch64-apple-darwin20 (64-bit)
Running under: macOS Ventura 13.3

Matrix products: default
BLAS:   /System/Library/Frameworks/Accelerate.framework/Versions/A/Frameworks/vecLib.framework/Versions/A/libBLAS.dylib 
LAPACK: /Library/Frameworks/R.framework/Versions/4.3-arm64/Resources/lib/libRlapack.dylib;  LAPACK version 3.11.0

locale:
[1] en_US.UTF-8/en_US.UTF-8/en_US.UTF-8/C/en_US.UTF-8/en_US.UTF-8

time zone: Europe/Prague
tzcode source: internal

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

other attached packages:
[1] devtools_2.4.5            usethis_2.1.6             stringr_1.5.0             scales_1.2.1              gridExtra_2.3            
[6] searchConsoleR_0.4.0.9000 dplyr_1.1.2               ggplot2_3.4.2            

loaded via a namespace (and not attached):
 [1] gtable_0.3.3      xfun_0.39         htmlwidgets_1.6.2 remotes_2.4.2     processx_3.8.1    gargle_1.4.0      callr_3.7.3      
 [8] vctrs_0.6.2       tools_4.3.0       ps_1.7.5          generics_0.1.3    curl_5.0.0        tibble_3.2.1      fansi_1.0.4      
[15] pkgconfig_2.0.3   desc_1.4.2        assertthat_0.2.1  lifecycle_1.0.3   compiler_4.3.0    munsell_0.5.0     httpuv_1.6.9     
[22] htmltools_0.5.5   urlchecker_1.0.1  later_1.3.0       pillar_1.9.0      crayon_1.5.2      ellipsis_0.3.2    openssl_2.0.6    
[29] cachem_1.0.7      sessioninfo_1.2.2 mime_0.12         googleAuthR_2.0.1 tidyselect_1.2.0  digest_0.6.31     stringi_1.7.12   
[36] purrr_1.0.1       rprojroot_2.0.3   fastmap_1.1.1     colorspace_2.1-0  cli_3.6.1         magrittr_2.0.3    pkgbuild_1.4.0   
[43] utf8_1.2.3        withr_2.5.0       prettyunits_1.1.1 promises_1.2.0.1  rappdirs_0.3.3    httr_1.4.5        askpass_1.1      
[50] memoise_2.0.1     shiny_1.7.4       knitr_1.42        miniUI_0.1.1.1    profvis_0.3.7     rlang_1.1.0       Rcpp_1.0.10      
[57] xtable_1.8-4      glue_1.6.2        pkgload_1.3.2     rstudioapi_0.14   jsonlite_1.8.4    R6_2.5.1          fs_1.6.2     
cartercoughlin commented 9 months ago

I am still seeing the same issue with the most updated R version (4.3.1) and the same example code above.

MarkEdmondson1234 commented 9 months ago

Update the package from GitHub - see Readme