R markdown Stargazer: knit to pdf issue: Executed haulted - pdf-generation

While trying to knit .rmd file to pdf, if code chunks has stargazer function, the file is not knitting to pdf format. I have several tables (both long and short) with combination of regression output via stargazer in latex format but none of them are converting to pdf. I am using MikTeX as LaTeX distribution. I have used following code (as an example)
stargazer(pre.ols.sp01SIOI,pre.ols.sp02SIOI,pre.ols.sp03SIOI,pre.ols.sp04SIOI,
post.ols.sp01SIOI,post.ols.sp02SIOI,post.ols.sp03SIOI,post.ols.sp04SIOI,
style = "qje", type = "latex", header=FALSE, title = "Regression Analysis").
I am getting the following error.
This is pdfTeX, Version 3.14159265-2.6-1.40.21 (MiKTeX 2.9.7440 64-bit) entering extended mode
I was unable to find any missing LaTeX packages from the error log Paper1.v7_11Jun2020.log.
Error: LaTeX failed to compile Paper1.v7_11Jun2020.tex. See
https://yihui.org/tinytex/r/#debugging for debugging tips.
In addition: Warning messages:
1: In readLines(log) : line 888 appears to contain an embedded nul
2: In readLines(log) :
incomplete final line found on 'Paper1.v7_11Jun2020.log'
3: In readLines(log) : line 888 appears to contain an embedded nul
4: In readLines(log) :
incomplete final line found on 'Paper1.v7_11Jun2020.log'
5: In readLines(log) : line 888 appears to contain an embedded nul
6: In readLines(log) :
incomplete final line found on 'Paper1.v7_11Jun2020.log'
Execution halted
I have followed the debugging tips mentioned on the yihui.org. But still no luck.
I have also tried to assign the stargazer output and then use kable() and still
it's not working. Moreover, I have tried to using landscape style.
I appreciate any assistance with the issue.
Thanks
Edit: The YAML header
title: XXX
documentclass: article
date: "r format(Sys.Date(),'%d %B, %Y')"
output:
pdf_document:
df_print: paged
fig_caption: yes
highlight: tango
number_sections: yes
citation_package: natbib
keep_tex: yes
bibliography: library.bib
header-includes:
-\usepackage{amsmath}
-\usepackage[utf8]{inputenc}
-\usepackage{autobreak}
-\usepackage{setspace}
-\usepackage{hyperref}
-\usepackage[authoryear]{natbib}
-\usepackage{caption}
-\usepackage{babel
-\usepackage{multirow}
-\usepackage{pdflscape}
-\usepackage{dcolumn}
-\usepackage{rotating}

Related

How to read a file in utf8 encoding and output in Windows 10?

What is proper procedure to read and output utf8 encoded data in Windows 10?
My attempt to read utf8 encoded file in Windows 10 and output lines into terminal does not reproduce symbols of some languages.
OS: Windows 10
Native codepage: 437
Switched codepage: 65001
In cmd window issued command chcp 65001. Following ruby code reads utf8 encoded file and outputs lines with puts.
fname = 'hello_world.dat'
File.open(fname,'r:UTF-8') do |f|
puts f.read
end
hello_world.dat content
Afrikaans: Hello Wêreld!
Albanian: Përshendetje Botë!
Amharic: ሰላም ልዑል!
Arabic: مرحبا بالعالم!
Armenian: Բարեւ աշխարհ!
Basque: Kaixo Mundua!
Belarussian: Прывітанне Сусвет!
Bengali: ওহে বিশ্ব!
Bulgarian: Здравей свят!
Catalan: Hola món!
Chichewa: Moni Dziko Lapansi!
Chinese: 你好世界!
Croatian: Pozdrav svijete!
Czech: Ahoj světe!
Danish: Hej Verden!
Dutch: Hallo Wereld!
English: Hello World!
Estonian: Tere maailm!
Finnish: Hei maailma!
French: Bonjour monde!
Frisian: Hallo wrâld!
Georgian: გამარჯობა მსოფლიო!
German: Hallo Welt!
Greek: Γειά σου Κόσμε!
Hausa: Sannu Duniya!
Hebrew: שלום עולם!
Hindi: नमस्ते दुनिया!
Hungarian: Helló Világ!
Icelandic: Halló heimur!
Igbo: Ndewo Ụwa!
Indonesian: Halo Dunia!
Italian: Ciao mondo!
Japanese: こんにちは世界!
Kazakh: Сәлем Әлем!
Khmer: សួស្តី​ពិភពលោក!
Kyrgyz: Салам дүйнө!
Lao: ສະ​ບາຍ​ດີ​ຊາວ​ໂລກ!
Latvian: Sveika pasaule!
Lithuanian: Labas pasauli!
Luxemburgish: Moien Welt!
Macedonian: Здраво свету!
Malay: Hai dunia!
Malayalam: ഹലോ വേൾഡ്!
Mongolian: Сайн уу дэлхий!
Myanmar: မင်္ဂလာပါကမ္ဘာလောက!
Nepali: नमस्कार संसार!
Norwegian: Hei Verden!
Pashto: سلام نړی!
Persian: سلام دنیا!
Polish: Witaj świecie!
Portuguese: Olá Mundo!
Punjabi: ਸਤਿ ਸ੍ਰੀ ਅਕਾਲ ਦੁਨਿਆ!
Romanian: Salut Lume!
Russian: Привет мир!
Scots Gaelic: Hàlo a Shaoghail!
Serbian: Здраво Свете!
Sesotho: Lefatše Lumela!
Sinhala: හෙලෝ වර්ල්ඩ්!
Slovenian: Pozdravljen svet!
Spanish: ¡Hola Mundo!
Sundanese: Halo Dunya!
Swahili: Salamu Dunia!
Swedish: Hej världen!
Tajik: Салом Ҷаҳон!
Thai: สวัสดีชาวโลก!
Turkish: Selam Dünya!
Ukrainian: Привіт Світ!
Uzbek: Salom Dunyo!
Vietnamese: Chào thế giới!
Welsh: Helo Byd!
Xhosa: Molo Lizwe!
Yiddish: העלא וועלט!
Yoruba: Mo ki O Ile Aiye!
Zulu: Sawubona Mhlaba!
Steven Penny suggested to use PowerShell and do not change code page. Following picture demonstrates that the issue persists.
Windows Terminal installer (which is not a part of Windows distribution) solves utf8 output issue, please see included screen capture.
The problem is, you are using a some methods and tools that are really old. First:
Native codepage: 437
Switched codepage: 65001
You don't need to mess with the codepage any more, just leave it as the default. Also, from you picture I see you are also using Console Host, which is also really old. Windows Terminal [1] has been available since 2019, and has built in UTF-8 support. Using Windows Terminal, I can run your script, even without specifying UTF-8:
fname = 'hello_world.dat'
File.open(fname,'r') do |f|
puts f.read
end
and I get perfect result:
To use Windows Terminal, download the msixbundle file [2], then install it. Or, as it's essentially just a Zip file, you can rename it to file.zip and extract it with Windows, then run WindowsTerminal.exe. Or, since you are really having trouble with this process, you can use a portable version I just created
[3] (at your own risk).
https://github.com/microsoft/terminal
https://github.com/microsoft/terminal/releases/tag/v1.8.1444.0
https://github.com/microsoft/terminal/files/6563899/CascadiaPackage_1.8.1444.0_x64.zip

Getting error when trying to echo string to a file

I have got the below content from a JSON API. I am trying to create a Markdown file from this content using the below script.
body="**Weekly Report 28-10-2020 for ravsam-web**\r\n\r\nJekyll website of RavSam\r\n\r\n**Updations**\r\n\r\n- Added json feed blog with 110 changes\r\n- Just some minor layout changes with 43 changes\r\n- Replaced blog images path with 6 changes\r\n- Commit added support for json feed with 155 changes\r\n\r\n\r\n```\r\nsend-email ravgeetdhillon#gmail.com\r\n```\r\n\r\n<sub>Created by [Github Actions](http://github.com/ravsamhq/client-reports)</sub>\r\n"
echo $body > ravgeet.md
Whenever I execute the above script, I get this error markdown.sh: line 3: rnsend-email: command not found. Any reason why?

Latex not opening png and windows not being able to generate bb

I'm using TexMaker (on Windows 10), using the pdflatex (F6) and yet I can't open the PNG file in the folder of my .tex
\usepackage{graphicx}
\begin{document}
\begin{figure}[h!]
\includegraphics[width=\linewidth]{File.png}
\end{figure}
\end{document}
so I tried to create an bb file from the PNG. I opened cmd at the folder and typed:
ebb File.png
ebb: file not writable for security reasons: File.bb
ebb: fatal: Unable to open output file File.bb
When clicking in the properties and security of File.png I see that my user both: is the owner of the folder and has all permissions set in (even tho I cannot uncheck any of the permissions I have, weirdly).
The folder which I'm working on has that black square marked on the "read only" attribute (in properties). Which I can't quite keep unchecked even tho I'm the owner of it. What is wrong?
EDIT: Here's what happens when I click on show permissions (>properties >security >advanced >show permissions) my user is the owner.
I can't click on anything even tho I'm the owner.
Edit, the logfile:
LOG FILE :
This is pdfTeX, Version 3.14159265-2.6-1.40.21 (MiKTeX 20.10) (preloaded format=pdflatex 2020.10.24) 25 OCT 2020 10:47
entering extended mode
**./test.tex
(test.tex
LaTeX2e <2020-10-01> patch level 1
L3 programming layer <2020-10-05> xparse <2020-03-03>
("C:\Program Files\MiKTeX\tex/latex/base\article.cls"
Document Class: article 2020/04/10 v1.4m Standard LaTeX document class
("C:\Program Files\MiKTeX\tex/latex/base\size12.clo"
File: size12.clo 2020/04/10 v1.4m Standard LaTeX file (size option)
)
\c#part=\count175
\c#section=\count176
\c#subsection=\count177
\c#subsubsection=\count178
\c#paragraph=\count179
\c#subparagraph=\count180
\c#figure=\count181
\c#table=\count182
\abovecaptionskip=\skip47
\belowcaptionskip=\skip48
\bibindent=\dimen138
)
("C:\Program Files\MiKTeX\tex/latex/graphics\graphicx.sty"
Package: graphicx 2020/09/09 v1.2b Enhanced LaTeX Graphics (DPC,SPQR)
("C:\Program Files\MiKTeX\tex/latex/graphics\keyval.sty"
Package: keyval 2014/10/28 v1.15 key=value parser (DPC)
\KV#toks#=\toks15
)
("C:\Program Files\MiKTeX\tex/latex/graphics\graphics.sty"
Package: graphics 2020/08/30 v1.4c Standard LaTeX Graphics (DPC,SPQR)
("C:\Program Files\MiKTeX\tex/latex/graphics\trig.sty"
Package: trig 2016/01/03 v1.10 sin cos tan (DPC)
)
("C:\Program Files\MiKTeX\tex/latex/graphics-cfg\graphics.cfg"
File: graphics.cfg 2016/06/04 v1.11 sample graphics configuration
)
Package graphics Info: Driver file: pdftex.def on input line 105.
("C:\Program Files\MiKTeX\tex/latex/graphics-def\pdftex.def"
File: pdftex.def 2020/10/05 v1.2a Graphics/color driver for pdftex
))
\Gin#req#height=\dimen139
\Gin#req#width=\dimen140
)
("C:\Program Files\MiKTeX\tex/latex/l3backend\l3backend-pdftex.def"
File: l3backend-pdftex.def 2020-09-24 L3 backend support: PDF output (pdfTeX)
\l__kernel_color_stack_int=\count183
\l__pdf_internal_box=\box47
) (test.aux)
\openout1 = `test.aux'.
LaTeX Font Info: Checking defaults for OML/cmm/m/it on input line 3.
LaTeX Font Info: ... okay on input line 3.
LaTeX Font Info: Checking defaults for OMS/cmsy/m/n on input line 3.
LaTeX Font Info: ... okay on input line 3.
LaTeX Font Info: Checking defaults for OT1/cmr/m/n on input line 3.
LaTeX Font Info: ... okay on input line 3.
LaTeX Font Info: Checking defaults for T1/cmr/m/n on input line 3.
LaTeX Font Info: ... okay on input line 3.
LaTeX Font Info: Checking defaults for TS1/cmr/m/n on input line 3.
LaTeX Font Info: ... okay on input line 3.
LaTeX Font Info: Checking defaults for OMX/cmex/m/n on input line 3.
LaTeX Font Info: ... okay on input line 3.
LaTeX Font Info: Checking defaults for U/cmr/m/n on input line 3.
LaTeX Font Info: ... okay on input line 3.
("C:\Program Files\MiKTeX\tex/context/base/mkii\supp-pdf.mkii"
[Loading MPS to PDF converter (version 2006.09.02).]
\scratchcounter=\count184
\scratchdimen=\dimen141
\scratchbox=\box48
\nofMPsegments=\count185
\nofMParguments=\count186
\everyMPshowfont=\toks16
\MPscratchCnt=\count187
\MPscratchDim=\dimen142
\MPnumerator=\count188
\makeMPintoPDFobject=\count189
\everyMPtoPDFconversion=\toks17
) ("C:\Program Files\MiKTeX\tex/latex/epstopdf-pkg\epstopdf-base.sty"
Package: epstopdf-base 2020-01-24 v2.11 Base part for package epstopdf
Package epstopdf-base Info: Redefining graphics rule for `.eps' on input line 4
85.
)
<semirreta.png, id=1, 368.1253pt x 99.37125pt>
[1{C:/Users/JoaoV/AppData/Local/MiKTeX/pdftex/config/pdftex.map}] (test.aux) )
Here is how much of TeX's memory you used:
1167 strings out of 480236
17436 string characters out of 2890433
280939 words of memory out of 3000000
17769 multiletter control sequences out of 15000+200000
535555 words of font info for 31 fonts, out of 3000000 for 9000
1141 hyphenation exceptions out of 8191
60i,4n,66p,199b,236s stack positions out of 5000i,500n,10000p,200000b,50000s
<C:/Program Files/MiKTeX/fonts/type1/public/amsfonts/cm/cmr12.pfb><C:/Program F
iles/MiKTeX/fonts/type1/public/amsfonts/cm/cmtt12.pfb>
Output written on test.pdf (1 page, 13448 bytes).
PDF statistics:
15 PDF objects out of 1000 (max. 8388607)
0 named destinations out of 1000 (max. 500000)
6 words of extra memory for PDF output out of 10000 (max. 10000000)
I made a little test:
the real image is suposed to be these two lines: https://ibb.co/yYQCfnd
Remove the draft option, this prevents images from showing up

