Displaying 20 results from an estimated 10000 matches similar to: "Newbie needs to count elements in a row"
2003 Oct 31
2
Summing elements in a list
Hi,
Suppose that I have a list where each component is a list of two
matrices. I also have a vector of weights. How can I collapse my
list of lists into a single list of two matrices where each matrix
in the result is the weighted sum of the corresponding matrices.
I could use a loop but this is a nested calculation so I was hoping
there is a more efficient way to do this. To help clarify,
2013 Mar 08
4
create bar chart with different totals in a bar
Hello together,
perhabs anyone of you, has an ideal, how i can do this:
I have a matrix, like this one:
[,1] [,2] [,3]
[,4]
abnr2 11425 11425 11555 11888
TIME 2 1 1 2
Cat 1 2 1
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.
2009 Jul 02
2
matching rows in matrices
I have a matrix such as this,
[,1] [,2] [,3]
[1,] 1 1 2
[2,] 2 5 5
and a larger matrix such as this,
a b
[1,] 1 5
[2,] 2 5
[3,] 4 9
[4,] 5 8
[5,] 7 8
[6,] 7 10
[7,] 9 10
what I want to do is check the number of times the columns in the first
matrix appear as rows in the second matrix. So for instance in this example
1,5 and 2,5 appear in both so I'd want
2013 Feb 21
3
Ask for help: find corresponding elements between matrix
Dear R experts,
I have two matrix (seq & mat) & I want to retrieve in a new matrix all the numbers from mat that =1 (corresponding to the same row/ column position) in seq, or all the numbers in mat that =-1 in seq. - Replace all the numbers with NA if it's not 1/-1 in seq. There are some "NA"s in seq.
seq=matrix(c(1,-1,0,1,1,-1,0,0,-1,1,1,NA),3,4)
2009 May 19
3
how to calculate means of matrix elements
useR's,
I have several matrices of size 4x4 that I want to calculate means of their
respective positions with. For example, consider I have 3 matrices given by
the code:
mat1 <- matrix(sample(1:20,16,replace=T),4,4)
mat2 <- matrix(sample(-5:15,16,replace=T),4,4)
mat3 <- matrix(sample(5:25,16,replace=T),4,4)
The result I want is one matrix of size 4x4 in which position [1,1] is the
2007 Nov 12
1
update matrix with subset of it where only row names match
I guess this has a simple solution:
I have matrix 'mat1' which has row and column names, e.g.:
A B C
row1 0 0 0
row2 0 0 0
....
rown 0 0 0
I have a another matrix 'mat2', essentially a subset of 'mat1' where the
rownames are all in 'mat1' e.g.:
B
row3 5
row8 6
row54 7
I want to insert the values of matrix mat2 for column B (in reality it
could be some or
2010 Jan 29
7
Simple question on replace a matrix row
Hello, I have a matrix mat1 of dim [1,8] and mat2 of dim[30,8], I want to
replace the first row of mat2 with mat1, this is what I do:
mat2[1,]<-mat1 but it transforms mat2 in a list I don't understand, I want
it to stay a matrix...
-----
Anna Lippel
--
View this message in context: http://n4.nabble.com/Simple-question-on-replace-a-matrix-row-tp1427857p1427857.html
Sent from the R help
2013 Sep 02
3
Product of certain rows in a matrix
Hi,
You could try:
A<- matrix(unlist(read.table(text="
1 2 3
4 5 6
7 8 9
9 8 7
6 5 4
3 2 1
",sep="",header=FALSE)),ncol=3,byrow=FALSE,dimnames=NULL)
library(matrixStats)
?res1<-t(sapply(split(as.data.frame(A),as.numeric(gl(nrow(A),2,6))),colProds))
?res1
#? [,1] [,2] [,3]
#1??? 4?? 10?? 18
#2?? 63?? 64?? 63
#3?? 18?? 10??? 4
2012 Jun 27
3
[LLVMdev] Counting instructions in MCJIT
Hi there,
I wondered whether anyone could give me any advice about counting
assembly instructions when using MCJIT?
For performance regression testing I would like to be able to count the
number of instructions generated during the jit compilation of a given
module.
The Statistic class, as far as I understand, cannot collect this data
per-module (per-ExecutionEngine/per-MCJIT), and there is
2011 Sep 30
2
remove elements from matrix
Dear all,
I have a numeric vector that contains indices.
I also have two matrices of [1,m] dimension and of [m,n] dimension.
I want for every indexto remove the current element from the [1,m] vector an the row from the [m,n] matrix.
How I can do that efficiently in R? So to say not have a for loop getting parameter after parameter and then removing row by row from the vector and the matrix.
I
2008 Aug 29
2
Newbie: Examples on functions callling a library etc.
Hello
R is pretty new to me. I need to write a function that returns three
matrices of different dimensions. In addition, I need to call a function
from a contributed package with the function. I have browsed several
manuals and docs but the examples on them are either very simple or
extremely hard to follow.
Many thanks
Ed
[[alternative HTML version deleted]]
2012 Oct 08
3
How to count combinations
Dear all,
Need a help. I would like to count combination of two columns:
structure(list(V1 = structure(c(4L, 1L, 1L, 1L, 1L, 1L, 1L, 1L,
1L, 1L, 1L, 1L, 1L, 2L, 2L, 3L, 3L, 3L, 3L, 3L, 3L, 3L), .Label = c("23",
"55", "67", "Env"), class = "factor"), V2 = structure(c(9L, 7L,
7L, 7L, 2L, 1L, 11L, 11L, 11L, 11L, 5L, 6L, 6L, 3L, 8L, 2L, 1L,
4L, 4L,
2005 Apr 29
1
na.action
Hi,
I had the following code:
testp <- rcorr(t(datcm1),type = "pearson")
mat1 <- testp[[1]][,] > 0.6
mat2 <- testp[[3]][,] < 0.05
mat3 <- mat1 + mat2
The resulting mat3 (smaller version) matrix looks like:
NA 0 0 0
0 NA 0 NA
0 0 NA 2
0 0 2 NA
To get to the number of times a '2' appears in the rows, I was
2012 Jun 28
0
[LLVMdev] Counting instructions in MCJIT
Hi Verena,
I think that we can count the number of instructions with "-stats"
command line option. As you mentioned, this option uses Statistic class
like "STATISTIC(EmittedInsts, "Number of machine instrs printed");"
I don't know exactly about parallel code generation environment but
this option seems like to work correctly in common case as following.
This is
2011 Apr 10
3
count number of TRUEs in each row
Hi all,
I have a huge matrix of TRUE/FALSE table like following, and I want to count
the number of TRUEs in each row. Instead of looping through each row and do
length(Z[Z==TRUE]), I am wondering if there is an easier way of doing this.
[,1] [,2] [,3]
[1,]TRUE FALSE FALSE
[2,]FALSE TRUE TRUE
Thank you in advance.
Wendy
--
View this message in context:
2012 Jul 31
3
[LLVMdev] mcjit
Thu Jul 12 03:42:12 CDT 2012, Verena Beckham verena at codeplay.com :
> I would not say it is trivial, having done it myself.
>
> MCJIT also doesn't support multiple modules, and it does not do JITing
> on demand, instead, it does all of it at the same time in the
> constructor (unless that is what you call "not lazy").
> So depending on how you've written your
2012 Jun 29
2
[LLVMdev] Comment "FIXME" in X86MachObjectWriter::RecordX86Relocation
Can I assume we're talking about MCJIT since a file format and relocations are involved?
Some changes are required in order to get MCJIT to generate ELF object files. Eli Bendersky submitted a patch some time ago to modify the target triple code to enable this, but after a bit of discussion there didn't seem to be a consensus for accepting this proposal.
If you want to try it out, the
2013 Jan 16
3
matrix manipulation with its rows
Dear R users,
I have a question about matrix manipulation with its rows.
Plz see the simple example below
sample <- list(matrix(1:6, nr=2,nc=3), matrix(7:12, nr=2,nc=3),
matrix(13:18,nr=2,nc=3))
> sample
[[1]]
[,1] [,2] [,3]
[1,] 1 3 5
[2,] 2 4 6
[[2]]
[,1] [,2] [,3]
[1,] 7 9 11
[2,] 8 10 12
[[3]]
[,1] [,2] [,3]
[1,] 13 15 17
[2,]
2013 Sep 27
3
Compare species presence and absence between sites
Dear List,
I want to compare the presence and absence of bird species based on the
sites in a matrix.
The matrix has 5 rows for Island A, B, C, D, and E.
It has 100 columns for bird species D001-D100.
In each cell of the matrix,
the presence-absence of bird species will be recorded as 1 or 0.
(For example, if species D001 is found on Island D,
the matrix cell of species D001 and Island D