How to use read.csv() In R Language
Another way is to access the csv file by giving the complete path of the file instead of going to that directory:
Example:
R
# Read the CSV file by giving the complete file path dataframe <- read.csv ( 'C:\\Users\\harsh\\Desktop\\w3wiki\\sample.csv' , header= TRUE , stringsAsFactors= FALSE ) # Display the dataframe dataframe |
Output:
How to Fix in R: error in file(file, “rt”) : cannot open the connection
In this article, we are going to see how to fix the error in file(file, “rt”) : cannot open the connection. When error that one may face in R is:
Error in file(file, "rt") : cannot open the connection In addition: Warning message: In file(file, "rt") : cannot open file 'sample.csv': No such file or directory
The R compiler produces such an error when one tries to read a CSV file but the file or the directory that is being accessed does not exist.