I cant speciy the file.path in R - r

Everytime I give the command in file.path, it always gives this error message , no matter what.
Error in file(file, "rt") : cannot open the connection
In addition: Warning message:
In file(file, "rt") :
cannot open file 'C/Users/Jbhanda/Desktop/NEW_GSE52778_All_Sample_FPKM_Matrix.csv': No such file or directory
I need to link my .csv file in desktop to the file.path command in R

First I note you are missing a colon after C, which (assuming this is a Windows machine) should be C:/.
Secondly you can try escaped backslashes:
C:\\Users\\Jbhanda\\Desktop\\NEW_GSE52778_All_Sample_FPKM_Matrix.csv

Related

read.delim no such file or directory in R

I got a list of files from list.files() in current directory such that:
setwd("~/Data/LUSC/unc.edu_LUSC.IlluminaHiSeq_RNASeq.Level_3.1.2.0")
exprs_files <- list.files()
exprs_files <- exprs_files[grepl('gene.quantification', exprs_files)]
exprs_files[88]
[1] "UNCID_586826.TCGA-60-2720-01A-01R-0851-07.110426_UNC12-SN629_0078_BB08WCABXX.6.trimmed.annotated.gene.quantification.txt"
But I got error when read it:
read.delim(exprs_files[88])
Error in file(file, "rt") : cannot open the connection
In addition: Warning message:
In file(file, "rt") :
cannot open file 'UNCID_586826.TCGA-60-2720-01A-01R-0851-07.110426_UNC12-SN629_0078_BB08WCABXX.6.trimmed.annotated.gene.quantification.txt': No such file or directory
I am using RStudio Version 1.3.959 on Windows 10.
Any suggestions?
Try using a double bracket:
read.delim(exprs_files[[88]])

Why read.delim() cannot open text files?

I have saved an Excel file as Tab delimited, but when I try to open it I get the following error:
a=read.delim("GBM tab")
Error in file(file, "rt") : cannot open the connection
In addition: Warning message:
In file(file, "rt") : cannot open file 'GBM tab': No such file or directory
While I have a text file named GBM tab in my working directory.
Even when I press Tab, no matches are found. What is the problem?
One easier option is to use file.choose() and then just direct to the file in the directory
a <- read.delim(file.choose())
In the OP's code, it is possible that a file have .txt or .csv at the end it needs to be specified
a <- read.delim("GBM tab.txt")

Error in file(file, "rt")

I'm using Rstudio and I cannot open several file .txt because of this error message :
Error in file(file, "rt") : cannot open the connection
I enter :
X1= read.table("fileX1.txt", header = FALSE)
I don't understand because some of my colleagues use the same function with the same .txt file and it works for them
Since you aren't specifying the path to the file, R will look for it in the current directory. If that isn't the directory containing the file, you'll get that error.
You can use setwd() (or a menu command in RStudio) to set the current directory. Alternatively, you could use file.choose() to get a dialog to choose the file; it will return the full filename including the path.

in file(file, "rt") : cannot open the connection In addition: Warning message: In file(file, "rt") : cannot open file: No such file or directory

I am trying to upload a file of csvs and other documents into R studio. My code looks like the following.
setwd("~/Dropbox/R")
getwd()
[1] "/Users/me/Dropbox/R"
myData <-read.csv("~/Dropbox/Exercise_Files")
The message returned is:
Error in file(file, "rt") : cannot open the connection
In addition: Warning message:
In file(file, "rt") :
cannot open file '/Users/me/Dropbox/R/Exercise_Files': No such file or
directory
I can't understand why R is telling me no such directory when getwd() shows the directory I am using. Nor do I understand why I am being told that there are no such files--I put them into the directory! They are right there! Please help; I have tried everything.
You have to specify the .csv extension:
myData <-read.csv("~/Dropbox/Exercise_Files.csv")
list.files() worked for me. I discovered that all my text files were being seen in R as filename.txt.txt but were seen as filename.txt in the Windows file manager. I changed the files to filename (without '.txt') in Windows and now they read into R correctly.

R tool Reading a text file shows Error,

This is my question
if i input this to my R data Mining tool
mydata <- read.csv("filename.txt")
it will shows an error like below
Error in file(file, "rt") : cannot open the connection
In addition: Warning message:
In file(file, "rt") :
cannot open file 'filename.txt': No such file or directory
what can i do to clear this error
Use read.delim("Path of the file like C://Users//Desktop//filename.txt")
which has more options than read.csv

Resources