Displaying 7 results from an estimated 7 matches for "mat1,1".
2013 Jan 10
1
merging command
HI Eliza,
You could do this:
set.seed(15)
mat1<-matrix(sample(1:800,124*12,replace=TRUE),nrow=12) # smaller dataset
#Your codes
?list1<-list()
?for(i in 1:ncol(mat1)){
? list1[[i]]<-t(apply(mat1,1,function(x) x[i]-x))
? list1}
?x<-list1??
x<-matrix(unlist(x),nrow=12)
x<-abs(x)
?y<-colSums(x, na.rm=FALSE)
z<-matrix(y,nco...
2012 Oct 05
3
loop for column substraction of a matrix
Dear useRs,
I have a matrix with 38 columns and 365 rows. what i want to do is the following.....
1. subtracting from each column, first itself and then all the remaining columns. More precisely, from column number 1, i will first subtract itself(column 1) and then the remaining 37 columns. Afterwards i will take column number 2 and do the same. In this way i want to proceed till 38th column.
2006 Aug 28
2
Cannot get simple data.frame binding.
...a <- c(3,5,3,6,4, 0)
dogb <- c(2,4,6,8,10, 12)
rata <- c (NA, 9, 9, 8, 9, 8)
ratb <- c( 1,2,3,4,5,6)
bata <- c( 12, 42,NA, 45, 32, 54)
batb <- c( 13, 15, 17,19,21,23)
id <- c('a', 'b', 'b', 'c', 'a', 'b')
site <- c(1,1,4,4,1,4)
mat1 <- cbind(cata, catb, doga, dogb, rata, ratb,
bata, batb)
data1 <- data.frame(site, id, mat1)
attach(data1)
data1
aa <- which(names(data1)=="rata")
bb <- length(names(data1))
mat1 <- as.matrix(data1[,aa:bb])
food <- apply( mat1, 1, sum , na.rm=T)
food
abba <- data....
2012 Nov 16
4
Deleting rows with special character
Dear all,
maybe a simple problem but I found no solution for my problem.
I have a matrix Y with 23 000 rows and 220 colums. The entries are "A", "B" or "C".
I want to extract all rows (as a matrix ) of the matrix Y where all entries of a row are (for example) "A".
Is there any solution? I tried the stringr- package but i doesn't work out.
All the best
2012 Dec 05
3
data manipulation between vector and matrix
Dear list,
I was curious how to subtract a vector from matrix?
Say, I have
mat <- matrix(1:40, nrow=20, ncol=2)
x <-c(1,2)
I want,
x-mat[1,] and x-mat[2,], and so on... Basically, subtract column elements
of x against column elements in mat.
But x-mat won't do it.
Thanks,
Mike
[[alternative HTML version deleted]]
2013 Apr 12
2
processing matrix equation derived from rows of two matrices
...2.2857143 1.9047619 1.9047619 2.2857143 2.2857143
#[15] 2.2857143 1.9523810 1.9523810 2.2857143 2.2857143 2.2857143 2.2857143
#[22] 1.6190476 1.6190476 1.9047619 1.9047619 1.9047619 1.9047619 1.8095238
#[29] 0.9047619 0.9047619 1.1428571 1.1428571 1.1428571 1.1428571 1.0000000
#[36] 0.4761905
#or
mat1<-matrix(((val-rep(meansb79,each=5))^2/6),ncol=5,byrow=TRUE)
diag(t(apply(tb,1,function(x) x))%*% apply(mat1,1,function(x) x))
# [1] 1.4761905 1.9047619 1.9047619 1.9047619 1.9047619 2.2857143 1.9047619
?#[8] 1.9047619 2.2857143 2.2857143 1.9047619 1.9047619 2.2857143 2.2857143
#[15] 2.2857143 1...
2011 Aug 04
1
matrix rows to single numeric element
I have a matrix of 5 columns and 64 rows, let's call it "mat1". All values are 1 or 0. I need to take the values of the elements by row and create a single numeric element that can be placed its respective slot in a 64-element list, named "list1". For example, mat1[11,1:5] = 0,1,1,0,1 and I must put 01101, with a length of 1, into the 11th e...