如何更改R plot默认选项

时间:2015-07-29 12:12:46

标签: r defaults

我想将默认情节选项从type = "p"更改为type = "l";我的意思是我希望它在每个新会话开始时都是这样,而不再指定它。

我试图在我的Rprofile.site中放入一些代码,但遗憾的是不是正确的代码:首先我想使用setDefaults但是这个包已被弃用;我也尝试设置一个钩子,但无法使它工作。

有什么想法吗?

谢谢!

1 个答案:

答案 0 :(得分:1)

可以通过添加到您的Rprofile

来完成
 <xsl:template match="root">
  <xsl:for-each select="rdf:RDF">
   <xsl:text>START HERE</xsl:text>
   <xsl:text>&#13;&#10;</xsl:text>
   <xsl:text>=LDR  00000nam  2200000Ia 4500</xsl:text>
   <xsl:text>&#13;&#10;</xsl:text>
  <xsl:apply-templates select="rdf:Description/skos:narrowMatch" />
   <xsl:text>&#13;&#10;</xsl:text>
  <xsl:apply-templates select="rdf:Description/skos:exactMatch" />
   <xsl:text>&#13;&#10;</xsl:text>
  <xsl:apply-templates select="skos:Concept" />
   <xsl:text>&#13;&#10;</xsl:text>
  <xsl:apply-templates select="skos:Concept/skos:altLabel" />
   <xsl:text>&#13;&#10;</xsl:text>
  <xsl:apply-templates select="skos:Concept/skos:prefLabel" />
   <xsl:text>&#13;&#10;</xsl:text>  
  </xsl:for-each>
 </xsl:template>

但由于罗兰在评论中所说的原因,这一点非常气馁。更好的解决方案是将其放在Rprofile中:

 <xsl:transform
  ......
 >
<xsl:template match="root">
 <xsl:for-each select="rdf:RDF">
   <xsl:text>START HERE</xsl:text>
   <xsl:text>&#13;&#10;</xsl:text>
   <xsl:text>=LDR  00000nam  2200000Ia 4500</xsl:text>
   <xsl:text>&#13;&#10;</xsl:text>
   <xsl:apply-templates select="rdf:Description/skos:narrowMatch" />
   <xsl:text>&#13;&#10;</xsl:text>
   <xsl:apply-templates select="rdf:Description/skos:exactMatch" />
   <xsl:text>&#13;&#10;</xsl:text>
   <xsl:apply-templates select="skos:Concept" />
   <xsl:text>&#13;&#10;</xsl:text>
   <xsl:apply-templates select="skos:Concept/skos:altLabel" />
   <xsl:text>&#13;&#10;</xsl:text>
   <xsl:apply-templates select="skos:Concept/skos:prefLabel" />
   <xsl:text>&#13;&#10;</xsl:text>  
  </xsl:for-each>
 </xsl:template>
 <xsl:output method="text" omit-xml-declaration="yes" encoding="UTF-8" indent="no" />
 <xsl:key name="concepts-by-about" match="//skos:Concept" use="@rdf:about" />

    <xsl:template match="//ns0:isUsedAs[key('concepts-by-about', @rdf:resource)]">        
=305 \\$aisUsedBy$b<xsl:value-of select="key('concepts-by-about', @rdf:resource)/skos:prefLabel[@xml:lang='en']" />        
    </xsl:template>

    <xsl:template match="text()" />
 </xsl:transform>

这为您提供了所需的默认值,如果需要可以恢复正常,并且不会影响现有的formals(plot.default)$type <- "l" 功能。

但这仍然伴随着lplot <- function(x, y, type = "l", ...){ plot(x, y, type = type, ...) } 功能的缺点,似乎无处不在。更好的方法是将plot放入包中。即使您在Rprofile中加载包,至少lplot会提取一些内容以指示它来自何处。