Couldn't see a solution online but I thought this might be quite common.
无法在线查看解决方案,但我认为这可能很常见。
- with
write.csv
I basically always have the argumentrow.name
set to F. Is it possible to run a line once and update the default value of the argument for the rest of the session? - 使用write.csv我基本上总是将参数row.name设置为F.是否可以运行一次行并更新会话其余部分的参数的默认值?
- I tried
paste <- paste(sep="")
which ran and returned no error but seemed to do nothing (and didn't destroy thepaste
function). This is another one, I always setsep=""
withpaste
... - 我尝试粘贴< - paste(sep =“”)运行并返回没有错误,但似乎什么都不做(并没有破坏粘贴功能)。这是另一个,我总是用贴纸设置sep =“”...
- like I always have
exclude=NULL
when I am usingtable
so I can see the N/A values. - 就像我在使用表时总是有exclude = NULL所以我可以看到N / A值。
EDIT: So, I'm looking for a solution that will work for multiple functions if possible: paste
, write.csv
, table
and other functions like these.
编辑:所以,我正在寻找一种解决方案,如果可能的话,它将适用于多种功能:paste,write.csv,table和其他类似的功能。
2 个解决方案
#1
5
Try this:
尝试这个:
paste <- paste
formals(paste)$sep <- ""
This creates a new copy of paste
in your workspace, and then modifies its default value for sep
to ""
. Subsequent calls to paste
will then use the modified copy, as it sits in front of the base environment in your search path.
这会在工作区中创建一个新的粘贴副本,然后将sep的默认值修改为“”。随后对粘贴的调用将使用修改后的副本,因为它位于搜索路径中的基础环境之前。
#2
8
paste <- paste(sep="")
puts the output of paste()
into an object named "paste". You would need to do something like this instead.
paste < - paste(sep =“”)将paste()的输出放入名为“paste”的对象中。你需要做这样的事情。
paste <- function (..., sep = "", collapse = NULL) {
base::paste(..., sep=sep, collapse=collapse)
}
You can also look at the Defaults package for this sort of thing, but it doesn't currently work for two of your examples.
您还可以查看Defaults包中的这类内容,但它目前不适用于您的两个示例。
#1
5
Try this:
尝试这个:
paste <- paste
formals(paste)$sep <- ""
This creates a new copy of paste
in your workspace, and then modifies its default value for sep
to ""
. Subsequent calls to paste
will then use the modified copy, as it sits in front of the base environment in your search path.
这会在工作区中创建一个新的粘贴副本,然后将sep的默认值修改为“”。随后对粘贴的调用将使用修改后的副本,因为它位于搜索路径中的基础环境之前。
#2
8
paste <- paste(sep="")
puts the output of paste()
into an object named "paste". You would need to do something like this instead.
paste < - paste(sep =“”)将paste()的输出放入名为“paste”的对象中。你需要做这样的事情。
paste <- function (..., sep = "", collapse = NULL) {
base::paste(..., sep=sep, collapse=collapse)
}
You can also look at the Defaults package for this sort of thing, but it doesn't currently work for two of your examples.
您还可以查看Defaults包中的这类内容,但它目前不适用于您的两个示例。