gpt4 book ai didi

r - nchar(substitute(a + b + c)) 实际上算什么?

转载 作者:行者123 更新时间:2023-12-01 10:35:07 25 4
gpt4 key购买 nike

我一直在研究 substitute,但不太明白 nchar(substitute(a + b + c)) 的结果到底是什么?结果是

nchar(substitute(a + b + c))
[1] 1 5 1

它到底算什么?我认为中间项只是该表达式的元素数。但是接下来的数是多少,其他 1 代表什么?

nchar(substitute(a + b))
[1] 1 1 1

最佳答案

我们可以检查从转换为字符

v1 <- as.character(substitute(a + b + c))
v1
#[1] "+" "a + b" "c"

nchar(v1)
#[1] 1 5 1

还计算空格以给出字符数。

鉴于

as.character(substitute(a + b))
#[1] "+" "a" "b"

是每个元素的一个字符长度。

关于r - nchar(substitute(a + b + c)) 实际上算什么?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/36969133/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com