$ 中的错误:'closure' 类型的对象不是可子集化的,我该如何解决这个问题?
Error in $: object of type 'closure' is not subsettable , how can i solve this?
我已经上传了两个 csv
并且我正在使用 shinyr
中的 reactive()
来操作 csv
数据。但是我收到此错误
Error in $: object of type 'closure' is not subsettable
我是 R 的新手ui,我怎样才能克服这个错误?!谢谢
##datasets
datatables
Client Amount Reason
1 0000001440MACT800 100000 6866755276
datatable
CLIENTID UPDATED.BY DEPOSIT.TYPE AMOUNT UPDATED.ON
1 0000001451MACT800 ADMIN Cash-Deposit 100,000.00 7/14/2016 09:33
2 0000001002MACT800 ADMIN Cash-Deposit 100,000.00 7/14/2016 09:23
3 0000001006MACT800 ADMIN Cash-Deposit 1,500,000.00 10/3/2016 11:48
4 0000001440MACT800 ADMIN Cash-Deposit 100,000.00 7/12/2016 14:13
5 0000001022MACT800 ADMIN Cash-Deposit 150,000.00 10/6/2016 14:23
6 0000001024MACT800 ADMIN Cash-Deposit 100,000.00 7/20/2016 08:18
7 0000001032MACT800 ADMIN Cash-Deposit 100,000.00 7/20/2016 08:17
8 0000001034MACT800 ADMIN Cash-Deposit 50,000.00 7/20/2016 08:29
9 0000001037MACT800 ADMIN Cash-Deposit 100,000.00 7/20/2016 08:17
10 0000001440MACT800 ADMIN Cash-Deposit 1,000,000.00 11/3/2016 14:40
11 0000001053MACT800 ADMIN Cash-Deposit 1,000,000.00 11/3/2016 14:51
12 0000001053MACT800 ADMIN Cash-Deposit 5,000,000.00 11/9/2016 15:02
13 0000001082MACT800 ADMIN Cash-Deposit 500,000.00 11/2/2016 12:47
14 0000001451MACT800 ADMIN Cash-Deposit 7,000,000.00 11/15/2016 13:12
15 0000001099MACT800 ADMIN Cash-Deposit 6,404,564.00 11/17/2016 14:23
16 0000001101MACT800 ADMIN Cash-Deposit 50,000.00 11/2/2016 12:50
function(input, output, session) {
dhh <- reactive({
inFile <- input$file
if (is.null(inFile)) return(NULL)
datatables <- read.csv(input$file[[1, 'datapath']], check.names=FALSE)
return(datatables)
})
output$terry <- renderDataTable({
if (is.null(dhh)) return(NULL)
datatables <- data.frame(dhh())
datatables
})
mk <- reactive({
if (is.null(input$file)) return(NULL)
inFile <- input$file
datatable <- read.csv(input$file[[2, 'datapath']], check.names=FALSE)
return(datatable)
})
output$contents <- renderDataTable({
if (is.null(mk)) return(NULL)
datatable <- data.frame(mk())
datatable
})
gloria <- reactive({
alice <- dhh()
calvin <- mk()
x1=calvin[order(nrow(calvin):1),] #invert row order
ppp <- as.character(alice$Client )
non <- data.frame(calvin$CLIENTID)
vcv <- c(ppp)
tttt <- as.vector(non)
r <- calvin[non %in% vcv, ]
pipo <- r %>%
mutate(UPDATED.ON=as.Date(factor(r$UPDATED.ON), format = "%m/%d/%Y"))%>%
group_by(r$CLIENTID) %>%
arrange(desc(UPDATED.ON)) %>%
slice(1)
#calculate difference in days
y <- pipo$UPDATED.ON
tr <- as.Date(factor(y), format = "%Y/%m/%d")
jp <- Sys.Date()
ty <- as.numeric(difftime(Sys.Date(), tr), units="days")
ty
ty <- data.frame(ty)
ty
#calculate account maintenance fees
acc <- 60.0885 * ty
acc
#calculate amount of money to be deposited to utrade
jjj <- mk$Amount
jjj
tmt <- jjj - acc
tmt
class(tmt)
#converting numeric to string
tb <- sprintf("%.0f", (tmt))
tb
Client <- x1$Client
btk <- data.frame( Client, "Acc Fees" = acc)
btk
uhy <- data.frame(Client, "Amount" = tb, "Reason" = x1$Reason)
uhy
names(btk) <- gsub(x = names(btk),
pattern = "\.",
replacement = " ")
btk
})
output$marvin <- renderDataTable({
gloria()
})}
这是服务器端的大部分代码。我认为 ui 方面不会有任何帮助。
您在不带括号的情况下引用了 mk
反应值,这是必需的,因为从技术上讲,该对象是一个反应性 函数。这应该可以解决您的问题:
jjj <- mk()$Amount
我已经上传了两个 csv
并且我正在使用 shinyr
中的 reactive()
来操作 csv
数据。但是我收到此错误
Error in $: object of type 'closure' is not subsettable
我是 R 的新手ui,我怎样才能克服这个错误?!谢谢
##datasets
datatables
Client Amount Reason
1 0000001440MACT800 100000 6866755276
datatable
CLIENTID UPDATED.BY DEPOSIT.TYPE AMOUNT UPDATED.ON
1 0000001451MACT800 ADMIN Cash-Deposit 100,000.00 7/14/2016 09:33
2 0000001002MACT800 ADMIN Cash-Deposit 100,000.00 7/14/2016 09:23
3 0000001006MACT800 ADMIN Cash-Deposit 1,500,000.00 10/3/2016 11:48
4 0000001440MACT800 ADMIN Cash-Deposit 100,000.00 7/12/2016 14:13
5 0000001022MACT800 ADMIN Cash-Deposit 150,000.00 10/6/2016 14:23
6 0000001024MACT800 ADMIN Cash-Deposit 100,000.00 7/20/2016 08:18
7 0000001032MACT800 ADMIN Cash-Deposit 100,000.00 7/20/2016 08:17
8 0000001034MACT800 ADMIN Cash-Deposit 50,000.00 7/20/2016 08:29
9 0000001037MACT800 ADMIN Cash-Deposit 100,000.00 7/20/2016 08:17
10 0000001440MACT800 ADMIN Cash-Deposit 1,000,000.00 11/3/2016 14:40
11 0000001053MACT800 ADMIN Cash-Deposit 1,000,000.00 11/3/2016 14:51
12 0000001053MACT800 ADMIN Cash-Deposit 5,000,000.00 11/9/2016 15:02
13 0000001082MACT800 ADMIN Cash-Deposit 500,000.00 11/2/2016 12:47
14 0000001451MACT800 ADMIN Cash-Deposit 7,000,000.00 11/15/2016 13:12
15 0000001099MACT800 ADMIN Cash-Deposit 6,404,564.00 11/17/2016 14:23
16 0000001101MACT800 ADMIN Cash-Deposit 50,000.00 11/2/2016 12:50
function(input, output, session) {
dhh <- reactive({
inFile <- input$file
if (is.null(inFile)) return(NULL)
datatables <- read.csv(input$file[[1, 'datapath']], check.names=FALSE)
return(datatables)
})
output$terry <- renderDataTable({
if (is.null(dhh)) return(NULL)
datatables <- data.frame(dhh())
datatables
})
mk <- reactive({
if (is.null(input$file)) return(NULL)
inFile <- input$file
datatable <- read.csv(input$file[[2, 'datapath']], check.names=FALSE)
return(datatable)
})
output$contents <- renderDataTable({
if (is.null(mk)) return(NULL)
datatable <- data.frame(mk())
datatable
})
gloria <- reactive({
alice <- dhh()
calvin <- mk()
x1=calvin[order(nrow(calvin):1),] #invert row order
ppp <- as.character(alice$Client )
non <- data.frame(calvin$CLIENTID)
vcv <- c(ppp)
tttt <- as.vector(non)
r <- calvin[non %in% vcv, ]
pipo <- r %>%
mutate(UPDATED.ON=as.Date(factor(r$UPDATED.ON), format = "%m/%d/%Y"))%>%
group_by(r$CLIENTID) %>%
arrange(desc(UPDATED.ON)) %>%
slice(1)
#calculate difference in days
y <- pipo$UPDATED.ON
tr <- as.Date(factor(y), format = "%Y/%m/%d")
jp <- Sys.Date()
ty <- as.numeric(difftime(Sys.Date(), tr), units="days")
ty
ty <- data.frame(ty)
ty
#calculate account maintenance fees
acc <- 60.0885 * ty
acc
#calculate amount of money to be deposited to utrade
jjj <- mk$Amount
jjj
tmt <- jjj - acc
tmt
class(tmt)
#converting numeric to string
tb <- sprintf("%.0f", (tmt))
tb
Client <- x1$Client
btk <- data.frame( Client, "Acc Fees" = acc)
btk
uhy <- data.frame(Client, "Amount" = tb, "Reason" = x1$Reason)
uhy
names(btk) <- gsub(x = names(btk),
pattern = "\.",
replacement = " ")
btk
})
output$marvin <- renderDataTable({
gloria()
})}
这是服务器端的大部分代码。我认为 ui 方面不会有任何帮助。
您在不带括号的情况下引用了 mk
反应值,这是必需的,因为从技术上讲,该对象是一个反应性 函数。这应该可以解决您的问题:
jjj <- mk()$Amount