Rmarkdown won't compile to html or pdf - r

I have a problem when compiling my rmarkdown to html. When I compile i receive the next message:
[WARNING] This document format requires a nonempty <title> element.
Please specify either 'title' or 'pagetitle' in the metadata,
e.g. by using --metadata pagetitle="..." on the command line.
Falling back to '1570037.knit'
Output created: 1570037.html
Warning messages:
1: In readLines(con, warn = FALSE) :
entrada inválida encontrada en la conexión de entrada '1570037.Rmd'
2: In xfun::read_utf8(input) :
The file 1570037.Rmd is not encoded in UTF-8. These lines contain invalid UTF-8 characters: 2, 3, 29, 91, 92, 95, ...
3: In readLines(con, warn = FALSE) :
entrada inválida encontrada en la conexión de entrada '1570037.knit.md'
4: In readLines(con, warn = FALSE) :
entrada inválida encontrada en la conexión de entrada '1570037.knit.md'
And I cant compile the script. Does someone know how to fix this?

First, try to set the header like this:
---
title: "Your Title"
output: html_document
---
Then, try to render the file in your R console like this:
rmarkdown::render('your_file.Rmd', encoding='UTF-8')

Related

Reading a vcf.bgz file in R

I downloaded some data from gnomad - https://gnomad.broadinstitute.org/downloads. it comes in the form of VCF.bgz file and I would like to read it as a vcf file.
i wrote some code:
install.packages("R.utils")
library("R.utils")
df=gunzip("gnomad.exomes.r2.1.1.sites.4.vcf.bgz", "gnomad.exomes.r2.1.1.sites.4.vcf")
install.packages("vcfR")
library("vcfR")
vc=read.vcfR("gnomad.exomes.r2.1.1.sites.4.vcf.bgz")
but it doesn't work -- it doesn't convert it to appropriate VCF file.
Warning message:
In file.remove(filename) :
cannot remove file 'gnomad.exomes.r2.1.1.sites.4.vcf.bgz', reason 'Permission denied'
Error in read.vcfR(df) :
File: gnomad.exomes.r2.1.1.sites.4.vcf does not appear to be a VCF file.
First line of file:
gnomad.exomes.r2.1.1.sites.4.vcf
Should begin with:
##fileformat=VCFv
In addition: Warning message:
In scan(file = file, what = character(), nmax = 1, sep = "\n", quiet = TRUE, :
embedded nul(s) found in input
would appreciate any help, thank you:)

Encoding issue with Shiny App and RStudio

