Knit to flexdashboard issue - r

I am trying to "knit to flex_dashboard" the following code in RStudio. I am giving a link because pasting it directly here is causing formatting problems.
https://github.com/futdevseige/R-code/blob/main/Code.rmd
Now, when I try to use the "knit to flex_dashboard" function in RStudio, it is giving me the following error:
I updated r version using the console, but that didn't fix it. RStudio is also up to date.

Related

! LaTeX Error: File `knitr.sty' not found

I am trying to knit a simple markdown file to a pdf using knitr and R Studio. The chunks all run fine and I have no problems knitting to an HTML document, but get the following error when trying to knit to a pdf:
! LaTeX Error: File `knitr.sty' not found.
I have reinstalled tinytex and made sure that the knitr and rmarkdown packages are up to date. I've looked around and while there are similar issue with other *.sty files, I can't find anything relating to this one.
Thanks in advance for any advice
Solved this: for some reason I had listed several R packages in the 'extra_dependencies' part of the YAML metadata. Once removed it worked.

R markdown - Not knitting despite the notebook running without Error

So I am trying to make a R markdown using a package loaded from source.
install.packages('/Users/~/Desktop/BPA/rBSEM_0.2.1.tar.gz', repos = NULL, type = 'source')
With a clear environment, the code runs successfully. However, when I try to knit the document, I run into several errors.
The first is that "object 'sample_SEM' not found". This stems from this line of code:
data(sample_SEM)
Where sample_SEM is data encoded into the rBSEM package.
The next problem is that it cannot find the function 'getInputGraph' - which is in the package.
inputAdj <- getInputGraph(blockList = blockL,blockGraph = G,varNames=names(sample_SEM))
Does anyone have any suggestions? Sorry I couldn't be more specific but I'm not quite sure what is happening here.
Thanks!
have you ran library(rBSEM) at the top of your first R chunk? You may have ran library(rBSEM) at the console, but if it's not in the first R chunk, it's not being loaded when knitting the document.

R Markdown - First Attempt - Strange Error Message

I'm trying to create an R Markdown script for the first time today in RStudio. I have an existing R script which produces lots of graphs, and I'm hoping to use Markdown to produce .pdf files containing these graphs.
I started very simple:
```{r}
10 * 10
```
When I clicked on the "knit" button I saw an error message:
I ran getOption("repos") at the console and I saw:
"https://mran.microsoft.com/snapshot/2019-02-01"
I don't know if it's relevant (I suspect it is): I'm not using standard R, I'm using Microsoft R Client 3.5.2 because I need access to the revoScaleR package.
I don't really understand what's going on here but it looks as if I'm using out of date stuff...can anyone help fix this please?
Thank you.
Ahhhh...I think I've fixed it:
options(repos = c(CRAN = "https://cran.rstudio.com"))
Hoping this doesn't have any unintended consequences! >crosses fingers<

ggplot2 plot executing correctly in Rstudio but not getting displayed in knitr html

I am facing a strange issue. Have written a code with ggplot2 which is getting executed perfectly in Rstudio and the plots are getting displayed.But when i am trying to publish into html using knitr the output plots are not getting displayed. I have tried print() to display and it is still not working.
I have tried reinstalling Rstudio as well.
{r,include=TRUE,echo=TRUE,eval=FALSE}
meandaytype<-
aggregate(analysis1$steps,by=list(analysis1$Daytype,analysis1$interval),mean)
names(meandaytype)[1]<-"Daytype"
names(meandaytype)[2]<-"Interval"
names(meandaytype)[3]<-"steps"
p<-ggplot(meandaytype,aes(x=Interval,y= steps,color=Daytype)) +
geom_line()+facet_grid(Daytype~.)+labs(title="Mean steps per inteval and day
type",x="Interval",y="MeanSteps")
print(p)
Any help would be appreciated. I am using version 1.1.447

knitr button in rstudio

I'm a beginner to R and Rstudio. One of my first problems is that I do not have the knitr option in rstudio, despite having installed the knitr package. I have checked and I do have the last version of Rstudio. I am aware of how dumb this question is, but I can't but ask it after I tried everything. Shockingly, I have the knitr option/button at work, where Rstudio was installed in the same fashion (apparently). I'm attaching a screenshot of my rstudio. Any ideas?
You apparently don't have your file saved with a standard extension where it will auto-detect the file type from. You can save with .Rmd or whatever is appropriate. Alternatively in the bottom right of your source pane you should see "Text File" -> Go ahead and click and change that to R Markdown or R presentation or whatever is appropriate for your particular file.

Resources