file name ends with a .csv
file name ends with a .csv
file name ends with a .xls or .xlsx
file name ends with a .xls or .xlsx
The function is read.csv()
and put the URL address in “” and add the stringsAsFactors=F
df_csv <- read.csv("https://data.ct.gov/api/views/iyru-82zq/rows.csv?accessType=DOWNLOAD", stringsAsFactors=F)
Why?
Blame statisticians.
Back when R was created the users weren’t using it as we use it now, with all these different strings.
When you right click on the link, instead of clicking Copy Link Address– this time, click Save Link As…
Save to the directory you’re working in
After saving to the directory, click on the circle arrow on the right to refresh the files to make sure it’s there.
Either by typing setwd("/directory/where/you/want")
or by clicking in the menu up top Session > Set Working Directory > Choose Directory…
Just like before, except instead of the URL, it’s the name of the file.
Note: This will only work if the working directory is set to where the csv file is.
df_csv <- read.csv("data/Admissions_to_DMHAS_Addiction_Treatment_by_Town__Year__and_Month.csv", stringsAsFactors=F)