我正在处理超过10万行的表并使用DT包(开发版本0.1.56)在Shiny App 中将其可视化.
此外,我使用DTExtensions作为:Buttons,以不同的格式下载数据.然而,虽然Scroller扩展也被激活,但我只能下载几行(不是所有数据).
示例代码:
library("shiny")
library("DT")
shinyApp(
ui = fluidPage(DT::dataTableOutput('tbl')),
server = function(input, output) {
output$tbl = DT::renderDataTable(
iris,extensions=c("Buttons",'Scroller'),options = list(dom = 'Bfrtip',
buttons = c('copy', 'csv', 'excel', 'pdf', 'print'),scrollY = 50,
scroller = TRUE
))
}
)
Run Code Online (Sandbox Code Playgroud)
另外如果我只运行R中的这部分代码并在查看器中获取数据表,我能够复制所有行,甚至可能如何?
library("DT")
datatable(
iris,
extensions = 'Buttons', options = list(
dom = 'Bfrtip',
buttons = c('copy', 'csv', 'excel', 'pdf', 'print')
)
)
Run Code Online (Sandbox Code Playgroud)
我尝试过不同的方法:
scrollY =在选项列表中更改... - >它正在工作,但scrollY实际显示所有数据行的数量必须很大,因此可以完全下载 …
我正面临一个问题,就是可能会采用html小部件的屏幕截图进行进一步实施,例如pdf文档.datatable(DT包)的屏幕截图具有太高的高度,它在rmarkdown文档中显示为空白区域(很容易被位置看到fig.cap,即低于结尾datatable).我无法理解为什么会发生这种情况而且我想要删除它(下面没有空格datatable).请看下面的示例,test.Rmd其中充分显示了问题:
---
output:
pdf_document:
toc: yes
header-includes:
- \usepackage{fancyhdr}
- \usepackage[ngerman]{babel}
---
\addtolength{\headheight}{1.0cm}
\pagestyle{fancyplain}
\renewcommand{\headrulewidth}{0.4pt}
\renewcommand{\footrulewidth}{0.4pt}
\chead{Test}
\lhead{\scriptsize\today}
```{r, fig.align='center', fig.pos='htb!', fig.width=12, fig.cap="The height of screenshot is too high!!",fig.height=3,echo=FALSE, cache=FALSE, warning = FALSE, message = FALSE, tidy=TRUE}
library(DT)
library(webshot)
datatable(mtcars[1:2,],rownames=FALSE, options = list(dom='t',ordering=F))
```
Run Code Online (Sandbox Code Playgroud)
datatable,我已经注意到,如果datatable 有> 20行然后数字与标题很好地显示.rmarkdown是一个属于的可下载报告shiny app),这就是为什么在示例中我只使用了来自 …我的目标是找到一个可控制的机器参数设置,它可以在目标上同时最小化方差,同时最小化方差,因此我找到了非常有趣的R包,称为JOP,它代表多重响应的联合优化.
我一直在尝试在我的数据中实现它,但我收到警告消息:
错误:Y1的模型构建失败检查分布假设或链接功能警告消息:由于分歧而截断的步长
我只是找不到原因(它实际上是使用小数据集子集,例如100行),我想让它工作...我不太适合数据分析领域,因此任何提示都会非常有帮助.下面是我的数据示例,以及使用JOP包的代码:
DATAX
datax <- structure(list(X1 = c(969L, 987L, 987L, 993L, 956L, 998L, 966L,
950L, 996L, 1004L, 955L, 980L, 974L, 955L, 966L, 978L, 977L,
984L, 972L, 989L, 974L, 986L, 953L, 974L, 977L, 989L, 1004L,
996L, 971L, 969L, 996L, 981L, 981L, 951L, 975L, 996L, 992L, 980L,
987L, 1000L, 985L, 1001L, 978L, 961L, 987L, 1003L, 974L, 982L,
993L, 991L, 998L, 955L, 980L, 950L, 961L, 974L, 988L, 987L, 986L,
962L, 976L, 970L, 1014L, 956L, 960L, 972L, 971L, 972L, 954L,
976L, 973L, …Run Code Online (Sandbox Code Playgroud) 我有一个关于在Shiny中使用的数据表(DT)的问题。我有相当大的数据(> 5000000行),并使用带有过滤器的数据表(DT)在闪亮的应用程序中显示它。根据用户对过滤的偏好,让我们假设它可以给我们550行(但可以给我们更多或更少的行)。由于分页,我无法看到所有550行(假设pageLength为100),甚至更糟的是,由于函数input$tabelle_rows_all使用当前页面上的行,因此我无法在绘图中进一步显示所有过滤的行(我必须首先更改条目号)。有什么方法可以在过滤数据表后获取所有找到的行(不依赖pageLength)?
例:
library(shiny)
library(DT)
library(ggplot2)
x <- as.numeric(1:1000000)
y <- as.numeric(1:1000000)
data <- data.frame(x,y)
shinyApp(
ui = fluidPage(dataTableOutput('tableId'),
plotOutput('plot1')),
server = function(input, output) {
output$tableId = renderDataTable({
datatable(data, options = list(pageLength = 100, lengthMenu=c(100,200,300,400,500,600)))
})
output$plot1 = renderPlot({
filtered_data <- data[input$tableId_rows_all, ]
ggplot(data=filtered_data, aes(x=x,y=y)) + geom_line()
})
}
)
Run Code Online (Sandbox Code Playgroud)
感谢您的任何信息
我有一个问题,使用ROracle从数据库中获取一些数据.一切都很完美(我从不同的表中获取数据没有任何问题),但其中一个表抛出一个错误:
library(ROracle)
con <- dbConnect(dbDriver("Oracle"),"xxx/x",username="user",password="pwd")
spalten<- dbListFields(con, name="xyz", schema = "x") # i still get the name of the columns for this table
rs <- dbSendQuery(con, "Select * From x.xyz") # no error
data <- fetch(rs) # this line throws an error
dbDisconnect(con)
Run Code Online (Sandbox Code Playgroud)
Fehler in .valueClassTest(ans,"data.frame","fetch"):来自泛型函数'fetch'的无效值,类"try-error",期望"data.frame"
我遵循了这个问题:在stackoverflow上,我选择了列
rs <- dbSendQuery(con, "Select a From x.xyz")
Run Code Online (Sandbox Code Playgroud)
但没有一个工作,并给了我同样的错误.
有什么想法我做错了什么?
PS我已经检查了Oracle SQL Developer中的sql查询,我确实得到了数据表
更新:
如果有人可以帮我找到/查询我的Oracle错误日志,那么也许我可以通过麻烦的查询找出数据库服务器上实际发生的情况.
我的plotly包有问题.图例无法正确显示或未显示所有值因为它被剪切!
我想在情节区域之外(在底部或右下角)获得传奇.
我已经尝试改变以下位置ggplot:
legend.position="bottom"
Run Code Online (Sandbox Code Playgroud)
根本没有结果......
然后我尝试了plotly网站上的代码:
p %>% layout(legend = list(x = 0.5, y = -100))
Run Code Online (Sandbox Code Playgroud)
它没有用,传说是在底部,但它被剪切,并在x轴标题后面......
以下是mtcars数据集中的示例代码:
a <- ggplot(mtcars, aes(x = interaction(cyl, carb, lex.order = T), y = mpg,fill = interaction(cyl, carb, lex.order = T))) +
geom_boxplot()
ggplotly(a)
Run Code Online (Sandbox Code Playgroud)
正如我们所看到的那样,传奇的标题也被切割了.
我将不胜感激任何帮助!
谢谢
是否有可能将应用程序(flexdashboard图片如下)嵌入ShinyApp(shinydashboard或shiny)中?
Shiny flexdashboard来自flexdashboard 网站的示例代码:
```{r}
renderGauge({
rate <- computeContactRate(input$region)
gauge(rate, min = 0, max = 100, symbol = '%', gaugeSectors(
success = c(80, 100), warning = c(40, 79), danger = c(0, 39)
))
})
```
Run Code Online (Sandbox Code Playgroud)
这是我失败的尝试:
library(shiny)
library(shinydashboard)
#library(flexdashboard)
ui <-dashboardPage(
dashboardHeader(),
dashboardSidebar(),
dashboardBody(
column(6,box(flexdashboard::gaugeOutput("plt1"),width=12,title="Gauge Graph",background ="green"))))
server <- shinyServer(function(input, output, session) {
output$plt1 <- flexdashboard::renderGauge({
gauge(56, min = 0, max = 100, symbol = '%', label = paste("Test …Run Code Online (Sandbox Code Playgroud) 我有一个如下所示的列表。我想打印它,就像它在我闪亮的应用程序中的样子一样。我尝试了 print(unlist(ls)) ,其中 ls 是下面显示的列表,但它只是打印数字。我还尝试了 Hmisc 包中的 print.char.list 但它给出了错误
Error in x[[1]][1, ] : incorrect number of dimensions.
Run Code Online (Sandbox Code Playgroud)
那么我怎样才能打印出名字呢?提前致谢。
$money
bankaccount cryin desperate feelin likely loaded poppin build moment
0.73 0.73 0.73 0.73 0.73 0.73 0.73 0.62 0.59
spend spent
0.51 0.51
$matter
becauseit racest spanish found whites races
0.63 0.63 0.63 0.56 0.56 0.55
$little
appropriate carrying usual
0.56 0.56 0.56
$still
cloth codes glamorous grade
0.57 0.57 0.57 0.57
Run Code Online (Sandbox Code Playgroud) 我很难解决这个问题.我将在示例的基础上解释它最好,让我们看看下面的数据:
order type_a type_b type_c type_d
1 1 0 50 10 0
2 2 10 0 0 80
3 3 15 0 0 35
4 4 0 0 30 0
5 5 0 20 40 0
Run Code Online (Sandbox Code Playgroud)
并且dput:
data <- structure(list(order = c(1, 2, 3, 4, 5), type_a = c(0, 10, 15,
0, 0), type_b = c(50, 0, 0, 0, 20), type_c = c(10, 0, 0, 30,
40), type_d = c(0, 80, 35, 0, 0)), .Names = c("order", "type_a", …Run Code Online (Sandbox Code Playgroud) 我确实需要一些帮助作为帖子:闪亮服务器中的动态颜色输入并不能完全解决我的问题.
我想在我闪亮的应用程序中选择动态颜色(填充).我准备了一个示例代码:
library(shiny)
library(shinyjs)
library(reshape2)
library(ggplot2)
dat <- data.frame(matrix(rnorm(60, 2, 3), ncol=3))
dat <- melt(dat)
runApp(shinyApp(
ui = fluidPage(
selectizeInput("select","Select:", choices=as.list(levels(dat$variable)), selected="X1",multiple =TRUE),
uiOutput('myPanel'),
plotOutput("plot"),
downloadButton('downloadplot',label='Download Plot')
),
server = function(input, output, session) {
cols <- reactive({
lapply(seq_along(unique(input$select)), function(i) {
colourInput(paste("col", i, sep="_"), "Choose colour:", "black")
})
})
output$myPanel <- renderUI({cols()})
cols2 <- reactive({
if (is.null(input$col_1)) {
cols <- rep("#000000", length(input$select))
} else {
cols <- unlist(colors())
}
cols})
testplot <- function(){
dat <- dat[dat$variable %in% …Run Code Online (Sandbox Code Playgroud) r ×9
shiny ×6
dt ×2
colors ×1
datatables ×1
ggplot2 ×1
optimization ×1
oracle ×1
plotly ×1
r-markdown ×1
r-plotly ×1
shinyjs ×1
sql ×1