【问题标题】: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 [duplicate]我正在尝试从 R 中的 github 读取 csv 文件。但是,当我尝试获取列的名称时,我只得到一个名称 [重复]
【发布时间】:2019-02-20 19:57:41
【问题描述】:

我正在运行此代码将 csv 文件导入电影。

movies <-read.csv("https://github.com/fivethirtyeight/data/blob/master/fandango/fandango_score_comparison.csv",header=TRUE) 
names(movies)

我在这里尝试获取列的名称

{r seeing variable names,echo=FALSE} names(movies)

我得到的只有这个

[1] "X..DOCTYPE.html."

我错过了什么?

【问题讨论】:

    标签: r


    【解决方案1】:

    从github读取数据时,需要传入read.csv()中数据的原始版本,你使用的是显示版本。您可以通过单击数据上方显示的 Raw 按钮获取原始版本的 URL。

    movies <- read.csv("https://raw.githubusercontent.com/fivethirtyeight/data/master/fandango/fandango_score_comparison.csv", header=TRUE)
    

    【讨论】:

      猜你喜欢
      • 2011-02-09
      • 2013-02-02
      • 2018-10-02
      • 2020-07-29
      • 2023-01-12
      • 2021-02-13
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多