Created
August 17, 2018 01:47
-
-
Save duttashi/fbdd0780229b3b4a97e95bef79df39fd to your computer and use it in GitHub Desktop.
I was trying to download a UCI ML dataset in R using the read.csv() but kept getting error "Error in file(file, "rt") : cannot open the connection In addition: Warning message: In file(file, "rt") : InternetOpenUrl failed: 'An error occurred in the secure channel support'"
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# Apparently the problem lies in https. The function read.csv() in R fails at this. I tried RCurl's getURL() still same error. | |
# Then I tried fread() from library(data.table) and it worked. | |
# I give below a minimum reproducible example to download data from a https base webpage. | |
# load the adult dataset | |
library(data.table) | |
dt<- fread("https://archive.ics.uci.edu/ml/machine-learning-databases/adult/adult.data",header = FALSE, sep=",") | |
head(dt) | |
V1 V2 V3 V4 V5 V6 | |
1: 39 State-gov 77516 Bachelors 13 Never-married | |
2: 50 Self-emp-not-inc 83311 Bachelors 13 Married-civ-spouse | |
3: 38 Private 215646 HS-grad 9 Divorced | |
4: 53 Private 234721 11th 7 Married-civ-spouse | |
5: 28 Private 338409 Bachelors 13 Married-civ-spouse | |
6: 37 Private 284582 Masters 14 Married-civ-spouse | |
V7 V8 V9 V10 V11 V12 V13 | |
1: Adm-clerical Not-in-family White Male 2174 0 40 | |
2: Exec-managerial Husband White Male 0 0 13 | |
3: Handlers-cleaners Not-in-family White Male 0 0 40 | |
4: Handlers-cleaners Husband Black Male 0 0 40 | |
5: Prof-specialty Wife Black Female 0 0 40 | |
6: Exec-managerial Wife White Female 0 0 40 | |
V14 V15 | |
1: United-States <=50K | |
2: United-States <=50K | |
3: United-States <=50K | |
4: United-States <=50K | |
5: Cuba <=50K | |
6: United-States <=50K |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment