How to install Pandoc for Windows? - r

I have been to their website. I have viewed a YouTube on a related subject. And, so far I don't really get it. My objective is to use Pandoc in conjunction with R Markdown to convert R Markdown HTML document into either Word or Pdf files.

You can install pandoc in several ways:
Using the x86 or x64 executable from here and installng like any other Windows app: pandoc downloads
Using the x86 or x64 flavor of the zip file (same link shown above), and unpack it on the folder of your preference. Then, set manually the path to that folder. Pandoc is only a couple of files pandoc.exe and pandoc-citeproc.exe. You may even copy then to your /bin folder of your preference if want to save adding another PATH.
Using the R package installr, and then run installr::install.pandoc().
It will automatically install the Windows msi and add the PATH for you.
You may review the user path in environment variables: C:\Users\user_name\AppData\Local\Pandoc\.
Reload the environment variables by restarting your PC.

If you have RStudio installed (and most R users do) then you already have a pandoc binary. Maybe just add that directory to your $PATH ?

If you have the Chocolatey package manager installed on your Windows machine, you can install the Pandoc package with:
choco install pandoc

Related

How do I configure Rtools40 in Windows 10 with R 4.0.0?

I recently installed R 4.0.0. Along with it, I also installed Rtools40. The CRAN website said I also need to specify path for Rtools make file in the .Renviron file. But when I created the .Renviron file, I cannot use stats package. If .Renviron file exists, it gives error that some shared dll file is missing. And if I delete the .Renviron file, this error goes away, but I cannot compile packages using Rtools40. How can I configure this .Renviron file so that I can also use both - Rtools40 and stats package?
My Rtools make file is in C:/(MyUserName)/Rtools40/usr/bin folder. This same folder also contains the bash file, which came with Rtools40.
writeLines('PATH="${PATH};${RTOOLS40_HOME}\\usr\\bin"', con = "~/.Renviron")
I had the same problem. I was following the Rtools40 download instructions, and instead of adding Rtools to the beginning of the path, adding it to the end fixed it.
I have been always using a folder "C:\s" to deploy the always changing versions of R related software friends. I recently installed Rtools40 to "C:\s\rtools40" and linking it with my R-4.0-1 was straightforward to me. I just went to "C:\s\R-4.0.1\etc\x64", edited the "Makeconf" file using WordPad, and replaced the line
RTOOLS40_HOME ?= c:/rtools40
With
RTOOLS40_HOME ?= c:/s/rtools40
Then I did the same for "C:\s\R-4.0.1\etc\x32". After these, I installed a package using RStudio (running install.packages("jsonlite", type = "source") in the R-4.0.1 console), and no warning related to Rtools was displayed in the console. I hope this works well in your machine.

How to use R CMD INSTALL to install only essential files

I am using R CMD INSTALL to install libraries from a folder with .zip binaries to my rlibs directory. When I do this, many folders for each library are installed in the rlibs directory. Take for example the bit package. I have downloaded the bit_1.1-12.zip file from https://cran.r-project.org/web/packages/bit/index.html.
Now I install it by using the following command:
R CMD INSTALL --library=./r_libs ./external/bit_1.1-12.zip
This will create a file structure underneath the folder ./r_libs/bit
Now here is my question: How can I install only the essential library files that R needs to import? I believe this is the ./r_libs/bit/libs/ folder (I might be wrong). Currently there is plenty of additional folders installed, such as html, help, Meta, and more.
I have tried several options that R CMD INSTALL --help gives me. The description in https://stat.ethz.ch/R-manual/R-devel/library/utils/html/INSTALL.html tells me to install just the compiled code for another sub-architecture, use --libs-only. However,
R CMD INSTALL --libs-only --library=./r_libs ./external/bit_1.1-12.zip
gives me an error message that there is no ./r_libs/bit/lib directory. The options --no-html, --no-help seem to not do anything.
I am working on a Windows 7 machine using R add-on package installer 3.0.2.
What am I missing here?
Thank you.

cygwin aspell installing new language

have a problem with adding new language to cygwin.
As source for language i tried using ubuntu dictionary files.
It would be interesting if anyone could install any non default languages in cygwin spell checker.
The Ubuntu packages use different directories (/usr/lib/aspell vs. /usr/lib/aspell-0.60 on Cygwin), so this isn't going to work. Instead, I suggest you build and install these from the source in one of the following ways:
Download the latest source tarball for your language from http://ftpmirror.gnu.org/aspell/dict/, unpack the tarball, then run ./configure, make, and make install.
Use cygport to build a package for you, then manually install it. For example, create an aspell-lt.cygport file with the following contents:
ASPELL_COMPAT=6
inherit aspell-dict
NAME="aspell-lt"
VERSION=1.2.1.0
RELEASE=1
CATEGORY="Text"
SUMMARY="Aspell Lithuanian dictionaries"
Then run cygport aspell-lt.cygport fetch prep build install package. Such a package would then be fit for contribution to the Cygwin distribution.

