install.package(miscTools)
library(miscTools)
#insertRow Insert Row into a Matrix
Description
Insert a new row into a matrix.
Usage
insertRow( m, r, v = NA, rName = "" )
Arguments
m matrix.
r row number where the new row should be inserted.
v optional values for the new row.
rName optional character string: the name of the new row.
#Examples
m <- matrix( 1:4, 2 )
insertRow( m, 2, 5:6 )
###insertCol Insert Column into a Matrix
Description
Insert a new column into a matrix.
Usage
insertCol( m, c, v = NA, cName = "" )
Arguments
m matrix.
c column number where the new column should be inserted.
v optional values of the new column.
cName optional character string: the name of the new column
##Examples
m <- matrix( 1:4, 2 )
insertCol( m, 2, 5:6 )
注:首先要把你的数据框变成矩阵格式;然后安装并调用miscTools包;按照上面的提示,湖综合学习miscTools的说明文件。
|