r - Rstudio,试图将数据从 EML.R 提取到表中,但出现错误:错误:必须命名第 1、2、3、4、5 和 18 列
问题描述
我对 R 很陌生,我正在尝试遵循教程。
以下是他们希望我们遵循的步骤。
# INSTALL AND LOAD PACKAGES ################################
# Load contributed packages with pacman
pacman::p_load(pacman, tidyverse, XML2R)
# pacman: for loading/unloading packages
# tidyverse: for so many reasons
# XML2R: for working with XML data
# GET DATA & RESTRUCTURE ###################################
# Data from http://ergast.com/mrd/
# File: http://ergast.com/api/f1/1954/results/1.xml
# Right click to "View page source" and see raw XML
# Import XML data from web (must be online)
df <- "http://ergast.com/api/f1/1954/results/1.xml" %>%
XML2Obs() %>%
collapse_obs() %>%
print()
# See variable (node) names and IDs
df %>%
names() %>%
print()
# EXTRACT & COMBINE DATA ###################################
# Extract data and save as tibble
df %<>% # %<>% is the compound assignment pipe operator
as_tibble() %>% # Save as tibble
select( # Select data
Race = matches("RaceName"), # Get race name
FirstName = matches("GivenName"), # Get first name
LastName = matches("FamilyName"), # Get last name
Team = matches("Constructor//Name") # Get team name
) %>%
print() # Each column is a list with two values (oops)
我正在为“提取和合并数据”这一步而苦苦挣扎
我收到错误消息:错误:第 1、2、3、4、5 和 18 列必须命名。
我尝试了一些选项,例如 .name_repair ,但它不起作用。
有任何想法吗?
解决方案
推荐阅读
- android - 如何在应用关闭之前从 firebase 实时数据库中删除?
- javascript - Angular:Http Post调用将pdf文档发送到服务器
- bash - 获取目录上的总空间和剩余空间以及其中所有目录的大小
- jquery - 如何在 jQuery 中使用 AM 和 PM 时间对下拉菜单进行排序?
- gridview - 在 yii2 中使用 pjax 时,浏览器后退和前进按钮的行为很奇怪
- bash - 如何在 awk 中拆分换行符分隔的字符串并在 bash 中的同一命令行上使用其输出?
- python - 哪一种是从数据集中消除异常值的最佳方法?
- python - 如何检查文本文件中的整数?
- reactjs - Gatsby 构建在 Bootstrap bundle.min.js 上返回错误
- javascript - 我的谷歌表格 webapp 中的过滤器+地图有时不会向我的 excel 返回值