reprex显示正确的输出,但rstudio控制台显示错误

时间:2020-07-29 14:32:19

标签: r reprex

Licencing

reprex package(v0.3.0)于2020-07-29创建

当我在Rstudio中运行此代码时,出现以下错误。有帮助吗?

library(tidyverse)
#> Warning: package 'tidyverse' was built under R version 3.6.3
#> Warning: package 'ggplot2' was built under R version 3.6.3
#> Warning: package 'tidyr' was built under R version 3.6.3
#> Warning: package 'purrr' was built under R version 3.6.3
#> Warning: package 'dplyr' was built under R version 3.6.3
#> Warning: package 'stringr' was built under R version 3.6.3
#> Warning: package 'forcats' was built under R version 3.6.3
mtcars = as_tibble(mtcars)
cars_nested = mtcars %>% group_by(cyl) %>% nest()

cars_fitted = cars_nested %>% 
  mutate(fit = map(data, function(x) lm(mpg ~ disp, data = x)))

1 个答案:

答案 0 :(得分:0)

感谢您的建议。我发现了为什么会出现这些错误。在先前的代码中,我在不知不觉中将mtcar嵌套到相同的mtcars数据集。因此,只有cyl和data列。那就是为什么我得到错误。