首页
学习
活动
专区
工具
TVP
发布
社区首页 >问答首页 >如何在R闪亮的文本输出中消除逗号前后的多余空格?

如何在R闪亮的文本输出中消除逗号前后的多余空格?
EN

Stack Overflow用户
提问于 2018-06-26 08:02:10
回答 2查看 346关注 0票数 0

我想知道如何摆脱我的R闪亮应用程序的文本输出中出现的额外空格。

下面是它的编码方式:

代码语言:javascript
复制
output$summary <- renderText ({
  isolate({
    paste("The power of this independent samples t-test, with population means of", 
          input$mu_1,"and", input$mu_2,
          ", standard deviations of", input$sigma_1, "and", input$sigma_2, 
          ", and sample sizes of", input$N_1, "and", input$N_2, ", is", Power)
  })
})


Power = mean(out.df$p.value < .05)

Power})

}

然而,在这款应用上,它是这样的:

这个独立样本t检验的能力是0.770562770562771,总体均值为10和13,标准差为2和5,样本量为21和27

如你所见,逗号前有多余的空格,我想知道如何去掉这些空格?我尝试过sep = "“,但这只是将所有数字捆绑在一起。不确定我是否把它放在正确的位置?

无论如何,提前谢谢你!

玛戈特

EN

回答 2

Stack Overflow用户

发布于 2018-06-26 08:10:15

使用,在文本中定义空格的sep = ""

代码语言:javascript
复制
paste("The power of this independent samples t-test, with population means of ", 
  input$mu_1," and ", input$mu_2,
  ", standard deviations of ", input$sigma_1, " and ", input$sigma_2, 
  ", and sample sizes of ", input$N_1, " and ", input$N_2, ", is ", Power, sep = "")

# [1] "The power of this independent samples t-test, with population means of 1 and 1, 
# standard deviations of 1 and 1, and sample sizes of 1 and 1, is 1"
票数 2
EN

Stack Overflow用户

发布于 2018-06-26 08:14:34

在paste函数中,sep的默认值是“”。您应该使用paste0 (没有SEP值)或在paste调用中设置sep=""

票数 1
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/51033237

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档