search for: 20x1

Displaying 2 results from an estimated 2 matches for "20x1".

Did you mean: 0x1
2004 Sep 25
2
making custom function compute/return multiple items
...vely new to R. I've read the intro guide, but I can't quite figure out how to: I have a function: Jcost <- function (theta, in, out) { a <- output - input %*% theta 1/2 * t(a) %*% a } where "theta" is a 2x1 matrix "in" is a 20x2 matrix "out" is a 20x1 matrix return value is a scaler This works well when I only want to compute given 1 theta matrix. How do I compute several (say N) 2x1 theta matrices and get back N scaler values? Thanks! -- -david David Chu
2023 Aug 06
2
Stacking matrix columns
I wish to stack columns of a matrix into one column. The following matrix command does it. Any other ways? Thanks. > x<-matrix(1:20,5,4) > x ???? [,1] [,2] [,3] [,4] [1,]??? 1??? 6?? 11?? 16 [2,]??? 2??? 7?? 12?? 17 [3,]??? 3??? 8?? 13?? 18 [4,]??? 4??? 9?? 14?? 19 [5,]??? 5?? 10?? 15?? 20 > matrix(x,ncol=1) ????? [,1] ?[1,]??? 1 ?[2,]??? 2 ?[3,]??? 3 ?[4,]??? 4 ?[5,]??? 5