我一直在使用RStudio DT如何與DT ::科學數據表的列數
library(shiny)
library(DT)
shinyApp(
ui = fluidPage(
DT::dataTableOutput('example')
),
server = function(input, output) {
output$example <- DT::renderDataTable({
table = cbind(LETTERS[1:5],c("9.95e-04","9.93e-06","9.93e-02","9.49e-03","9.10e-02"))
table
}, options = list(
columnDefs = list(list(type = "scientific", targets = 1))
))
}
)
下面的代碼,但排序它,因爲我打算不科學的列進行排序。什麼是正確的做法?
正確的遞減順序應該是:
V1 V2
C 0.0993
E 0.091
D 0.00949
A 0.000995
B 0.00000993
這裏http://stackoverflow.com/questions/35657271/ordering-factors-in-data-table-using-dt-package –
看一看你V2是一個字符,而不是數字。目前它按字母順序排序。一旦將它強制轉換爲數字,排序應該起作用。 –
@RomanLuštrik但我想保留科學記數法。如果我做'as.numeric',科學記數法就不復存在了。 – neversaint