标点符号向量
vector of punctuation
对于数字,我可以这样写一个向量:
digits <- c("0","1","2","3","4","5","6","7","8","9")
如何获得标点符号的类似向量?
您可以使用 Unicode 代码点将数字转换为标点符号(感谢 Konrad,指出这一点)。
strsplit(intToUtf8(c(33:47, 58:64, 91:96)), "")[[1]]
# [1] "!" "\"" "#" "$" "%" "&" "'" "(" ")" "*" "+" "," "-" "."
#[15] "/" ":" ";" "<" "=" ">" "?" "@" "[" "\" "]" "^" "_" "`"
一些埃塞俄比亚标点符号 (0x1361:0x1367
):
strsplit(intToUtf8(0x1361:0x1367), "")[[1]]
[1] "፡" "።" "፣" "፤" "፥" "፦" "፧"
如果缺少您要使用的标点符号,您可以查找与您想要的标点符号关联的 unicode 点,然后使用它(例如 http://www.fileformat.info/info/unicode/category/Po/list.htm 之类的地方)。您还可以从 utf8ToInt
中获取整数。例如上面没有包含“~”:
utf8ToInt("~")
#[1] 126
对于数字,我可以这样写一个向量:
digits <- c("0","1","2","3","4","5","6","7","8","9")
如何获得标点符号的类似向量?
您可以使用 Unicode 代码点将数字转换为标点符号(感谢 Konrad,指出这一点)。
strsplit(intToUtf8(c(33:47, 58:64, 91:96)), "")[[1]]
# [1] "!" "\"" "#" "$" "%" "&" "'" "(" ")" "*" "+" "," "-" "."
#[15] "/" ":" ";" "<" "=" ">" "?" "@" "[" "\" "]" "^" "_" "`"
一些埃塞俄比亚标点符号 (0x1361:0x1367
):
strsplit(intToUtf8(0x1361:0x1367), "")[[1]]
[1] "፡" "።" "፣" "፤" "፥" "፦" "፧"
如果缺少您要使用的标点符号,您可以查找与您想要的标点符号关联的 unicode 点,然后使用它(例如 http://www.fileformat.info/info/unicode/category/Po/list.htm 之类的地方)。您还可以从 utf8ToInt
中获取整数。例如上面没有包含“~”:
utf8ToInt("~")
#[1] 126