Just showing an example to represent my seemingly simple problem.

i generate a variable with random TRUE/FALSE.

data <- sample(c(TRUE, FALSE), size = 1, replace = TRUE)

Somewhere in the TeX (knitr), i need to print whether its TRUE or FALSE.


but my text output is blank. I am not sure whats the problem?

1 Answer 1


Do the following:


data <- sample(c(TRUE, FALSE), size = 1, replace = TRUE)

  • Thanks R. Schumacher. This works. Now how about for variables with NA? Can I display Exists / NA if the variable has a value other than NA, or print NA?
    – tallharish
    Aug 16, 2015 at 16:56
  • I suspect that this can be done, but because of the specific issues in dealing with NA in R this question will get a better answer on stackoverflow.com/questions/tagged/r Aug 17, 2015 at 0:03

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.