Warning: file_get_contents(/data/phpspider/zhask/data//catemap/4/r/69.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
R中函数内的花括号_R - Fatal编程技术网

R中函数内的花括号

R中函数内的花括号,r,R,我遇到了以下格式为x({…})的函数,而不仅仅是x()。例如: suppressWarnings({ yahoo_answer <- tryCatch({ getSymbols(ticker, src ="yahoo") }, error = function(err) { NA }) }) suppressWarnings({yahoo_answer花括号允许在suppressWarnings()中放置多行代码。在您的示例中,它们不是必需的,因为您只有一个命令 suppressWar

我遇到了以下格式为x({…})的函数,而不仅仅是x()。例如:

suppressWarnings({ yahoo_answer <- tryCatch({ getSymbols(ticker, src ="yahoo")
 }, error = function(err) { NA }) })

suppressWarnings({yahoo_answer花括号允许在suppressWarnings()中放置多行代码。在您的示例中,它们不是必需的,因为您只有一个命令

suppressWarnings({
    warning("test1")
    warning("test2")
})

花括号允许在suppressWarnings()中放置多行代码。在您的示例中,它们不是必需的,因为您只有一个命令

suppressWarnings({
    warning("test1")
    warning("test2")
})