I am trying to take in a data frame an excel sheet that has two columns,
Column A contains names of stores Column B contains the URL of those stores.
I would like to take Column A and make it a clickable hyperlink so instead of plain text, it is a hyperlink to the store website.
I have attempted to use openxlsx package to generate the correct output.
I have attempted to use the following code snip.
x <- c("https://www.google.com", "https://www.google.com.au")
names(x) <- c("google", "google Aus")
class(x) <- "hyperlink"
writeData(wb, sheet = 1, x = x, startCol = 10)
which comes from this post of a similar nature. https://mcmap.net/q/1325337/-r-write-to-excel-with-links
My problem however is when I replace the appropriate parts of the code e.g.:
x <- df$b
names(x) <- df$a
class(x) <- "hyperlink"
writeData(wb, sheet = 1, x = x, startCol = 10)
instead of giving me a column of hyperlinks that has the store name as the output, it gives me the entire URL as the output. Is there something I am missing from my code?
I get an output that has a clickable link, but instead of the URL appearing with the name, it instead just prints out the URL.
df
withhead(dput(df))
? – Latini