Displaying 20 results from an estimated 6000 matches similar to: "Add grand mean to every entry in a matrix"
2007 Nov 01
2
computing the mean of a few variables
hello,
I have a simple question:
I want to compute the average of 6 variables,
my data looks like this:
t0 t1 t2 t3 t4 t5
1 32 34 36 40 38 40
2 35 37 38 36 33 39
.
.
.
I want the mean of t0-t5 for each row (observation).
thank you,
sigalit.
[[alternative HTML version deleted]]
2005 Jul 12
1
vectorizaton
Hi,
I got 1000 NxN matrices grouped in one array. I want one matrix in which p_ij is the average of all the 1000 matrices in the array. Here's what I'm trying to do:
# P is the NxNx1000 array
for(i in 1:N)
for(j in 1:N)
for(k in 1: 1000)
mymat[ i, j ] <- mean( P [i , j , k ] )
Otherwise, I could have a NxNx1000 vector, and get the N^2 means of the 1+ (N^2)*(0: 999) elements. I
2017 Jun 27
2
paste strings in C
Dear R-devs,
Below is a small example of what I am trying to achieve, that is trivial in
R and I would like to learn how to do in C, for very large matrices:
> (mymat <- matrix(c(1,0,0,2,2,1), nrow = 2))
[,1] [,2] [,3]
[1,] 1 0 2
[2,] 0 2 1
And I would like to produce:
[1] "a*C" "B*c"
Which can be trivially done in R via something like:
foo
2010 Jul 15
2
replace negative numbers by smallest positive value in matrix
Hi Group,
I have a matrix, and I would like to replace numbers less than 0 by
the smallest minimum number. Below is an
small matrix, and the loop I used. I would like to get suggestions on
the "R way" to do this.
Thanks,
Juliet
# example data set
mymat <- structure(c(-0.503183609420937, 0.179063475173256, 0.130473004669938,
-1.80825226960127, -0.794910626384209, 1.03857280868547,
2009 Jul 08
1
heatmap.2: question regarding the "raw z-score"
Hi,
I am analysing gene expression data using the heatmap.2 function in R and I
was wondering what is the formula of the "raw z-score" bar which shows the
colors for each pixel.
According to that post:
https://mailman.stat.ethz.ch/pipermail/r-help/2006-September/113598.html, it
is the
(actual value - mean of the group) / standard deviation.
But, mean of which group? Mean of the gene
2008 Sep 21
1
How to put given values in lower triangle of splom-plot?
Dear R-experts,
I have found a splom-modification online which is given below. This
works perfectly, but I would like to have a matrix of given
correlation values to be used in the lower triangular part
(lower.panel) of the splom-plot instead of calculated correlation
values. Here is the matrix I would like to use (it can be any other
convenient data structure):
2011 Oct 01
1
class definition
Hi everybody!
I have a matrix of class "myClass", for example:
myMat <- matrix(rnorm(30), nrow = 6)
attr(myMat, "class") <- "myClass"
class(myMat)
When I extract part of ''myMat'', the corresponding class ''myClass'' unfortunately disappear:
myMat.p <- myMat[,1:2]
class(myMat.p)
Please for any advice / suggestions, how
2006 Mar 21
1
rownames, colnames, and date and time
I noticed something surprising (in R 2.2.1 on WinXP)
According to the documentation, rownames and colnames are character vectors.
Assigning a vector of class POSIXct or POSIXlt as rownames or colnames
therefore is not strictly according to the rules.
In some cases, R performs a reasonable typecast, but in some other cases
where the same typecast also would be possible, it does not.
Assigning a
2006 Mar 21
1
rownames, colnames, and date and time
I noticed something surprising (in R 2.2.1 on WinXP)
According to the documentation, rownames and colnames are character vectors.
Assigning a vector of class POSIXct or POSIXlt as rownames or colnames
therefore is not strictly according to the rules.
In some cases, R performs a reasonable typecast, but in some other cases
where the same typecast also would be possible, it does not.
Assigning a
2006 Jul 03
1
rownames, colnames, and date and time
Hi all
I was wondering whether there has ever been an update on the rownames and
colnames behaviour as described by Eric below?
I still get the same behaviour, exactly as described by Eric, on my WinXP
installation of R-2.3.0. I also posted a message to r-help on Friday but
looking through the online archives it seems to have not made it to the
list. I would agree with Eric that a consistent
2002 Aug 14
3
t-test via matrix operations
I need to calculate a large number of t statistics, and would like to do so via matrix operations. So far I have figured out a way to calculate the mean of each row of the matrix:
d <- matrix(runif(100000,1,10), 1000, 10) # some test data
s <- rep(1,ncol(d)) # a sum vector to use for matrix multiplication
means <- (d%*%s)/ncol(d)
This is at least 1 order of magnitude faster than
2005 Oct 11
1
problems with levelplot and contourplot
Hello,
Using the following code i want to make a level or contourplot of some
data that I produced
library(grid);library(lattice);
mydata <- read.table("avgee.dat");
mymat <- as.matrix(mydata);
mymat <-t(mymat)
vals<-as.vector(mymat);
conc<-c(0.0, 0.5, 1, 1.5, 2, 2.5, 3, 3.5, 4, 4.5, 5);
a<- c(0.01, 0.025, 0.05, 0.075, 0.1, 0.25, 0.5, 0.75, 1, 2.5,5.0,
7.5,10,
2011 Aug 25
2
How to store the output of a loop into a matrix??
Hello,
I want to create a matrix of N random numbers with a uniform distributions. Later, I want to repeat T times each row of this matrix. For this I do the following loop:
N<-45
T<-10
n<-N*T
a<-matrix(runif(N,min=-1,max=1),nr=N)
mymat<-matrix(rep(NA,n),nr=n,nc=1)
for(i in i:N){
b<-rep(a[i,],T)
mymat[i,]<-b
}
Mi problem is that with this loop I can see the output of the
2008 Apr 10
2
subtract the mean from each column
Hi,
I am new to R an dI need some help
I have a matrix of real values 100*300 and I would like to calculate the
mean for each column , then for each entry in a column i need to subtract
the mean so I will have a matrix where the columns have zero mean. any one
know how to do that . Thanks
--
View this message in context:
2010 Jan 15
1
Lattice: How to color the data points in splom() according to the panel they are plotted?
Dear ExpeRts,
I have the scatter plot matrix as given below. I would like the different "sub-plots" in the scatter plot matrix to be colored differently. How do I get all points shown in the upper-left plot (on position (1,1) in the scatter plot matrix) to be plotted in blue, and the points shown in the plot to the right (on position (1,2) in the scatter plot matrix) to be plotted in
2010 Mar 23
2
Adding matrix rows that have the same name?
Does anyone know if there is an R function that will take a matrix like this
jim 1 0 0 0 0 0
jim 0 1 0 0 0 0
jim 0 0 1 0 0 0
bob 1 0 0 0 0 0
bob 0 0 1 0 0 0
harry 0 0 1 0 0 0
harry 0 0 0 1 0 0
harry 0 0 0 0 1 0
harry 0 0 0 0 0 1
and make it like this? (that is, add together rows that have the same name?)
jim 1 1 1 0 0 0
bob
2011 Feb 21
1
Query: matrix definition
Dear list users,
if within a function I first define a matrix
mymat <- matrix(NA, nrow=m, ncol=n)
and somewhere afterwards by mistake
mymat <- c(1,2,3)
this second command deletes the first one.
How can I make sure that within the function mymat will always remain the matrix defined at the beginning, without possibility of changing it throughout the code?
Secondly, is it possible to define
2009 Sep 09
1
Stats help with calculating between and within subject variance and confidence intervals
Hello.
I'm trying to find a way in R to calculate between and within subject
variances and confidence intervals for some analytical method
development data.
I've found a reference to a method in Burdick, R. K. & Graybill, F. A.
1992, Confidence Intervals on variance components, CRC Press. This
example is for Balanced Data confidence interval calculation from Pg
62. The data are
2009 Jul 13
4
Combine two matricies
Hi,
I have two matricies a and x:
a<-matrix(c(3,4,5,2,3,4,1,1,2), nrow=3, ncol=3)
[,1] [,2] [,3]
[1,] 3 2 1
[2,] 4 3 1
[3,] 5 4 2
x<-matrix(c(3, NA, NA, NA, 2, 5, NA, 2, 2), nrow=3, ncol=3)
[,1] [,2] [,3]
[1,] 3 NA NA
[2,] NA 2 2
[3,] NA 5 2
I wish to combine these two into one matrix using the values from x where x has values, and
2008 Mar 28
3
Converting a data frame to matrix
Hello:
I have a tab delim file with 100 rows and 100 columns.
I have numerical values in this table. What I want is to create an image
color map with color gradation.
my values range from -5 to 0. max value is 0.
to acheive this, I need to convert my data.frame into matrix.
I tried following :
mydf <- read.table('mytable',sep='\t',header=T)
mydf1 <- mydf[,2:100]