Use browseURL but let URL be variable from some point

172 Views Asked by At

I'm trying to use the browseURL() command for opening different filenames of one website from my data-frame. My problem is, I don't have the full URL inside my columns but rather just the part after the hostname (the filename). Now, can I somehow adjust the command so that it allows the second part of the URL-string to be a variable, for example as in

browseURL("http://www.example-website.com

this is where I'm looking for help

example_exampledata[1, "exampleText"]")

For better understanding: posts_exampledata is my data-frame on which I'm trying to address the first line and the column "exampleText", which contains a filename such as /forum/exapmle-theme/12345-what-is-example.html

Any tips and hints are highly appreciated, and please excuse the potential unclarity of this post since I'm very new to R and english isn't my native language.

1

There are 1 best solutions below

1
On BEST ANSWER

you could use the paste0() function. You would be able to directly paste the variable URL to your browseURL() function.

Example of paste0 :

# the paste0() function in R

paste0("one", "two", "three")
[1] "onetwothree"

url <- "www.url.com"

paste0("/some/kind/of_URL")
[1] "/some/kind/of_URL"

paste0(url, "/some/kind/of_URL")
[1] "www.url.com/some/kind/of_URL"

This function should allow you to do what your seeking for.

Edit : Sorry noticed ismirsehregal comment.