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

The code below returns "http://www.yahoo.com" when I knit. How do I format it to just show Yahoo with a clickable hyperlink?

Code Chunk -

count <- 3
cutoff <- 4
espn <- "http://espn.com"
yahoo <- "http://www.yahoo.com"

In Line -

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

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


count <- 3
cutoff <- 4
espn <- "http://espn.com"
yahoo <- "http://www.yahoo.com"
output<-NULL
name_output<-NULL
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

 htmltools::a(name_output,
              href=output)

@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.