Warning: file_get_contents(/data/phpspider/zhask/data//catemap/4/r/74.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,我是R的初学者,我想问你,我需要创建一个函数,将向量拆分为字符,然后用单个“字母”打印向量 例如: “你好”。。。“H”、“e”、“l”、“l”、“o” 1435年。。。1,4,3,5 我不能使用strsplit函数。我的第一选择是使用strsplit(“hello”,“hello”)[[1]]。 数字字符串可以拆分为strsplit(作为.character(12345),“”)[[1]] 由于您请求的不是strsplit,因此可以执行以下操作 string <- "hello" sub

我是R的初学者,我想问你,我需要创建一个函数,将向量拆分为字符,然后用单个“字母”打印向量

例如:

“你好”。。。“H”、“e”、“l”、“l”、“o”

1435年。。。1,4,3,5


我不能使用strsplit函数。

我的第一选择是使用
strsplit(“hello”,“hello”)[[1]]
。 数字字符串可以拆分为
strsplit(作为.character(12345),“”)[[1]]

由于您请求的不是strsplit,因此可以执行以下操作

string <- "hello"
substring(string, 1:nchar(string), 1:nchar(string))
#[1] "h" "e" "l" "l" "o"

string谢谢!我还有一个问题。我需要创建一个函数,它可以从两个3位数字的乘积中找到最大的回文。我需要使用strsplit函数。你能帮助我吗?