R How to Solve Error in File RT – Cannot Open the Connection (2 Examples)
In this tutorial you’ll learn how to handle the error message “Error in file(file, “rt”) : cannot open the connection” in the R programming language.
Example 1: Why the Error Occurrrs
df <- read.csv2("data_file.csv") # Import of data doesn't work # Error in file(file, "rt") : cannot open the connection # In addition: Warning message: # In file(file, "rt") : # cannot open file 'data_file.csv': No such file or directory |
df <- read.csv2("data_file.csv") # Import of data doesn't work # Error in file(file, "rt") : cannot open the connection # In addition: Warning message: # In file(file, "rt") : # cannot open file 'data_file.csv': No such file or directory
Example 2: How to Fix the Error Message
setwd("C:/Users/Data Hacks/Desktop/My Folder/") # Switching working directory |
setwd("C:/Users/Data Hacks/Desktop/My Folder/") # Switching working directory
df <- read.csv2("data_file.csv") # Importing data to R |
df <- read.csv2("data_file.csv") # Importing data to R