更新 - 12/17/2012 9am CDT:示例已更新为演示数据和完整代码.[/更新].
示例数据: https ://gist.github.com/4318774
描述:
我一直在玩新的Shiny包(喜欢它!)但是还不明白我遇到的错误runApp("")
.错误是Error in tag("div", list(...)): argument is missing
.
我正在尝试创建一个交互式网络应用程序,用于人口统计数据的图形化探索.我使用以下作为指南:
https ://gist.github.com/4026749
http://rstudio.github.com/shiny/tutorial/
有options(error= recover)
,我得到:
Listening on port 8100
Error in tag("div", list(...)) : argument is missing, with no default
Enter a frame number, or 0 to exit
1: runApp("//~~my app~~")
2: tryCatch(while (TRUE) {
serviceApp(ws_env)
}, finally = {
timerCallbacks$clear()
websocket_close(ws_env)
})
3: tryCatchList(expr, classes, parentenv, handlers)
4: serviceApp(ws_env)
5: service(server = …
Run Code Online (Sandbox Code Playgroud) 我正在编写一个函数来生成股票价格的时间序列图.但是,我收到以下错误
eval中的错误(expr,envir,enclos):找不到对象'df1234'
这是函数的一个例子:
plot.prices <- function(df1234) {
require(ggplot2)
g <- ggplot(df1234, aes(x= as.Date(Date, format= "%Y-%m-%d"), y= df1234[, 3],
colour= brewer.pal(12,"Set3")[1])) + geom_point(size=1)
g + geom_point(aes(x= date, y = df1234[, 4],
colour= brewer.pal(12,"Set3")[2]), size=1)
# ... code not shown...
g
}
Run Code Online (Sandbox Code Playgroud)
示例数据:
spy <- read.csv(file= 'http://ichart.finance.yahoo.com/table.csv?s=SPY&d=11&e=1&f=2012&g=d&a=0&b=29&c=1993&ignore=.csv', header= T)
plot.prices(spy) # produces error
g <- ggplot(spy, aes(x= as.Date(Date, format= "%Y-%m-%d"), y= spy[, 3],
colour= brewer.pal(12,"Set3")[1])) + geom_point(size=1)
g + geom_point(aes(x= as.Date(Date), y = spy[, 4],
colour= brewer.pal(12,"Set3")[2]), size=1)
## does not …
Run Code Online (Sandbox Code Playgroud) 我正在尝试加载一个zip级别的shapefile来做一些绘图,按:https: //github.com/hadley/ggplot2/wiki/plotting-polygon-shapefiles http://www.nceas.ucsb.edu/scicomp/ usecases/ReadWriteESRIShapeFiles等
我的代码:
library(rgdal)
library(RColorBrewer)
library(ggplot2)
zipmap = readOGR(dsn="file.zip/", layer="myZIPmap")
Run Code Online (Sandbox Code Playgroud)
我收到这个错误:
Error in ogrInfo(dsn = dsn, layer = layer, input_field_name_encoding = input_field_name_encoding) :
Cannot open file
Run Code Online (Sandbox Code Playgroud)
我检查了驱动程序,但说实话,我无法解释输出:
ogrDrivers()
name write
1 AeronavFAA FALSE
2 ARCGEN FALSE
3 AVCBin FALSE
4 AVCE00 FALSE
5 BNA TRUE
6 CSV TRUE
7 DGN TRUE
8 DXF TRUE
9 EDIGEO FALSE
10 ESRI Shapefile TRUE
11 Geoconcept TRUE
12 GeoJSON TRUE
13 Geomedia FALSE
14 GeoRSS TRUE
15 GML TRUE …
Run Code Online (Sandbox Code Playgroud) 我学习Rcpp类/数据结构时的一个新手问题:是否有成员函数来擦除类对象的行/列Rcpp::NumericMatrix
?(或者其他类型的type **Matrix
- 我假设它是模板类)?
library(Rcpp)
cppFunction('
NumericMatrix sub1 {NumericMatrix x, int& rowID, int& colID) {
// let's assume separate functions for rowID or colID
// but for the example case here
x.row(rowID).erase(); // ??? does this type of member function exist?
x.col(colID).erase(); // ???
return x;
}')
Run Code Online (Sandbox Code Playgroud)
如果这种类型的成员函数不存在,那怎么样?
cppFunction('NumericMatrix row_erase (NumericMatrix& x, int& rowID) {
// a similar function would exist for removing a column.
NumericMatrix x2(Dimension(x.nrow()-1, x.ncol());
int iter = 0; // possibly make this a …
Run Code Online (Sandbox Code Playgroud) 比如说,我正在使用朴素贝叶斯在 R 中开发机器学习模型。所以我将使用 naiveBayes 包构建一个模型,如下所示
model <- naiveBayes(Class ~ ., data = HouseVotes84)
Run Code Online (Sandbox Code Playgroud)
我还可以通过打印模型来打印模型的权重。
我按如下方式进行预测,这给了我一个作为预测的类
predict(model, HouseVotes84[1:10,], type = "raw")
Run Code Online (Sandbox Code Playgroud)
但是,我的问题是,有没有办法查看哪些列对这个预测影响最大?因此,我可以了解导致学生不及格的最重要因素是什么,例如,如果这是响应变量,而各种可能的因素是其他预测变量列。
我的问题是对于 R 中的任何包,上面的 naiveBayes 只是一个例子。
data.table
由于本文未包含的各种原因,我想在该框架中工作。包中是否data.table
有指示矩阵的稀疏表示Matrix
?
library(Matrix)
library(data.table)
set.seed(123409L)
ints <- sample.int(2L, 1e6, replace=T, prob= c(0.9, 0.1)) - 1
m <- Matrix(ints, ncol= 1000)
dt <- data.table(matrix(ints, ncol= 1000))
pryr::object_size(m) # 1.22 MB
pryr::object_size(dt) # 8.1 MB
Run Code Online (Sandbox Code Playgroud)
假设在实际用例中我更接近6e8
元素,假设增长是无限的。
如果这个问题已经得到解答,请提前致歉。我很高兴它被标记为重复项;但我没有通过搜索找到重复的。
感觉我在这里遗漏了一些明显的东西,所以提前道歉。无论如何,这是a
我尝试投射的一些数据:
acct_num year_prem prem exc
001 2012 2763585 exclusive
001 2011 2377688 exclusive
001 2010 2083065 exclusive
001 2009 1751722 exclusive
001 2008 1639484 exclusive
Run Code Online (Sandbox Code Playgroud)
然而,转换给了我一个我无法弄清楚/解释的错误:
b <- dcast(a, formula= acct_num + exc ~ year_prem, value.var= prem, fill= NA)
Error in .subset2(x, i, exact = exact) : invalid subscript type 'list'
Run Code Online (Sandbox Code Playgroud)
我认为我不需要fill= NA
。但不管有没有它我都会遇到同样的错误。任何帮助,将不胜感激。
我收到这个错误:
Something is wrong; all the Accuracy metric values are missing:
Accuracy Kappa
Min. : NA Min. : NA
1st Qu.: NA 1st Qu.: NA
Median : NA Median : NA
Mean :NaN Mean :NaN
3rd Qu.: NA 3rd Qu.: NA
Max. : NA Max. : NA
NA's :5 NA's :5
Error in train.default(x, y, weights = w, ...) : Stopping
In addition: Warning message:
In nominalTrainWorkflow(x = x, y = y, wts = weights, info = …
Run Code Online (Sandbox Code Playgroud) 试图将这些想法更进一步:
我想包括反应降价文件(*.Md
)在mainPanel
有条件的输入到selectInput
。我该怎么做?
我已经尝试了renderText
,renderPrint
并使用eval
inside 的变体includeMarkdown
。到目前为止似乎没有任何效果。
例如。
### ui.R
shinyUI(fluidPage(
sidebarLayout(
sidebarPanel(
selectInput("var1",
label= "Please Select option",
choices= c("option1", "option2", "option3"),
selected= "option1"
),
mainPanel(
h3("guide:")
includeMarkdown("md_file")
)
)
))
### server.R
shinyServer(function(input, output) {
output$md_file <-
if (input$var1 == "option1") {
renderPrint({"option1.Md"})
} else if (input$var1 == "option2") {
renderPrint({"option2.Md"})
} (input$var1 == "option3") {
renderPrint({"option3.Md"})
}
})
})
R> shiny::runApp('C:/Shiny_demo')
Run Code Online (Sandbox Code Playgroud)
我正在尝试将 R 连接到 Teradata,但不确定RODBC::odbcDriverConnect()
. 有一个 teradataR 包,但它仅用于 R 版本 3 及以下版本,我既没有也不想切换到。下面是使 ODBCDriverConnect 工作的输入参数列表。“连接”我认为是最重要的。我需要一个司机的地址,我什至不知道我有没有。这是我最需要帮助的。如何获取 Teradata 驱动程序以连接到 R?我工作中的 IT 不确定如何执行此操作。另外,如果有人知道将 Teradata 连接到 R 的另一种方法(其他一些软件包?),请告诉我。
connection = ""
case
believeNRows = TRUE
colQuote, tabQuote = colQuote
interpretDot = TRUE
DBMSencoding = "",
rows_at_time = 100
readOnlyOptimize = FALSE
Run Code Online (Sandbox Code Playgroud)
感谢您的帮助!