"Attempt to apply non-function" error when trying to write.csv - r

I'm just trying to export my data using write.csv like you'd expect
write.csv(df, "df.csv")
and I'm getting this error:
"Error in app$vspace(new_style$`margin-top` %||% 0) : attempt to apply non-function."
I'm not sure how to troubleshoot this/solve the issue! I double checked that my data is a standard class (it's a data.frame), but beyond that I'm at a loss because it looks like every other data.frame I've ever (successfully) exported. I'm not an experienced error-reader, but if it's helpful, the top line of the traceback is this:
clii__container_start(app, "span", class = funname)
I also did all the basics like quitting and restarting my R session, moving my working directory around, and checking if other data.frames can export -- they can, it's just this one that's stuck.
Here's the output for sessionInfo():
> sessionInfo()
R version 4.1.0 (2021-05-18)
Platform: x86_64-w64-mingw32/x64 (64-bit)
Running under: Windows 10 x64 (build 22000)
Matrix products: default
locale:
[1] LC_COLLATE=English_United States.1252 LC_CTYPE=English_United States.1252
[3] LC_MONETARY=English_United States.1252 LC_NUMERIC=C
[5] LC_TIME=English_United States.1252
attached base packages:
[1] stats graphics grDevices utils datasets methods base
loaded via a namespace (and not attached):
[1] fansi_0.4.2 assertthat_0.2.1 utf8_1.2.1 crayon_1.5.1 dplyr_1.0.8 R6_2.5.1
[7] DBI_1.1.2 lifecycle_1.0.1 magrittr_2.0.1 pillar_1.7.0 rlang_1.0.2 cli_3.2.0
[13] rstudioapi_0.13 remotes_2.4.2 vctrs_0.3.8 generics_0.1.2 ellipsis_0.3.2 tools_4.1.0
[19] glue_1.4.2 purrr_0.3.4 xfun_0.30 compiler_4.1.0 pkgconfig_2.0.3 knitr_1.39
[25] tidyselect_1.1.2 tibble_3.1.2
and for rstudioapi::getVersion()
> rstudioapi::getVersion()
[1] ‘1.4.1106’

Related

R gt gtsave Error in s$close() : attempt to apply non-function

I use the gt package to create and save a table that I produce. Recently, I have sometimes been getting the following error when I attempt to gtsave.
Error in s$close() : attempt to apply non-function
Here is session information:
> sessionInfo()
R version 4.1.1 (2021-08-10)
Platform: x86_64-w64-mingw32/x64 (64-bit)
Running under: Windows 10 x64 (build 22000)
Matrix products: default
locale:
[1] LC_COLLATE=English_United States.1252 LC_CTYPE=English_United States.1252 LC_MONETARY=English_United States.1252
[4] LC_NUMERIC=C LC_TIME=English_United States.1252
attached base packages:
[1] stats graphics grDevices utils datasets methods base
loaded via a namespace (and not attached):
[1] Rcpp_1.0.9 later_1.3.0 cellranger_1.1.0 pillar_1.8.1 compiler_4.1.1 tools_4.1.1
[7] digest_0.6.29 jsonlite_1.8.0 googledrive_2.0.0 lifecycle_1.0.2 gargle_1.2.1 tibble_3.1.8
[13] gtable_0.3.1 pkgconfig_2.0.3 rlang_1.0.5 svGUI_1.0.1 cli_3.4.0 rstudioapi_0.14
[19] commonmark_1.8.0 curl_4.3.2 fastmap_1.1.0 webshot2_0.1.0 dplyr_1.0.10 stringr_1.4.1
[25] generics_0.1.3 fs_1.5.2 vctrs_0.4.1 sass_0.4.2 svDialogs_1.1.0 websocket_1.4.1
[31] googlesheets4_1.0.1 grid_4.1.1 tidyselect_1.1.2 chromote_0.1.1 glue_1.6.2 R6_2.5.1
[37] processx_3.7.0 fansi_1.0.3 tidyr_1.2.1 purrr_0.3.4 ggplot2_3.3.6 magrittr_2.0.3
[43] ps_1.7.1 promises_1.2.0.1 scales_1.2.1 htmltools_0.5.3 ellipsis_0.3.2 gt_0.7.0
[49] colorspace_2.0-3 utf8_1.2.2 stringi_1.7.8 munsell_0.5.0
I can install.packages("webshot") again to and then re-run my code usually without issue. However, this isn't a great solution. Anyone have any suggestions? I have managed to recreate this issue on two different, independent computers (and code) after updating my R, Rstudio, and all of my packages.
Thanks!

warning "using locale code page other than 65001 ("UTF-8") may cause problems" after R 4.2 update

