R中的全局变量 [英] Global variables in R
问题描述
问题2:如何在函数中设置全局变量?
关于绘图,我在一张纸上绘制了多张图,并且为了区分它们中的每一张,我想为它们中的每一张添加标题。任何人都可以告诉我怎么做到这一点?
每个主要问题使用一个帖子。
-
正如assign()向你展示的第一个答案所示,有一种方法可以在全局环境中进行分配。使用
<< - < $ code>运算符,即更简单,更短(但不是更好的)分配方式,即
a<< - 新
为每个情节。使用类似于 As the first answer with assign() showed you, there is a way to assign in the global environment. A simpler, shorter (but not better ... stick with assign) way is to use the
<<-
operator, iea <<- "new"
inside the function.
For your plots, use
main="My title here"
for each plot. Use something likepar(mar=c(3,3,3,1))
to give sufficient spacing.
par(mar = c(3,3,3,1))
的东西来给出足够的间隔。 I am poking into the manuals, I wanted to ask the community: How can we set global variables inside a function?
Question-2: Regarding plotting,
I am using plotting multiple graphs in a single sheet, and to differentiate each one of them, I want to add title for each one of them. Can anyone tell me how I can achieve this?
Use one post per main question.
这篇关于R中的全局变量的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!