Read a CSV from github into R
Try this:
library(RCurl)
x <- getURL("https://raw.github.com/aronlindberg/latent_growth_classes/master/LGC_data.csv")
y <- read.csv(text = x)
You have two problems:
- You're not linking to the "raw" text file, but Github's display version (visit the URL for https:\raw.github.com....csv to see the difference between the raw version and the display version).
- https is a problem for R in many cases, so you need to use a package like
RCurl
to get around it. In some cases (not with Github, though) you can simply replace https with http and things work out, so you can always try that out first, but I find using RCurl reliable and not too much extra typing.
I'm trying to read in a csv file from github in R. However, when I try to get the names of the columns, I only get one name
When reading data from github, you need to pass in the raw version of the data in read.csv()
, you are using the display version. You can get the URL for the raw version by clicking on the Raw button displayed above the data.
movies <- read.csv("https://raw.githubusercontent.com/fivethirtyeight/data/master/fandango/fandango_score_comparison.csv", header=TRUE)
Related Topics
Find How Many Times Duplicated Rows Repeat in R Data Frame
Count the Number of All Words in a String
R: Gsub, Pattern = Vector and Replacement = Vector
Find Which Season a Particular Date Belongs To
Dplyr: "Error in N(): Function Should Not Be Called Directly"
Assign Multiple Objects to .Globalenv from Within a Function
How to Order Data by Value Within Ggplot Facets
How to Delete Rows from a Dataframe That Contain N*Na
Call Apply-Like Function on Each Row of Dataframe With Multiple Arguments from Each Row
Gradient of N Colors Ranging from Color 1 and Color 2
How to Install Packages in Latest Version of Rstudio and R Version.3.1.1
Convert Unix Epoch to Date Object
How to Change the Y-Axis Figures into Percentages in a Barplot
Replace All Particular Values in a Data Frame
How to Add Code Folding to Output Chunks in Rmarkdown HTML Documents
Ggplot Combining Two Plots from Different Data.Frames
Forcing Garbage Collection to Run in R With the Gc() Command