I work with multiple locales/languages on Windows, and after my recent update to R 4.2, I keep seeing a warning " using locale code page other than 65001 ("UTF-8") may cause problems" whenever I try to set the system locale (and regardless of what language I try to set it to).
When I revert back to R 4.1.3, the warning doesn't appear.
Can anyone tell me what this warning means and whether there's anyway to get rid of it? Thanks!
> Sys.setlocale("LC_ALL","English")
[1] "LC_COLLATE=English_United States.1252;LC_CTYPE=English_United States.1252;LC_MONETARY=English_United States.1252;LC_NUMERIC=C;LC_TIME=English_United States.1252"
Warning message:
In Sys.setlocale("LC_ALL", "English") :
using locale code page other than 65001 ("UTF-8") may cause problems
> sessionInfo()
R version 4.2.0 (2022-04-22 ucrt)
Platform: x86_64-w64-mingw32/x64 (64-bit)
Running under: Windows 10 x64 (build 22000)
Matrix products: default
locale:
[1] LC_COLLATE=English_United States.1252
[2] LC_CTYPE=English_United States.1252
[3] LC_MONETARY=English_United States.1252
[4] LC_NUMERIC=C
[5] LC_TIME=English_United States.1252
system code page: 65001
attached base packages:
[1] stats graphics grDevices utils datasets methods base
loaded via a namespace (and not attached):
[1] fansi_1.0.3 assertthat_0.2.1 dplyr_1.0.9 utf8_1.2.2
[5] crayon_1.5.1 grid_4.2.0 R6_2.5.1 DBI_1.1.2
[9] lifecycle_1.0.1 gtable_0.3.0 magrittr_2.0.3 scales_1.2.0
[13] ggplot2_3.3.6 pillar_1.7.0 rlang_1.0.2 cli_3.3.0
[17] generics_0.1.2 vctrs_0.4.1 ellipsis_0.3.2 glue_1.6.2
[21] purrr_0.3.4 munsell_0.5.0 compiler_4.2.0 pkgconfig_2.0.3
[25] colorspace_2.0-3 tidyselect_1.1.2 tibble_3.1.7
>

Error in if (num_colors <256) when importing csv files?

