R语言paste函数解析

一、paste函数

paste (..., sep = " ", collapse = NULL)

paste0(..., collapse = NULL)

paste converts its arguments (via as.character) to character strings, and concatenates them (separating them by the string given by sep). If the arguments are vectors, they are concatenated term-by-term to give a character vector result. Vector arguments are recycled as needed, with zero-length arguments being recycled to "".
Note that paste() coerces NA_character_, the character missing value, to "NA" which may seem undesirable, e.g., when pasting two character vectors, or very desirable, e.g. in paste("the value of p is ", p).
paste0(..., collapse) is equivalent to paste(..., sep = "", collapse), slightly more efficiently.paste

paste函数将他的参数转换为字符串并连接他们,字符串之间用seq间隔分开。

当参数是多个向量时,分别取每个参数中索引为0的连接起来,如果规定了seq,他们之间用seq间隔,如此循环下去若规定了collapse参数,每个有参数连接的结果用collapse连接。

R语言paste函数解析_第1张图片

R语言paste函数解析_第2张图片


你可能感兴趣的:(R)