I would like to conditionally display this block of text but I don't understand how to put the part nrow(subset(df, column == 1))
readable for the program and not inside the string.
`r if(nrow( subset(df,column == 1) != 0){"Multiple choice variable with nrow(subset(df, column == 1)) missing values."}`
CodePudding user response:
Using paste
you could do:
Also note that there was a bug in your condition which I fixed.
---
title: "Untitled"
output: html_document
date: '2022-07-22'
---
```{r}
df <- data.frame(
column = 1:2
)
```
`r if (nrow( subset(df,column == 1)) != 0) paste("Multiple choice variable with", nrow(subset(df, column == 1)), "missing values.") else ""`