knitr, lyx, mac, Korean - r

Dear Friends in the knitr community with lyx and Apple Mac
Hello! I am using Apple Mac for Reproducible research of R. Currently, I enjoy knitr in lyx for writing some R scripts. The problem I have is related non-English characters, specially Korean in the knitr chunk.
When I type any Korean Character in a Chunk for typing file name or some extra explanations in #, the pdf output of the file does not print Korean properly. No matter of choosing or not choosing the option "eval=FALSE", R in lyx does not show Korean on the output. But, in the ordinary text part of the writing, Korean shows well. This problem seems to be Apple Mac specific, because another lyx environment in Linux (ubutu) makes the similar problem at al. Is it a lyx issue with MacTex or knitr one? Thank you in advance.
regards,
Jong-Hwa

Related

Using accented letters in R package documentation using bibtex and roxygen2

I am developing an R package in RStudio (R version 3.6.1; RStudio version 1.2.1335) using roxygen2 (version 6.1.1) and am using the \insertCite{} command together with a bibtex file in order to cite references in the documentation for individual functions. I am following the instructions Inserting references in Rd and roxygen2 documentation. Everything works fine, except when I try to include a reference with accented characters. So my REFERENCES.bib file contains the following entry:
#ARTICLE{Cabcdef15,
author={John {\c C}abcdef},
title={A title},
journal={Journal of Applied Stuff},
year={2015},
volume={81},
number={1},
pages={100--200},
}
The {\c C} is the LaTeX command for a C-cedilla (Ç). (I also tried \c{C} and pasting Ç directly and neither resolved the issue.)
I cited this reference in the roxygen2 preamble for my R function myfunction using \insertCite{Cabcdef15}{mypackage}. However, in the documentation output (after running devtools::document() and devtools::build(), installing the package and running library(mypackage) and ?myfunction) the citation appears in my browser (Google Chrome) as (Çabcdef 2015) rather than as (Çabcdef 2015).
Presumably this is an encoding issue. However, from what I read in the aforementioned instructions (under 4.4 Encoding of file REFERENCES.bib) this should be working, provided that I have the line Encoding: UTF-8 in the DESCRIPTION file for my R package, which I do. Hence I am stumped.
I have a strong suspicion you are using a Microsoft operating system.
I have code in a roxygen2 examples block which outputs accented French characters: works fine with non-French locales on MacOS and Linux: Windows makes a mess of it. I have UTF-8 in package DESCRIPTION. For me, the obvious work-around is not to use Windows for documenting the package. UTF-8 everywhere seems to work well for me, except on Windows. The R documentation links are helpful, and, in a related post, the mighty Yihui Xie writes about this issue.
This WONTFIX R issue also hints at the root cause: Windows.
A more palatable and Windows-compatible workaround is discussed in platform specific sections in Writing R Extensions.

R I want to remove those red lines

I want to remove those red lines in r studio.
I upgraded to the latest version, according to someone's suggestion.
But it is not working.
The problem occurs when I write Korean words.
The default encoding is UTF-8.
I found a similar problem here, but it didn't work for me.
https://community.rstudio.com/t/why-and-where-is-a-an-unexpected-token-in-r-and-how-should-i-deal-with-it/26496/4
df$번호
df$이름
df$성별
This is a bug -- unfortunately, the RStudio diagnostics system does not correctly handle multibyte characters in R Markdown documents on Windows. This will hopefully be fixed in the next release (v1.3).

Chinese in stylo (R and R studio)

I'm quite new to R and R studio, but I wanted to use the stylo package for stylometric analyses.
I collected two Chinese corpora in .txt, followed the instructions on https://sites.google.com/site/computationalstylistics/ , but neither R or R studio seemed to be able to read the Chinese text.
I know Chinese isn't one of the default supported languages of the stylo package, but here they mentioned that results for Chinese and the stylo package are 'quite promising'.
Also, in R it doesn't seem to be able to type Chinese characters, but in R studio it does. Am I doing something wrong? I believe my encoding is in unicode.
I hope you can help me
Thomas

Syntax highlighting for Python chunks does not work

I'm trying to create notebooks in which I present the same algorithm written in R and Python. I can easily integrate the R and Python code in a Rmd file and then create a HTML output using the 'Knit HTML' button in RStudio. However the Python code is always displayed without syntax highlighting (not like in the example at https://github.com/yihui/knitr-examples/blob/master/023-engine-python.md). I have Andre Simon's highlight software installed and functioning on my computer (MacBook Pro Retina, MacOS X 10.9).
Currently, I have the following libraries installed in R: markdown 0.6.4, knitr 1.5.15, highr 0.3.1.
Any idea what could be the problem? Thanks for your help!.
That is specific to the RStudio Markdown render, which did not enable syntax highlighting for code blocks that are not R or C++. RStudio uses highlight.js, and you can use your own version of highlight.js to highlight Python code. Or use other Markdown converters such as Pandoc.

How do I get RStudio to publish R-markdown to the rpubs.org site?

According to a response from the RStudio team, the "standard" solution would be to follow the instructions for "Using R Markdown with RStudio", and notice the button on the third screenshot with the "Publish" button. A wonderfully simple solution that I'm quite grateful they have built.
However, the "Publish" button with the nice arrow and picture of the earth doesn't show up in my preview window, no matter how badly I want it to.
I am using RStudio (RStudio.version() 0.96.231) in Mac OS X Lion (10.7), with latest R version and updated markdown and knitr packages. I have an RPubs account, and have followed the RPubs instructions for creating and previewing the html rendered from an R markdown file from within RStudio.
This seems to be related to a post on the RStudio support blog about not-seeing a Publish button.
However, this question is different, as it requires actually getting content up onto RPubs. I have posted an analogous question on the RStudio Support blog.
The Rstudio team already answered how to get graphics embedded in html rendered by RStudio from R Markdown source; especially by pointing me to this extremely useful page explaining the way RStudio renders and packages R Markdown using knitr:
Using RStudio to render R Markdown
Finally, if you haven't heard about R-markdown (I just learned of it),
go here for details about R-markdown.
Confirmed by Josh Paulson at RStudio, this was a bug with RStudio in OS X Lion and not some weird extra set of unstated dependencies or unclear instructions.
Just install v0.96.233 or greater and this should work on Mac OS X Lion (10.7).
Actually, the implementation and instructions are quite straightforward.

Resources