Knit function in rmarkdown


I am getting following problem when I try to knit my work into pdf:

[Error in rcorr(data_rcorr) : could not find function "rcorr"
Calls: ... handle -> withCallingHandlers -> withVisible -> eval -> eval
Execution halted

Can any body help me in this regards?


You need to have the library that contains the function in your document in order for the function to be used. I'm guessing you're looking for rcorr() from the Hmisc package. So, you can either attack Hmisc, or prefix it Hmisc::rcorr().

Thanks Mara!

The problem still exists after installing the package. This function works when I try to run junk but it could not create pdf file through knit function. Can you please try this with your codes in rmarkdown?

Thank you!

It's not about installation, it's about calling the library first. Here's a gist with the .Rmd and the .md, which I just knit successfully.

The body of the Rmd here, too.

title: '`rcorr()` test'
author: "Mara Averick"
date: "6/25/2019"
    keep_md: TRUE

```{r setup, include=FALSE}
knitr::opts_chunk$set(echo = TRUE, collapse = TRUE)


x <- c(-2, -1, 0, 1, 2)
y <- c(4,   1, 0, 1, 4)
z <- c(1,   2, 3, 4, NA)
v <- c(1,   2, 3, 4, 5)

Thank you, Mara!

It works now.


This topic was automatically closed 7 days after the last reply. New replies are no longer allowed.