I have the following line in my R Markdown code chunk
RStudio.Version()$version
when I run the knit on the R Markdown to create a Word document, I get the following error message:
Error in RStudio.Version(): could not find function "RStudio.Version"
When I run this function RStudio.Version() in RStudio console, I get the version and the function runs, but not with knit when I run R Markdown.
Anyone has an advice or solution?
I was able to replicate your issue running RStudio.Version() while knitting. As Phil suggests, rstudioapi::versionInfo() seems the best alternative while knitting.
Related
trying to knit a document in R but keep getting message
"Error in read_xlsx("Feb'22-divvy-tripdata.xlsx") : could not find function "read_xlsx"
trying to knit a docutment and expecting a markdown report
Try rather with the function read_excel() from the library(readxl).
Or the function read.xlsx() of the library(openxlsx). (version 4.2.5.1)
Do not forget to install the packages if there are not already downloaded.
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.
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.
I'm trying to create a PDF in R Markdown and I keep getting this error message every time I try to click "Knit to PDF":
output file: test_4_for_r.knit.md
Output created: test_4_for_r.pdf
Error in tools::file_path_as_absolute(output_file) :
file 'test_4_for_r.pdf' does not exist
Calls: <Anonymous> -> <Anonymous>
In addition: Warning message:
In readLines(logfile) : incomplete final line found on 'test_4_for_r.log'
Execution halted
I do not have a lot of familiarity with RStudio, so I have no idea why I'm getting this message. I've read several things online saying creating PDFs in R Markdown requires several packages, but so far I've only found the name of knitr. That is the only one I have currently installed. I'm not sure if that is the issue or not.
Can someone please point me in the right direction on how to remedy this? Any help would be GREATLY appreciated.
In R-Studio Tools > Global Options, under the Sweave tab, try changing "Weave Rnw using:" from sweave to knitr. Also try
install.packages('tinytex')
tinytex::install_tinytex()
and then try to knit your PDF.
If those don't work, please paste the markdown code giving you trouble. Could you knit the example markdown file, found when you File > New File > R Markdown?
I am trying to generate the following plot as an html document, using Rmarkdown, in Rstudio:
color2D.matplot(M,cs1=c(0,1),cs2=c(0,1),cs3=c(0,1),
extremes=c(1,3),cellcolors=NA,show.legend=TRUE,nslices=10,xlab="Base Price (R)",
ylab="GP (%)",do.hex=FALSE,axes=FALSE,show.values=FALSE,vcol=NA,vcex=1,
border="black",na.color=NA,xrange=NULL,color.spec="rgb",yrev=TRUE,
xat=NULL,yat=NULL,Hinton=FALSE)
But I get the following error:
## Error: could not find function "color2D.matplot"
However, the plot generates perfectly in the Rstudio 'Plots' display. Is there something that can be done so that Rmarkdown can find the function and display the output? Thank you
Use library(plotrix) before you call its function color2D.matplot().