Question: I got this error, Error in paste0(C:/Users/Desktop/Homework 2, file) : cannot coerce type 'closure' to vector of type 'character' and here is my code range

I got this error,

Error in paste0("C:/Users/Desktop/Homework 2", file) : cannot coerce type 'closure' to vector of type 'character'

and here is my code

range <- function (v) { pat <- paste0("(", paste0(v, collapse="|"), ")") } path_RHelp = "C:/Users/Desktop/Homework 2/RHelpArchives"

year <- c(2016, 2017, 2018, 2019, 2020, 2021, 2022) month <- c('January', "February", "March", "April", "May", "June", "July", "August", "September", "October", "November", "December") file_range <- paste0(range(year), "-", range(month), ".txt") year_2016_2022_mails <- list.files(path_RHelp, pattern = file_range)

year_2016_2022_mails

read_mails <- function (file){ path = paste0("C:/Users/Desktop/Homework 2", file) read.table(path, quote = "", header = FALSE, sep = " ", skipNul=TRUE) }

files_ <- map(year_2016_2022_mails, read_mails) summary(files_)

I got that error when I try to learn path = paste0("C:/Users/Desktop/Homework 2", file). I don't know because of this but I cannot run the files_ <- map(year_2016_2022_mails, read_mails). When I run this, I got this error.

Error in file(file, "rt") : cannot open the connection

Can anyone please help me to fix this problem?

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Mathematics Questions!