Reputation: 66
I have a table and I'm showing a link to google which performs a search of the variable name (this works well), but now I want to perform a search using three different variables.
This is the 1 variable code:
createLink <- function(val) {
sprintf('<a href="https://www.google.com/#q=%s" target="_blank" class="btn btn-link"> Search </a>',val)
}
I have tried something like this, but it is probably some kind of aberration :(
createLink <- function(chr,start,end) {
sprintf('<a href="https://www.melonomics.net/melonomics.html#/jbrowse?chr="',chr,'&start=',start,'&end=', end, 'target="_blank" class="btn btn-link"> Search </a>')
}
My question is how can I use three variables in the html code. I add an image of the table with the current working link.
Good bye and thank you very much!
Upvotes: 1
Views: 235
Reputation:
You were almost there ! You can find below a working example using the 3 variables in the link construction :
createLink <- function(chr,start,end) {
sprintf('<a href="https://www.melonomics.net/melonomics.html#/jbrowse?
chr=%s&start=%s&end=%s" "target="_blank" class="btn btn-link"> Search </a>',chr,start,end)
}
#Testing the function
createLink("a","b","c")
#Result :
#[1] "<a href=\"https://www.melonomics.net/melonomics.html#/jbrowse?chr=a&start=b&end=c\" \"target=\"_blank\" class=\"btn btn-link\"> Search </a>"
Upvotes: 1