Dear R helpers
Suppose
x - c(1:3)
y - matrix(1:12, ncol = 3, nrow = 4)
y
[,1] [,2] [,3]
[1,] 1 5 9
[2,] 2 6 10
[3,] 3 7 11
[4,] 4 8 12
I wish to multiply 1st column of y by first element of x i.e. 1, 2nd column of
y by 2nd element of x i.e. 2 an so
try this:
x - 1:3
y - matrix(1:12, ncol = 3, nrow = 4)
y * rep(x, each = nrow(y))
I hope it helps.
Best,
Dimitris
On 4/20/2012 10:51 AM, Vincy Pyne wrote:
Dear R helpers
Suppose
x- c(1:3)
y- matrix(1:12, ncol = 3, nrow = 4)
y
[,1] [,2] [,3]
[1,]159
[2,]26
Dear Mr. Dimitris Rizopoulos,
Thanks a lot for your great help. It worked nicely. I couldn't have figured it
out. Thanks again.
Regards
Vincy
--- On Fri, 4/20/12, Dimitris Rizopoulos d.rizopou...@erasmusmc.nl wrote:
From: Dimitris Rizopoulos d.rizopou...@erasmusmc.nl
Subject: Re: [R] Matrix
On Apr 20, 2012, at 4:57 AM, Dimitris Rizopoulos wrote:
try this:
x - 1:3
y - matrix(1:12, ncol = 3, nrow = 4)
y * rep(x, each = nrow(y))
Another way with a function specifically designed for that purpose:
sweep(y, 2, x, *)
--
David.
I hope it helps.
Best,
Dimitris
On
And another way is to remember properties of matrix multiplication:
y %*% diag(x)
On Fri, Apr 20, 2012 at 8:35 AM, David Winsemius dwinsem...@comcast.net wrote:
On Apr 20, 2012, at 4:57 AM, Dimitris Rizopoulos wrote:
try this:
x - 1:3
y - matrix(1:12, ncol = 3, nrow = 4)
y * rep(x,
Friends
I am extracting sub-sets of the rows of a matrix. Generally the result is
a matrix. But there is a special case. When the result returned is a
single row it is returned as a vector (in the example below an integer
vector). If there are 0, or more than 1 rows returned the result is a
On Apr 10, 2012, at 7:33 PM, Worik R wrote:
Friends
I am extracting sub-sets of the rows of a matrix. Generally the
result is
a matrix. But there is a special case. When the result returned is a
single row it is returned as a vector (in the example below an integer
vector). If there
Thank you.
That was exactly what I need.
Looking at '?[' I see...
drop: For matrices and arrays. If TRUE the result is coerced to
the lowest possible dimension (see the examples). This only
works for extracting elements, not for the replacement. See
drop
On Apr 10, 2012, at 8:01 PM, Worik R wrote:
Thank you.
That was exactly what I need.
Looking at '?[' I see...
drop: For matrices and arrays. If TRUE the result is coerced to
the lowest possible dimension (see the examples). This only
works for extracting
Hello!
I got something to ask..whether you can help me with the R program...i got this
for example 5x4 matrix..and i want to find:
i) mean for each row of the matrix
ii) median for each column of the matrix
and i need to do this using a loop function...below is my program..u try to
check it for
apply(x, 1, mean)
apply(x, 2, median)
or for more speed rowMeans()
? apply
Michael
On Thu, Mar 29, 2012 at 9:00 AM, Christopher Kelvin
chris_kelvin2...@yahoo.com wrote:
Hello!
I got something to ask..whether you can help me with the R program...i got
this for example 5x4 matrix..and i want
Chris Kelvin
- Original Message -
From: R. Michael Weylandt michael.weyla...@gmail.com
To: Christopher Kelvin chris_kelvin2...@yahoo.com
Cc: r-help@r-project.org r-help@r-project.org
Sent: Thursday, March 29, 2012 11:33 PM
Subject: Re: [R] matrix with Loop
apply(x, 1, mean)
apply(x
Nobody any solution for my problem??
--
View this message in context:
http://r.789695.n4.nabble.com/matrix-unlist-strsplit-missing-value-issue-tp4509065p4511668.html
Sent from the R help mailing list archive at Nabble.com.
__
R-help@r-project.org
What problem? Nabble is not available to all and here is not much to cook
from.
Nobody any solution for my problem??
--
View this message in context:
http://r.789695.n4.nabble.com/matrix-unlist-
strsplit-missing-value-issue-tp4509065p4511668.html
Sent from the R help mailing list
On Wed, Mar 28, 2012 at 6:49 AM, Petr PIKAL petr.pi...@precheza.cz wrote:
What problem? Nabble is not available to all and here is not much to cook
from.
Indeed. Also the OP actually provided their own solution, just 5 more
minutes of googling to find ?sub.
bankoffer.3 -
Thank you!!
Been googling for hours, but kind of hard to find something if you don't
know how to look for it.
So thanks again!!
Greetings Maarten
ilai-2 wrote
On Wed, Mar 28, 2012 at 6:49 AM, Petr PIKAL lt;petr.pikal@gt; wrote:
What problem? Nabble is not available to all and here is not
*I'm still a R noob, just had a couple of lectures about it in our research
master.
There is a Deal or no deal experiment where I have to write some code for.
Someone wrote a website to gather the data and write it in a .xlsx file.
These are seperate files for seperate participants so first I
On 13.03.2012 15:40, RMSOPS wrote:
Hello
Error: could not find function sqldf:
Hello, I'm using R Studio, and installed the option of installing the
packages sqldbf function.
But When I run the code give the next error.
install.packages(sqldf)
library(RSQLite)
require(sqldf)
x-
Hello
I am developing a small program that to calculate the maximum, minimum
and average.
The data.frame v is
POS DIF
4 - 4 56
4 - 3 61
3 - 3 300
3 - 327
3 - 3 33
3 - 3 87
3 - 4 49
4 - 4 71
4 - 3 121
3 - 4 138
4 - 3 15
Hi
Hello
I am developing a small program that to calculate the maximum,
minimum
and average.
The data.frame v is
POS DIF
4 - 4 56
4 - 3 61
3 - 3 300
3 - 327
3 - 3 33
3 - 3 87
3 - 4 49
4 - 4 71
4 - 3 121
3 -
Try this:
require(sqldf)
x - read.fwf(textConnection(4 - 4 56
+ 4 - 3 61
+ 3 - 3 300
+ 3 - 327
+ 3 - 3 33
+ 3 - 3 87
+ 3 - 4 49
+ 4 - 4 71
+ 4 - 3 121
+ 3 - 4 138
+ 4 - 3 15), width = c(7,8) , header = FALSE, as.is = TRUE)
I have next table
source destine
33
77
6 6
3 4
4 4
4 3
3 3
3 3
3 3
3 3
3 4
4 4
4 3
3 4
4 3
I'm trying to create an array with the number of occurrences between the
source and destination.
Hello
is the dataset that was sent to help, has over two columns the source and
destination, is the separation of position pos
POS DIF SourceDest
4 - 4 56 4 4
4 - 3 61 4 3
3 - 3 300 3 3
3 -
I have next table
source destine
3 3
7 7
6 6
3 4
4 4
4 3
3 3
3 3
3 3
3 3
3 4
4 4
4 3
3 4
4 3
I'm trying to create an array with the number of occurrences between the
source and destination. id_ap-levels(factor(df$v_source))
num_AP-length(levels(factor(df$v_source)))
Hi,
On Tue, Mar 13, 2012 at 7:51 AM, RMSOPS ricardosousa2...@clix.pt wrote:
I have next table
source destine
3 3
7 7
6 6
3 4
4 4
4 3
3 3
3 3
3 3
3 3
3 4
4 4
4 3
3 4
4 3
It is so much easier if you use dput to provide reproducible data, as
the posting guide asks. There's
Hello
Error: could not find function sqldf:
Hello, I'm using R Studio, and installed the option of installing the
packages sqldbf function.
But When I run the code give the next error.
install.packages(sqldf)
library(RSQLite)
require(sqldf)
x - read.fwf(textConnection(4 - 4 56
+ 4
Hello,
this solve my problem. table(testdata$source, testdata$destine)
Thanks
--
View this message in context:
http://r.789695.n4.nabble.com/Re-Matrix-Another-table-tp4469376p4469384.html
Sent from the R help mailing list archive at Nabble.com.
Dear list,
I understand that to raise matrix A to power (-1/2) we should use something
like this:
eigen(A)$vectors%*%diag(1/sqrt(eigen(A)$values))%*%t(eigen(A)$vectors)
[from previous discussions:
http://r.789695.n4.nabble.com/matrix-power-td900335.html]
But this will only do it for negative
On Sun, Mar 11, 2012 at 1:46 AM, Ebrahim Jahanshiri
e.jahansh...@gmail.com wrote:
Dear list,
I understand that to raise matrix A to power (-1/2) we should use something
like this:
eigen(A)$vectors%*%diag(1/sqrt(eigen(A)$values))%*%t(eigen(A)$vectors)
[from previous discussions:
On Sun, Mar 11, 2012 at 8:56 AM, Peter Langfelder
peter.langfel...@gmail.com wrote:
On Sun, Mar 11, 2012 at 1:46 AM, Ebrahim Jahanshiri
e.jahansh...@gmail.com wrote:
Dear list,
I understand that to raise matrix A to power (-1/2) we should use something
like this:
If my memory is correct, the archives of this list contains
several discussions of round off error problems associated with
different methods for computing things like this. The Matrix package
(part of the base distribution) contains a function expm, whose help
file says, The expm
On 11-03-2012, at 17:52, Spencer Graves wrote:
If my memory is correct, the archives of this list contains several
discussions of round off error problems associated with different methods for
computing things like this. The Matrix package (part of the base
distribution) contains a
On 11-03-2012, at 18:18, Berend Hasselman wrote:
On 11-03-2012, at 17:52, Spencer Graves wrote:
If my memory is correct, the archives of this list contains several
discussions of round off error problems associated with different methods
for computing things like this. The Matrix
Hello,
I have a lot of data and it has a lot of NaN values. I want to compress the
data so I don't have memory issues later.
Using the Matrix package, sparseMatrix function, and some fiddling around,
I have successfully reduced the 'size' of my data (as measured by
object.size()). However, NaN
set.seed(1)
(DFid - data.frame(
x = sample(1:20,10),
y = sample(1:20,10),
IDs = sapply(1:10,function(i) paste(ID,i,sep=
require(spdep)
coordinates(DFid) - ~x+y
coords - coordinates(DFid)
dnn4 - dnearneigh(DFid,0,4)
summary(dnn4)
plot(DFid)
plot(dnn4,coords,add=T,col=2)
nb2mat(dnn4,
Dear List,
I have been trying to extract associations from a matrix whereby individual
locations are within a certain distance threshold from one another.
I have been able to extract those individuals where there is 'no interaction'
(i.e. where these individuals are not within a specified
I am trying to use matrix algebra to get the beta coefficients from a simple
bivariate linear regression, y=f(x).
The coefficients should be computable using the following matrix algebra: t(X)Y
/ t(x)X
I have pasted the code I wrote below. I clearly odes not work both because it
returns a
Hi John: I don't understand what you're doing ( not saying that it's wrong.
I just don't
follow it ). Below is code for computing the coefficients using the matrix
way I follow.
Others may understand what you're doing and be able to fix it so I wouldn't
just
use below immediately.
xprimex -
Mark
Thank you!
John
John David Sorkin M.D., Ph.D.
Chief, Biostatistics and Informatics
University of Maryland School of Medicine Division of Gerontology
Baltimore VA Medical Center
10 North Greene Street
GRECC (BT/18/GR)
Baltimore, MD 21201-1524
(Phone) 410-605-7119
(Fax) 410-605-7913 (Please
On 18-02-2012, at 14:36, John Sorkin wrote:
I am trying to use matrix algebra to get the beta coefficients from a simple
bivariate linear regression, y=f(x).
The coefficients should be computable using the following matrix algebra:
t(X)Y / t(x)X
I have pasted the code I wrote below. I
Thank you,
John
John David Sorkin M.D., Ph.D.
Chief, Biostatistics and Informatics
University of Maryland School of Medicine Division of Gerontology
Baltimore VA Medical Center
10 North Greene Street
GRECC (BT/18/GR)
Baltimore, MD 21201-1524
(Phone) 410-605-7119
(Fax) 410-605-7913 (Please call
The Wilcoxon test is not related to the difference in medians but rather to
the Hodges-Lehmann estimator, which is the median of all possible
differences of observations between sample 1 and sample 2. So what's needed
is a confidence interval for this estimate, obtainable from inverting the
if I have a vector, I can find the indexes which satisfy a condition:
x - rnorm(10)
[1] 0.4751132 -0.5442322 -0.1979854 -0.2455521 0.8349336 -0.4283345
[7] 0.6108130 2.0576160 1.1251716 -1.3933637
x[x0]
[1] 0.4751132 0.8349336 0.6108130 2.0576160 1.1251716
(1:10)[x0]
[1] 1 5 7 8 9
how
which(x0)
or
which(x0, arr.ind=TRUE)
depending on your application.
Michael
On Feb 13, 2012, at 5:38 PM, Sam Steingold s...@gnu.org wrote:
if I have a vector, I can find the indexes which satisfy a condition:
x - rnorm(10)
[1] 0.4751132 -0.5442322 -0.1979854 -0.2455521 0.8349336
On 12-02-13 5:46 PM, R. Michael Weylandt michael.weyla...@gmail.com wrote:
which(x0)
or
which(x0, arr.ind=TRUE)
depending on your application.
Or even x0 if you want a matrix of TRUE/FALSE values. You can use
x[x0] to get the values, but they won't be in matrix form.
Duncan Murdoch
How can I pass from position in length inside a matrix to position in dim ?
a=matrix(c(1:999),nrow=9)
which(a==87)#position in length 1:length(a)
87
which(a==87,arr.ind=TRUE) #position in dim
row col
[1,] 6 10
__
R-help@r-project.org
On Thu, Feb 02, 2012 at 02:08:37PM +0100, Ana wrote:
How can I pass from position in length inside a matrix to position in dim ?
a=matrix(c(1:999),nrow=9)
which(a==87)#position in length 1:length(a)
87
which(a==87,arr.ind=TRUE) #position in dim
row col
[1,] 6 10
Hi.
Also take a look at the arrayInd() function which is what's used by
which() internally for the arr.ind = TRUE case.
Michael
On Thu, Feb 2, 2012 at 8:25 AM, Petr Savicky savi...@cs.cas.cz wrote:
On Thu, Feb 02, 2012 at 02:08:37PM +0100, Ana wrote:
How can I pass from position in length inside a
Hello,
I made a boucle that put data inside N matrix. So for N=45, I have M1:M45.
Then I want to make a sn.em on each columns of each matrix. I don't know how
to call a i matrix (matrix(i) / matrix[i]) for i in 1:45.
Here is the code to make M1:M45
numberOfConfig8min -
Hi Ana,
d=dim(A)
d
[1] 2 4
cbind(rep(1:d[1], each=d[2]), rep(1:d[2], d[1]))
[,1] [,2]
[1,]11
[2,]12
[3,]13
[4,]14
[5,]21
[6,]22
[7,]23
[8,]24
Thanks,
wr
* Ana rrast...@gmail.com [2012-01-01 23:21:12 +0100]:
How can I
Hi Ana,
most probably this is one of the more ugly solutions:
d=dim(A)
d
[1] 2 4
cbind(rep(1:d[1], each=d[2]), rep(1:d[2], d[1]))
[,1] [,2]
[1,]11
[2,]12
[3,]13
[4,]14
[5,]21
[6,]22
[7,]23
[8,]24
Thanks,
wr
* Ana
How can I extract a list of the positions in the matrix?
A=matrix(1:8, nrow=2,ncol=4)
A
[,1] [,2] [,3] [,4]
[1,]1357
[2,]2468
Something like this
pos.A
1 1
1 2
1 3
1 4
2 1
2 2
2 3
2 4
__
R-help@r-project.org
Here's one way:
data.frame(rowID=as.vector(row(A)), colID=as.vector(col(A)), A=as.vector(A))
rowID colID A
1 1 1 1
2 2 1 2
3 1 2 3
4 2 2 4
5 1 3 5
6 2 3 6
7 1 4 7
8 2 4 8
You can sort that as desired.
Sarah
On Sun, Jan 1, 2012
Hi Ana,
most probably this is one of the more ugly solutions:
d=dim(A)
d
[1] 2 4
cbind(rep(1:d[1], each=d[2]), rep(1:d[2], d[1]))
[,1] [,2]
[1,]11
[2,]12
[3,]13
[4,]14
[5,]21
[6,]22
[7,]23
[8,]24
Thanks,
wr
* Ana
[This question is hopefully straight-forward, but difficult to provide
reproducible code.]
I'm doing a multivariate bootstrap, using boot::boot(),
where the output of the basic computation is a k x p matrix of coefficients,
representing a tuning constant x variable, as shown in the $t0
-
From: r-help-boun...@r-project.org [mailto:r-help-bounces@r-
project.org] On Behalf Of Michael Friendly
Sent: December-21-11 2:17 PM
To: R-help
Subject: [R] matrix multivariate bootstrap: order of results in $t
component
[This question is hopefully straight-forward, but difficult
Perhaps something like this (untested) -- it's going to depend on the
exact structure of your data so if this doesn't work, please use
dput() to send a plain text representation:
tapply(data, data$animal, function(d) d[, c(A01, A02)] - d[d$time
== d0, c(A01, A02)] )
In short, take data split it
On Dec 10, 2011, at 9:13 AM, R. Michael Weylandt wrote:
Perhaps something like this (untested) -- it's going to depend on the
exact structure of your data so if this doesn't work, please use
dput() to send a plain text representation:
tapply(data, data$animal, function(d) d[, c(A01, A02)] -
Hello,
I have a matrix
animaltime A01 A02
A d0 -5.4 2.7
A d1124.6 5.9
A d224 3.96.3
B
hi @ all,
I have problem with creating a matrix for a cor() function.
I try to use the cor() function on a matrix to test the correlation between
each value in a column.
Maybe like corr(x, method = xyz).
My x has two columns maybe like this:
MEDIA VALUE
Car 23
Train26
Plane 25
Cab
I'm not sure how you mean to calculate correlation if you have a
single observation of each mediumcan you provide your data (or a
subset thereof) so we can see what you are actually working with and
if correlation makes sense.
Michael
On Tue, Nov 29, 2011 at 10:41 AM, Geophagus
On 29.11.2011 16:41, Geophagus wrote:
hi @ all,
I have problem with creating a matrix for a cor() function.
I try to use the cor() function on a matrix to test the correlation between
each value in a column.
Maybe like corr(x, method = xyz).
My x has two columns maybe like this:
MEDIA VALUE
...@twain-systems.com
CC: r-help@r-project.org
Subject: Re: [R] Matrix for correlation
On 29.11.2011 16:41, Geophagus wrote:
hi @ all,
I have problem with creating a matrix for a cor() function.
I try to use the cor() function on a matrix to test the correlation between
each value
Hi Michael,
thank you so much for your fast reply.
On the image below there is an example of what I mean.
I need the correlation between the values on the fields with ?.
http://r.789695.n4.nabble.com/file/n4119734/corr_ex.png
But my source data is not in a matrix. It looks like the table in
I think everyone is worried about your data, not what a correlation
matrix is. Now I think you may be even more turned around: you want a
correlation between the values of the correlation matrix?
Just dput() your data object and copy it into your email and we'll see
if it's possible to calculate
Hi @ all and sorry for the confusion,
my problem is solved. I also know a corellation is - it was only a
formatting and describing problem. Grant gave me the right advice with the
kruskal-wallis!
Thanks
GeOphagus
--
View this message in context:
On Nov 6, 2011, at 12:21 AM, R. Michael Weylandt wrote:
There are a few (nasty?) side-effects to c(), one of which is
stripping a matrix of its dimensionality. E.g.,
x - matrix(1:4, 2)
c(x)
[1] 1 2 3 4
So that's probably what happened to you. R has a somewhat odd feature
of not really
It looks like pdf is not a scalar (that term actually has no meaning in R but
I know what you mean) but is rather a 1x1 matrix, as attested by the fact it
has dimensions. If you give dnorm() a matrix it will return one, as it did
here.
Perhaps you should look at the is.matrix() and
Hi,
R may not have a special scalar, but it is common, if informal, in
linear algebra to refer to a 1 x 1 matrix as a scalar. Indeed,
something like:
1:10 * matrix(2)
or
matrix(2) * 1:10
are both valid. Even
matrix(2) %*% 1:10
and
1:10 %*% matrix(2)
work, where the vector seems to be
Mucha gracias!! as.vector worked like a charm and, in this case,
produced the same results as c():
c(pdf)*v
as.vector(pdf)*v
At 07:02 PM 11/6/2011, R. Michael Weylandt michael.weyla...@gmail.com wrote:
It looks like pdf is not a scalar (that term actually has no
meaning in R but I
There are a few (nasty?) side-effects to c(), one of which is
stripping a matrix of its dimensionality. E.g.,
x - matrix(1:4, 2)
c(x)
[1] 1 2 3 4
So that's probably what happened to you. R has a somewhat odd feature
of not really considering a pure vector as a column or row vector but
being
is there a way to do element-by-element multiplication as in Gauss
and MATLAB, as shown below? Thanks.
---
a
1.000
2.000
3.000
x
1.0002.0003.000
2.0004.0006.000
3.000
Did you even try?
a - 1:3
x - matrix(c(1,2,3,2,4,6,3,6,9),3)
a*x
[,1] [,2] [,3]
[1,]123
[2,]48 12
[3,]9 18 27
Michael
On Fri, Nov 4, 2011 at 7:26 PM, Steven Yen s...@utk.edu wrote:
is there a way to do element-by-element multiplication as in Gauss
and
Need help with finding out approx over each row of a matrix. Here is the
setup:
years - matrix(c(1,2,3,1,2,3),nrow=2, ncol=3,byrow=TRUE)
rates - matrix(c(1,2,3,11,12,13), nrow = 2, ncol=3, byrow=TRUE)
points - matrix(c(1.5, 1.5), nrow=2, ncol=1, byrow=TRUE)
so basically i have above three
Your question as answered by Timothy in your previous thread
http://r.789695.n4.nabble.com/Re-Creating-the-mean-using-algebra-matrix-td3895689.html
flokke wrote:
Dear all,
Sorry to bother you with such a stupid question, but I just cannot find
the solution to my problem.
I'd like to
Dear all,
Sorry to bother you with such a stupid question, but I just cannot find the
solution to my problem.
I'd like to use matrix multiplication for meanA and factorial 3.
I use the command meanA%*%factorial 3.
But everything I get is: Error in factorial3 %*% A : non-conformable
arguments
On 12/10/11 09:11, flokke wrote:
Dear all,
Sorry to bother you with such a stupid question, but I just cannot find the
solution to my problem.
I'd like to use matrix multiplication for meanA and factorial 3.
I use the command meanA%*%factorial 3.
But everything I get is: Error in factorial3 %*%
the 1*1.3 part because 3+2 4
[1] 3.6
Cheers,
Fer
-Original Message-
From: David Reiner [mailto:david.rei...@xrtrading.com]
Sent: 3. oktober 2011 17:57
To: Cabrera, Fernando Álvarez; r-help@r-project.org
Subject: RE: [R] Matrix/Vector manipulation
sum(ifelse(cumsum(W)=v, W, 0) * R)
HTH
(W) = 4, W, 0) * R) # ignores the 1*1.3 part because 3+2 4
[1] 3.6
Cheers,
Fer
-Original Message-
From: David Reiner [mailto:david.rei...@xrtrading.com]
Sent: 3. oktober 2011 17:57
To: Cabrera, Fernando Álvarez; r-help@r-project.org
Subject: RE: [R] Matrix/Vector manipulation
sum(ifelse
Hi everybody
I have a questionnaire with a lot of questions that allow for more than one
option to be chosen (like a tickbox in a html form). The data captured on a
mobile device and is supplied in a format where every option is a separate
variable (logical). I want to develop a generic function
Hi guys,
Have the following problem computing vectors with pure vector algebra and end
up reverting to recursion or for-looping.
Function my_cumsum calculates a weighted average (W) of ratios (R), but only up
to the given size/volume (v). Now I recurse into the vector (from left to
right)
sum(ifelse(cumsum(W)=v, W, 0) * R)
HTH,
David L. Reiner
-Original Message-
From: r-help-boun...@r-project.org [mailto:r-help-boun...@r-project.org] On
Behalf Of fernando.cabr...@nordea.com
Sent: Monday, October 03, 2011 9:50 AM
To: r-help@r-project.org
Subject: [SPAM] - [R] Matrix
Thanks Michael it works!
Have to say it is amazing what you can do in R with a few lines (a line in this
case) of code.
Fernando
From: R. Michael Weylandt [mailto:michael.weyla...@gmail.com]
Sent: 27. september 2011 15:43
To: Cabrera, Fernando Álvarez
Subject: Re: [R] Matrix and list indices
Hi guys,
I am trying to replace all elements of earth that are equal to zero with their
corresponding elements in mars. I can do the replace with a bunch of for-loops,
but I don't think this is the R way of doing things.
my_list - list( earth=array(c(0,0,45,0,0,45,0,45),dim=c(2,2,2)),
On Tue, Sep 27, 2011 at 9:43 AM, R. Michael Weylandt
michael.weyla...@gmail.com wrote:
Untested, I believe this should work, though you might need to modify for
floating point funny business in testing the equalities:
my_list - list( earth=array(c(0,0,45,0,0,45,0,45),dim=c(2,2,2)),
Dear all,
When trying to multiply the same matrices repeatedly I get different
results some of the times.
It is not systematic, which is the fact that is giving me more trouble to
try to isolate the problem.
Basically I am doing X %*% B, where X is a Nx2 matrix and B is a vector
with 2 values.
I cannot replicate this on, even with 1 milllion reps on:
R version 2.13.1 (2011-07-08)
Platform: i386-pc-mingw32/i386 (32-bit)
or
R Under development (unstable) (2011-08-13 r56733)
Platform: x86_64-pc-mingw32/x64 (64-bit)
Perhaps it is OS dependent (I am away from my linux box at the moment)?
Joshua Wiley vas escriure el dia dt, 13 set 2011:
I cannot replicate this on, even with 1 milllion reps on:
R version 2.13.1 (2011-07-08)
Platform: i386-pc-mingw32/i386 (32-bit)
or
R Under development (unstable) (2011-08-13 r56733)
Platform: x86_64-pc-mingw32/x64 (64-bit)
Perhaps
I tried your example code on my laptop running Ubuntu Linux,
and of course it ran --- just as it should (*has* to!) without any
problem; no errors thrown.
This sort of thing should not/does not/cannot happen under
``normal circumstances''. There has to be something wrong
somewhere in your
Rolf Turner vas escriure el dia dt, 13 set 2011:
I tried your example code on my laptop running Ubuntu Linux,
and of course it ran --- just as it should (*has* to!) without any
problem; no errors thrown.
This sort of thing should not/does not/cannot happen under
``normal circumstances''.
Xavier Fernández i Marín xfim.ll at gmail.com writes:
Rolf Turner vas escriure el dia dt, 13 set 2011:
[snip]
This sort of thing should not/does not/cannot happen under
``normal circumstances''. There has to be something wrong
somewhere in your setup. Either your hardware or your
Xavier Fernández i Marín xfim.ll at gmail.com writes:
More elements: In python the same algorithm does not show this strange
behaviour.
Is Python using the same BLAS/LAPACK?
__
R-help@r-project.org mailing list
Ben Bolker vas escriure el dia dt, 13 set 2011:
You mentioned that you had compiled R yourself.
Can you replicate this with a stock R binary, i.e. from a
Red Hat or Ubuntu repository? If not, can you give details of
your compilation setup, especially if you are using a specialized
or
Hi Gabor,
Thanks. I will try to figure out the solution you suggest. I found out
about melt() from a discussion forum; it seems to me that
melt()$value is similar to c(), and when I modified the script as
below it 'seems' to be running faster. Anyway in the end I only needed
to use a smaller
sessionInfo()
R version 2.13.1 (2011-07-08)
Platform: x86_64-apple-darwin9.8.0/x86_64 (64-bit)
locale:
[1] en_US.UTF-8/en_US.UTF-8/C/C/en_US.UTF-8/en_US.UTF-8
attached base packages:
[1] stats graphics grDevices utils datasets methods base
other attached packages:
[1]
This is not an igraph issue, I believe. You need to go over your
indices and update the matrix, i.e.
for (i in seq_along(t.list)) { temp[t.list[i], c.list[i]] -
temp[t.list[i], c.list[i]] + 1 }
Best,
Gabor
On Tue, Aug 2, 2011 at 4:50 PM, Robinson, David G dro...@sandia.gov wrote:
I realize
Joe,
what is melt() supposed to do here?
What's wrong with the simple solution of creating a data.frame first,
and then filling it with values through a loop? Actually, keeping the
matrix is just as good, indexing is just as fast, and takes the same
amount of memory as your three column matrix,
Dear all,
I'm calculating matrix correlations with permutation tests and I got this
funny result. All correlation coefficients are the same with mantel.test
{ncf} and pcol {simba} but the two functions yield dramatically different
p-values (using the same number of permutations). Could
Dear Veronika,
I'm calculating matrix correlations with permutation tests and I got this
funny result. All correlation coefficients are the same with mantel.test
{ncf} and pcol {simba} but the two functions yield dramatically different
p-values (using the same number of permutations). Could
Using Igraph, I create shortest paths, then convert the matrix into
three column vectors - vertex1, vertex2, shortestpath - as the
code below shows.
#code for generating shortest path matrix and creating a 3 columns
from an igraph graph object y
y_s-shortest.paths(y, weights = NULL)
y_s -
301 - 400 of 903 matches
Mail list logo