Print bold text conditionally

Hello. I am using r markdown and I have an issue in printing bold text subject to a condition. I want r to evaluate a string variable, if the variable is non-empty then the variable should be printed in bold. The final document is written in word. Here's the code that I have used:

myvar = "some string variable"

(r if (myvar != "") {myvar})

This code works fine when the string is non-empty. However, when I pass an empty string I expect no actions but the code prints a black line. I attached a screenshot of the final document, where you can see 7 black lines, one for each empty variable passed in the code.

Any idea to solve this?


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

If you have a query related to it or one of the replies, start a new topic and refer back with a link.