RStudio cannot load web file, but R in terminal can; why? - r

I'm running RStudio on Ubuntu 18.04. When I want to load this data from GitHub
d <- read.csv("https://raw.githubusercontent.com/fivethirtyeight/data/master/airline-safety/airline-safety.csv")
I get the following error message.
Error in file(file, "rt") : cannot open the connection to 'https://raw.githubusercontent.com/fivethirtyeight/data/master/airline-safety/airline-safety.csv'
In addition: Warning message:
In file(file, "rt") :
URL 'https://raw.githubusercontent.com/fivethirtyeight/data/master/airline-safety/airline-safety.csv': status was 'Problem with the SSL CA cert (path? access rights?)'
Yet when I run the very same command in the terminal it works without any error. How can that be? And how can I fix it?

That seems similar to issue 1079 which includes:
Please restart R
then install.packages(c("curl", "httr"))
then try again.
If this is not enough, follow swirldev/swirl/issue 475.

Related

Error in file(file, "rt") : cannot open the connection In addition: Warning message: In file(file, "rt") : cannot open file

I am very new to R and hoping that someone can help me out. I run this code and I keep getting the cannot open the connection error. I set the directory to the folder I saved the data in and even checked with file.existis("file_Path/filename") and I got True. Yet, I still get this error. Please help me! Here is the first part of the Code:
daphnia=function(dr="c")
{
da=read.csv(paste(dr,":Data_Path/filename",sep=""))
}
Usually, this error means that the filepath is incorrect. Can you print out the entire path, i.e. print(paste(dr,":Data_Path/filename",sep="")? Sometimes there is an issue of using \ instead of / as well. Is it possible you need C:/Data_Path/filename?

Trouble opening file in Rstudio

This is my code
dat <- read.csv("../rawdata/uscrime.csv")
and this is the error I am getting
Error in file(file, "rt") : cannot open the connection
why won't it open my file?
I have done this several times in other projects but now that I have started a new project I can't get it to work.

error in file(con, "w")

This is windows 10 context. R Script (as function) listens to some realtime data and then is supposed to play an audible alarm once some level is tripped. The alarm is activated by a separate function call, and that function simply plays an mp3 file which I play via the following
command: system("powershell.exe", input="C:/Users/ThisUser/Music/Alarms/alarm_alarm_alarm2.mp3").
Additional background is that I'm typically running 3 (or more) other rstudio sessions on the machine. This is the error:
Error in file(con, "w") : cannot open the connection In addition: Warning messages:
1: package ‘httpuv’ was built under R version 3.4.1
2: In file(con, "w") :
cannot open file 'C:\Users\ThisUser\AppData\Local\Temp\Rtmp9w7SM3\file44982a915cf4': No such file or directory
I can test that system command from the console in another rstudio session and it works fine, but if I test in the console of the session where the error resides, I continue to get the error. Also, when I check the tempdir this is what I get:
tempdir()
[1] "C:\Users\ThisUser\AppData\Local\Temp\Rtmp9w7SM3"
Are my other sessions messing up the Temp files or directory path? How can I fix? Thank you.

issue in getting data with getGEO in R

I want to download the soft file of the GPL6480 platform in R.
I've used this command :
gset<-getGEO("GPL6480")
but I faced with this problem:
curl: (6) Could not resolve host: www.ncbi.nlm.nih.gov
File stored at:
/tmp/RtmpbHgZqQ/GPL6480.soft
Error in file(fname, "r") : cannot open the connection
In addition: Warning messages:
1: In download.file(myurl, destfile, mode = mode, quiet = TRUE, method = getOption("download.file.method.GEOquery")) :
download had nonzero exit status
2: In file(fname, "r") :
cannot open file '/tmp/RtmpbHgZqQ/GPL6480.soft': No such file or directory
I googled for this problem but I can't find the answer. acctauly i don't know that what is the problem exactly.you should know that my connection to net is ok.
I'm using R version 3.2.0 on Ubuntu 14.04.2 trusty
tnx mansoor

Importing a csv into R using read.csv in Ubuntu

I have just installed Ubuntu on my computer and I am re-running some codes that previously worked in Windows. I have copied my directories into Ubuntu with all my files.
When I run this line of code to import a database into R, I get the following error:
Annot <- read.csv("~/Documents/DATABASES/Functional_Annotations/Salar_2_Annot_light.csv", header = TRUE)
Error in file(file, "rt") : cannot open the connection
In addition: Warning message: In file(file, "rt") : cannot open file
'/home/cd46/Documents/DATABASES/Functional_Annotations/Salar_2_Annot_light.csv':
No such file or directory
The code is right, hasn't changed since before. In fact if I run:
setwd("~/Documents/DATABASES/Functional_Annotations")
It works fine and recognize the directory. And the file it there too.
I am not sure what this can be, does anyone have a suggestion? The only thing I have done was to switch over to Ubuntu, so I would imagine the problem would lie there.
I have installed the readr package in R
then simply write this :
df <- read_csv("/your path/file.csv")
And this work for me and solved the problem.

Resources