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)
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
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
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
I have created a function in R and have been using it in research for well over a month now. This function I have created takes use of the embrace operator {{. The purpose of the function isn't really important, but basically at the beginning of my function I created a tibble from the data given in which I use through the function.
f <- function(data, x, y, z){
tb <- data %>%
transmute("var1" = {{x}},
"var2" = {{y}},
"var3" = {{z}})
# Do some stuff with tb
return(tb)
}
My data lets call df already has the variable names x, y, and z so I have been able to just use function by just putting in the data name as shown below.
df <- tibble("x" = 1:3,
"y" = 4:6,
"z" = 7:9)
f(data = df)
> output
However, today I installed tidymodels and right after I installed it I have been getting an error.
f(data = df)
>Error in is_data_pronoun(expr) :
argument "expr" is missing, with no default
It seems to fix this error all I have to do is give the variables names in the function and it works as show below.
f(data = df, x = x, y = y, z = z)
># A tibble: 3 x 3
var1 var2 var3
<int> <int> <int>
1 1 4 7
2 2 5 8
3 3 6 9
This is kinda annoying as now I would have to go all throughout my file when I use the function and put x = x, y = y, z = z in the function. Does anyone have any idea why I am getting this error and why it all the sudden as come up and how to fix it? I am planning on publishing the function for others to use so thats why I'm using the {{. I have also already completely uninstalled R and all my packages and reinstalled what I was using except for tidymodels and am still getting the error. My guess is it has something to do with updated version of dplyr?
Here is my session info
> sessionInfo()
R version 4.1.3 (2022-03-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
[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] tseries_0.10-50 knitr_1.38
[3] tidyquant_1.0.3 quantmod_0.4.18
[5] TTR_0.24.3 PerformanceAnalytics_2.0.4
[7] xts_0.12.1 zoo_1.8-9
[9] lubridate_1.8.0 forecast_8.16
[11] timetk_2.8.0 forcats_0.5.1
[13] stringr_1.4.0 dplyr_1.0.8
[15] purrr_0.3.4 readr_2.1.2
[17] tidyr_1.2.0 tibble_3.1.6
[19] ggplot2_3.3.5 tidyverse_1.3.1
loaded via a namespace (and not attached):
[1] colorspace_2.0-3 ggsignif_0.6.3 ellipsis_0.3.2 class_7.3-20
[5] fs_1.5.2 rstudioapi_0.13 ggpubr_0.4.0 listenv_0.8.0
[9] furrr_0.2.3 prodlim_2019.11.13 fansi_1.0.3 xml2_1.3.3
[13] codetools_0.2-18 splines_4.1.3 jsonlite_1.8.0 broom_0.7.12
[17] dbplyr_2.1.1 compiler_4.1.3 httr_1.4.2 backports_1.4.1
[21] assertthat_0.2.1 Matrix_1.4-0 fastmap_1.1.0 cli_3.2.0
[25] htmltools_0.5.2 tools_4.1.3 gtable_0.3.0 glue_1.6.2
[29] Rcpp_1.0.8.3 carData_3.0-5 cellranger_1.1.0 fracdiff_1.5-1
[33] vctrs_0.4.0 urca_1.3-0 nlme_3.1-155 lmtest_0.9-40
[37] timeDate_3043.102 gower_1.0.0 xfun_0.30 globals_0.14.0
[41] rvest_1.0.2 lifecycle_1.0.1 rstatix_0.7.0 future_1.24.0
[45] MASS_7.3-55 scales_1.1.1 ipred_0.9-12 hms_1.1.1
[49] parallel_4.1.3 yaml_2.3.5 curl_4.3.2 rpart_4.1.16
[53] stringi_1.7.6 hardhat_0.2.0 lava_1.6.10 rlang_1.0.2
[57] pkgconfig_2.0.3 rsample_0.1.1 evaluate_0.15 lattice_0.20-45
[61] recipes_0.2.0 tidyselect_1.1.2 parallelly_1.31.0 magrittr_2.0.3
[65] R6_2.5.1 generics_0.1.2 DBI_1.1.2 pillar_1.7.0
[69] haven_2.4.3 withr_2.5.0 survival_3.2-13 abind_1.4-5
[73] nnet_7.3-17 future.apply_1.8.1 modelr_0.1.8 crayon_1.5.1
[77] car_3.0-12 Quandl_2.11.0 utf8_1.2.2 tzdb_0.3.0
[81] rmarkdown_2.13 grid_4.1.3 readxl_1.4.0 reprex_2.0.1
[85] digest_0.6.29 munsell_0.5.0 quadprog_1.5-8
I am trying to get started with the fable package in R for forecasting.
I am using the basic examples from their website:
I am trying to run the following example but it doesn't ever run, it runs eternally.
I have upgraded my version of RStudio and have had to restart multiple times but I have had no success.
library(fable)
library(tsibble)
library(tsibbledata)
library(lubridate)
library(dplyr)
aus_retail %>%
filter(
State %in% c("New South Wales", "Victoria"),
Industry == "Department stores"
) %>%
model(
ets = ETS(box_cox(Turnover, 0.3)),
arima = ARIMA(log(Turnover)),
snaive = SNAIVE(Turnover)
) %>%
forecast(h = "2 years") %>%
autoplot(filter(aus_retail, year(Month) > 2010), level = NULL)
Here is my sessioninfo()
> sessionInfo()
R version 4.0.2 (2020-06-22)
Platform: x86_64-w64-mingw32/x64 (64-bit)
Running under: Windows 10 x64 (build 19042)
Matrix products: default
locale:
[1] LC_COLLATE=English_Ireland.1252 LC_CTYPE=English_Ireland.1252
[3] LC_MONETARY=English_Ireland.1252 LC_NUMERIC=C
[5] LC_TIME=English_Ireland.1252
attached base packages:
[1] stats graphics grDevices utils datasets methods base
loaded via a namespace (and not attached):
[1] compiler_4.0.2 magrittr_2.0.1 ellipsis_0.3.1 cli_2.4.0 tools_4.0.2
[6] pillar_1.5.1 glue_1.4.2 rstudioapi_0.13 tibble_3.1.0 crayon_1.4.1
[11] utf8_1.2.1 fansi_0.4.1 vctrs_0.3.4 hardhat_0.1.5 lifecycle_1.0.0
[16] pkgconfig_2.0.3 rlang_0.4.10
Any suggestions would be appreciated
I updated R to 4.1.0 and my issues have disappeared. I had to include some additional packages such as feasts and urca to remove any errors/warnings post upgrade to 4.1.0
sessionInfo()
R version 4.1.0 (2021-05-18)
Platform: x86_64-w64-mingw32/x64 (64-bit)
Running under: Windows 10 x64 (build 19042)
Matrix products: default
locale:
[1] LC_COLLATE=English_Ireland.1252 LC_CTYPE=English_Ireland.1252
[3] LC_MONETARY=English_Ireland.1252 LC_NUMERIC=C
[5] LC_TIME=English_Ireland.1252
attached base packages:
[1] stats graphics grDevices utils datasets methods base
other attached packages:
[1] urca_1.3-0 feasts_0.2.2 lubridate_1.7.10 tsibbledata_0.3.0 tsibble_1.0.1
[6] fable_0.3.1 fabletools_0.3.1 forcats_0.5.1 stringr_1.4.0 dplyr_1.0.7
[11] purrr_0.3.4 readr_1.4.0 tidyr_1.1.3 tibble_3.1.2 ggplot2_3.3.5
[16] tidyverse_1.3.1
loaded via a namespace (and not attached):
[1] tidyselect_1.1.1 lattice_0.20-44 haven_2.4.1 colorspace_2.0-2
[5] vctrs_0.3.8 generics_0.1.0 utf8_1.2.1 rlang_0.4.11
[9] pillar_1.6.1 glue_1.4.2 withr_2.4.2 DBI_1.1.1
[13] dbplyr_2.1.1 modelr_0.1.8 readxl_1.3.1 distributional_0.2.2
[17] lifecycle_1.0.0 progressr_0.8.0 munsell_0.5.0 gtable_0.3.0
[21] anytime_0.3.9 cellranger_1.1.0 rvest_1.0.0 labeling_0.4.2
[25] fansi_0.5.0 broom_0.7.8 Rcpp_1.0.7 scales_1.1.1
[29] backports_1.2.1 jsonlite_1.7.2 farver_2.1.0 fs_1.5.0
[33] digest_0.6.27 hms_1.1.0 stringi_1.6.2 numDeriv_2016.8-1.1
[37] grid_4.1.0 cli_3.0.1 tools_4.1.0 magrittr_2.0.1
[41] pacman_0.5.1 crayon_1.4.1 pkgconfig_2.0.3 ellipsis_0.3.2
[45] xml2_1.3.2 reprex_2.0.0 assertthat_0.2.1 httr_1.4.2
[49] rstudioapi_0.13 R6_2.5.0 nlme_3.1-152 compiler_4.1.0