Suppose I have a simple function that returns a matrix, such as:
test <- function(x){ return(matrix(c(x,x^2,x^3,x^4),2,2)) }
so that test returns:
[ x x^3 ]
[ x^2x^4 ]
Is it possible for me to get the derivative of an expression such as:
c(1,0) %*% test() %*% c(0,1)
The vectors are us
Suppose I have a simple function that returns a matrix, such as:
test <- function(x){ return(matrix(c(x,x^2,x^3,x^4),2,2)) }
so that test returns:
[ x x^3 ]
[ x^2x^4 ]
Is it possible for me to get the derivative of an expression such as:
c(1,0) %*% test() %*% c(0,1)
The vectors are us
I have 3 basic questions (sorry, but R is a bit new to me)
First)
The following code will work on C, but something happens with R:
> x<-c(0,1,1,0,0,1,0,0,1)
> dim(x)<-c(3,3)
> types<-numeric(3)
> for (i in 1:3) {
+ j<-1
+ while (x[i,j]!=1) j<-j+1
+ if (j==4) types[i]<-0
+ else types[i]<-1
+ }
Er