.chapter7<-function(i=0){ " i Chapter 7: Data input i Explanations - ---------------------------------- -- ------------------------------- 1 data packages: search() 21 Reading from a clipboard 2 : datasets 22 : last line issue 3 : data('Titanic') 23 Load an R data set: locally 4 : data('iris') 24 : remotely 5 : sleeping data 25 delimited input file: read.delim() 6 : help(data) 26 fixed width file: read.fwf() 7 all packages: 27 tibble table 8 : data sets 28 read_sas(): input a SAS data set 9 : list 29 Inputting other types of data sets other ones 10 :.searchDataInPackages() 30 download.file() function 11 data set from a specific package 31 Manually download data Yahoo!Finance 12 read.csv(): function 32 scan() function 13 : help(read.csv) 33 examples 14 : a few lines 34 USArrests 15 : local csv 35 our data sets: data_csv/list.txt 16 : remove csv files 36 : data_txt/list.txt 17 relative vs. absolute address 37 : data_R/list.txt 18 read.table() function 38 : data_excel/list.txt 19 Youtubes 39 generate RData for datasets package 20 Links 40 Closing a link: unlink() function Example #1:> .c7 # see the above list Example #2:> .c7() # the same as the above Example #3:> .c7(1) # see the first explanation ";.zchapter7(i)} .c7<-.chapter7 .n7chapter<-40 .zchapter7<-function(i){ if(i==0){ print(.c7) }else{ .printEachQ(7,i,.n7chapter) } } .C7EXPLAIN1<-" /////////////////////////////// To find the preloaded packages, we can use the search() function. > search() [1] \".GlobalEnv\" \"package:httr\" \"package:stats\" [4] \"package:graphics\" \"package:grDevices\" \"package:utils\" [7] \"package:datasets\" \"package:methods\" \"Autoloads\" [10] \"package:base\" > ///////////////////////////////// " .C7EXPLAIN2<-"data sets in side the package 'datasets' /////////////////////////////// data(packag='datasets') Data sets in package ‘datasets’: AirPassengers Monthly Airline Passenger Numbers 1949-1960 BJsales Sales Data with Leading Indicator BJsales.lead (BJsales) Sales Data with Leading Indicator BOD Biochemical Oxygen Demand CO2 Carbon Dioxide Uptake in Grass Plants ChickWeight Weight versus age of chicks on different diets DNase Elisa assay of DNase EuStockMarkets Daily Closing Prices of Major European Stock Indices, 1991-1998 Formaldehyde Determination of Formaldehyde HairEyeColor Hair and Eye Color of Statistics Students Harman23.cor Harman Example 2.3 Harman74.cor Harman Example 7.4 Indometh Pharmacokinetics of Indomethacin InsectSprays Effectiveness of Insect Sprays JohnsonJohnson Quarterly Earnings per Johnson & Johnson Share LakeHuron Level of Lake Huron 1875-1972 LifeCycleSavings Intercountry Life-Cycle Savings Data Loblolly Growth of Loblolly pine trees Nile Flow of the River Nile Orange Growth of Orange Trees OrchardSprays Potency of Orchard Sprays PlantGrowth Results from an Experiment on Plant Growth Puromycin Reaction Velocity of an Enzymatic Reaction Seatbelts Road Casualties in Great Britain 1969-84 Theoph Pharmacokinetics of Theophylline Titanic Survival of passengers on the Titanic ToothGrowth The Effect of Vitamin C on Tooth Growth in Guinea Pigs UCBAdmissions Student Admissions at UC Berkeley UKDriverDeaths Road Casualties in Great Britain 1969-84 UKgas UK Quarterly Gas Consumption USAccDeaths Accidental Deaths in the US 1973-1978 USArrests Violent Crime Rates by US State USJudgeRatings Lawyers' Ratings of State Judges in the US Superior Court USPersonalExpenditure Personal Expenditure Data UScitiesD Distances Between European Cities and Between US Cities VADeaths Death Rates in Virginia (1940) WWWusage Internet Usage per Minute WorldPhones The World's Telephones ability.cov Ability and Intelligence Tests airmiles Passenger Miles on Commercial US Airlines, 1937-1960 airquality New York Air Quality Measurements anscombe Anscombe's Quartet of 'Identical' Simple Linear Regressions attenu The Joyner-Boore Attenuation Data attitude The Chatterjee-Price Attitude Data austres Quarterly Time Series of the Number of Australian Residents beaver1 (beavers) Body Temperature Series of Two Beavers beaver2 (beavers) Body Temperature Series of Two Beavers cars Speed and Stopping Distances of Cars chickwts Chicken Weights by Feed Type co2 Mauna Loa Atmospheric CO2 Concentration crimtab Student's 3000 Criminals Data discoveries Yearly Numbers of Important Discoveries esoph Smoking, Alcohol and (O)esophageal Cancer euro Conversion Rates of Euro Currencies euro.cross (euro) Conversion Rates of Euro Currencies eurodist Distances Between European Cities and Between US Cities faithful Old Faithful Geyser Data fdeaths (UKLungDeaths) Monthly Deaths from Lung Diseases in the UK freeny Freeny's Revenue Data freeny.x (freeny) Freeny's Revenue Data freeny.y (freeny) Freeny's Revenue Data infert Infertility after Spontaneous and Induced Abortion iris Edgar Anderson's Iris Data iris3 Edgar Anderson's Iris Data islands Areas of the World's Major Landmasses ldeaths (UKLungDeaths) Monthly Deaths from Lung Diseases in the UK lh Luteinizing Hormone in Blood Samples longley Longley's Economic Regression Data lynx Annual Canadian Lynx trappings 1821-1934 mdeaths (UKLungDeaths) Monthly Deaths from Lung Diseases in the UK morley Michelson Speed of Light Data mtcars Motor Trend Car Road Tests nhtemp Average Yearly Temperatures in New Haven nottem Average Monthly Temperatures at Nottingham, 1920-1939 npk Classical N, P, K Factorial Experiment occupationalStatus Occupational Status of Fathers and their Sons precip Annual Precipitation in US Cities presidents Quarterly Approval Ratings of US Presidents pressure Vapor Pressure of Mercury as a Function of Temperature quakes Locations of Earthquakes off Fiji randu Random Numbers from Congruential Generator RANDU rivers Lengths of Major North American Rivers rock Measurements on Petroleum Rock Samples sleep Student's Sleep Data stack.loss (stackloss) Brownlee's Stack Loss Plant Data stack.x (stackloss) Brownlee's Stack Loss Plant Data stackloss Brownlee's Stack Loss Plant Data state.abb (state) US State Facts and Figures state.area (state) US State Facts and Figures state.center (state) US State Facts and Figures state.division (state) US State Facts and Figures state.name (state) US State Facts and Figures state.region (state) US State Facts and Figures state.x77 (state) US State Facts and Figures sunspot.month Monthly Sunspot Data, from 1749 to \"Present\" sunspot.year Yearly Sunspot Data, 1700-1988 sunspots Monthly Sunspot Numbers, 1749-1983 swiss Swiss Fertility and Socioeconomic Indicators (1888) Data treering Yearly Treering Data, -6000-1979 trees Diameter, Height and Volume for Black Cherry Trees uspop Populations Recorded by the US Census volcano Topographic Information on Auckland's Maunga Whau Volcano warpbreaks The Number of Breaks in Yarn during Weaving women Average Heights and Weights for American Women ///////////////////////////////// " .C7EXPLAIN3<-"data set: Titanic /////////////////////////////// > data('Titanic') > x<-Titanic > df<-data.frame(x) > dim(df) [1] 32 5 > head(df) Class Sex Age Survived Freq 1 1st Male Child No 0 2 2nd Male Child No 0 3 3rd Male Child No 35 4 Crew Male Child No 0 5 1st Female Child No 0 6 2nd Female Child No 0 ///////////////////////////////// " .C7EXPLAIN4<-"data: iris /////////////////////////////// > data('iris') > x<-iris > df<-data.frame(x) > dim(df) [1] 150 5 > head(df,4) Sepal.Length Sepal.Width Petal.Length Petal.Width Species 1 5.1 3.5 1.4 0.2 setosa 2 4.9 3.0 1.4 0.2 setosa 3 4.7 3.2 1.3 0.2 setosa 4 4.6 3.1 1.5 0.2 setosa > tail(df,4) Sepal.Length Sepal.Width Petal.Length Petal.Width Species 147 6.3 2.5 5.0 1.9 virginica 148 6.5 3.0 5.2 2.0 virginica 149 6.2 3.4 5.4 2.3 virginica 150 5.9 3.0 5.1 1.8 virginica ///////////////////////////////// " .C7EXPLAIN5<-"Sleeping data /////////////////////////////// > data(sleep) > sleep extra group ID 1 0.7 1 1 2 -1.6 1 2 3 -0.2 1 3 4 -1.2 1 4 5 -0.1 1 5 6 3.4 1 6 7 3.7 1 7 8 0.8 1 8 9 0.0 1 9 10 2.0 1 10 11 1.9 2 1 12 0.8 2 2 13 1.1 2 3 14 0.1 2 4 15 -0.1 2 5 16 4.4 2 6 17 5.5 2 7 18 1.6 2 8 19 4.6 2 9 20 3.4 2 10 ///////////////////////////////// " .C7EXPLAIN6<-"help(data) /////////////////////////////// data {utils} R Documentation Data Sets Description Loads specified data sets, or list the available data sets. Usage data(..., list = character(), package = NULL, lib.loc = NULL, verbose = getOption(\"verbose\"), envir = .GlobalEnv, overwrite = TRUE) ///////////////////////////////// " .C7EXPLAIN7<-"list of all packages /////////////////////////////// a<-.packages(all.available = TRUE) > length(a) [1] 187 ///////////////////////////////// " .C7EXPLAIN8<-"List all data sets /////////////////////////////// a<-data(package = .packages(all.available = TRUE)) df<-data.frame(unlist(a)) > dim(df) [1] 2477 1 > head(df) unlist.a. title Data sets results1 datasets results2 datasets results3 datasets results4 datasets results5 datasets > ??? ///////////////////////////////// " .C7EXPLAIN9<-"R data set for all data sets ///////////////////////////////// R data set for all the data sets included in various R packages a<-load(url('http://datayyy.com/fmr2/allDataInPackages.RData')) > a [1] \"df\" > head(df) Package Name Explanation 1 datasets AirPassengers Monthly Airline Passenger Numbers 1949-1960 2 datasets BJsales Sales Data with Leading Indicator 3 datasets BJsales.lead (BJsales) Sales Data with Leading Indicator 4 datasets BOD Biochemical Oxygen Demand 5 datasets CO2 Carbon Dioxide Uptake in Grass Plants 6 datasets ChickWeight Weight versus age of chicks on different diets > tail(df) Package Name Explanation 614 survival udca Data from a trial of usrodeoxycholic acid 615 survival udca1 (udca) Data from a trial of usrodeoxycholic acid 616 survival udca2 (udca) Data from a trial of usrodeoxycholic acid 617 survival uspop2 (survexp) Projected US Population 618 survival valveSeat (reliability) datasets 619 survival veteran (cancer) datasets > ///////////////////////////////// " .C7EXPLAIN10<-".searchDataInPackages() ///////////////////////////////// > .searchDataInPackages('titanic') Package Name Explanation datasets Titanic Survival of passengers on the Titanic rpart.plot ptitanic Titanic data with passenger names and other details removed. ///////////////////////////////// " .C7EXPLAIN11<-" /////////////////////////////// > data(\"aids\") Warning message: In data(\"aids\") : data set 'aids' not found > data(\"aids\",package=\"boot\") > x<-aids > dim(x) [1] 570 6 > head(x) year quarter delay dud time y 1 1983 3 0 0 1 2 2 1983 3 2 0 1 6 3 1983 3 5 0 1 0 4 1983 3 8 0 1 1 5 1983 3 11 0 1 1 6 1983 3 14 0 1 0 > ///////////////////////////////// " .C7EXPLAIN12<-"read.csv() function /////////////////////////////// Assume that you have a csv data file under c:/temp/ibm.csv > x<-read.csv(\"c:/temp/ibm.csv\") ///////////////////////////////// " .C7EXPLAIN13<-"help(read.csv) /////////////////////////////// read.csv(file, header = TRUE, sep = \",\", quote = \"\\\"\", dec = \".\", fill = TRUE, comment.char = \"\", ...) read.csv2(file, header = TRUE, sep = \";\", quote = \"\\\"\", dec = \",\", fill = TRUE, comment.char = \"\", ...) ///////////////////////////////// " .C7EXPLAIN14<-"Reading a small data set /////////////////////////////// x<-read.csv(\"c:/temp/bigData.csv\",skip=10, nrow=100) ///////////////////////////////// " .C7EXPLAIN15<-"relative vs. absolute address /////////////////////////////// Absolute address ---------------- > x<-read.csv(\"c:/temp/ibm.csv\") Relative address ------------------ Our programs read (retrieve) data from the current working directory) > setwd(\"c:/temp\") > getwd() [1] \"c:/temp\" > x<-read.csv(\"ibm.csv\") ///////////////////////////////// " .C7EXPLAIN16<-"Reading CSV data from internet ///////////////////////////////// path<-\"http://datayyy.com/data_csv/ibmMonthly.csv\" infile<-url(path) x<-read.csv(infile) > head(x) Date Open High Low Close Adj.Close Volume 1 1962-01-01 7.713333 7.713333 7.003334 7.226666 0.598839 8760000 2 1962-02-01 7.300000 7.480000 7.093333 7.160000 0.593315 5737600 3 1962-03-01 7.186666 7.413333 7.070000 7.103333 0.588699 5344000 4 1962-04-01 7.100000 7.100000 6.000000 6.053333 0.501678 12851200 5 1962-05-01 6.053333 6.530000 4.733333 5.233333 0.433720 49307200 6 1962-06-01 5.213333 5.213333 4.000000 4.523334 0.374937 68451200 ///////////////////////////////// " .C7EXPLAIN17<-"help(read.table) ///////////////////////////////// read.table(file, header = FALSE, sep = \"\", quote = \"\\\"'\", dec = \".\", numerals = c(\"allow.loss\", \"warn.loss\", \"no.loss\"), row.names, col.names, as.is = !stringsAsFactors, na.strings = \"NA\", colClasses = NA, nrows = -1, skip = 0, check.names = TRUE, fill = !blank.lines.skip, strip.white = FALSE, blank.lines.skip = TRUE, comment.char = \"#\", allowEscapes = FALSE, flush = FALSE, stringsAsFactors = default.stringsAsFactors(), fileEncoding = \"\", encoding = \"unknown\", text, skipNul = FALSE) ///////////////////////////////// " .C7EXPLAIN18<-"read.table() function /////////////////////////////// x<-read.csv(\"c:/temp/ibm.csv\",sep=\",\") ///////////////////////////////// " .C7EXPLAIN19<-"Youtubes ///////////////////////////////// MarinStatsLectures- R Programming & Statistics,2013, Import Data, Copy Data from Excel to R CSV & TXT Files | R Tutorial 1.5 | MarinStatsLectures (617k,s67k,t6:58) https://www.youtube.com/watch?v=qPk0YEKhqB8 MrClean1796,2015,R Studio: Importing & Analyzing Data (v212k,s20k,t7:21) https://www.youtube.com/watch?v=Uo1C7Iligw0 Tuke,Jonathan, 2012, Entering data into R (v26k,s366k,t9:47) https://www.youtube.com/watch?v=dBZ_vBqkSug ///////////////////////////////// " .C7EXPLAIN20<-"Links ///////////////////////////////// help(read.csv) help(read.table) help(read.delim) library(haven) help(package=haven) library(tibble) help(package=tibble) ///////////////////////////////// " .C7EXPLAIN21<-"Read from a clipboard ///////////////////////////////// Method I: using read.table('clipboard') --------------------------------------- Step 1: high light a data set and copy [could from Excel, Notepad, Microsoft Word] 2 3 4 1 5 6 Step 2 Issue the following line x<-read.table('clipboard') x V1 V2 V3 1 2 3 4 2 1 5 6 Method II: using readClipboard() function ---------------------------------------- Step 1: same as before Step 2: issue the following command x<-readClipboard() x [1] \"2 3 4\" \"1 5 6\" ///////////////////////////////// " .C7EXPLAIN22<-"Last line issue ///////////////////////////////// Last line issue ///////////////////////////////// " .C7EXPLAIN23<-"Loading an R data set locally ///////////////////////////////// Step 1: download an R data set http://datayyy.com/data_R/index1999q4.RData Assume that the data set is saved under c:/temp Step 2: using load() function load(\"c://temp/index1999q4.RData\") > head(.x) YEAR QUARTER CIK NAME FORM DATEFILING LOCATION 1 1999 4 1054476 1 800 AUTOTOW INC RW 1999-10-18 0001042910-99-001363 2 1999 4 1050122 1 800 CONTACTS INC 10-Q 1999-11-16 0000927356-99-001881 3 1999 4 1084869 1 800 FLOWERS COM INC 10-K/A 1999-10-25 0000912057-99-002087 4 1999 4 1084869 1 800 FLOWERS COM INC 10-Q 1999-11-10 0001005477-99-005094 5 1999 4 1084869 1 800 FLOWERS COM INC 8-K 1999-12-09 0001005477-99-005774 6 1999 4 1101417 1 SOLUTION CORP 10SB12G 1999-12-23 0001090002-99-000021 > tail(.x) YEAR QUARTER CIK NAME FORM DATEFILING LOCATION 68823 1999 4 921439 ZYMETX INC 4 1999-11-09 0000921439-99-000014 68824 1999 4 921439 ZYMETX INC 4 1999-11-10 0000921439-99-000015 68825 1999 4 921439 ZYMETX INC 4 1999-11-10 0000921439-99-000016 68826 1999 4 921439 ZYMETX INC 4 1999-11-10 0000921439-99-000017 68827 1999 4 921439 ZYMETX INC 4 1999-11-19 0000921439-99-000018 68828 1999 4 921439 ZYMETX INC DEF 14A 1999-10-21 0000950134-99-009092 ///////////////////////////////// " .C7EXPLAIN24<-"Loading an R data set from the internet ///////////////////////////////// path<-'http://datayyy.com/data_R/index2006q1.RData' con<-url(path) load(con) > head(.x,2) YEAR QUARTER CIK NAME FORM DATEFILING LOCATION 1 2006 1 1114831 033 ASSET MANAGEMENT LLC / 13F-HR 2006-02-13 0001110550-06-000003 2 2006 1 1114831 033 ASSET MANAGEMENT LLC / SC 13D 2006-02-14 0000950136-06-000985 > tail(.x,3) YEAR QUARTER CIK NAME FORM DATEFILING LOCATION 335575 2006 1 1354993 walker jack jonas 3 2006-03-06 0001354993-06-000001 335576 2006 1 1345570 wyman jill l 4 2006-01-25 0000708955-06-000030 335577 2006 1 1298698 ye tao SC 13G 2006-02-10 0001193125-06-026991 ///////////////////////////////// " .C7EXPLAIN25<-"Inputting from a delimited input file (read.delim) ///////////////////////////////// read.delim(file, header = TRUE, sep = \"\\t\", quote = \"\\\"\", dec = \".\", fill = TRUE, comment.char = \"\", ...) read.delim2(file, header = TRUE, sep = \"\\t\", quote = \"\\\"\", dec = \",\", fill = TRUE, comment.char = \"\", ...) ///////////////////////////////// " .C7EXPLAIN26<-"Inputting from a fixed width file (read.fwf) ///////////////////////////////// myfile<- tempfile() cat(file = myfile, \"123456\", \"987654\", sep = \"\\n\") a<-read.fwf(myfile, widths = c(1,2,3)) a V1 V2 V3 1 1 23 456 2 9 87 654 b<-read.fwf(myfile, widths = c(1,-2,3)) b V1 V2 1 1 456 2 9 654 read.fwf(myfile, widths = c(1,-2,3)) #> 1 456 \ 9 654 unlink(myfile) ///////////////////////////////// " .C7EXPLAIN27<-"tibble table ///////////////////////////////// tibble() is a trimmed down version of data.frame() that: 1) Never coerces inputs (i.e. strings stay as strings!). 2) Never adds row.names. 3) Never munges column names. 4) Only recycles length 1 inputs. 5) Evaluates its arguments lazily and in order. 6) Adds tbl_df class to output. 7) Automatically adds column names. library(tibble) help(package=tibble) a <- 1:100 b <-a*2 data1<-data.frame(a,b) data2<-tibble(a, b) > data2 # A tibble: 100 x 2 a b 1 1 2 2 2 4 3 3 6 4 4 8 5 5 10 6 6 12 7 7 14 8 8 16 9 9 18 10 10 20 # ... with 90 more rows ///////////////////////////////// " .C7EXPLAIN28<-"read_sas(): input a SAS data set ///////////////////////////////// library(haven) path<-'http://datayyy.com/data_sas/sheep.sas7bdat' x<-read_sas(url(path)) x # A tibble: 49 x 6 XBAR QBAR N LBAR KBAR DISTRICT 1 3.11 8.31 1 6.05 5.21 1 2 6.31 11.9 1 10.0 8.92 2 3 4.91 10.4 15 8.30 7.18 3 4 4.80 10.4 20 8.53 7.09 4 5 5.04 10.3 15 8.85 7.03 5 6 5.37 10.7 19 9.01 7.47 6 7 5.58 10.6 15 9.51 7.28 7 8 4.91 11.0 1 8.55 7.53 8 9 4.77 10.9 1 8.96 7.41 9 10 3.89 9.78 5 7.45 6.72 10 # ... with 39 more rows ///////////////////////////////// " .C7EXPLAIN29<-"Inputting other types of data sets other ones ///////////////////////////////// library(haven) read_dta Read and write Stata DTA files. read_por Read SPSS ('.sav', '.zsav', '.por') files. Write '.sav' and '.zsav' files. read_sas Read and write SAS files. read_sav Read SPSS ('.sav', '.zsav', '.por') files. Write '.sav' and '.zsav' files. read_spss Read SPSS ('.sav', '.zsav', '.por') files. Write '.sav' and '.zsav' files. read_stata Read and write Stata DTA files. read_xpt Read and write SAS transport files ///////////////////////////////// " .C7EXPLAIN30<-"download.file() function ///////////////////////////////// Example #1: download.file(\"http://datayyy.com/data_csv/ibmMonthly.csv\",\"c:/temp/ibmMonthly.csv\",quiet = TRUE,mode='wb') Example #2: inFile<-'https://www.sec.gov/Archives/edgar/full-index/1999/QTR1/company.idx' outFile= 'c:/temp/secindex1999q1.txt' download.file(inFile, outFile,quiet = TRUE,mode='wb') ///////////////////////////////// " .C7EXPLAIN31<-"Manually download data from Yahoo!Finance /////////////////////////////// Step 1: go to https://finance.yahoo.com Step 2: enter a ticker such as ibm Step 3: Click 'historical data' Step 4: from period to choose MAX then click Done Step 5: Choose monthly click Apply Step 6: Click Download Data > infile<-'http://datayyy.com/data_csv/ibmMonthly.csv' > .is404(infile) [1] 200 ///////////////////////////////// " .C7EXPLAIN32<-"scan() function ///////////////////////////////// x<-scan() > x<-scan() 1: 1 2 3: 2 3 5: 3 4 7: 5 5 9: Read 8 items > x [1] 1 2 2 3 3 4 5 5 ///////////////////////////////// " .C7EXPLAIN33<-" ///////////////////////////////// ///////////////////////////////// " .C7EXPLAIN34<-"USArrests /////////////////////////////// > data('USArrests') > x<-USArrests > head(x) Murder Assault UrbanPop Rape Alabama 13.2 236 58 21.2 Alaska 10.0 263 48 44.5 Arizona 8.1 294 80 31.0 Arkansas 8.8 190 50 19.5 California 9.0 276 91 40.6 Colorado 7.9 204 78 38.7 > dim(x) [1] 50 4 ///////////////////////////////// " .C7EXPLAIN35<-" ///////////////////////////////// ///////////////////////////////// " .C7EXPLAIN36<-" ///////////////////////////////// ///////////////////////////////// " .C7EXPLAIN37<-" ///////////////////////////////// ///////////////////////////////// " .C7EXPLAIN38<-" ///////////////////////////////// ///////////////////////////////// " .C7EXPLAIN39<-"generate RData for a list for datasets ///////////////////////////////// a<-data() write(unlist(a),file=\"c://temp/t.txt\") x<-readLines('c://temp/t.txt') n<-length(x) x2<-x[2:(n-2)] k<-grep(\"C:/Program\",x2) n3<-length(k) # [1] 104 x3<-x2[-k] x4<-matrix(x3,n3,3) df<-data.frame(x4[,1],x4[,3]) colnames(df)<-c(\"Package\",\"Name\") save(df,file=\"c://temp/datasets.RData\") ///////////////////////////////// " .C7EXPLAIN40<-"Closing a link: unlink() function ///////////////////////////////// path<-\"http://datayyy.com/data_csv/ibmMonthly.csv\" con<-url(path) x<-read.csv(con) unlink(con) ///////////////////////////////// "