我有这个使用paste0函数创建超链接的代码。 但点击后,URL显示为:
http://127.0.0.1:4350/www.companyname.com/test/test/product.html
http://127.0.0.1:4350/永远在此之前。 在另一部分的其余代码中它可以正常工作。
URL1列中的数据为www.companyname.com/test/test/product.html 这是一些代码:
UI
#! /bin/bash
list_junk()
{
echo "Junk Directory"
format="%8s%10s%10s %-s\n"
printf "$format" "File" "Size" "Type"
printf "$format" "----" "----" "----"
if [$(id -u)= "0"]; then
dir_list="/home/student/bin/junk_dir/*"
else
dir_list=$HOME
fi
for file in $dir_list; do
filename=$(ls -al /home/student/bin/junk_dir)
filesize=$(wc -c /home/student/bin/junk_dir)
filetype=$(ls --file-type /home/student/bin/junk_dir)
printf "$format" $filename $filesize $filetype
done
}
服务器
(...)
tabsetPanel(
tabPanel("Products", dataTableOutput("table1")),
(...)
答案 0 :(得分:0)
URL1列数据为www.companyname.com/test/test/product.html
如果您添加网址的http://前面,它应该有效。列中的URL应为:
http://www.companyname.com/test/test/product.html
希望有效。
答案 1 :(得分:0)
根据您的评论,您的数据如下所示:
Model URL1
1 www.companyname.com/test/test/product.html
2 www.companyname.com/test/test/product.html
以下是您的代码工作的最小示例:
library(shiny)
df <- data.frame(Model = c("1", "2"), URL1 = c("www.companyname.com/test/test/product.html", "www.companyname.com/test/test/product.html"))
ui <- fluidPage(DT::dataTableOutput("table"))
server <- function(input, output){
output$table <- DT::renderDataTable({
df$Model <- paste0("<a href= '","http://",df$URL1,"' target='_blank '>",df$Model,"</a>")
DT::datatable(df, escape = FALSE)
})
}
shinyApp(ui, server)
您的URL1缺少导致错误的http://
。另外,我必须使用paste
代替paste0
,以便没有不必要的空格。
希望它有所帮助!