How to use RStudio to write a RMarkdown file with Stata commands?

My problem is explained in the title. I've tried compiling a sample .Rmd I found here: http://www.ssc.wisc.edu/~hemken/Stataworkshops/Stata%20and%20R%20Markdown/
in addition to looking up various resources online to no avail. While my resource, Doug, was able to compile an RMarkdown, I am getting an error for the MWE below.
The MWE is:
---
title: "Stata and R Markdown (Windows)"
author: "Doug Hemken"
date: "July 2015"
output:
html_document:
toc: yes
---
```{r, echo=FALSE, message=FALSE}
require(knitr)
statapath <- "/Applications/Stata/Stata.app"
opts_chunk$set(engine="stata", engine.path=statapath, comment="")
```
### Descriptive Statistics
A simple example.
```{r}
sysuse auto
summarize
```
The output/error from the RStudio console is:
processing file: stata.Rmd
|................ | 25%
ordinary text without R code
|................................ | 50%
label: unnamed-chunk-1 (with options)
List of 2
$ echo : logi FALSE
$ message: logi FALSE
Loading required package: knitr
|................................................. | 75%
ordinary text without R code
|.................................................................| 100%
label: unnamed-chunk-2
running: /Applications/Stata/Stata.app -q -b stata47b9d14e1c.do
Quitting from lines 20-22 (stata.Rmd)
Error in engine(options) :
sh: /Applications/Stata/Stata.app: is a directory
Calls: <Anonymous> ... process_group.block -> call_block -> block_exec -> in_dir -> engine
In addition: Warning message:
running command ''/Applications/Stata/Stata.app' -q -b stata47b9d14e1c.do 2>&1' had status 126
Execution halted
The page you link to points to this page. There, it is written: "For example, if Stata is installed in /Applications/Stata/, then the path to the Stata executable is /Applications/Stata/Stata.app/Contents/MacOS/", and they give appropriate links for all different flavours of Stata. Also, you need to refer to the executable, not the folder where it is located. If I change your MWE as below, everything works for me (note that I use Stata-SE; you might need to change this for your system).
---
title: "Stata and R Markdown (Windows)"
author: "Doug Hemken"
date: "July 2015"
output:
html_document:
toc: yes
---
```{r, echo=FALSE, message=FALSE}
require(knitr)
statapath <- "/Applications/Stata/StataSE.app/Contents/MacOS/stata-se"
opts_chunk$set(engine="stata", engine.path=statapath, comment="")
```
### Descriptive Statistics
A simple example.
```{r}
sysuse auto
summarize
```

read pdf document properties from terminal as seen in nautilus

From the terminal I would like to be access the data that is readable when right clicking on a pdf file and selecting "document".
Example :
I have tried reading metadata with tools such as mminfo and pdftk but some files are password protected so they can't show me the meta data.
Help appreciated.
pdfinfo reveals following information for me:
pdfinfo XY.pdf
Title: XY Zufriedenheitsbefragung XY: 2012/5
Producer: Apache FOP Version SVN branches/fop-0_95
CreationDate: Fri May 18 13:38:45 2012
Tagged: no
Pages: 8
Encrypted: no
Page size: 595 x 842 pts (A4)
File size: 33666 bytes
Optimized: no
PDF version: 1.4
but I don't know how it works on encrypted PDFs. But if nautilus can read them - why shouldn't a command line tool?
When I look for pdfinfo, I get 2 alternative answers:
apt-cache search pdfinfo
poppler-utils - PDF-Werkzeuge (basierend auf libpoppler)
xpdf-utils - Portable Document Format (PDF) suite -- utilities

Resources