我编写了用因子变量绘制条形图的函数.当我运行我的功能时,显示错误消息.eval中的错误(expr,envir,enclos):找不到对象'dset'如何修改我的函数?谢谢!
x1=factor(c("f","m","f","f","m","f","f","m","f","m"))
x2=factor(c("1","2","1","1","1","2","2","2","1","1"))
y1=c(10,11,12,13,14,15,16,17,18,19)
y2=c(10,12,12,13,14,15,15,17,18,19)
y3=c(10,12,12,14,14,15,15,17,18,19)
bbb<- data.frame(x1,x2,y1,y2,y3)
myfunc<-function(dataframe){
library(ggplot2)
dset<-dataframe
for (i in 1:ncol(dset)){
if (is.factor(dset[,i])==T){
p3<-ggplot(data=dset, aes(x=dset[,i]))
p3<-p3+geom_bar(colour='blue',fill='blue')
print(p3)
}
}
}
myfunc(dataframe=bbb)
Run Code Online (Sandbox Code Playgroud) 如何显示h3(“数值结果”)和h3(“摘要陈述”)?谢谢。
这是我的 ui.R 和 server.R。
下面是我的 ui.R 文件的代码:
library(shiny)
ui <- shinyUI(fluidPage(
titlePanel("aaaaaaaaaaaaaaaa"),
tabsetPanel(
navbarMenu("Means",
tabPanel("One Mean"),
tabPanel("Two Means",
wellPanel(
checkboxInput(inputId = "s1", label = "S1" , value = FALSE),
checkboxInput(inputId = "s2", label = "S2", value = FALSE)
),
sidebarPanel(
p(strong("Error Rates")),
numericInput("alpha", label="Alpha", min=0, max=1,value=0.05),
numericInput("power", "Power", 0.8),
actionButton("submit","Submit")
),
mainPanel(
tabsetPanel(
tabPanel("Main",
tableOutput("Table"),
verbatimTextOutput("Text")
)
)
)
)
))))
Run Code Online (Sandbox Code Playgroud)
以下是我的 server.R 文件的代码:
server <- shinyServer(function(input, output) {
output$Table <- renderTable({
if(input$submit > 0) {
h3("Numeric Results")
output<-data.frame(input$alpha,input$power) …Run Code Online (Sandbox Code Playgroud) x <- c(9, 5, 9 ,10, 13, 8, 8, 13, 18, 30)
y <- c(10, 6, 9, 8, 11, 4, 1, 3, 3, 10)
wilcox.test(y,x, paired=TRUE,correct = FALSE)
Run Code Online (Sandbox Code Playgroud)
提交这些代码时出现警告消息.如何避免wilcox.test.Thanks中的警告消息!
x<-c(0.2,0.4,0.8,2.3)
y4<-c(190.66,185.55,188.53,187.51)
par(mar=c(2.0,4.5,0.5,2.5))
plot(x,y4,type="l",xaxt="n",yaxt="n",col="navy",frame=F,lwd=2,
xlab="levels(ppm)",ylab=expression(bold(paste("HOMA-",beta,"(%)"))),font.lab=2,
xlim=c(0,2.5),ylim=c(185,195))
axis(1,at=c(0,0.5,1.0,1.5,2.0,2.5),lwd=2)
axis(2,at=c(185,190,195),lwd=2)
abline(h=190.66,lty=2)
text(2.0,192, "P for trend<0.01",cex=0.75)
Run Code Online (Sandbox Code Playgroud)
如何使轴标签中的 beta 斜体和粗体以及文本中的 P 斜体和粗体?谢谢。