我试图将圆环图中标签的位置移动到图表的右侧,但我无法做到。我正在使用 ggplot 和 ggrepel 来制作图表。
library(ggplot2)
library(ggrepel)
expenditurePie = data.frame(
value = c(98,2),
area = c("A","B"),
label = c("","This is a label"))
ggplot(expenditurePie, aes(y=value, fill = area, label = label)) +
geom_bar(aes(x = 4), stat = "identity", show.legend = F) +
geom_text_repel(size = 5, x= 4, point.padding = unit(1.8, "lines"), direction = "x") +
xlim(0.5, 4.5) +
annotate(geom = "text", x=0.5, y=0, label = "24 444", size = 16, color = "grey") +
scale_fill_manual(values = c(A = "grey", B = …Run Code Online (Sandbox Code Playgroud) 我正在尝试学习如何使用 Shiny 创建问卷。我需要每个问题都在一个新页面上。例如,当用户回答一个问题时,按下“下一步”按钮,一个新页面会加载另一个问题。关于如何做到这一点的任何想法?因为我想简化我的代码,所以我为每个问题创建了一个模块。该ui是这样的:
library(shiny)
fluidPage(
div(class = 'container',
div(class = 'col-sm-2'),
div(class = 'col-sm-8',
h1("Welcome!"),
p("Lorem ipsum dolor sit amet, consectetur adipiscing elit. "),
br(),
actionButton("page1", "Start")
)),
source("questions/question1.R", local = TRUE)$value,
source("questions/question2.R", local = TRUE)$value
)
Run Code Online (Sandbox Code Playgroud)
模块问题 1:
div(class = 'container',
div(class = 'col-sm-2'),
div(class = 'col-sm-8',
radioButtons("question1", "Please select a number: ", choices = c(10,20,30)),
actionButton("page3", "Next"),
br()
)
)
Run Code Online (Sandbox Code Playgroud)
模块问题 2:
div(class = 'container',
div(class = 'col-sm-2'),
div(class = 'col-sm-8',
radioButtons("question2", "Please select a color: …Run Code Online (Sandbox Code Playgroud) 我有一个数据框列表,其中一些数据框的列较少。参见示例:
a <- data.frame (x1 = 1, x3 = 2, x4 = 7)
b <- data.frame (x1 = 3, x2 = 4, x3 = 3, x4 = 8)
c <- data.frame (x1 = 9, x2 = 5, x3 = 2, x4 = 9)
myList = list(a, b, c)
Run Code Online (Sandbox Code Playgroud)
数据帧a未命中列x2。我需要myList之外的数据框,因此我需要执行以下操作:
mydf = do.call(rbind, myList)
Run Code Online (Sandbox Code Playgroud)
但是问题是我得到以下错误:
Error in rbind(deparse.level, ...) :
numbers of columns of arguments do not match
Run Code Online (Sandbox Code Playgroud)
我怎样才能得到其中列数据帧x2进行a填充NA?
我正在尝试使用官员更改段落的字体大小,但我无法做到。谁能告诉我我做错了什么?
library(officer)
text_style <- fp_text(font.size = 12)
my_doc <- read_docx()
body_add_par(my_doc,"This is a test", style = text_style)
print(my_doc, target = "dummy.docx")
Run Code Online (Sandbox Code Playgroud)