R markdown error: non-numeric argument to binary operator - r

Code:
Error:
Quitting from lines 40-46 (Code.Rmd)
Error in ggplot(Fat) : could not find function "ggplot"
Calls: ... handle -> withCallingHandlers -> withVisible -> eval -> eval
Execution halted
I can't convert this code into pdf, can anyone please tell me why this error had occurred and what should I do>

Related

Errors During R Notebook Compilation

How to resolve the following errors occurring when compiling/knitting R Notebook into a document? All the required packages are successfully loaded, still, the issue persists.
I restarted RStudio several times. Loaded all the necessary packages. Explored several websites for the resolution, but in vain.
Code:
# pipe operator
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
The error is "Error in x %>% mean : could not find function "%>%""
Try to add library(tidyverse) before this code (you need to load all the required packages in the .Rmd file so it can knit)
Also, you will be able to use the diamonds dataset
Hope this can help you!

Error with setwd() when compile Rmarkdown

I am doing an R markdown file, I have the last versiĆ³n of R and RStudio, but I get an error when I trie to compile. My file is pretty simple, that's the reason why I don't know what it is happening.
I have already consulted this pages:
Shiny demo doesnt work: Error in setwd(old) : character argument expected #844
character argument expected #14
Error for Knit to HTML
But I can't found the problem.
This is the error:
setwd(wd): character argument expected
Error in setwd(wd) : character argument expected
Calls: <Anonymous> ... call_inline -> in_dir -> .handleSimpleError -> h -> setwd
Error in setwd(wd) : character argument expected
Calls: <Anonymous> ... in_dir -> setwd -> .handleSimpleError -> h -> setwd
Error in setwd(oldwd) : character argument expected
Calls: <Anonymous> -> setwd
Execution halted
Thank you very much.

Object: "DF" not found when knitting rmd

I get this error when knitting any rmd. file using this data set (Aviste_Affect_Data).(The problem also happens with other data frames when I tried to reproduce the problem) All of the code within the files run and the data set itself appears to be fine (it was imported from SPSS). The error occurs on the first line of code in each rmd. file and if I delete that line the error just happens again on the next line of code and so on.
This is the first line of code that the error occurs on, which again runs fine (the package dplyr is being used):
Data_na2014<-Aviste_Affect_Data %>% filter(!Year==14)
Error Message:
Error in eval(las, parent, parent) : object 'Aviste_Affect_Data' not found Calls: ...withCallingHandlers -> withVisible -> eval -> eval -> $>$ ->eval ->eval Execution halted
If I try different code as the first code, the error is mostly the same:
Aviste_Affect_Data$Worry<-as.numeric(Aviste_Affect_Data$x78)
Error Message:
Error in eval(expo,envir,enclos) : object 'Aviste_Affect_Data' not found Calls: ...handle-> withCallingHandlers -> withVisible -> eval -> eval Execution halted

Couldnt not find function "cc" Knit PDF in R

When trying to Knit PDF on R Studio i get this error. cc() is a function from package CCA(), which I've installed and loaded previously. It runs perfectly in the console as does this other function: plt.cc(), which needs the same package and library, too.
Quitting from lines 125-128 (Preview-ecc331f1f51.Rmd) Error in eval(expr, envir, enclos) : could not find function "cc" Calls: <Anonymous> ... handle -> withCallingHandlers -> withVisible -> eval -> eval Execution halted
Need some help guys, i'm 'bout to crack my display !
You should do this
require(CCA)
cc(SOMETHING) ...

Cryptic dplyr error when trying to knit html

I have a snippet that depends on a package that I wrote. I'm trying to knit a markdown document and am getting an error:
Error in eval(expr, envir, enclos) : not a vector
Calls: <Anonymous> ... freduce -> <Anonymous> -> bind_rows -> rbind_all -> .Call
The same snippet runs in the console, and the previous line is a lapply that returns a list of data frames. There's confidential data and it'd take a while to come up with a reproducible example so I thought I'd see if others have any tips.

Resources