2016-05-15 70 views
1

我試圖在robustbase庫中使用閃亮的函數Qn。此功能可以給C例程QN0通話爲如下:在光澤中使用.C

.C(Qn0, as.double(x), n, res = double(1))$res 

當我運行(說)Qn(rnorm(10))在'r運行完全正常,但是當我運行它裏面有光澤它提供了錯誤信息

錯誤QN(RNORM(10)):對象 'QN0' 未找到

下面是一些示例代碼

ui.R

shinyUI(fluidPage(
    sidebarLayout(
     sidebarPanel(), 
     mainPanel(uiOutput("txt")) 
    )  
)) 

server.R

library(robustbase) 
shinyServer(function(input, output) {   
     output$txt <- renderText({ 
      print(getDLLRegisteredRoutines("robustbase"))   
      Qn(rnorm(10)) 
     }) 
}) 

的getDLLRegisteredRoutines( 「robustbase」)列出了QN0,但後來我得到的錯誤呢。我懷疑名稱空間有問題,但我一直無法弄清楚它是什麼。

沃爾夫岡

回答

1

此代碼:

library(robustbase) 

ui_foo = shinyUI(fluidPage(
    sidebarLayout(
    sidebarPanel(), 
    mainPanel(uiOutput("txt")) 
)  
)) 

server_foo = shinyServer(function(input, output) {   
    output$txt <- renderText({ 
    print(getDLLRegisteredRoutines("robustbase"))   
    Qn(rnorm(10)) 
    }) 
}) 

shinyApp(ui = ui_foo, server = server_foo) 

不拋出任何錯誤我。這裏是我的sessionInfo

> sessionInfo() 
R version 3.2.5 (2016-04-14) 
Platform: x86_64-w64-mingw32/x64 (64-bit) 
Running under: Windows >= 8 x64 (build 9200) 

locale: 
[1] LC_COLLATE=English_United States.1252 LC_CTYPE=English_United States.1252 
[3] LC_MONETARY=English_United States.1252 LC_NUMERIC=C       
[5] LC_TIME=English_United States.1252  

attached base packages: 
[1] stats  graphics grDevices utils  datasets methods base  

other attached packages: 
[1] robustbase_0.92-5 RSQLite_1.0.0  shiny_0.13.2   stringr_1.0.0  zoo_1.7-12   
[6] chron_2.3-47   ggplot2_2.1.0  RMySQL_0.10.9  DBI_0.4-1   assertthat_0.1  
[11] readr_0.2.2   dplyr_0.4.3   XLConnect_0.2-11  XLConnectJars_0.2-9 readxl_0.1.1   
[16] openxlsx_3.0.0  lubridate_1.5.6.9000 

loaded via a namespace (and not attached): 
[1] Rcpp_0.12.4  DEoptimR_1.0-4 plyr_1.8.3.9000 tools_3.2.5  digest_0.6.9  jsonlite_0.9.19 
[7] gtable_0.2.0  lattice_0.20-33 parallel_3.2.5 rJava_0.9-8  grid_3.2.5  data.table_1.9.6 
[13] R6_2.1.2   magrittr_1.5  scales_0.4.0  htmltools_0.3.5 mime_0.4   colorspace_1.2-6 
[19] xtable_1.8-2  httpuv_1.3.3  labeling_0.3  stringi_1.0-1 lazyeval_0.1.10 munsell_0.4.3 
+0

奇怪!我完全按照你的方式運行了應用程序,並得到相同的錯誤!我從sessionInfo看到的唯一區別是:我運行的是Win7,R-3.2.2和shiny_0.12.2,但這些都不重要。 –

+0

@WolfgangRolke爲什麼不將這段代碼部署到shinyapps.io中,看看它是否會引發錯誤。 – tchakravarty

0

我剛剛通過安裝R和閃亮的最新版本解決了問題。感謝tchakravarty試圖幫助!