Displaying 20 results from an estimated 30000 matches similar to: "Adding elements of matrices of different dimensions"
2005 Nov 21
3
Comparing rows of matrices with different dimensions
Hi there,
I have a question, which I thought is very easy to solve, but somehow I can't find a solution. Probably someone could help me quickly?
Here it is:
I have two matrices:
a
[,1] [,2] [,3]
[1,] 1 4 9
[2,] 2 6 10
[3,] 3 6 11
[4,] 4 8 12
b
[,1] [,2]
[1,] 1 4
[2,] 2 5
[3,] 3 6
Now I want to find
2008 Mar 13
2
joining matrices, vectors, scalars in one object
Hi,
I have:
a <- matrix(c(0,1,0,1),nrow=2)
b <- matrix(c(1,1,1,0,0,0),nrow=3)
c <- 1
d <- c(1,0,1)
And I would like to join them in an object 'thing' so that I can
access a, b, c, or d through an index in a for loop.
For example:
thing[4]
would return
[1] 1 0 1
Note however, that I have many of these 'thing' components. So many
that a command like
thing
2007 May 04
2
Get the difference between two matrices with different length
Hello,
I have got two matrices with different length. The matrices have 3
columuns. The first two are coordinates. The third is a measurement.
Now I want to get a subtraction between every single value of the
third column (between matrix1 and matrix2), but only if the two
first coordinates in matrix1 and matrix2 are the same.
I tried "FUN=?" in aggregate and ave, but I don't know
2008 Apr 09
4
apply lm() for all the columns of a matrix
Hi all,
My question is not really urgent. I can write a loop and solve the
problem. But I know that I'll be in a similar situation many more times so
it would be useful to find out the answer
Is there a fast way to perform linear fit to all the columns of a matrix?
(or in the one dimension of a multi-dimensional array.) I'm talking about
many single linear fits, not about a multiple fit.
2007 May 20
2
Number of NA's in every second column
Hi R-users,
How do I calculate a number of NA's in a row of every second column in my
data frame?
As a starting point:
dfr <- data.frame(sapply(x, function(x) sample(0:x, 6, replace = TRUE)))
dfr[dfr==0] <- NA
So, I would like to count the number of NA in row one, two, three etc. of
columns X1, X3, X5 etc.
Thanks in advance
Lauri
[[alternative HTML version deleted]]
2006 May 12
3
Maximum likelihood estimate of bivariate vonmises-weibulldistribution
Thanks Dimitris!!! That's much clearer now. Still have a lot of work to
do this weekend to understand every bit but your code will prove very
useful.
Cheers,
Aziz
-----Original Message-----
From: Dimitrios Rizopoulos [mailto:Dimitris.Rizopoulos at med.kuleuven.be]
Sent: May 12, 2006 4:35 PM
To: Chaouch, Aziz
Subject: RE: [R] Maximum likelihood estimate of bivariate
2006 Jan 10
2
Correct way to test for exact dimensions of matrix or array
Dear R Users,
I want to test the dimensions of an incoming vector, matrix or array safely
and succinctly. Specifically I want to check if the unknown object has
exactly 2 dimensions with a specified number of rows and columns.
I thought that the following would work:
> obj=matrix(1,nrow=3,ncol=5)
> identical( dim( obj) , c(3,5) )
[1] FALSE
But it doesn't because c(3,5) is numeric
2006 Jul 06
3
Comparing two matrices
hi:
I have matrix with dimensions(200 X 20,000). I have
another file, a tab-delim file where first column
variables are row names and second column variables
are column names.
For instance:
> tmat
Apple Orange Mango Grape Star
A 0 0 0 0 0
O 0 0 0 0 0
M 0 0 0 0 0
G 0 0 0 0 0
S 0 0 0 0 0
2005 Sep 22
2
R: extracting elements in a matrix
Dear R-users
For a given matrix of dimension, say (n,p), I'd like to extract for every
column those elements that are bigger than twice the interquartile range of
the corresponding column.
Can I get these elements without using a loop?
Thank you for your help
Frank
[[alternative HTML version deleted]]
2007 Jan 24
4
Replace missing values in lapply
I have some matrices stored as elements in a list that I am working
with. On example is provided below as TP[[18]]
> TP[[18]]
level2
level1 1 2 3 4
1 79 0 0 0
2 0 0 0 0
3 0 0 0 0
4 0 0 0 0
Now, using prop.table on this gives
> prop.table(TP[[18]],1)
level2
level1 1 2 3 4
1 1 0 0 0
2
3
2008 Jun 04
4
sum of unknown number of matrices
Hi R,
I have a list of matrices. I need to get the sum of all the matrices in
the list.
Example:
a=b=c=d=matrix(1:4,2,2)
l=list(a,b,c,d)
I need:
> a+b+c+d
[,1] [,2]
[1,] 4 12
[2,] 8 16
Something like do.call("+",l) is not working...why is this?
I may not be knowing the number of matrices in the list...
Thanks, Shubha
This e-mail
2007 May 04
4
logical or for two vectors or matrices
Hello,
it might be a very simple question but I cannot find the solution (I tried a || b, any(a,b)... but none works). My problem is:
I have two vectors,
a <- c(TRUE,FALSE,FALSE)
b <- c(TRUE,FALSE,TRUE)
and I would like to obtain a vector that indicates if it is TRUE in any of the two vectors. Hence, the desired output would be: TRUE, FALSE, TRUE
Thank you in advance,
Federico
2005 Sep 25
2
getting variable length numerical gradient
Hi all.
I have a numerical function f(x), with x being a vector of generic
size (say k=4), and I wanna take the numerically computed gradient,
using deriv or numericDeriv (or something else).
My difficulties here are that in deriv and numericDeric the function
is passed as an expression, and one have to pass the list of variables
involved as a char vector... So, it's a pure R programming
2006 Nov 09
4
Plotting symbols with two positions?
Thanks a lot to Demitris for a prompt answer some minutes ago on another
tread (see below). To avoid excess mails on the list, I move onto next
question:
I have another small plotting problem that confuses me. I want to plot
results from a field trial series, using the numbers of the trials as
symbols in the plot.
pch = as.character(trial_no)
works fine, but truncates the trial number to the
2006 Mar 02
2
'...' passed to both plot() and legend()
Dear R-devels,
I'd like to create a plot method for a class of objects that passes
the '...' argument to both plot() and legend(), e.g.,
x <- list(data = rnorm(1000))
class(x) <- "foo"
plot.foo <- function(x, legend = FALSE, cx = "topright", cy = NULL,
...){
dx <- sort(x$data)
plot(dx, dnorm(dx), type = "l", ...)
if (legend)
2006 Jun 16
3
Vector Manipulation
I have a vector that has 1,974 elements and each element is one of the
following (B, F, N, Y). How do I recreate that vector accept in the
place of N put 0 and in the place of B, F or Y put a 1?
Thanks,
Jacob
[[alternative HTML version deleted]]
2006 Sep 28
2
get index of elements in vector
Hello all
Is There a fuction that return a index of a element in vector?
like this semantic example:
vector = c( 100, 200, 300 )
getINDEX( vector, value = 200 )
Thanks in advance for your attention.
Cleber Borges
2006 Feb 14
2
combine elements of a character vector into a character
Hi R users
I have a simple question to ask
x <- c("a","b","c")
x
[1] "a" "b" "c"
I like to have "abc" instead of having "a" "b" "c"
I tried to use paste and other functions related to character.
Is there any function (command) that enable me to combine elements of a
character vector into
2007 Jul 23
3
extraction of vector elements to new list
Dear R-community,
I have got a list of vectors and would like to extract the first two
elements of each vector to a new list.
My list is of the style:
my.list = list(c("a", "b", "c"), c("d", "e"), c("f", "g", "h", "i"), ...)
#I want:
new.list = list(c("a", "b"), c("d",
2008 Jun 09
3
Overlaying the matrices
Hi R,
I have a matrix,
> x1=matrix(NA,6,6,dimnames=list(letters[1:6],LETTERS[1:6]))
> x1
A B C D E F
a NA NA NA NA NA NA
b NA NA NA NA NA NA
c NA NA NA NA NA NA
d NA NA NA NA NA NA
e NA NA NA NA NA NA
f NA NA NA NA NA NA
> x2=matrix(rpois(9,1),3,3,dimnames=list(c("b","a","f"),c("D","E","F")))
> x2