I recently updated to R 4.03 and since doing so I have had difficulty uploading csv files in R studio. This is true whether trying to import with code or when manually importing using the tab Environment -> "Import Dataset." The error message I receive is "Error in if (num_colors < 256) { : missing value where TRUE/FALSE needed."
Here is the code I am using:
library(readr)
df <- read_csv("df.csv")
Error in if (num_colors < 256) { : missing value where TRUE/FALSE needed`
I thought this may have something to do with the package "crayon" but loading this library does not seem to make a difference.
Furthermore, when I save "df.csv" as an excel file "df.xlsx" I am able to load the dataset without issue using the following code
library(readxl)
df <- read_excel(df.xlsx)
I don't encounter this problem when using R 4.0.2 on a different machine, so I suspect this issue may be related to the upgrade.
Any insights are appreciated.
Update:
Newish R user and I appreciate everyone's interest in this question. I believe the session is clean. Per Ben's request:
find("read_csv")
[1] "package:readr"
sessionInfo()
R version 4.0.3 (2020-10-10)
Platform: x86_64-w64-mingw32/x64 (64-bit)
Running under: Windows >= 8 x64 (build 9200)
Matrix products: default
locale:
[1] LC_COLLATE=English_United States.1252 LC_CTYPE=English_United States.1252 LC_MONETARY=English_United States.1252 LC_NUMERIC=C
[5] LC_TIME=English_United States.1252
attached base packages:
[1] stats graphics grDevices utils datasets methods base
other attached packages:
[1] dplyr_1.0.3 crayon_1.4.1 readxl_1.3.1 plyr_1.8.6 readr_1.4.0
loaded via a namespace (and not attached):
[1] Rcpp_1.0.6 rstudioapi_0.13 magrittr_2.0.1 hms_1.0.0 tidyselect_1.1.0 lattice_0.20-41 R6_2.5.0 rlang_0.4.10 fansi_0.4.2
[10] tools_4.0.3 grid_4.0.3 utf8_1.1.4 DBI_1.1.1 cli_2.3.0 ellipsis_0.3.1 assertthat_0.2.1 tibble_3.0.5 lifecycle_0.2.0
[19] Matrix_1.2-18 purrr_0.3.4 vctrs_0.3.6 glue_1.4.2 compiler_4.0.3 pillar_1.4.7 cellranger_1.1.0 generics_0.1.0 pkgconfig_2.0.3
I'd suggest updating RStudio to the latest version as well as R.
That did the trick for me.
Edit
In view of Ben's request below.
R version: 4.0.4;
RStudio version: 1.4.1103

Distortions while reading svg with magick in R

I am trying to read a svg image (created with inkscape) with magick in R. From the introduction here, imagemagick can read svg image.
This is the svg image that I am trying to read.
https://www.dropbox.com/s/3dqcr7qr286m1k5/image.svg?dl=0
library(magrittr)
library(magick)
i <- "image.svg"
myimage <- image_read(i)
myimage
I can read the image successfully, but when I view the image in the Rstudio viewer, the image has some distortions especially in the labels.
Is there a way to avoid such distortions in svg image?
My Sys.info
sysname release
"Windows" "10 x64"
version nodename
"build 19041" "SUMANKHANAL"
machine login
"x86-64" "suman"
user effective_user
"suman" "suman"
sessionInfo
R version 4.0.3 (2020-10-10)
Platform: x86_64-w64-mingw32/x64 (64-bit)
Running under: Windows 10 x64 (build 19041)
Matrix products: default
locale:
[1] LC_COLLATE=English_United States.1252
[2] LC_CTYPE=English_United States.1252
[3] LC_MONETARY=English_United States.1252
[4] LC_NUMERIC=C
[5] LC_TIME=English_United States.1252
attached base packages:
[1] stats graphics grDevices
[4] utils datasets methods
[7] base
other attached packages:
[1] magick_2.5.2 magrittr_2.0.1
[3] reprex_0.3.0
loaded via a namespace (and not attached):
[1] Rcpp_1.0.5 rstudioapi_0.13
[3] knitr_1.30 whisker_0.4
[5] R6_2.4.1 rlang_0.4.10
[7] tools_4.0.3 xfun_0.20
[9] tinytex_0.26 clipr_0.7.0
[11] htmltools_0.5.0 ellipsis_0.3.1
[13] digest_0.6.27 tibble_3.0.3
[15] lifecycle_0.2.0 crayon_1.3.4
[17] processx_3.4.4 callr_3.5.1
[19] vctrs_0.3.5 fs_1.5.0
[21] ps_1.3.4 evaluate_0.14
[23] rmarkdown_2.5 compiler_4.0.3
[25] pillar_1.4.6 pkgconfig_2.0.3

R3.6.3 finreportr error while getting financial data from edgar

I am using rstudio Version 1.2.1335.
I updated all my package using rstudio. So everything should be updated.
The strange thing was it was working for me a few hours ago when I was using R 3.6.0. Then it stopped working. Then I updated my R to 3.6.3 just now, but still not working. It either gives me an error or it will be running for so long I have to alt+ctrl+del to quit rstudio.
companyinfo() works
but getbalancesheet, getincome, getcashflow do not work. Anyone know why? Thank you.
I received the following error, which seems to has an impossible URL, don't know why and how can I fix it?:
GetBalanceSheet("SQ",2019) (SQ is the company Square inc)
> Error in fileFromCache(file) : Error in download.file(file,
> cached.file, quiet = !verbose) : cannot open URL
> 'https://www.sec.gov/Archives/edgar/data/1512673/000151267319000003/https://xbrl.sec.gov/dei/2018/dei-2018-01-31.xsd'
>
> In addition: Warning message: In download.file(file, cached.file,
> quiet = !verbose) : cannot open URL
> 'https://www.sec.gov/Archives/edgar/data/1512673/000151267319000003/https://xbrl.sec.gov/dei/2018/dei-2018-01-31.xsd':
> HTTP status was '404 Not Found'
Thank you for the reply. I tried GetBalanceSheet("FB", 2019), it gives me a similar error. I think the URL it is showing in the error message suggest the function is trying to open an invalid URL.
Below is my session info
R version 3.6.3 (2020-02-29)
Platform: x86_64-w64-mingw32/x64 (64-bit)
Running under: Windows 10 x64 (build 16299)
Matrix products: default
locale:
[1] LC_COLLATE=English_United States.1252
[2] LC_CTYPE=English_United States.1252
[3] LC_MONETARY=English_United States.1252
[4] LC_NUMERIC=C
[5] LC_TIME=English_United States.1252
attached base packages:
[1] stats graphics grDevices utils datasets methods base
other attached packages:
[1] finreportr_1.0.1 edgar_2.0.2
loaded via a namespace (and not attached):
[1] Rcpp_1.0.1 rstudioapi_0.11 knitr_1.28 xml2_1.2.5
[5] magrittr_1.5 tidyselect_1.0.0 tm_0.7-7 R6_2.4.1
[9] rlang_0.4.5 stringr_1.4.0 dplyr_0.8.5 tools_3.6.3
[13] parallel_3.6.3 xfun_0.12 R.oo_1.23.0 assertthat_0.2.1
[17] tibble_2.1.3 crayon_1.3.4 NLP_0.2-0 purrr_0.3.3
[21] R.utils_2.9.2 curl_4.3 glue_1.3.2 slam_0.1-47
[25] qdapRegex_0.7.2 stringi_1.4.6 compiler_3.6.3 pillar_1.4.3
[29] R.methodsS3_1.8.0 XML_3.99-0.3 pkgconfig_2.0.3
Update
I found that if I use a VPN....then the function work...is SEC blocking my IP??? is the even possible?

Resources