我刚刚完成了一门学习R数据分析的课程,现在我正在自己做一个案例研究。
由于我是初学者,请帮助我理解这个问题,我没有在课程中。
我已经导入了csv文件,我希望将它们分配给具有更好名称的变量。
我使用以下包装: tidyverse,readr,lubridate,ggplot2,janitor,tidyr,skimr。
这是我的密码:
daily_Activity <- read_csv("../input/bellabeat-dataset/dailyActivity_merged.csv")
daily_Calories <- read_csv("../input/bellabeat-dataset/dailyCalories_merged.csv")
daily_Intesities <- read_csv("../input/bellabeat-dataset/dailyIntensities_merged.csv")
daily_Steps <- read_csv("../input/bellabeat-dataset/dailySteps_merged.csv")
hourly_Calories <- read_csv("../input/bellabeat-dataset/hourlyCalories_merged.csv")
sleep_Day <- read_csv("../input/bellabeat-dataset/sleepDay_merged.csv")
weight_Log <- read_csv("../input/bellabeat-dataset/weightLogInfo_merged.csv")
当我运行代码时,新表是用新名称创建的,但是控制台也向我显示了以下消息:
ℹ Use `spec()` to retrieve the full column specification for this data.
ℹ Specify the column types or set `show_col_types = FALSE` to quiet this message.
我不太明白这是个问题还是我应该忽视它。
发布于 2022-02-26 16:17:08
资源:
列规格
如果在读取文件时必须指定每一列的类型,这将是很繁琐的。相反,readr
使用一些启发式方法来猜测每一列的类型。您可以使用guess_parser()
自己访问这些结果
列规范描述了每一列的类型,以及readr用来猜测类型的策略,因此您不需要提供所有这些类型。
df <- read_csv(readr_example("mtcars.csv"))
将给予:
Rows: 32 Columns: 11
-- Column specification ---------------------
Delimiter: ","
dbl (11): mpg, cyl, disp, hp, drat, wt, q...
i Use `spec()` to retrieve the full column specification for this data.
i Specify the column types or set `show_col_types = FALSE` to quiet this message.
如果我们然后使用spec(df):
spec(df)
我们会得到:
cols(
mpg = col_double(),
cyl = col_double(),
disp = col_double(),
hp = col_double(),
drat = col_double(),
wt = col_double(),
qsec = col_double(),
vs = col_double(),
am = col_double(),
gear = col_double(),
carb = col_double()
)
readr
就会猜测数据类型。这可能会消耗时间。readr
无法猜测数据类型的情况下(例如,混乱的日期输入)。使用spec()
,我们必须识别和确定这个特定列的类型.https://stackoverflow.com/questions/71278038
复制相似问题