0

I am using paste() function to combine text with numbers and statistics using the paste() function.

However, when I knit the PDF in RMarkdown a [1] appears before this statement. Is there an option or different function that I can use to prevent this?

I am combined many lines so, having three or four [1]s can be distracting.

Tried using cat() and noquote()

message<-paste("We examined",nrow(patients))

Actual:

[1] We examined 100 patients

Desired:

We examined 100 patients
divibisan
  • 11,659
  • 11
  • 40
  • 58
jontheepi
  • 25
  • 4
  • 2
    I'm surprised you got a `[1]` with `cat()`. Can you please provide a minimal [reproducible example](https://stackoverflow.com/questions/5963269/how-to-make-a-great-r-reproducible-example) of what your rmarkdown file looks like? – MrFlick Jan 23 '19 at 19:39
  • For me `cat("We examined ",nrow(patients), " patients\n" )` works. – G5W Jan 23 '19 at 19:49
  • For some reason cat(paste()) didn't work well with noquote(). I switched to print() – jontheepi Jan 24 '19 at 15:46

2 Answers2

2

try this:

write(message,stdout())
0

A combination of cat and results="asis" chunk option should help resolve your issue:

```{r results='asis'}
cat(paste("We examined", 100, "patients"))
```
Jozef
  • 2,617
  • 14
  • 19