Warning: file_get_contents(/data/phpspider/zhask/data//catemap/3/apache-spark/5.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,我正在从2个向量创建一个表,将值转换为百分比,然后需要在末尾添加“%”符号 my.table <- table(vecA, vecB) my.table <- round(prop.table(my.table, margin = 2) * 100, digits = 2) my.table 如果您希望它作为一个表而不仅仅是一个矩阵,您可以在结果上使用as.table my.table <- apply(round(prop.table(my.table, margin =

我正在从2个向量创建一个表,将值转换为百分比,然后需要在末尾添加“%”符号

my.table <- table(vecA, vecB)
my.table <- round(prop.table(my.table, margin = 2) * 100, digits = 2)
my.table
如果您希望它作为一个表而不仅仅是一个矩阵,您可以在结果上使用
as.table

my.table <- apply(round(prop.table(my.table, margin = 2) * 100, digits = 2), 1, paste0, '%')
my.table <- apply(prop.table(my.table, margin = 2), 1, scales::percent)