I have a PostgreSQL database on my machine that I routinely connect to through R. I have had no issues reading, writing, or appending data to the database in the past. Recently I upgraded to R 4.2.1 and since then any time I try to read data from the database with DBI::dbGetQuery() or to write data using DBI::dbWriteTable(append = TRUE) RStudio crashed.
Any help would be appreciated!
Here is the code I am running:
library(DBI)
library(RPostgreSQL)
pg <- dbDriver("PostgreSQL")
db_connection <- dbConnect(pg, dbname = "williampetti",
user = "williampetti",
password = "",
host = "localhost",
port = 5432)
data(mtcars)
# create a table using the mtcars dataset
# there is no issue writing to create a brand new table
DBI::dbWriteTable(db_connection
, name = 'mtcars_test'
, value = mtcars
, overwrite = TRUE)
# view the fields in the new table
# no error here
DBI::dbListFields(db_connection, 'mtcars_test')
# attempt to read data from the table
# this crashes RStudio, but processes fine when using R directly
DBI::dbGetQuery(db_connection
, 'select * from mtcars_test')
# Trying to append the table results in a crash in both RStudio and R directly
DBI::dbWriteTable(db_connection
, name = 'mtcars_test'
, value = mtcars
, append = TRUE)
My session info is below:
PostgresSQL 12
RStudio 2022.07.1 (Build 554)
R version 4.2.1 (2022-06-23)
Platform: x86_64-apple-darwin17.0 (64-bit)
Running under: macOS Monterey 12.5.1
Matrix products: default
LAPACK: /Library/Frameworks/R.framework/Versions/4.2/Resources/lib/libRlapack.dylib
Random number generation:
RNG: Mersenne-Twister
Normal: Inversion
Sample: Rounding
locale:
[1] en_US.UTF-8/en_US.UTF-8/en_US.UTF-8/C/en_US.UTF-8/en_US.UTF-8
attached base packages:
[1] stats graphics grDevices utils datasets methods base
other attached packages:
[1] RPostgres_1.4.4 DBI_1.1.3
loaded via a namespace (and not attached):
[1] Rcpp_1.0.9 svglite_2.1.0 lubridate_1.8.0 tidyr_1.2.0
[5] assertthat_0.2.1 digest_0.6.29 utf8_1.2.2 mime_0.12
[9] R6_2.5.1 baseballr_1.2.0 evaluate_0.15 httr_1.4.3
[13] ggplot2_3.3.6 pillar_1.8.0 rlang_1.0.4 RPostgreSQL_0.7-3
[17] curl_4.3.2 rstudioapi_0.13 data.table_1.14.2 blob_1.2.3
[21] rmarkdown_2.14 urltools_1.7.3 RMySQL_0.10.23 webshot_0.5.3
[25] readr_2.1.2 stringr_1.4.0 bit_4.0.4 RCurl_1.98-1.8
[29] triebeard_0.3.0 munsell_0.5.0 compiler_4.2.1 janitor_2.1.0
[33] xfun_0.31 pkgconfig_2.0.3 systemfonts_1.0.4 base64enc_0.1-3
[37] htmltools_0.5.3 tidyselect_1.1.2 tibble_3.1.8 myDBconnections_0.1.0
[41] fansi_1.0.3 viridisLite_0.4.0 dplyr_1.0.9 tzdb_0.3.0
[45] bitops_1.0-7 commonmark_1.8.0 grid_4.2.1 jsonlite_1.8.0
[49] gtable_0.3.0 lifecycle_1.0.1 magrittr_2.0.3 scales_1.2.0
[53] RcppParallel_5.1.5 cli_3.3.0 stringi_1.7.8 snakecase_0.11.0
[57] xml2_1.3.3 logger_0.2.2 ellipsis_0.3.2 generics_0.1.3
[61] vctrs_0.4.1 kableExtra_1.3.4 tools_4.2.1 bit64_4.0.5
[65] emayili_0.7.10 glue_1.6.2 purrr_0.3.4 hms_1.1.1
[69] fastmap_1.1.0 colorspace_2.0-3 bpettir_0.1.0 h2o_3.36.1.2
[73] rvest_1.0.2 knitr_1.39
Related
I am trying to import a .py file in RStudio and I am getting the error message:
Error in dir.exists(x) : file name conversion problem -- name too long?)
I have already tried to run it through a path that only contains English letters and it didn't work. Also, the output of list.files() includes the file I'm trying to import.
library(reticulate)
library(tidyverse)
library(forcats)
setwd("C:/Users/Κατερίνα/Nextcloud/Multipic_Exp.1")
source_python("euler.py") --> Here I get the error message.
The traceback() output:
12: dir.exists(x)
11: utils::file_test("-d", version_dir)
10: read_python_versions_from_registry("HCU", key = "PythonCore")
9: rbind(read_python_versions_from_registry("HCU", key = "PythonCore"),
read_python_versions_from_registry("HLM", key = "PythonCore"),
windows_registry_anaconda_versions())
8: py_versions_windows()
7: python_conda_versions()
6: py_discover_config(required_module, use_environment)
5: (function() {
op <- options(reticulate.python.initializing = TRUE)
on.exit(options(op), add = TRUE)
py_discover_config(required_module, use_environment)
})()
4: initialize_python(required_module, use_environment)
3: ensure_python_initialized()
2: py_run_file(file, local = FALSE, convert = convert)
1: source_python("euler.py")
My sessionInfo():
R version 4.1.0 (2021-05-18)
Platform: x86_64-w64-mingw32/x64 (64-bit)
Running under: Windows 10 x64 (build 19044)
Matrix products: default
locale:
[1] LC_COLLATE=Greek_Greece.1253 LC_CTYPE=Greek_Greece.1253 LC_MONETARY=Greek_Greece.1253
[4] LC_NUMERIC=C LC_TIME=Greek_Greece.1253
attached base packages:
[1] stats graphics grDevices utils datasets methods base
other attached packages:
[1] forcats_0.5.1 stringr_1.4.0 dplyr_1.0.7 purrr_0.3.4 readr_1.4.0 tidyr_1.1.3 tibble_3.1.2
[8] ggplot2_3.3.5 tidyverse_1.3.1 reticulate_1.26
loaded via a namespace (and not attached):
[1] Rcpp_1.0.9 cellranger_1.1.0 pillar_1.6.1 compiler_4.1.0 dbplyr_2.1.1 tools_4.1.0
[7] lubridate_1.8.0 jsonlite_1.8.4 lifecycle_1.0.3 gtable_0.3.0 lattice_0.20-44 pkgconfig_2.0.3
[13] png_0.1-7 rlang_1.0.6 reprex_2.0.1 Matrix_1.3-3 cli_3.4.1 DBI_1.1.1
[19] rstudioapi_0.13 haven_2.4.1 xml2_1.3.2 withr_2.4.2 httr_1.4.2 fs_1.5.2
[25] hms_1.1.0 generics_0.1.0 vctrs_0.5.1 rprojroot_2.0.2 grid_4.1.0 tidyselect_1.1.1
[31] here_1.0.1 glue_1.6.2 R6_2.5.1 fansi_0.5.0 readxl_1.3.1 modelr_0.1.8
[37] magrittr_2.0.3 scales_1.1.1 backports_1.2.1 ellipsis_0.3.2 rvest_1.0.2 assertthat_0.2.1
[43] colorspace_2.0-2 utf8_1.2.1 stringi_1.7.6 munsell_0.5.0 broom_0.7.8 crayon_1.4.1
As the title says when I use the fill_colour parameter my session crashes.
For example if I take from the Colours section of the mapdeck site and run
library(mapdeck)
library(sf)
sf <- spatialwidget::widget_melbourne
mapdeck() %>%
add_polygon(
data = sf
, fill_colour = "SA2_NAME"
)
Then the system crashes with "R Session Aborted"
If I amend the above to just
library(mapdeck)
library(sf)
sf <- spatialwidget::widget_melbourne
mapdeck() %>%
add_polygon(
data = sf
)
then the plot comes out without an error.
If I go to the logs from the help menu in Rstudio then there's nothing about the crash.
What should I be checking, removing, reinstalling, etc?
sessionInfo()
R version 4.2.0 (2022-04-22 ucrt)
Platform: x86_64-w64-mingw32/x64 (64-bit)
Running under: Windows 10 x64 (build 19044)
Matrix products: default
locale:
[1] LC_COLLATE=English_United States.utf8 LC_CTYPE=English_United States.utf8 LC_MONETARY=English_United States.utf8 LC_NUMERIC=C
[5] LC_TIME=English_United States.utf8
attached base packages:
[1] stats graphics grDevices utils datasets methods base
other attached packages:
[1] units_0.8-0 dplyr_1.0.9 jsonify_1.2.1 RColorBrewer_1.1-3 sf_1.0-8 mapdeck_0.3.4 stringr_1.4.0 arrow_8.0.0
[9] webshot2_0.1.0 ggplot2_3.3.6 glue_1.6.2 magrittr_2.0.3 flextable_0.7.0 data.table_1.14.2 lubridate_1.8.0
loaded via a namespace (and not attached):
[1] Rcpp_1.0.8.3 class_7.3-20 ps_1.7.0 assertthat_0.2.1 digest_0.6.29 utf8_1.2.2 R6_2.5.1 evaluate_0.15
[9] e1071_1.7-9 pillar_1.7.0 gdtools_0.2.4 rlang_1.0.2 uuid_1.1-0 rmarkdown_2.14 htmlwidgets_1.5.4 bit_4.0.4
[17] munsell_0.5.0 proxy_0.4-26 compiler_4.2.0 xfun_0.31 pkgconfig_2.0.3 systemfonts_1.0.4 base64enc_0.1-3 htmltools_0.5.2
[25] spatialwidget_0.2.3 websocket_1.4.1 tidyselect_1.1.2 tibble_3.1.7 fansi_1.0.3 crayon_1.5.1 withr_2.5.0 later_1.3.0
[33] grid_4.2.0 jsonlite_1.8.0 gtable_0.3.0 lifecycle_1.0.1 DBI_1.1.2 scales_1.2.0 KernSmooth_2.23-20 zip_2.2.0
[41] cli_3.3.0 stringi_1.7.6 promises_1.2.0.1 xml2_1.3.3 ellipsis_0.3.2 generics_0.1.2 vctrs_0.4.1 tools_4.2.0
[49] bit64_4.0.5 officer_0.4.2 purrr_0.3.4 processx_3.5.3 fastmap_1.1.0 yaml_2.3.5 chromote_0.1.0 colorspace_2.0-3
[57] classInt_0.4-3 knitr_1.39
Using the data available on FactoMineR package: (http://factominer.free.fr/book/orange.csv), I created a PCA and after a PCA with supplementary information. The latter step when I used the function dimdesc() I obtained an error that surfing through internet I was not able to find a way to solve it.
I post here if someone could help me. I attach below my code. Thanks on advance for your comments/hints.
data_orange<-read.delim("orange.csv", header = T, sep = ";")
data_orange_subset <- data_orange[,1:8]
res.pca<-PCA(data_orange_subset, graph = F)
dimdesc(res.pca,axes=1:2)
--> This works
When considering supplementary information in the PCA:
data_orange_2 <- data_orange[,-c(16,17)]
res.pca.all <- PCA(data_orange_2, graph = F,
quanti.sup = 9:15,
quali.sup = 1)
dimdesc(res.pca.all, axes = 1:2)
Error in if (sum(tabF[, 2] <= proba) > 0) resF <- tabF[tabF[, 2] <= proba, :
missing value where TRUE/FALSE needed
I've checked for NA values in dataframe but it is not the case.
SessionInfo()
R version 4.1.2 (2021-11-01)
Platform: x86_64-pc-linux-gnu (64-bit)
Running under: Linux Mint 19.1
Matrix products: default
BLAS: /usr/lib/x86_64-linux-gnu/blas/libblas.so.3.7.1
LAPACK: /usr/lib/x86_64-linux-gnu/lapack/liblapack.so.3.7.1
locale:
[1] LC_CTYPE=en_GB.UTF-8 LC_NUMERIC=C LC_TIME=en_GB.UTF-8
[4] LC_COLLATE=en_GB.UTF-8 LC_MONETARY=es_ES.UTF-8 LC_MESSAGES=en_GB.UTF-8
[7] LC_PAPER=es_ES.UTF-8 LC_NAME=C LC_ADDRESS=C
[10] LC_TELEPHONE=C LC_MEASUREMENT=es_ES.UTF-8 LC_IDENTIFICATION=C
attached base packages:
[1] stats graphics grDevices utils datasets methods base
other attached packages:
[1] factoextra_1.0.7.999 ggplot2_3.3.6 FactoMineR_2.4
loaded via a namespace (and not attached):
[1] ggrepel_0.9.1 Rcpp_1.0.8.3 lattice_0.20-45 tidyr_1.2.0
[5] assertthat_0.2.1 digest_0.6.29 utf8_1.2.2 R6_2.5.1
[9] backports_1.4.1 evaluate_0.15 pillar_1.7.0 rlang_1.0.3
[13] rstudioapi_0.13 minqa_1.2.4 car_3.1-0 nloptr_2.0.3
[17] Matrix_1.4-1 DT_0.23 rmarkdown_2.13 labeling_0.4.2
[21] splines_4.1.2 lme4_1.1-29 htmlwidgets_1.5.4 munsell_0.5.0
[25] broom_0.8.0 compiler_4.1.2 xfun_0.31 pkgconfig_2.0.3
[29] faraway_1.0.7 htmltools_0.5.2 flashClust_1.01-2 tidyselect_1.1.2
[33] tibble_3.1.7 gridExtra_2.3 dendextend_1.15.2 viridisLite_0.4.0
[37] fansi_1.0.3 crayon_1.5.1 dplyr_1.0.9 withr_2.5.0
[41] ggpubr_0.4.0 MASS_7.3-56 leaps_3.1 grid_4.1.2
[45] nlme_3.1-157 gtable_0.3.0 lifecycle_1.0.1 DBI_1.1.2
[49] magrittr_2.0.3 scales_1.2.0 cli_3.3.0 carData_3.0-5
[53] farver_2.1.0 ggsignif_0.6.3 viridis_0.6.2 scatterplot3d_0.3-41
[57] ellipsis_0.3.2 generics_0.1.2 vctrs_0.4.1 boot_1.3-28
[61] ggsci_2.9 tools_4.1.2 glue_1.6.2 purrr_0.3.4
[65] abind_1.4-5 fastmap_1.1.0 yaml_2.3.5 colorspace_2.0-3
[69] cluster_2.1.3 rstatix_0.7.0 knitr_1.39
a<- paste0("\U2265",80)
b<- paste0("\U2265",80)
data <- data.frame(a,b)
write.csv(data, "C:/NMPED Data Transformation/Newfile.csv", row.names = F, na = "",fileEncoding = "UTF-8")
But the output showing as :
a b
80 80
expected output is:
a b
≥80 ≥80
my output of sessioninfo() is
sessionInfo()
R version 4.1.3 (2022-03-10)
Platform: x86_64-w64-mingw32/x64 (64-bit)
Running under: Windows 10 x64 (build 19044)
Matrix products: default
locale:
LC_COLLATE=English_India.1252 LC_CTYPE=English_India.1252 LC_MONETARY=English_India.1252 LC_NUMERIC=C LC_TIME=English_India.1252
attached base packages:
stats graphics grDevices utils datasets methods base
other attached packages:
haven_2.5.0 ggmap_3.0.0 readxl_1.3.1 RODBC_1.3-19 data.table_1.14.2 forcats_0.5.1 stringr_1.4.0 dplyr_1.0.7 purrr_0.3.4
readr_2.1.1 tidyr_1.1.4 tibble_3.1.6 ggplot2_3.3.5 tidyverse_1.3.1
loaded via a namespace (and not attached):
tidyselect_1.1.1 lattice_0.20-45 colorspace_2.0-2 vctrs_0.3.8 generics_0.1.1 utf8_1.2.2 rlang_0.4.12 pillar_1.6.4
glue_1.5.0 withr_2.4.3 DBI_1.1.1 sp_1.4-6 dbplyr_2.1.1 modelr_0.1.8 plyr_1.8.6 jpeg_0.1-9
lifecycle_1.0.1 munsell_0.5.0 gtable_0.3.0 cellranger_1.1.0 rvest_1.0.2 RgoogleMaps_1.4.5.3 tzdb_0.2.0 fansi_0.5.0
broom_0.7.10 Rcpp_1.0.7 scales_1.1.1 backports_1.3.0 jsonlite_1.7.2 fs_1.5.1 rjson_0.2.20 hms_1.1.1
png_0.1-7 stringi_1.7.6 grid_4.1.3 cli_3.1.0 tools_4.1.3 bitops_1.0-7 magrittr_2.0.1 crayon_1.4.2
pkgconfig_2.0.3 ellipsis_0.3.2 xml2_1.3.3 reprex_2.0.1 lubridate_1.8.0 assertthat_0.2.1 httr_1.4.2 rstudioapi_0.13
R6_2.5.1 compiler_4.1.3
Use the locale English_India.utf8.
In the example below I first set your locale (since mine is different) and the wanted symbols are not printed.
Then I set LC_CTYPE = "English_India.utf8" and the greater-than-or-equal-to symbols are there.
In the end I reset the original locale.
old_loc <- Sys.getlocale("LC_CTYPE")
a <- paste0("\U2265",80)
b <- paste0("\U2265",80)
data <- data.frame(a, b)
Sys.setlocale("LC_CTYPE", "English_India.1252")
data
#> a b
#> 1 =80 =80
Sys.setlocale("LC_CTYPE", "English_India.utf8")
#> [1] "English_India.utf8"
data
#> a b
#> 1 ≥80 ≥80
write.csv(data, "~/Temp/Newfile.csv",
row.names = FALSE,
na = "",
fileEncoding = "UTF-8")
Sys.setlocale("LC_CTYPE", old_loc)
#> [1] "Portuguese_Portugal.utf8"
Created on 2022-05-01 by the reprex package (v2.0.1)
I have a problem with converting ggplots into rayshader 3d graphs. I have tested many different examples on the rayshader homepage but it just won't work. For example this code I have from the demonstration examples of the official homepage:
library(rayshader)
library(ggplot2)
mtplot = ggplot(mtcars) +
geom_point(aes(x=mpg,y=disp,color=cyl)) +
scale_color_continuous(limits=c(0,8))
plot_gg(mtplot, width=3.5, multicore = TRUE, windowsize = c(1400,866), sunangle=225,
zoom = 0.60, phi = 30, theta = 45)
When I execute this code the x11 windows opens but it is blank and looks like this. when I use preview=T it works fine since the x11 windows does not open. When I close this blank window my R session is aborted and in the console it says:
pure virtual method called. I have no clue how to get rid of the problem, I could not find anything on the internet so far.
this is my session info:
R version 4.1.0 (2021-05-18)
Platform: x86_64-w64-mingw32/x64 (64-bit)
Running under: Windows 10 x64 (build 19041)
Matrix products: default
locale:
[1] LC_COLLATE=German_Germany.1252 LC_CTYPE=German_Germany.1252 LC_MONETARY=German_Germany.1252
[4] LC_NUMERIC=C LC_TIME=German_Germany.1252
attached base packages:
[1] stats graphics grDevices utils datasets methods base
other attached packages:
[1] ggplot2_3.3.3 rayshader_0.24.11
loaded via a namespace (and not attached):
[1] Rcpp_1.0.6 pillar_1.6.1 compiler_4.1.0 later_1.2.0
[5] prettyunits_1.1.1 iterators_1.0.13 tools_4.1.0 progress_1.2.2
[9] digest_0.6.27 tibble_3.1.2 jsonlite_1.7.2 lifecycle_1.0.0
[13] gtable_0.3.0 pkgconfig_2.0.3 rlang_0.4.11 foreach_1.5.1
[17] DBI_1.1.1 shiny_1.6.0 crosstalk_1.1.1 parallel_4.1.0
[21] xfun_0.23 fastmap_1.1.0 withr_2.4.2 dplyr_1.0.6
[25] knitr_1.33 generics_0.1.0 vctrs_0.3.8 htmlwidgets_1.5.3
[29] hms_1.1.0 tidyselect_1.1.1 manipulateWidget_0.10.1 webshot_0.5.2
[33] grid_4.1.0 glue_1.4.2 R6_2.5.0 fansi_0.4.2
[37] rgl_0.106.8 purrr_0.3.4 magrittr_2.0.1 scales_1.1.1
[41] codetools_0.2-18 promises_1.2.0.1 ellipsis_0.3.2 htmltools_0.5.1.1
[45] assertthat_0.2.1 mime_0.10 xtable_1.8-4 colorspace_2.0-1
[49] httpuv_1.6.1 utf8_1.2.1 miniUI_0.1.1.1 doParallel_1.0.16
[53] munsell_0.5.0 crayon_1.4.1