I did that, and It doesn't work
setwd("D:/mywork/abc.txt.gz")
I am trying to read a zipped file into R from my working directory (D:/mywork) using read.table function in R as shown below:
setwd("D:/mywork") # setting directory to read data from it
Data = read.table(gzfile("mywork/abc.txt.gz"),sep="\t")
Note: I set my directory using setwd("D:/mywork) to read this file from it.
But it gave the following error for reading this file
When I tried to write the path of this file in read.table function
Data = read.table(gzfile("D:/mywork/abc.txt.gz"),sep="\t")
it worked. So is there any help to let the function reads this file directly from the working directory instead of writing the path every time for each dataset.
If your working directory is D:/mywork, then specifying a file named mywork/abc.txt.gz is asking for D:/mywork/mywork/abc.txt.gz. That's how relative paths work.
BTW, this isn't really a bioinformatics question.
I did that, and It doesn't work
setwd("D:/mywork/abc.txt.gz")
Log in to answer this question.
By the way,
read.tablecan read gzip'd files straightaway, likeData<- read.table('abc.txt.gz'), no need ofgzfile().