matrix - R Function %*% Explanation -
i have small data frame looks below -
name,standrewslodge,loyalnine,northcaucus,longroomclub,teaparty,bostoncommittee,londonenemies adams.john,0,0,1,1,0,0,0 adams.samuel,0,0,1,1,0,1,1 allen.dr,0,0,1,0,0,0,0 appleton.nathaniel,0,0,1,0,0,1,0 data <- as.matrix(read.csv("data.csv",row.names=1)) data.t = t(data)
once imported r data set, can transpose using t() function.
post create new data set using
data.ts = data %*% t(data)
i trying understand %*% function does. numbers come out make no sense.
if has used can pls explain.
thanks,
it's matrix multiplication, see help("%*%")
.
multiplies 2 matrices, if conformable. if 1 argument vector, promoted either row or column matrix make 2 arguments conformable. if both vectors of same length, return inner product (as matrix).
Comments
Post a Comment