I am having a problem at the time of publishing a Shiny app created in RStudio. Locally it works great, but at the time of publishing, i am getting the following error:
Preparing to deploy application...DONE
Uploading bundle for application: 6271509...Detecting system locale ... DONE
Deploying bundle: 5891038 for application: 6271509 ...
Waiting for task: 1150562680
building: Building image: 6880241
building: Installing packages
building: Installing files
building: Pushing image: 6880241
deploying: Starting instances
success: Stopping old instances
Application successfully deployed to https://victuol.shinyapps.io/CorresponsalesSingleApp/
Deployment completed: https://victuol.shinyapps.io/CorresponsalesSingleApp/
Warning message:
Error detecting locale: Error in read.table(file = file, header = header, sep = sep, quote = quote, : incomplete final line found by readTableHeader on 'raw'
(Using default: en_US)
The following is my working code:
library(shiny)
library(DT)
setwd("C:/Users/Usuario/Desktop/Proyecto Shiny Corresponsales")
library("openxlsx")
df<-read.xlsx("Base Datos Corresponsales Bancolombia LIMPIO Hoja 3.xlsx", sheet = 3,colNames = TRUE,cols=c(1,2,3,4,5,6))
ui <- basicPage(
tags$a(
href="https://lotopunto.negocio.site/",
tags$img(src = "Logo Loto Punto PNG.png", height = 260, width = 320, title = "Loto Punto Corresponsal Bancario")
),
h2(strong("Paga, Juega y Recarga. ¡Todo aquí!")),
h1("Mapa de Corresponsales Bancarios Bancolombia"),
h3("Digita en la celda 'Search', la ciudad donde estás ubicado.
Se desplegarán los Corresponsales Bancarios Bancolombia disponibles"),
DT::dataTableOutput("mytable")
)
server <- function(input, output) {
output$mytable = DT::renderDataTable({
df
})
}
# Run the application
shinyApp(ui, server)
I am using an excel table, which have characters in Spanish (e.g. "'"). Might this be the problem? How can this be fixed? Please provide an example of the solution.
Solved! All i had to do was to eliminate the following line:
setwd("C:/Users/Usuario/Desktop/Proyecto Shiny Corresponsales")
I tried this solution, written at this post: https://groups.google.com/g/shinyapps-users/c/Fuh74H78G4s

How to prevent for hyphenated words in pdf output with Rmarkdown?

I'm working with Rmarkdown and my output is a pdf document. When reading the pdf, I noticed that so many words are printed incomplete (hyphenated) such as "ar- rojan" and "progra- mación" (which should be "arrojan" and "programación").
Note: My words are complete in my Rmd file
This is how text appears in the pdf output:
Los operadores <, >, <=, >=, == y != se denominan “lógicos” o “booleanos” porque nos ar­-
rojan como resultado TRUE si se cumple la condición o comparación o FALSE en caso contrario.
Sin embargo, R, al igual que la mayoría de los lenguajes de progra­-
mación distingue entre mayúsculas y minúsculas (“case sensitive”),
Based on my little experience with Rmarkdown, I guess in the YAML section I must include some option to prevent that kind of behaviour. (What I need is something like the Microsoft Word function "Justify"). I found that ragged2e should help in this kind of situations so I included it in my YAML and then I use the \justify command before my text as follows:
---
title: "--"
author: ""
date: "Abril 2020"
output:
pdf_document:
latex_engine: xelatex
html_document:
df_print: paged
mainfont: Times New Roman
header-includes:
- \usepackage{titling}
- \pretitle{\begin{flushleft}\huge\bfseries}
- \posttitle{\end{flushleft}}
- \preauthor{\begin{flushleft}\Large}
- \postauthor{\end{flushleft}}
- \predate{\begin{flushleft}\large}
- \postdate{\end{flushleft}}
- \usepackage[document]{ragged2e}
fontsize: 12pt
urlcolor: blue
linestretch: 1.15
---
\justify
Rest of the document
My problem is that this is not printing my output as expected so I appreciate any suggestion or comment.

Unable to deploy my Shiny App with shinyapps.io

Thanks in advance for your support about the following issue. I want to deploy my shiny app on shinyapps.io.
It runs perfectly using R-Studio, but when I'm trying to use shinyapps.io it returns a lot of erros that I can't fix at all. I'm using the next documents:
abrev_mes.csv
app.R
BDD_SIAF_2014_122019_02012020.sav
catalogo_cantones.xlsx
catalogo_delitos.xlsx
catalogo_region.xlsx
mes20142041.xlsx
trimestre20142041.xlsx
They are located at the root with no subdirectory folders whatsoever.
Can somebody help me with this issue? I don't know what else should I present to you in order to understand what the issue could be. The following are the errors that shinyapps.io returns:
An error has occurred
The application failed to start (exited with code 1).
Warning in readLines(file, warn = FALSE) :
entrada inválida encontrada en la conexión de entrada '/srv/connect/apps/dashboard-fiscalia/app.R'
Error in parse(file, keep.source = FALSE, srcfile = src, encoding = enc) :
carácter multibyte inválido en la linea 122
Possible missing comma at:
443: for (i in 1:which(grepl(input$periodo_x, vfecha_anio))) {
^
Possible missing comma at:
443: for (i in 1:which(grepl(input$periodo_x, vfecha_anio))) {
^
Possible missing comma at:
589: for (i in 1:15) {
^
Possible missing comma at:
589: for (i in 1:15) {
^
Possible missing comma at:
685: for (i in 1:15) {
^
Possible missing comma at:
685: for (i in 1:15) {
^
Possible missing comma at:
848: } else if (req(input$periodo_tipo_st)== "Trimestral") {
^
Possible missing comma at:
900: for (i in 1:15) {
^
Possible missing comma at:
900: for (i in 1:15) {
^
Error in value[[3L]](cond) :
invalid multibyte string at '<fa>mero <64>e denuncias" = n,'
Calls: local ... tryCatch -> tryCatchList -> tryCatchOne -> <Anonymous>
Ejecución interrumpida

Garbled utf-8 QString when reading network reply

I am building a BlackBerry 10 application and I am using the QT libraries. However I got some character encoding issues and I was wondering if you might have a clue as how to solve this.
I have the following data that gets send to me via a web service.
{"title":"Seconde Guerre mondiale - Wikipédia","content":"Théâtre européen L’Europe au 1er septembre 1939 Après s’être assuré de ne pas risquer une guerre avec l’URSS en signant le Pacte germano-soviétique, Hitler lance ses armées sur la Pologne, l...","favicon":"http://fr.m.wikipedia.org//bits.wikimedia.org/favicon/wikipedia.ico"}
If I wireshark it, the raw data is:
[truncated] {"title":"Seconde Guerre mondiale - Wikip\303\251dia","content":"Th\303\251\303\242tre
However when I parse this using the following code:
void WebpageFetcher::onPageRequestFinished(QNetworkReply* networkReply)
{
qDebug() << "WebpageFetcher:: onPageRequestFinished";
QByteArray content = networkReply->readAll();
qDebug() << QString::fromUtf8(content.data(), content.size());
}
I get this result:
"{"title":"Seconde Guerre mondiale - Wikipédia","content":"Théâtre européen L’Europe au 1er septembre 1939 Après s’être assuré de ne pas risquer une guerre avec l’URSS en signant le Pacte germano-soviétique, Hitler lance ses armées sur la Pologne, l...","favicon":"http://fr.m.wikipedia.org//bits.wikimedia.org/favicon/wikipedia.ico"}"
Not exactly what I am looking for. Does anyone have a clue? My browsers seem to be able to interpret the characters in this JSON reply perfectly.

Resources