小编jdh*_*son的帖子

Rstudio Shiny如何在Shiny页面中显示Shiny服务器的版本?

是否有变量或方式查询正在运行的RStudio Shiny网页以显示正在运行的服务器的版本?例如shiny-0.10.1在网页上显示类似的内容.

有任何想法吗?

r shiny shiny-server

10
推荐指数
1
解决办法
6986
查看次数

RStudio来自检查dataTables中的行的Shiny列表

我想有一个类似的工作示例:https: //demo.shinyapps.io/029-row-selection/

我试过例如在我闪亮的服务器上运行Shiny Server v1.1.0.10000,packageVersion: 0.10.0并且Node.js v0.10.21,但是即使我加载从网站的JS和CSS文件,它不工作.它根本不从表中选择行:

# ui.R
library(shiny)

shinyUI(fluidPage(
  title = 'Row selection in DataTables',
  tagList(
          singleton(tags$head(tags$script(src='//cdn.datatables.net/1.10.2/js/jquery.dataTables.js',type='text/javascript'))),
          singleton(tags$head(tags$script(src='//cdn.datatables.net/1.10.2/css/jquery.dataTables.min.css',type='text/css')))
        ),
  sidebarLayout(
    sidebarPanel(textOutput('rows_out')),
    mainPanel(dataTableOutput('tbl')),
    position = 'right'
  )
))

# server.R
library(shiny)

