在 Shinyapps.io 上运行带有多个文件夹的闪亮应用程序。该应用程序有一个从 S3 中提取数据的函数(使用一个包装器get_bucket()),当我在我的项目 .Renviron 文件中设置 AWS 秘密和凭证时,它在本地工作正常,但一旦推送,我就会收到 HTTP 403 错误:
Error in value[[3L]](cond) : Forbidden (HTTP 403).
Calls: local ... tryCatch -> tryCatchList -> tryCatchOne -> <Anonymous>
Execution halted
Run Code Online (Sandbox Code Playgroud)
我尝试过的事情:
get_bucket()调用中包含 aws 密钥、秘密和区域sys.setenv()我对这个完全没有想法。它源于一个更广泛的问题,即如何在 Shinyapps.io 应用程序中设置 .Renviron 变量。我读过的内容说要添加到主文件夹或其他选项,但正如我上面所说的那样没有用。
我正在阅读数据,shiny::reactivePoll()但不知道这是怎么回事。
感谢您的帮助,这几天一直被困在这个问题上。
我正在一个项目中,将PDF扫描将打字机写的《战争日记》笔记转换为文本。我可以成功提取(可能是90%的原始未调整大小的文件)提取主文本,然后我首先进行裁剪。
Reprex数据:您可以从图片开始或从下面提供的文字开始尝试。
我的挑战是保持文本的“每日”结构,该结构每天有7个段落或节,并且用“ \ n”或“ \ n \ n”进行拆分并不完全正确。
我正在为项目使用pdftools / stringr / tesseract / magick的组合:
library(tesseract)
library(dplyr)
library(stringr)
library(pdftools)
library(readr)
library(magick)
Run Code Online (Sandbox Code Playgroud)
使用方法:
image <- image_read("./test-data/page_1.png") #change to your path
text -> image %>%
image_crop(geometry_area(width = 1220, height = 900,
y_off = 260, x_off = 355)) %>%
image_resize("2000x") %>%
image_convert(type = 'Grayscale') %>%
image_trim(fuzz = 40) %>%
image_write(format = 'png', density = '300x300') %>%
tesseract::ocr()
Run Code Online (Sandbox Code Playgroud)
给出一个字符串:
[1] "Weather clear all day. A smaii arms inspection hela at i400 hrs. A …Run Code Online (Sandbox Code Playgroud) 我不确定我在这里是否有正确的方法,我一整天都在寻找一种方法来做到这一点,没有一个文档的说明足够明确。
我想使用如下所示的模板样式:
我有 .sty 文件。我尝试在 rmarkdown 中连接该文件,标题如下:
---
title: "title"
author: "author"
date: "`r format(Sys.time(), '%d %B, %Y')`"
mainfont: Arial
output:
pdf_document:
latex_engine: xelatex
includes:
template: analysis_orax.sty
---
Run Code Online (Sandbox Code Playgroud)
然而,这并没有添加样式。如果我添加 .tex 文件,它会添加所有正文文本,这不是我想要的。
我不太喜欢使用 .tex 或 .sty;我想要的只是有一个格式良好的 .pdf 报告!
.sty:
\usepackage{titlesec}
\usepackage{tikz}
\usepackage{fontspec}
\usepackage{xcolor}
\usepackage[left=4cm,right=2.5cm,top=2.5cm,bottom=2cm]{geometry}
\usepackage{fancyhdr}
%------------------Main Font-------------------------
\setmainfont{Fira Sans}
%Make sure you have the compiler "XeLaTeX" activated on your settings for your LaTeX document in order to see the font
%------------------Color Set--------------------------
\definecolor{LightBlue}{RGB}{66, 163, 251}
\definecolor{DarkBlue}{RGB}{36, 100, 176}
\definecolor{LightGray}{gray}{.94}
\definecolor{DarkGray}{gray}{.172}
\definecolor{Orange}{RGB}{229, …Run Code Online (Sandbox Code Playgroud) 我的目标是像这样的着色,但只填充到最大级别(例如填充停止在当前级别):
创建此数据的数据是:
df <- tribble(~Question_Code, ~RespondentLevel,
"Engagement - Inclusion", 5,
"External engagement - policies", 2,
"External engagement - technology", 5,
"Community data ", 5,
"Internal engagement", 5,
"Internal use of technology", 4,
"Familiarity/Alignment", 5,
"Environmental impacts", 5,
"Innovation", 2,
"Use of open-source technology", 2,
"Regulation of hardware & software", 5,
"In-house technical capacity", 5,
"Infrastructure procurement", 5,
"Algorithmic Error & Bias", 2,
"Control: Privacy", 5,
"Accountability in Governance Structures", 3,
"Open procurement", 5,
"Use in decision-making", 1,
"Accountability", 1, …Run Code Online (Sandbox Code Playgroud)