我開發了一個簡單的閃亮應用程序,輸入分數爲my_x
,分佈的均值爲my_mean
,標準差爲。作爲輸出,應用程序返回一個正態標準分佈的格點圖,其相應的z-score
爲my_x
。請在GitHub找到應用程序的代碼。現在在Shiny中調用附加函數
,我想的第二功能添加到該應用:
通過檢查一個checkboxInput
我將計算,例如,輸入端的pnorm
和色調曲線圖的相對面積。
我爲圖形編寫了代碼(這裏是預期結果的一個例子),但我無法弄清楚如何使它在Shiny中工作。特別是,我無法確定如何使用複選框在第一個繪製圖形的函數中正常工作時激活該功能。
library(lattice)
e4a <- seq(60, 170, length = 10000)
e4b <- dnorm(e4a, 110, 15)
#z-score is calculated with the inputs listed above:
z_score <- (my_x - my_mean)/my_sd
plot_e4d <- xyplot(e4b ~ e4a,
type = "l",
main = "Plot 4",
scales = list(x = list(at = seq(60, 170, 10)), rot = 45),
panel = function(x,y, ...){
panel.xyplot(x,y, ...)
panel.abline(v = c(z_score, 110), lty = 2)
xx <- c(60, x[x>=60 & x<=z_score], z_score)
yy <- c(0, y[x>=60 & x<=z_score], 0)
panel.polygon(xx,yy, ..., col='red')
})
print(plot_e4d)
你想讓你的函數在複選框被選中時被調用嗎? – tospig
正是@tospig。 – Worice
每個值在這個向量中代表什麼:'v = c(80,95,110)'?我想這些應該是反應值。 – zx8754