R strsplit 不拆分“。”?
R strsplit doesn't split on "."?
我正在编写一个 R 脚本,并希望定义一个变量以作为文件名的一部分在绘图注释中使用。我想我会使用 strsplit() 函数。这是我的代码和输出:
infile = "ACC_1346.table.txt"
x = strsplit(infile, ".")
class(infile)
[1] "character"
class(x)
[1] "list"
str(x)
List of 1
$ : chr [1:18] "" "" "" "" ...
x[[1]]
[1] "" "" "" "" "" "" "" "" "" "" "" "" "" "" "" "" "" ""
我预计最终输出为:
[1] "ACC_1346" "table" "txt"
这是怎么回事?
我正在编写一个 R 脚本,并希望定义一个变量以作为文件名的一部分在绘图注释中使用。我想我会使用 strsplit() 函数。这是我的代码和输出:
infile = "ACC_1346.table.txt"
x = strsplit(infile, ".")
class(infile)
[1] "character"
class(x)
[1] "list"
str(x)
List of 1
$ : chr [1:18] "" "" "" "" ...
x[[1]]
[1] "" "" "" "" "" "" "" "" "" "" "" "" "" "" "" "" "" ""
我预计最终输出为:
[1] "ACC_1346" "table" "txt"
这是怎么回事?