Having problem in unzipping a file in Studio R

dl <- "ml-10M100K.zip"

if(!file.exists(dl))

ratings_file <- "ml-10M100K/ratings.dat"
if(!file.exists(ratings_file))

  • unzip(dl, ratings_file)
    Warning message:
    In unzip(dl, ratings_file) : error 1 in extracting from zip file

This is the error message I got.

I checked my working directory and can confirm that the zip file is also in the same directory.

getwd()
[1] "C:/Users/vcheo/Desktop/R/Projects"

files <- list.files(path = "C:/Users/vcheo/Desktop/R/Projects", pattern = ".zip$")
files
[1] "ml-10M100K.zip"

So, I don't know what is the issue.

Does anyone know what else can I do to resolve this issue?

Thanks a lot

Valerie

This works for me:

dl <- "ml-10M100K.zip"

if(!file.exists(dl)) {
  download.file("https://files.grouplens.org/datasets/movielens/ml-10m.zip", dl)
}
ratings_file <- "ml-10M100K/ratings.dat"

if(!file.exists(ratings_file))  {
  unzip(dl, ratings_file)
  }

df <- read.delim(ratings_file, header = FALSE, sep = ":")[c(1, 3, 5, 7)]
1 Like

@mduvekot , hello

Thank you so much for your help!

Best wishes

Valerie

@prubin

Hello

Thank you for your comments.

Best wishes

Valerie