Extract and Manipulate the dataset from Kaggle into RStudio

Dear all R experts:

Good day, everyone. My name is Chuan. I need expert opinions from the experts. I manage to extract and manipulate the dataset from Kaggle (For example New York City Airport Activity | Kaggle). I am interested to import the CSV directly into R without download it. Is it possible to conduct this task using R?

I have tried several methods that I found from several R-related forums. However, it's not working well.

Your expert favour is highly appreciated.

Best Wishes
Chuan

Check out this answer on Stack Overflow - might be helpful in your case!

Dear Equation:

I highly appreciated your prompt response. However, I get errors as follow:

library(httr)
dataset <- httr::GET("https://www.kaggle.com/api/v1/competitions/data/download/10445/train.csv", httr::authenticate(username, authkey, type = "basic"))
Error in stopifnot(is.character(user), length(user) == 1) :
object 'username' not found

temp <- tempfile()
download.file(dataset$url,temp)
Error in charToRaw(URL) : object 'dataset' not found
data <- read.csv(unz(temp, "train.csv"))
Error in open.connection(file, "rt") : cannot open the connection
In addition: Warning message:
In open.connection(file, "rt") :
cannot open zip file 'C:\Users\User\AppData\Local\Temp\RtmpyaRqJ1\file91463966cdb'
unlink(temp)

Appreciated it and thank you again.

Best Wishes
Chuan

This topic was automatically closed 21 days after the last reply. New replies are no longer allowed.

If you have a query related to it or one of the replies, start a new topic and refer back with a link.