【问题标题】:Errors During R Notebook CompilationR 笔记本编译期间的错误
【发布时间】:2023-02-08 02:33:09
【问题描述】:

将R Notebook编译/编入文档时出现如下错误如何解决?
所有必需的包都已成功加载,但问题仍然存在。请尽快提供帮助。

代码:-

x<-5:15
mean(x)
x%>%mean

sum(z,na.rm=TRUE)
z%>%sum(na.rm=TRUE)

sum(is.na(z))
z%>%is.na%>%sum

mean(is.na(z))
z%>%is.na%>%mean````


OUTPUT:-
|...................................                 |  67% (unnamed-chunk-1)

processing file: qwerty.Rmd
Quitting from lines 13-124 (qwerty.Rmd) 
Error in x %>% mean : could not find function "%>%"
Calls: <Anonymous> ... withVisible -> eval_with_user_handlers -> eval -> eval
                                                                                                            
Execution halted


CODE:-
````data(diamonds)
View(diamonds)

# base histogram(s)
hist(x=diamonds$carat,main="FREQUENCY vs. CARAT",xlab="carat",ylab="frequency")

# base scatter plot(s)
(plot(x=diamonds$carat,y=diamonds$price,xlab="carat",ylab="price"))````

OUTPUT:-
 |...................................                 |  67% (unnamed-chunk-1)

processing file: qwerty.Rmd
                                                                                                            
Quitting from lines 13-24 (qwerty.Rmd) 
Error in as.data.frame(x) : object 'diamonds' not found
Calls: <Anonymous> ... eval_with_user_handlers -> eval -> eval -> View -> as.data.frame
Execution halted

Restarted RStudio several times.
Loaded all the necessary packages.
Explored several websites for the resolution, but in vain.

【问题讨论】:

    标签: r


    【解决方案1】:

    错误是“x %>% 的错误意味着:找不到函数“%>%”” 尝试在此代码之前添加库(tidyverse)(您需要在 .Rmd 文件中加载所有必需的包,以便它可以编织) 此外,您将能够使用钻石数据集

    希望这可以帮到你!

    【讨论】:

      猜你喜欢
      • 2016-10-10
      • 2013-07-07
      • 2023-03-24
      • 2018-08-30
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2015-05-12
      相关资源
      最近更新 更多