我有一个非常大的data.frame并希望对每列中的值求和.
所以我使用了以下代码:
sum(production[,4],na.rm=TRUE)
Run Code Online (Sandbox Code Playgroud)
要么
sum(production$X1961,na.rm=TRUE)
Run Code Online (Sandbox Code Playgroud)
问题是data.frame非常大.而且我只想将40个特定列与我的data.frame的不同名称相加.而且我不想列出每一列.有更聪明的解决方案吗?
最后,我还想将新列的总和存储在新的data.frame中.
提前致谢!
我有一个数组,并且想要构建一个循环,该循环从数组的第一个值开始平均每秒的值,并且在第一轮之后循环应该以数组的第二个值开始.
例如:
3,6,18,10,2
Run Code Online (Sandbox Code Playgroud)
结果应该是:
7.666,8,10
for 7.6666= (3+18+2)/3
for 8= (6+10)/2
for 10=(18+2)/2
Run Code Online (Sandbox Code Playgroud)
提前致谢
是否可以仅在条件满足时显示绘图并在条件满足时隐藏其他绘图?
我尝试过conditionalPanel().如果条件满足,它可以工作并显示情节,但它也显示其他两个图.我想显示coolPlot并且coolPlot_2仅当所选输入是
"X1_P" "X2_S" "X3_W" "X4_S" "X5_P" "X6_P" "X7_P"
"X8_S" "X9_P" "X10_P" "X11_P" "X12_I"
Run Code Online (Sandbox Code Playgroud)
并且coolPlot_3必须仅在"X13_K"选中时显示,并且应隐藏其他两个面板.我使用了以下代码.
ui = fluidPage(
titlePanel("Data Visualization"),
sidebarLayout(
sidebarPanel(
uiOutput("variableOutput"),
uiOutput("text1Output")
),
mainPanel(
conditionalPanel(
condition = "input.variableOutput != 'X13_K'",
plotOutput("coolPlot")),
br(),
br(),
conditionalPanel(
condition = "input.variableOutput != 'X13_K'",
plotOutput("coolPlot_2")),
conditionalPanel(
condition = "input.variableOutput == 'X13_K'",
plotOutput("coolPlot_3")),
br(),
br(),
dataTableOutput(
"coolTable"
)
)
)
)
Run Code Online (Sandbox Code Playgroud)
正如尼斯所建议的那样,我也在发布服务器代码.
server = function(input,output){
output$variableOutput = renderUI({
selectInput("VariableInput",
"Variable auswählen",
choices = colnames(training)[-1] …Run Code Online (Sandbox Code Playgroud) 我有一个三维数组,想要总结每个维度的值,最后得到一个数据矩阵.
这是一个例子:
array1 <- array(c(-5.5,6,3),dim = c(3,4,3))
matrix <- matrix(NA, nrow=3, ncol=4)
matrix
[,1] [,2] [,3] [,4]
[1,] -16.5 -16.5 -16.5 -16.5
[2,] 18 18 18 18
[3,] 9 9 9 9
Run Code Online (Sandbox Code Playgroud)
有可能以某种方式使用循环而不是使用任何应用函数吗?
提前致谢!
给出了以下数据集(实际上更多情况):
data_test = data.frame(ID = c ("1","2","3","4","5"),
product = c("A","B","C","A","C"),
milieu = c("good","medium","bad","medium","bad"),
online = c(1,0,1,1,0),
ooh = c(0,1,0,1,1),
event = c(1,1,0,0,0))
Run Code Online (Sandbox Code Playgroud)
现在我想建立一个闪亮的应用程序,有人可以选择一个环境,让我们说"好"和一个产品"A",所有在线的"1"和具有这些设置的数据表都会被给出.在示例ID 1中.
我尝试了以下内容
用户界面:
shinyUI(fluidPage(
titlePanel("product milieu"),
sidebarLayout(
sidebarPanel("select",
selectInput("select_milieu",
label = "Milieu",
choices = list("good",
"medium",
"bad")
),
selectInput("select_product",
label = "Product",
choices = list("A",
"B",
"C")
),
selectInput("select_online",
label = "Online",
choices = list(1,
0)
),
selectInput("select_ooh",
label = "ooh",
choices = list(1,
0)
),
selectInput("select_Event",
label = "Event",
choices = list(1,
0)
)
),
mainPanel("My …Run Code Online (Sandbox Code Playgroud) 我有一张桌子,想要执行以下操作where.我想选择所有行NUM_ORDERS = 1所在的CHANNEL_ID in (1,2,3,4)行NUM_ORDERS > 1以及所有行where 和CHANNEL_ID in (1,2,3).我如何结合这两个条件?
感谢帮助.