How do I format code for hyperlink when using "if else" statements.

The code below returns "" when I knit. How do I format it to just show Yahoo with a clickable hyperlink?

Code Chunk -

count <- 3
cutoff <- 4
espn <- ""
yahoo <- ""

In Line -

r if(count > cutoff){espn} else {yahoo}

Your issue is in a Rmardown document. If so, you can do something like this on your Rmarkdown:

count <- 3
cutoff <- 4
espn <- ""
yahoo <- ""
output <- if(count > cutoff){espn} else {yahoo}
name_output <- if(count > cutoff){'ESPN'} else {'YAHOO'}

[r name_output](r output)


It will Print Yahoo or ESPN depends on condition

Hope it help


going with Rodrigues general approach its also possible with


@Rodrigue Thank you. This works.

Happy it's work for you.

Can you mark the solution so that people with a similar question can quickly see what worked for you.

1 Like

This topic was automatically closed 7 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.