qpdf.exe for compactPDF?

I am trying to check a package that I have built (with vignette) using R CMD check --as-cran [my package] in my windows command prompt. All goes well until I get the message,
WARNING 'qpdf' is needed for checks on size reduction of PDFs
I have downloaded qpdf, put the unzipped folder in my program files directory, and added the bin folder to the PATH.
Not quite sure what else I need to do? I have the feeling I have not installed qpdf correctly or I need to build this program itself? I have read through the readme files and manual for qpdf which appear to be more aimed at unix users (which I have no experience with... I am your standard/regular windows user with little to no programming experience outside of statistical languages). I have had a go at trying to build qpdf using cgywin, but ended up failing to install zlib and prec. Any tips?
I would try
Sys.which(Sys.getenv("R_QPDF", "qpdf"))
Sys.getenv("PATH")
to establish that R is really not finding the qpdf executable, and see where it is looking. You probably shouldn't need to rebuild everything, just figure out why R is not finding the qpdf executable ... does running qpdf from a terminal window work ... ? How are you starting R, and did it have a chance to get the new PATH definition (i.e. do you need to open a new terminal window, or ?? reboot ??)
The incantation above was extracted from tools::compactPDF, from the default value of the qpdf argument, on a Linux machine. You should check for yourself, in case (e.g.) the Windows version is looking for qpdf.exe rather than qpdf ...
There are a couple of other things to consider on a Windows machine:
If you are running the 32-bit version of R, it is important that you download the 32-bit version of qpdf, which is the version linked from the SourceForge homepage. If you are running a 64-bit installation of R, you will need to do a bit of digging to locate the 64-bit version of qpdf, which is buried a little more deeply (version 7.0 is listed here).
Once you have extracted the zipped qpdf directory to your hard disk, perhaps under C:\Program Files\, added C:\Program Files\qpdf-version_number\bin to your system PATH under the environment variables, and re-launched R, Windows needs to establish that pqdf is safe to run.
Navigate to C:\Program Files\qpdf-version_numer\bin and execute qpdf.exe (by double-clicking). Windows 10 throws up a security warning, as it's an unrecognized executable file. You'll need to use the more options link to find the button to run the program. This done, Windows will recognize the file as safe to run and allow other software, including R, to use it.
Recent developments: If you install Rtools 3.5 qpdf is included and that warning is gone. Rtools is a toolset for building packages on Windows and is recently reworked by Jeroen Ooms.
More information : https://cran.r-project.org/bin/windows/Rtools/
Note that the changelog is incomplete, as Rtools 3.5 isn't frozen yet at the time of writing (2019-03-01). Even though it's not visible on the page yet, qpdf.exe is included in the bin directory after installation.
After installing the latest version of RTools, the warning still popped up.
However, I noticed that the Windows "where" command gave two paths to qpdf (different versions). After removing the R_QPDF environment variable and removing the new install of qpdf from the Windows path, so that only qpdf in RTools was found, the warning disappeared.
I got the same warning on Ubuntu so here's a Ubuntu solution for completeness:
First update packages
sudo apt update
Then install qpdf with
sudo apt install qpdf
Tested on Ubuntu 20.04.

R install package globally

How do I install an R package globally, so it's available to all users? Currently I'm doing
R.exe CMD INSTALL *.zip
But it does
* installing to library 'C:/Users/Matt/Documents/R/win-library/2.15'
I would like to install the packages alongside R in Windows' 'program files'.
Your big problem here is installing to C:\Program Files\. This means on versions of windows with file permissions, you need admin permissions to write to that folder. As R does not commonly request admin permissions, it will on default install to an user subdirectory, unless you run R as administrator (by right clicking on the shortcut). In which case you can use the GUI to install packages and it will install them globally by default. For working on the command line, you can also run the cmd session as administrator.
In future, it's recommended that you install R to say, C:\R\ to avoid this.
What worked for me was running:
install.packages("MyPackage", lib="C:\\Program Files\\R\\R-3.0.1\\library")
Installing it to Program Files wasn't a problem for me - the problem was that the default installation directory was in C:\\Users\\Mike\\Documents\\R\\...
Ultimately you just want to install it to wherever .libPaths() looks by default, and in my environment that was most commonly C:\\Program Files\\R\\R-3.0.1\\library
Here is a way to specify where to find or install libraries. You can put the libraries in a common directory.
http://cran.r-project.org/doc/manuals/R-admin.html#Managing-libraries

Resources