在学习「R shiny 基础」如何进行网页布局 时,打这段代码又双报错:
ui <- fluidPage(
titlePanel("title Panel"),
sidebarLayout(
sidebarPanel(
tags$hgroup(h1("Side Bar"), h2("Panel"))
),
mainPanel(
HTML("<p>You can add content to your Shiny app by placing it inside a <code>*Panel</code> function. For example, the apps above display a character string in each of their panels. The words “sidebar panel” appear in the sidebar panel, because we added the string to the <code>sidebarPanel</code> function, e.g. <code>sidebarPanel(\"sidebar panel\")</code>. The same is true for the text in the title panel and the main panel.</p>"),
div()
)
)
)
我就纳闷了,我过年前打的时候也没见过这么红的R啊。
解决方案:
“sidebar panel”
里面这个“”用的是中文符号……改成\"sidebar panel\"
可能是语法升级或者别的什么原因(几次报错都有显示我这个file不是UTF-8编写的,我也不知道怎么弄)
反正现在能正常显示了
将R的编码设置为UTF-8
参考这篇文章进行设置即可
补充一点,每次改了点东西记得保存了再重新run,否则会出现以下情况还不知道代码出了啥问题。