importing data and installing packages??

hello guys, im a newbie (more or less) at programming with R, and I havent used Rstudio since 2019, so now when I try to install some packages, I get a message saying "Warning message:
the 'rlang' package was compiled with R 3.6.3"
so I thought maybe this means I have an old version or smtg, so I installed the latest version and still no use, I still get this msg. And this poses problems when I try to import data. at first I used the rio package and it worked once and I was able to use the import function, but after few days, I retried it and it wont work. this is what it says"Error: package or namespace load failed for 'rio' in loadNamespace(i, c(lib.loc, .libPaths()), versionCheck = vI[[i]]) :
package 'rlang' 0.4.11 is already loaded, but >= 1.0.0 is required"
now im just trying to import a csv the traditional way but that also doesnt work, this is what I get :

setwd("C:/Users/user/Documents/targetTS/")
Error in setwd("C:/Users/user/Documents/targetTS/") :
cannot change working directory
data <- read.csv("targetTS.csv")
Error in file(file, "rt") : cannot open the connection
In addition: Warning message:
In file(file, "rt") :
cannot open file 'targetTS.csv': No such file or directory.
Please help Im really desperate rn, if my supervisor knows im still stuck at this step I would be in big trouble. Thanks

Run install.packages("rlang") and then read the error message, it says it cannot find C:/Users/user/Documents/targetTS/ and therefore cannot open targetTS.csv, so check that you got those directories right or even better... Run your project using projects in RStudio :+1:

1 Like

Hello, I am indeed working with Rstudio, and I checked the directory from the file's properties so normally it should be correct and I tried reversing these "/" but it still didnt work.

Try to play around with list.files() and put in your path gradually to see where it fails?

1 Like

you might try file.choose()

1 Like

list.files("C:/Users/user/Documents/targetTS/")
character(0)
this is what I get when I try list.files, im not sure if thats the right way to use it.
I also tried file.choose and I select the file I need, it gives me the directory or path of the file but what should I do next?
file.choose("targetTS.csv")
[1] "C:\Users\user\Documents\targetTS.csv"

the result of file.choose shows you were incorrect that there was a folder 'targetTS' involved.
rather your folder path is C:\Users\user\Documents\ and the filename is targetTS.csv
you wont be able to setwd() on a folder path that doesnt exist ; such as targetTS.
so either, you setwd() on your documents path. or you make a folder called targetTS and move targetTS.csv into it.

1 Like

I created a folder and put my data file in it and it finally worked. Thanks you for your help
Thanks Leon and nirgrahamuk.

1 Like

I have a problem installing some packages and I know the problem is on my end.
I'm on a Mac, Ventura 13.3.1 OS, latest versions of R and RStudio.

Here is my code (quite simple):

remotes::install_github("stan-dev/cmdstanr")
devtools::install_github("rmcelreath/rethinking")

here is the error message:

Downloading GitHub repo stan-dev/cmdstanr@HEAD
── R CMD build ──────────────────────────────────────────────────────────────────────────
:heavy_check_mark: checking for file β€˜/private/var/folders/66/6yy31gvd2ggdrcmn0v72j0z40000gn/T/Rtmpe1DO8E/remotes97c752247d2/stan-dev-cmdstanr-7036eee/DESCRIPTION’ ...
─ preparing β€˜cmdstanr’:
:heavy_check_mark: checking DESCRIPTION meta-information ...
─ checking for LF line-endings in source and make files and shell scripts
─ checking for empty or unneeded directories
Omitted β€˜LazyData’ from DESCRIPTION
─ building β€˜cmdstanr_0.5.3.tar.gz’

Error: 3:49: unexpected string constant
3: if (Sys.getenv("RSTUDIO") == "1" && RSTUDIO_TERM")) &&
4: Sys.info()["
^
Execution halted
Warning: installation of package β€˜/var/folders/66/6yy31gvd2ggdrcmn0v72j0z40000gn/T//Rtmpe1DO8E/file97c1d996812/cmdstanr_0.5.3.tar.gz’ had non-zero exit statusDownloading GitHub repo rmcelreath/rethinking@HEAD
Skipping 1 packages not available: cmdstanr
── R CMD build ──────────────────────────────────────────────────────────────────────────
:heavy_check_mark: checking for file β€˜/private/var/folders/66/6yy31gvd2ggdrcmn0v72j0z40000gn/T/Rtmpe1DO8E/remotes97c17c66e2e/rmcelreath-rethinking-2f01a9c/DESCRIPTION’ ...
─ preparing β€˜rethinking’:
:heavy_check_mark: checking DESCRIPTION meta-information
─ checking for LF line-endings in source and make files and shell scripts
─ checking for empty or unneeded directories
─ looking to see if a β€˜data/datalist’ file should be added
─ building β€˜rethinking_2.31.tar.gz’

Error: 3:49: unexpected string constant
3: if (Sys.getenv("RSTUDIO") == "1" && RSTUDIO_TERM")) &&
4: Sys.info()["
^
Execution halted
Warning: installation of package β€˜/var/folders/66/6yy31gvd2ggdrcmn0v72j0z40000gn/T//Rtmpe1DO8E/file97c646b9a33/rethinking_2.31.tar.gz’ had non-zero exit status.

I uninstalled and reinstalled R this morning with same result. I tried installing on R (not RStudio) with same result.

Any ideas?

Many thanks.

This topic was automatically closed 21 days after the last reply. New replies are no longer allowed.

If you have a query related to it or one of the replies, start a new topic and refer back with a link.