uncool
uncool

Reputation: 2703

Knitr Markdown - Sourced Script returns empty lists + ugly source file output

I'm trying on a simple knitr markdown "exercise". What I want to do is to simply source my R script file and output some of the data, e.g. the mean of a vector.

My code

```{r, echo = FALSE}
summary(cars)
source("GETPrices.R")

x  <- BooliReq()
mean(x$sold$listPrice)

```

Firstly, the source ("GETPrices.R") generates an ugly

Attaching package: 'jsonlite'

The following object is masked from 'package:utils':

View

in the output file. How can this be prevented?

Secondly, when I e.g. try to output the mean value (see code above), all I get is

Warning in mean.default(x$sold$listPrice): argument is not numeric or

logical: returning NA

Outputting the mean in this way works fine though in console. So what is the issue?

Upvotes: 0

Views: 95

Answers (1)

Robert
Robert

Reputation: 5152

For the first error, use the options:

{r, echo = FALSE, message=FALSE,warning=FALSE}

Upvotes: 1

Related Questions