小编sch*_*sie的帖子

托管和设置自己的闪亮应用程序,没有闪亮的服务器

我正在尝试为我的同事提供闪亮的应用程序,而无需他们运行甚至安装R.

所以我看了这个网页 ,发现这句话:

如果您熟悉Web托管或可以访问IT部门,则可以自己托管您的Shiny应用程序.

在" 共享为网页 "部分下.

我怎样才能做到这一点?

问题是我的公司必然会受到关于网络托管和安全等的某些限制,并且不会(现在)支付闪亮的服务器专业版.

但上面的句子让我希望自己设置一些东西来说服他们.

web-hosting r shiny shiny-server

83
推荐指数
4
解决办法
3万
查看次数

如何在ggplot2中使用x轴上的月份名称

我试图使用x在x轴上绘制月份ggplot2,但月份名称会自动显示为带小数的数字.我怎么能强制脚本绘制数字的月份名称?我用过这段代码:

ggplot(df3, aes(x = month, y = PM)) + 
geom_line(aes(col = factor(travel))) + 
xlab("Month") + 
ylab(expression(paste("PM(",mu,"g/", m^3,")", sep=""))) 
Run Code Online (Sandbox Code Playgroud)

数据如下:

df3 <- structure(list(month = c(9, 10, 9, 10, 1, 2, 3, 4, 5, 9, 10, 
                            1, 2, 3, 4, 5, 9, 10, 11, 12, 1, 2, 3, 4, 5, 11), 
                  travel = c("Diesel bus", 
                             "Diesel bus", "Diesel bus", "Diesel bus", "Diesel bus", "Diesel car", 
                             "Diesel car", "Diesel car", "Diesel car", "Diesel car", "Bicycle", 
                             "Bicycle", "Bicycle", "Bicycle", "Bicycle", "Gasoline car", …
Run Code Online (Sandbox Code Playgroud)

plot r ggplot2

7
推荐指数
2
解决办法
4091
查看次数

R多重图中的dygraph同时出现

我想使用dygraph一次绘制多个图(它们不必在第一步中同步)

基础R-例子:

temperature <- ts(frequency = 12, start = c(1980, 1),
       data = c(7.0, 6.9, 9.5, 14.5, 18.2, 21.5, 
       25.2, 26.5, 23.3, 18.3, 13.9, 9.6))
rainfall <- ts(frequency = 12, start = c(1980, 1),
       data = c(49.9, 71.5, 106.4, 129.2, 144.0, 176.0, 
       135.6, 148.5, 216.4, 194.1, 95.6, 54.4))

par(mfrow = c(2, 1))
plot(temperature)
plot(rainfall)
Run Code Online (Sandbox Code Playgroud)

使用dygraph这种方法不起作用

require(dygraphs)
par(mfrow = c(2, 1))
dygraph(temperature)
dygraph(rainfall)
Run Code Online (Sandbox Code Playgroud)

我知道有可能显示第二轴等.但也许有人知道一次显示两个图的答案

plot r time-series dygraphs

7
推荐指数
1
解决办法
3458
查看次数

多项式混合logit模型mlogit r-package

我发现了mlogit- 多项logit模型的包,用于寻找多项式混合logit模型.在阅读了优秀的插图后,我发现我无法在任何描述的示例中应用我的数据.

我现在写信希望对我的问题有所帮助,并创建了一个简单的例子来说明我的情况.

问题如下:在某处有辅音'Q'的单词.现在,我们进行了一项实验,他们的任务是听取这些话,并说他们是否听过Q,U或其他辅音.这必须依赖于诸如音节位置或真实/非真实单词之类的一些因素来建模.

在最小的例子中,我用音节位置创建了4个人和他们的答案.

library(mlogit)
library(nnet)
set.seed(1234)
data <- data.frame(personID = as.factor(sample(1:4, 40, replace=TRUE)),
               decision = as.factor(sample(c("Q","U", "other"), 40, replace=TRUE)),
               syllable = as.factor(sample(1:4, 40, replace=TRUE)))
summary(data)
 personID  decision  syllable
 1:11     other:10   1:18    
 2:10     Q    :18   2: 9    
 3:10     U    :12   3: 5    
 4: 9                4: 8 
Run Code Online (Sandbox Code Playgroud)

据我所知nnet,multinom功能不包括混合型号.

modNnet1 <- multinom(decision ~ syllable, data=data)
Run Code Online (Sandbox Code Playgroud)

首先,我使用mlogit.data-function来重塑文件.在与同事讨论后,我们得出结论,没有替代品.特定.变量.

 dataMod <- mlogit.data(data, shape="wide", choice="decision", id.var="personID")

 mod1 <- mlogit(formula = decision ~ 0|syllable,
           data = …
Run Code Online (Sandbox Code Playgroud)

r mixed-models multinomial mlogit

5
推荐指数
1
解决办法
5211
查看次数

ggplot2和chron barplot的时间数据scale_x_chron

我有很多次,想要在一个条形图中绘制每次的频率

library(ggplot2)
library(chron)
test <- data.frame(times = c(rep("7:00:00",4), rep("8:00:00",3), 
                         rep("12:00:00",1), rep("13:00:00",5)))
test$times <- times(test$times)
test
      times
1  07:00:00
2  07:00:00
3  07:00:00
4  07:00:00
5  08:00:00
6  08:00:00
7  08:00:00
8  12:00:00
9  13:00:00
10 13:00:00
11 13:00:00
12 13:00:00
13 13:00:00
Run Code Online (Sandbox Code Playgroud)

binwidth选择值代表分钟

p <- ggplot(test, aes(x = times)) + geom_bar(binwidth=1/24/60)
p + scale_x_chron(format="%H:%M")
Run Code Online (Sandbox Code Playgroud)

如您所见,x轴上的刻度加一小时:

在此输入图像描述

我觉得这与时区有关,但我真的不能这样做:

Sys.timezone()
[1] "CET"
Run Code Online (Sandbox Code Playgroud)

编辑:感谢@shadow的评论

更新:

如果我先跑,Sys.setenv(TZ='GMT')它会很完美.问题在于times()功能.我自动设置时区GMT,如果我正在绘制x轴,ggplot会注意到我的系统时区是CET并且在绘图上增加了一个小时.现在如果我将我的系统时区设置为GMT,ggplot不会增加一小时.

time r ggplot2 chron

5
推荐指数
1
解决办法
2019
查看次数

Plotly subplot有两个ggplots和常见的传说?

我正在尝试将两个ggplot对象转换为一个绘图对象,并使用一个常见的图例.但传说在某种程度上翻了一番:

在此输入图像描述

df1 <- read.table(text = "group   x     y   
              group1 -0.212201  0.358867
              group2 -0.279756 -0.126194
              group3  0.186860 -0.203273
              group4  0.417117 -0.002592
              group1 -0.212201  0.358867
              group2 -0.279756 -0.126194
              group3  0.186860 -0.203273
              group4  0.186860 -0.203273", header = TRUE)

df2 <- read.table(text = "group   x     y   
              group1  0.211826 -0.306214
              group2 -0.072626  0.104988
              group3 -0.072626  0.104988
              group4 -0.072626  0.104988
              group1  0.211826 -0.306214
              group2 -0.072626  0.104988
              group3 -0.072626  0.104988
              group4 -0.072626  0.104988", header = TRUE)
library(dplyr)
library(ggplot2)
library(plotly)

p1 <- ggplot(df1, aes(x = x, y = …
Run Code Online (Sandbox Code Playgroud)

plot r ggplot2 plotly

3
推荐指数
1
解决办法
738
查看次数

将字符转换为R中的lowerCamelCase

我有字符向量,看起来像这样:

x <- c("cult", "brother sister relationship", "word title")
Run Code Online (Sandbox Code Playgroud)

我想将它转换为如下所示的lowerCamelCase样式:

c("cult", "brotherSisterRelationship", "wordTitle")
Run Code Online (Sandbox Code Playgroud)

我打得四处gsub,gregexpr,strplit,regmatches等众多功能,但无法获得抓地力.

特别是角色中的两个空格似乎难以处理.

也许这里有人知道如何做到这一点.

regex r character gsub

2
推荐指数
2
解决办法
103
查看次数