External source script not working while knitting the rmarkdown into document - r

I have large function in another R script. when I used it as a source and call the function, it is working fine but it does not work if I try to knit it into document.
line73 source('PATH\\function.R', local = knitr::knit_global())
line74 table1 <- demograph(arg1, arg2)
here , demograph() is the function from external R scriptfunction.R
I can get the results in the console but while trying to knit it to document I got following error:
Quitting from lines 73-81 (vision_rmd.Rmd)
Error in eval(x, envir = envir) : object 'False' not found
Calls: <Anonymous> ... eval_lang -> in_input_dir -> in_dir -> eval -> eval
Execution halted

Related

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

How to resolve this Error when knit markdown

I'm trying to knit an RMarkdown to an HTML file.
But I got an error like this
Quitting from lines 28-34 (learning_map2.Rmd)
Error in slot(p, "Polygons") :
cannot get a slot ("Polygons") from an object of type "NULL"
Calls: ... createSPComment -> lapply -> FUN -> sapply -> lapply -> slot
Execution halted
screenshot_1598604180|690x133
But I can run it on my mac. It's just doesn't run in my Window PC.
Thanks all!

Code runs fine in R but Knit shows an error

I'm having a problem with the following code in an Rmd file, the problem is that if I run the commands in the console, the code runs perfectly fine, and also there is no mistakes in the syntax, I have change several styles but I'm still receiving the same error when I knit the file.
Raw_Data96_11$EVTYPE <- as.character(Raw_Data96_11$EVTYPE)
List_Events <- count(Raw_Data96_11, vars = "EVTYPE")
List_Events <- arrange(List_Events,desc(n))
List_Events <- mutate(List_Events, percentage = trunc((100*(n/653530))))
Top_10_Events <- List_Events[1:10,2:3]
I had to change the syntax for count, when I run the command in the console, I did not had to use vars, but now I cannot run the command arrange, this is the error :
Quitting from lines 98-117 (PA_2_Reproducible_Research.Rmd)
Error in order(List_Events$n) : argument 1 is not a vector
Calls: ... withVisible -> eval -> eval -> arrange -> eval -> eval -> order
Execution halted
I have included the libraries in that chunk but I'm still receiving an error, does anyone know what is going, is it the syntax or what else do I need to do?

Cannot knit RMarkdown with large raster

I'm running into some issues while knitting an RMarkdown document that reads in a large raster. The code chunk runs without error in the console, but fails when I try and knit the markdown document.
Here is the line in the document that produces the error:
r <- raster("./data/very_large_raster.img")
Error in if (x == "" | x == ".") { : argument is of length zero
Calls: <Anonymous> ... raster -> raster -> .local -> .rasterObjectFromFile
Execution halted

Trying to Knit but can't because read excel function is not being recognized in R

My whole program is working but when I try to knit to a document the same error is being thrown.
Quitting from lines 3-78 (Untitled.spin.Rmd)
Error in eval(expr, envir, enclos) : could not find function "read_excel"
Calls: <Anonymous> ... handle -> withCallingHandlers -> withVisible -> eval -> eval
Execution halted
I don't under stand why. Where are the first 5 lines of my code.
Dataset_Stats1Project <- read_excel(Users/jamiestokes16/Desktop/Dataset_WomeninGov5.xlsx)
#Descriptive stats for important variables
summary(Dataset_WomeninGov$Wcongress)
summary(Dataset_WomeninGov$Wgov)
summary(Dataset_WomeninGov$Wleg)
Any help would be appreciated.
When you knit a document, knitr essentially creates a new R session for the code to run in. So any packages loaded session will not be accessible unless you load them directly within the .Rmd file.
I always find it easiest to include a chunk at the start of the document loading any packages used:
```{r LoadPackages, include = FALSE}
library(readlx)
# add other packages here
```

Resources