小编Nic*_*ick的帖子

在 dplyr summarise() 中,我可以构建新创建的列,如何在 data.table 中执行此操作?

我是 dplyr 用户。我经常使用它的连接、管道函数、group_by 和汇总函数,但是有一天 data.table 的出现占用了我正在处理的一大数据集,并将我的计算时间减少了 87%。现在我想从 dplyr 切换到 data.table。但是,在我的代码中,我有下表:

structure(list(tariff_label = c("tv_special", "tv_special", "tv_special", 
"tv_special", "tv_special", "tv_special", "tv_special", "tv_special", 
"tv_special", "tv_special", "tv_special", "tv_special", "tv_special", 
"tv_special", "tv_special", "tv_special", "tv_special", "tv_special", 
"tv_special", "tv_special", "tv_special", "tv_special", "tv_special", 
"tv_special", "tv_special", "tv_special", "tv_special", "tv_special", 
"tv_special", "tv_special", "tv_special", "tv_special", "tv_special", 
"tv_special", "tv_special", "tv_special", "tv_special", "tv_special", 
"tv_special", "tariff", "tariff", "tariff", "tariff", "tariff", 
"tariff", "tariff", "tariff", "tariff", "tariff", "tariff", "tariff", 
"tv_special", "tv_special", "tv_special", "tv_special", "tv_special", 
"tv_special", "tv_special", "tv_special", "tv_special", "tv_special", 
"tv_special", "tv_special", "tariff", "tariff", "tariff", "tariff", 
"tariff", …
Run Code Online (Sandbox Code Playgroud)

r dplyr data.table

6
推荐指数
1
解决办法
133
查看次数

由于 reticulate_python 导致闪亮应用程序部署出现问题

我有一个应用程序想要部署在shinyapps.io 上。我认为值得注意的是,应用程序中的数据是从 athena 的数据库中提取的。我使用Rathena包连接到数据库,并且所有内容都可以从我的计算机本地正常运行。但是,我尝试将其部署到shinyapps.io 上,但收到一条消息,指出发生了错误。我只是在部署后弹出的窗口中看到了这一点。我查看了shinyapps.io 的日志部分,看到这样的消息:

警告:使用网状但未指定 python;将在 /usr/bin/python3 使用 python 您是否忘记在发布之前在 .Rprofile 中设置 RETICULATE_PYTHON 环境变量?

我从未使用过 .Rprofile,而且我不知道 RETICULATE_PYTHON 是什么意思。无论如何,他们在堆栈溢出上说谷歌是你最好的朋友。我在 Github 上找到了这个名为 Tutorial: using Shiny + reticulate to create apps with R and Python 3 的教程。我按照它所说的执行了最初的步骤,然后在最后说:

确认 .Rprofile 文件包含在您的项目目录中,并与 server.R 和 ui.R 一起部署到shinyapps.io。该文件设置 RETICULATE_PYTHON 环境变量,该变量告诉 reticulate 在shinyapps.io 服务器上的何处定位 Python 虚拟环境。

我查了一下 .Rprofile 是什么,我认为它只是一个代码脚本,但它没有告诉我应该在那里放什么代码。我想我需要提到Rathena包使用 Python 代码来连接到数据库。

我还在某处读到,我应该将此行RETICULATE_PYTHON = /usr/local/bin/python3放在我的 .Renviron 文件中。我这样做了,现在当我尝试在我的计算机上本地运行该应用程序时,我收到错误消息:

错误:未检测到 Boto3 请使用以下任一方式安装 boto3:pip install boto3 numpy在终端中或install_boto(). 如果这不起作用,请设置您正在使用的 python …

python r shiny reticulate

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

更改 Flexdashboard 中值框的高度

我正在制作一个面向列的 Flexdashboard,包含四个值框以及图表和表格。值框之前有一定的高度,但我最近更改了其中一个值框中的信息,现在所有框的高度都更大了。以下是代码查找四个值框的方式

\n
vb1<-valueBox(Parkvorgaenge_Insgesamt,"Parkvorg\xc3\xa4nge Insgesamt", icon = "fa-car", color = "warning")\nvb2<-valueBox(Parkstunden_Insgesamt,"Parkstunden Insgesamt", icon = "fa-hourglass-end", color = "warning")\nvb3<-valueBox(Einnahmen_Insgesamt,"Einnahmen Insgesamt", icon = "fa-eur", color = "warning")\nvb4<-valueBox(Durchschnittliche_Parkdauer,"Durchschnittliche Parkdauer", icon = "fa-clock", color = "warning")\n
Run Code Online (Sandbox Code Playgroud)\n
Column {data-width=350}\n-----------------------------------------------------------------------\n\n### \n\n``{r}\nrenderValueBox(vb1)\n``\n\n### \n\n``{r}\nrenderValueBox(vb2)\n\n``\n\n\n### \n\n``{r}\nrenderValueBox(vb3)\n\n``\n\n### \n\n``{r}\nrenderValueBox(vb4)\n\n``\n
Run Code Online (Sandbox Code Playgroud)\n

我尝试添加{data-height = some number}三个主题标签中的每一个(例如 ### {data-height = some number}),但这对改变高度没有任何作用。我在网上查过,但没有任何直接答案。

\n

简而言之,如何控制 Flexdashboard 中值框的高度?

\n

css r shiny flexdashboard

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

标签 统计

r ×3

shiny ×2

css ×1

data.table ×1

dplyr ×1

flexdashboard ×1

python ×1

reticulate ×1