首页 > 解决方案 > 继承错误(x,“tbl_df”):缺少参数“x”,没有默认值

问题描述

我正在尝试复制在 R 博客上发布的代码,但是我对数据有一些问题。

这是我下载的包:

# Load the necessary packages
# Tidyverse is our rock in data analysis (includes ggplot2)
if(!require("tidyverse")) install.packages("tidyverse") 
# Janitor cleans data like the best janitor out there!
if(!require("janitor")) install.packages("janitor")
# ggsci has my favourite color palettes
if(!require("ggsci")) install.packages("ggsci")
# ggalt is necessary for the dumbbell chart
if(!require("ggalt")) install.packages("ggalt") 
# ggtext allows for great text to include for charts
if(!require("ggtext")) install.packages("ggtext")   

这是我的问题:

# Load the csv data file
df <- read_csv("WomenInGovernment_Data.csv")
── 

Column specification ────────────────────────────────────────────────────────────────────────────────────────
cols(
  .default = col_character()
)
ℹ Use `spec()` for the full column specifications.

Warning: 13 parsing failures.
row col   expected    actual                         file
33  -- 27 columns 1 columns 'WomenInGovernment_Data.csv'
64  -- 27 columns 1 columns 'WomenInGovernment_Data.csv'
65  -- 27 columns 1 columns 'WomenInGovernment_Data.csv'
78  -- 27 columns 1 columns 'WomenInGovernment_Data.csv'
91  -- 27 columns 1 columns 'WomenInGovernment_Data.csv'
... ... .......... ......... ............................
See problems(...) for more details.

> spec()
Error in inherits(x, "tbl_df") : argument "x" is missing, with no default

我从 GitHub 1下载数据作为 csv 文件。

标签: rcsv

解决方案


推荐阅读