R Doesn't Recognize Pandoc Linux Mint

R doesn't recognize Pandoc Linux Mint

I was having issues with this as well. I installed pandoc via cabal as well. If you install via apt-get there shouldn't be an issue. If I launched R from a terminal I had no issues but attempting to detect pandoc from within RStudio gave some troubles. The reason is that RStudio doesn't read in your bash environment variables so if you modify the path in .bashrc RStudio won't detect that. A solution is to modify the path via .profile instead.

Add this to the bottom of your .profile file and remove the path modfication in your .bashrc file and you should be able to recognize pandoc from within R.

if [ -d "$HOME/.cabal/bin" ] ; then
PATH="$PATH:$HOME/.cabal/bin"
fi

Running R with Linux Mint

Mint is basing on Ubuntu. Using option 4 will be fine.

You can check on this page http://www.linuxmint.com/about.php

  • Based on Debian and Ubuntu, it provides about 30,000 packages and one
    of the best software managers.

Actually, it uses basic apt repositories from Ubuntu. Using apt to install the packages is fine, as mentioned by jms.

check if a program is installed

This suggestion is based entirely on my personal experience with this question that RStudio can't seem to read what's in my .bashrc file on my Ubuntu system. I have installed Pandoc using the cabal install pandoc method described here since there were features I needed from more recent versions of Pandoc than were available with Ubuntu's package manager. Running R from the terminal could detect Pandoc as expected using Sys.which, but when using RStudio, it could not. I have no idea if this is a problem with Windows users or not though!

One alternative/workaround in this case is actually creating a vector of typical paths where you expect the Pandoc executable to be found (under the presumption that many users don't really futz around with where they install programs). This info is, again, available at the install page linked above, plus the typical C:\\PROGRA~1\\... path for Windows. Thus, you might have something like the following as the paths to Pandoc:

myPaths <- c("pandoc", 
"~/.cabal/bin/pandoc",
"~/Library/Haskell/bin/pandoc",
"C:\\PROGRA~1\\Pandoc\\bin\\pandoc")
# Maybe a .exe is required for that last one?
# Don't think so, but not a regular Windows user

Which you can use with Sys.which() (for example, Sys.which(myPaths)) and some of the other ideas already shared.

  • If the first option is uniquely matched, then there's no problem: you can use system calls to Pandoc directly.
  • If any of the other options are uniquely matched, you can write your functions in such a way that you paste in the full path to the executable in your system call instead of just "pandoc".
  • If the first option and any of the other options are matched, then you can just select the first option and proceed.
  • If none are matched, prompt the user for the path to their Pandoc installation or provide a message on how to install Pandoc.

Where is pandoc installed on Windows?

Location for Pandoc - C:\Users\YourUserName\AppData\Local\Pandoc

Scanner doesn't work anymore after upgrading to Linux Mint 18

I finally found the solution. I post it here if it can help someone.

With versions prior to Linux Mint 18, the Epson driver was necessary to make the scanner work but it's not the case anymore (supported out of the box).

For this, we need to remove the deb package for this driver: packages isane*.

After having removed them, execute the following command:

$ sudo sane-find-scanner

# sane-find-scanner will now attempt to detect your scanner. If the
# result is different from what you expected, first make sure your
# scanner is powered up and properly connected to your computer.

# No SCSI scanners found. If you expected something different, make sure that
# you have loaded a kernel SCSI driver for your SCSI adapter.

could not fetch string descriptor: Pipe error
could not fetch string descriptor: Pipe error
found USB scanner (vendor=0x04b8, product=0x0884) at libusb:002:010
# Your USB scanner was (probably) detected. It may or may not be supported by
# SANE. Try scanimage -L and read the backend's manpage.

# Not checking for parallel port scanners.

# Most Scanners connected to the parallel port or other proprietary ports
# can't be detected by this program.

After that, I can see my scanner in the list with the command scanimage -L:

$ scanimage -L
device `epson2:libusb:002:010' is a Epson PID 0884 flatbed scanner

We can then use again the scanner using XSane!

Platform neutral way to check if a program exists (e.g. pdfcrop) while creating vignette

R has a function Sys.which() for just this purpose. It is, in the words of its help page, "an interface to the system command ‘which’, or to an emulation on Windows".

Here's what a call to it looks like on my own Windows machine:

Sys.which("pdfcrop")
# pdfcrop
# "C:\\PROGRA~2\\MIKTEX~1.9\\miktex\\bin\\pdfcrop.exe"

To test whether an executable exists, you could do something like this:

Sys.which("pdfcrop") != ""
# pdfcrop
# TRUE

Sys.which("pdfpop") != ""
# pdfpop
# FALSE

Compile CMU PocketSphynx at Linux Mint 13

To recognize from microphone

pocketsphinx_continuous

To recognize a file (16khz mono 16bit)

pocketsphinx_continuous -infile file.wav

To create /dev/dsp you need to load kernel driver for oss

modprobe snd_pcm_oss

Development libs are for development, not for /dev/dsp. After you installed development libraries, you need to recompile and reinstall sphinxbase. It will detect development libraries and use alsa instead of oss.

Authors and affiliations in the YAML of RMarkdown

There is, to the best of my knowledge, no one-size-fits-it-all solution as of now.

If the target was only PDF, I'd suggest rticles by RStudio. It's great.

A solution which also works with docx is more difficult. One possibility is to use pandoc Lua filters. The repository collecting useful filters contains two filters which will help you: scholarly-metadata and author-info-blocks. (Disclosure: I wrote these.)

Place the .lua files in your directory, change the YAML structure a bit, and instruct pandoc to run the filters:

---
title: "My title"
author:
- Mario Modesto-Mata:
email: paleomariomm@gmail.com
institute: [astro, med]
correspondence: true
- name: Christopher
institute: astro
- name: Seaghán Mhartain
institute: med
- name: Rita Yuri Ynoue
institute: astro
institute:
- astro: Instituto de Astronomía, Geofísica e Ciências Atmosféricas, Universidade de São Paulo
- med: Faculdade de Medicina, Universidade de São Paulo
date: "1 October 2018"
output:
word_document:
toc: yes
pandoc_args:
- '--lua-filter=scholarly-metadata.lua'
- '--lua-filter=author-info-blocks.lua'
pdf_document:
number_sections: yes
toc: yes
toc_depth: 4
pandoc_args:
- '--lua-filter=scholarly-metadata.lua'
- '--lua-filter=author-info-blocks.lua'
---

This will be the PDF output:

example pdf output

while this is what it looks like in Word:

Sample Image

The affiliation and contact information is added to the body text, which is why the toc is displayed above it.



Related Topics



Leave a reply



Submit