shinyServer(function(input, output) {
  output$tbl <- renderDataTable(
    mtcars,
    options = list(pageLength = 10),
    callback = "function(table) {
      table.on('click.dt', 'tr', function() {
        $(this).toggleClass('selected');
        Shiny.onInputChange('rows',
                            table.rows('.selected').indexes().toArray());
      });
    }"
  )
  output$rows_out <- renderText({
    paste(c('You selected these rows on the page:', input$rows),
          collapse = ' …
Run Code Online (Sandbox Code Playgroud)

r datatables shiny

10
推荐指数
2
解决办法
1万
查看次数

引用类,选项卡完成和强制方法定义

我目前正在使用引用类编写包.我通过阅读各种来源遇到了一个问题:

R参考类中的方法初始化

在Snowfall中无法可靠地使用RefClass方法

我收集是因为引用方法并非全部复制到类中的每个对象,而是在首次访问时复制它们.

https://stat.ethz.ch/pipermail/r-devel/2011-June/061261.html

作为一个例子定义:

test <- setRefClass("TEST",
                fields = list( a = "numeric"),
                methods = list(
                   addone = function(){
                                        a <<- a+1
                                      },
                   initialize = function(){
                                            a <<- 1
                                          }
                              )
               )

example <- test$new()
Run Code Online (Sandbox Code Playgroud)

所以示例是类的新对象TEST.example$在控制台中键入和标签给出

> example$
# example$.->a         example$.refClassDef example$.self        
# example$a            example$initialize 
Run Code Online (Sandbox Code Playgroud)

所以该方法addone不作为选项提供.但它可以打电话:

example$addone()
Run Code Online (Sandbox Code Playgroud)

现在标签再次显示

# > 
# > example
# Reference class object of class "TEST"
# Field "a":
# [1] 2
# > example$
# example$.->a         example$.refClassDef …
Run Code Online (Sandbox Code Playgroud)

r s4 reference-class

7
推荐指数
1
解决办法
657
查看次数

在conditionalPanel中选择元素的闪亮使用数量

我想显示我的闪亮应用程序的内容,具体取决于多选输入的所选项目的数量.到目前为止,我无法弄清楚使这项工作的条件应该是什么样的.

library(shiny)

shinyUI(pageWithSidebar(
  headerPanel("select and conditional panel"),
  sidebarPanel(
    selectInput(inputId = "someSelect", multiple=TRUE, label = "Genes:", choices = colnames(someDataFrame), selected = c("ESR1", "CD44")),
  ),
  mainPanel(
    conditionalPanel(
      condition="length(input.someSelect.selected) > 2",
      tabsetPanel(
...
      )
    )
  )
))
Run Code Online (Sandbox Code Playgroud)

r shiny

7
推荐指数
2
解决办法
1507
查看次数

使用Shiny中的滑块更改图像大小

目标:响应在Shiny(RStudio)中移动滑块,使图像更改大小.想想放大缩小效果.

问题:有一个错误说"basename错误(imageinfo $ src):预期的字符向量参数".我找不到任何直接回答这个问题的东西,我不知道还有什么可以尝试的.是否有一个问题,如何在server.R中将sliderInput用作输入$ slider?

我当前的进展:我的理由是在ui.R文件中设置滑块,然后将图像的宽度作为server.R文件中的输入.

ui.R部分:

shinyUI(fluidPage(
  titlePanel("Nancy's Brainstorming"),
  sidebarLayout(

sidebarPanel(
  h3(
    strong("What is this?", style = "font-si24pt")),
  p("This is a pilot project."),
  sliderInput("slider", 
              label = "", 
              min = 100, 
              max = 300, 
              value = 200),
   imageOutput("logo", width = 200)
      )
    )
))
Run Code Online (Sandbox Code Playgroud)

server.R部分:

 shinyServer(function(input, output) {

  output$logo = renderImage({
  img(src = "mylogo.png", width = input$slider)
  })
})
Run Code Online (Sandbox Code Playgroud)

附加信息:当我使用img(src ="mylogo.png",width = 200)时,图像会自动显示.另外,我这样做只是为了更好地构建Shiny应用程序.

r slider shiny

7
推荐指数
1
解决办法
3748
查看次数

如何在Shiny应用程序中嵌入Twitter时间线

我热衷于将Twitter时间线嵌入Shiny App中.我有相关的代码片段

<a class="twitter-timeline" href="https://twitter.com/pssGuy/timelines/524678699061641216" 
data-widget-id="524686407298596864">Soccer</a>

<script>!function(d,s,id){var js,fjs=d.getElementsByTagName(s)    [0],p=/^http:/.test(d.location)?'http':'https';if(!d.getElementById(id)){js=d.createElement(s);js.id=id;js.src=p+"://platform.twitter.com/widgets.js";fjs.parentNode.insertBefore(js,fjs);}}(document,"script","twitter-wjs");</script>
Run Code Online (Sandbox Code Playgroud)

我创建了一个twitter.js文件(上面减去了脚本标签)和一个ui.R,如下所示

library(shiny)
shinyUI(fluidPage(

tags$head(includeScript("twitter.js")),

titlePanel(""),

sidebarLayout(
sidebarPanel(
),

mainPanel(
  a("Soccer", class="twitter-timeline",    href="https://twitter.com/pssGuy/timelines/524678699061641216",  data-widget-id="524686407298596864")

)
)
))
Run Code Online (Sandbox Code Playgroud)

这会产生错误

ERROR: C:\Users\pssguy\Documents\R\testGoogleTwitter/ui.R:19:124: unexpected '='
18:     mainPanel(
19:       a("Soccer", class="twitter-timeline",     href="https://twitter.com/pssGuy/timelines/524678699061641216",  data-widget-id=
Run Code Online (Sandbox Code Playgroud)

如果我省略了data-widget-id ="524686407298596864",我会得到一个链接,当点击该链接时,会打开一个带有正确时间轴的浏览器窗口

我注意到的一件事是给出的脚本与twitters开发教程https://dev.twitter.com/web/embedded-timelines中的脚本不完全相同

<script type="text/javascript">
window.twttr = (function (d, s, id) {
var t, js, fjs = d.getElementsByTagName(s)[0];
if (d.getElementById(id)) return;
js = d.createElement(s); js.id = id; js.src= "https://platform.twitter.com/widgets.js";
fjs.parentNode.insertBefore(js, fjs);
return window.twttr || (t = { _e: [], ready: function …
Run Code Online (Sandbox Code Playgroud)

javascript twitter r shiny

7
推荐指数
1
解决办法
841
查看次数

让CodeIgniter HelloWorld示例正常工作

伙计我是代码点火器的新手..我不明白如何使用这个框架.它只是打开用户指南.谁能告诉我在代码点火器上执行"hello world"程序需要遵循的步骤?

php codeigniter

5
推荐指数
1
解决办法
1万
查看次数

我的Android"Hello World"应用程序没有说"你好"

我创建了一个Hello World应用程序,系统生成了下面的大部分Android语言.在没有System.out语句的情况下运行应用程序时,模拟器中没有显示"Hello".然后,使用Eclipse教程,我读到我可以将System.out.println语句添加到main.应用程序再次运行,但没有输出.

我在这里不理解什么?

<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
    android:orientation="vertical"
    android:layout_width="fill_parent"
    android:layout_height="fill_parent"
    >
<TextView  
    android:layout_width="fill_parent" 
    android:layout_height="wrap_content" 
    android:text="@string/hello"
    System.out.println =" Hello world!" 
    />
</LinearLayout>
Run Code Online (Sandbox Code Playgroud)

android

5
推荐指数
2
解决办法
1万
查看次数

Windows中的长路径/文件名使R中出现write.table()错误

在R中,我write.table()用来将文件写入具有长名称的目录中嵌入的位置。但是它的错误如下:

file(file,ifelse(append,“ a”,“ w”))中的错误:无法打开连接另外:警告消息:在file(file,ifelse(append,“ a”,“ w”))中:无法打开文件'data / production / Weekly_Prod_201407_Selling_Price_Snapshot_20140930_Median_Selling_Price_Map.csv':没有此类文件或目录

然后当我将文件名缩短为 Weekly_Prod.csv,它起作用了!因此,似乎长路径和长文件名导致R错误。

我对其进行了几次测试,发现路径+文件名的总长度限制为260个字符。也就是说,R大于等于261个字符时会出错。有办法解决这个问题吗?请帮忙。谢谢!

r long-filenames

5
推荐指数
1
解决办法
3181
查看次数

在RSelenium中指定下载文件夹

RSelenium用来导航到一个网页,其中包含一个下载文件的按钮.我使用RSelenium单击此按钮下载文件.但是,文件默认下载到我的文件夹'downloads'中,而我想将文件下载到我的工作目录中.我尝试指定一个chrome配置文件,如下所示,但这似乎没有做到这一点:

wd <- getwd()
cprof <- getChromeProfile(wd, "Profile 1")
remDr <- remoteDriver(browserName= "chrome", extraCapabilities = cprof) 
Run Code Online (Sandbox Code Playgroud)

该文件仍然下载在"downloads"文件夹中,而不是我的工作目录中.怎么解决这个问题?

google-chrome r rselenium

5
推荐指数
2
解决办法
2465
查看次数