【发布时间】:2014-07-03 02:20:04
【问题描述】:
如果我按下按钮的次数是偶数还是奇数,我希望这段代码能写出来?相反,什么也没有发生。
我的index.html
<html>
<head>
<script type="text/javascript" src="shared/jquery.js"></script>
<script type="text/javascript" src="shared/shiny.js"></script>
</head>
<body>
<input type="submit" name="submit" value="Press me!" class="button">
<p><div id="text" class="shiny-text-output" style="width: 150px; height: 25px; border: 1px solid black;"></div>
</body>
</html>
我的server.R
shinyServer (function (input, output, session)
{
observe ({
x = input$button;
output$text = renderText ({
if (! is.null (x))
{
if (x %% 2 == 0) {
"You are even";
}
else {
"You are odd";
}
}
})
});
})
【问题讨论】: