Я хотел бы сохранить строку, выбранную как массив или какой-либо другой индексный объект. Но я просто не понимаю, как это сделать.Извлечение строк из DataTable Shiny
Вот код. Линия дает мне неприятности является output$rowData <- renderText({input$table1[s]})
fluidPage(
title = " Nanoproject",
h1("Peak Table and Views"),
# first row will contain the peak table and peak view
fluidRow(
# give the table half of the page
column(6, dataTableOutput('table1'), height = 2500),
#give the other half of the page to the images
column(6 ,
imageOutput("image1",width = "auto",height = "auto"),
htmlOutput("rowData")
)
server.R
# prompt user to select the peak table file
writeLines("Please select the peaks file")
peaksPath = file.choose()
# read the tsv file
peaksTable = read.csv(peaksPath , header = TRUE , row.names = NULL , sep = "\t")
server = function(input, output) {
output$table1 = renderDataTable({
# the peak table
datatable(peaksTable,
# when rowname is false each row does not have a numeriC# associated with it
rownames = TRUE,
# specify the name of the column headers
colnames = c("Seqnames", "Start", "End","Width","Strand","P","Q","Effectsize",
"FDR","Keep","Gene_name","Gene.nearest","Count","Count.pred",
"Coverage","Local.mut.density","Base.context.GC","Tn.Context.TpC",
"Tn.context.CpG","Dnase","Activechrom","Hetchrom","Rept"),
# make the table scrollable (horizontally)
options = list(scrollX = TRUE))
},
escape = FALSE)
output$image1 <- renderImage({
# save which row was selected
s = input$table1_rows_selected
# output the data of the row that was selected
output$rowData <- renderText({input$table1[s]})
#output$rowsSelected <- renderText({s})
list(src=paste0(imagePath,"/peak" , s,".png"),width=700,height=2500)},deleteFile=FALSE)
Каких неприятностей? –
Прочтите страницу справки. Обычно «cat» используется для его побочного эффекта и возвращает NULL. –