#选择日期的格式
mydate <- function(type = "long"){
switch(type,
long = format(Sys.time(), "%A %B %d %Y"),
short = format(Sys.time(), "%m-%d-%y"),
cat(type, "is not a recognized typen")
)
}
上面为自编函数,保存为mydate.R文件
调用:
> source("mydate.R")
> mydate("long")
[1] "星期二 三月 24 2015"
> mydate("short")
[1] "03-24-15"
> mydate("")
is not a recognized type
最后
以上就是呆萌魔镜最近收集整理的关于6、R语言,调用自编函数的全部内容,更多相关6、R语言内容请搜索靠谱客的其他文章。
本图文内容来源于网友提供,作为学习参考使用,或来自网络收集整理,版权属于原作者所有。
发表评论 取消回复