如果您在Github上有一个csv文件,则可以通过使用其URL直接将其导入R中,但是请确保在存储数据的Github页面上单击Raw选项。许多人没有单击Raw选项,因此他们阅读HTML而不是CSV并感到困惑。在这里,我正在共享一个包含数据集列表的公共数据集。该数据集具有12个变量。现在让我们导入它-
> Data<-read.csv("https://raw.githubusercontent.com/curran/data/gh-pages/dataSoup/datasets.csv") > str(Data) 'data.frame': 57 obs. of 12 variables: $ Dataset.Name : Factor w/ 57 levels " ","2008 Election Results",..: 2 33 32 36 52 49 50 23 25 41 ... $ Person.Adding : Factor w/ 11 levels "Curran","EJ",..: 2 2 2 6 6 6 6 6 6 6 ... $ Date.Added : Factor w/ 14 levels "1/1/2013","11/7/2012",..: 2 2 2 2 2 2 2 2 2 2 ... $ Dataset.Link : Factor w/ 57 levels "ask Jan...","http://api.occupy-data.org/v1/",..: 35 38 2 8 15 42 40 39 22 28 ... $ Most.Recent.Year.in.Data: Factor w/ 9 levels "","2007","2008",..: 3 6 5 6 6 4 2 5 6 5 ... $ Earliest.Year.In.Data : int NA NA 2003 1789 1996 1946 1960 1989 2000 2000 ... $ Status : Factor w/ 6 levels "","much talked about",..: 5 5 5 5 5 5 5 5 5 5 ... $ Dataset.Type : Factor w/ 8 levels "","API","Dataset",..: 3 3 2 3 3 3 3 1 1 5 ... $ Documentation : Factor w/ 18 levels "","http://data.gov/metric",..: 1 1 17 1 6 3 1 1 1 1 ... $ Existing.Work : Factor w/ 10 levels "","http://databits.io/challenges/airbnb-user-pathways-challenge",..: 1 1 7 1 1 1 1 1 1 1 ... $ Tags : Factor w/ 12 levels "","astronomy",..: 11 7 8 9 1 1 1 1 1 2 ... $ Active : Factor w/ 3 levels "","n","y": 2 2 3 3 2 3 2 2 2 2 ... > head(Data) Dataset.Name Person.Adding Date.Added 1 2008 Election Results EJ 11/7/2012 2 Occupy Oakland Finances EJ 11/7/2012 3 NYPD Stop-and-Frisk DB API EJ 11/7/2012 4 Presidential Speech Archive Kai 11/7/2012 5 USDA National Nutrient Database Kai 11/7/2012 6 US Foreign Aid Kai 11/7/2012 Dataset.Link 1 https://docs.google.com/spreadsheet/ccc?key=0ApAkxBfw1JT4dFliRjhYOW5WLXk1WkZfNFFQTGxmSGc#gid=02 https://docs.google.com/spreadsheet/pub?key=0ApAkxBfw1JT4dHhNSkpva0RrQUFfcDIyUHl3LWFCVEE&output=html 3 http://api.occupy-data.org/v1/4 http://millercenter.org/president/speeches 5 http://www.ars.usda.gov/Services/docs.htm?docid=89646 https://explore.data.gov/Foreign-Commerce-and-Aid/U-S-Overseas-Loans-and-Grants-Greenbook-/5gah-bvex Most.Recent.Year.in.Data Earliest.Year.In.Data Status Dataset.Type 1 2008 NA Unused Dataset 2 2012 NA Unused Dataset 3 2011 2003 Unused API 4 2012 1789 Unused Dataset 5 2012 1996 Unused Dataset 6 2010 1946 Unused Dataset Documentation 1 2 3 https://github.com/stopfrisknyc/docs4 5 http://www.ars.usda.gov/SP2UserFiles/Place/12354500/Data/SR25/sr25_doc.pdf6 http://gbk.eads.usaidallnet.gov/about/ Existing.Work 1 2 3 http://www.forbes.com/sites/jasonoberholtzer/2012/07/17/stop-and-frisk-by-the-numbers/,http://www.dnainfo.com/new-york/20120604/new-york-city/port-authority-is-top-stop-and-frisk-hotspot-regardless-of-race4 5 6 Tags Active 1 state-scale,politics n 2 historical,money n 3 historical,people y 4 historical,text y 5 n 6 y