使用RMD创建乳胶文档的低质量数据

时间:2018-11-18 17:12:56

标签: r pdf graph r-markdown

早上好

我决定尝试使用RMarkdown来创建简短的白皮书,我将定期对其进行更新。 rmd代码提取美联储数据,对其进行组织,然后创建图形,并在图形上对此进行简短注释。

我的问题是关于输出的。 Rstudio中创建的图形清晰明了,是我想要的。 pdf输出应使线条更粗且不那么清晰。

我的代码块在下面。我曾尝试更改块顶部的dpi,但这并没有更改pdf输出。

关于使用Rmarkdown在RStudio中将相同的清晰线条导入pdf的任何想法吗?

谢谢!

using System.Text.RegularExpressions; //https://docs.microsoft.com/en-us/dotnet/api/system.text.regularexpressions.regex?view=netframework-4.7.2
//...
readonly Regex isNumeric = new Regex("^[+-]?\d*\.?\d*$", RegexOptions.Compiled); //treat "." as "0.0", ".9" as "0.9", etc
readonly Regex isInteger = new Regex("^[+-]?\d+$", RegexOptions.Compiled); //requires at least 1 digit; i.e. "" is not "0" 
readonly Regex isIntegerLike = new Regex("^[+-]?\d*\.?\0*$", RegexOptions.Compiled); //same as integer, only 12.0 is treated as 12, whilst 12.1 is invalid; i.e. only an integer if we can remove digits after the decimal point without truncating the value.

//...
public bool IsNumeric(string input)
{
    return isNumeric.IsMatch(input); //if you'd wanted 4.4 to be true, use this
}
public bool IsInteger(string input)
{
    return isInteger.IsMatch(input); //as you want 4.4 to be false, use this
}
public bool IsIntegerLike(string input)
{
    return isIntegerLike.IsMatch(input); //4.4 is false, but both 4 and 4.0 are true 
}

1 个答案:

答案 0 :(得分:0)

在编译为PDF时具有较高质量的绘图输出的一种简单解决方案是通过设置chunkk选项dev="tikz"(或全局使用opts_chunk$set(dev = "tikz"))来使用tikz图形设备。

Tikz是一个TeX软件包,它允许使用简单的语法创建矢量图形。使用矢量图形的优点是可伸缩,绘图中的注释将使用与文档中使用的相同的主字体,并且您可以使用TeX语法轻松地将数学符号添加到绘图中:

plot(..., main = "$\\bar{\\mu}$")