Displaying 20 results from an estimated 10000 matches similar to: "identical matrices"
2012 Nov 18
1
i want to put the results of the list in a for loop
Dear R users,
i want to put the results of a list to a for loop.
i will give an example
m1<-matrix(rep(1,15),ncol=5)
ind.sgn <- lapply(1:ncol(m1), combn, x = ncol(m1))
ind.sgn
[[1]]
[,1] [,2] [,3] [,4] [,5]
[1,] 1 2 3 4 5
[[2]]
[,1] [,2] [,3] [,4] [,5] [,6] [,7] [,8] [,9] [,10]
[1,] 1 1 1 1 2 2 2 3 3 4
[2,] 2 3 4 5
2008 Dec 11
3
generate combination multiset (set with repetition)
Hi,
This has been asked before but not sufficiently answered from what I
could find. How do you create combinations
with repetitions (multisets) in R?
If I have
> set <- array(1:3)
And I want to choose all combinations of picking 2 numbers, I want to
get a print out like
[,1] [,2]
[1,] 1 1
[2,] 1 2
[3,] 1 3
[4,] 2 2
[5,] 2 3
[6,] 3 3
subsets(set,
2012 Nov 17
2
problem with "any" function
Dear R users,
I have the "any" function of R
any(ind.c, ind.r, ind.sgn)
all are logical factors
it works fine when any of three is true
but when they are combined it doesnt work.
i tried
this
any(ind.c, ind.r, ind.sgn,((ind.c==TRUE) & (ind.r==TRUE)),
((ind.c==TRUE) & (ind.sgn==TRUE)),((ind.r==TRUE) & (ind.sgn==TRUE)),
((ind.c==TRUE) & (ind.r==TRUE) &
2012 Nov 11
2
changing the signs in rows or columns in matrices and check them if they are identical
Dear R users,
i have this problem with matrices i want to check between two matrices if they are isomorphic i will give an example for what excactly i want
1 -1 1 -1 1 1
-1 1 -1 1 -1 -1
1 1 -1 1 1 -1
this two matrices are isomorphic beacause if i change the first 2 columns the matrices
2012 Oct 30
5
Swap rows and columns in a matrix
Dear R users,
I want a help to write an algorithm for swapping rows and columns in a matrix
thanks in advance
[[alternative HTML version deleted]]
2012 Nov 12
2
Selected matrices of an array and put into a list
Dear R users,
I have an array that has matrices that i want BB[16,5,2:27]
i want to put each of the 26 matrices into a List
thanks in advance
[[alternative HTML version deleted]]
2009 Nov 16
1
No Visible Binding for global variable
While building a package, I see the following:
* checking R code for possible problems ... NOTE
cheat.fit: no visible binding for global variable 'Zobs'
plot.jml: no visible binding for global variable 'Var1'
I see the issue has come up before, but I'm having a hard time discerning how solutions applied elsewhere would apply here. The entire code for both functions is below,
2006 May 09
1
combn(n, k, ...) and all its re-inventions
It seems people are reinventing the wheel here:
The goal is to generate all combinations of 1:n of size k.
This (typically) results in a matrix of size k * choose(n,k)
i.e. needs O(n ^ k) space, hence is only applicable to
relatively small k.
Then alternatives have been devised to generate the combinations
"one by one", and I think I remember there has been a
quiz/challenge about 20
2008 May 09
0
applying cor.test to a (m, n) matrix - SUMMARY
Hi again,
I've got few very good options from the list and since they were not posted to the list, I will provide a summary. Thank you very much to all who answered and I hope this summary will benefit others interested in solving similar problems like that.
Yasir Kaheil re-wrote my original code in a more streamlined way:
pr<-array(0,c(dim(x)[2],dim(x)[2]));
for (i in 1:dim(x)[2]) for
2012 Aug 26
3
Two selections from Bag A
All, I am looking at an example in Aliaga's Interactive Statistics. Bag A has
the following vouchers.
BagA <- c(-1000,10,10,10,10,10,10,
10,20,20,20,20,20,20,30,
30,40,40,50,60)
Bag B has the following vouchers.
BagB <- c(10,20,30,30,40,40,50,50,
50,50,50,50,60,60,60,60,
60,60,60,1000)
Two values are selected (from BagA or BagB) without
2012 Nov 13
2
multiply each row in a matrix with the help of the for loop
Dear R users,
I have this program
aa<-array(rep(0,27),dim=c(3,3,3))
a<-matrix(rep(1,9),ncol=3)
n<-0
for (i in 1:3) {
a[i,]<-a[i,]*(-1)
n<-n+1
aa[,,n]<-a[i,]
}
but i real want to multiply each row with -1 according to for loop and after that to put it in the array.
I will give an example for what excaclty want
-1 -1 -1
1 1 1
1 1 1
-1 -1 -1
-1
2010 Mar 26
2
R loop help
Hi,
I am tring to write a loop to compute this,
==========================
x1=c(
rep(-1,4),
rep(1,4)
)
x2=c(
rep(c(-1,-1,1,1),2)
)
x3=c(
rep(c(-1,1),4)
)
x1*x2
x1*x3
x2*x3
========================
suppose i have x1,x2,x3
i want to compute their ' two factor interactions', x1x2,x1x3 and x2x3,
I wrote
========================
for(i in 1:2){
for( j in i+1:3){
xij=c()
2005 Sep 15
1
how to do sthg like "mat[!=(ind),]"
Hi
I want to do something which seems straightforward, but I couldn't find the
way to do this.
I have a matrix called m for example, and a vector of values (let's call ind
this vector) which are indices of lines I don't want to keep.
for example I have:
> m
v1 v2 v3
[1,] 1 4 7
[2,] 2 5 8
[3,] 3 6 9
[4,] 10 11 12
> ind
[1] 2 4
I would like to obtain this:
> m2
v1 v2
2016 Jan 25
4
Corregir mismo ID para individuos diferentes en una serie temporal
Hola a todos,
Quería preguntar si alguno sabe como puedo identificar registros con un mismo ID en el tiempo, pero que hacer referencia a objetos o individuos diferentes.
En mi caso en particular estoy estudiando un animal que tiene una vida media cercana 2 años, y tengo una serie longitudinal de 25 años. El problema es que durante el muestreo en algunos casos durante la recoleccion de los datos,
2008 Nov 26
2
Very slow: using double apply and cor.test to compute correlation p.values for 2 matrices
My two matrices are roughly the sizes of m1 and m2. I tried using two apply and cor.test to compute the correlation p.values. More than an hour, and the codes are still running. Please help to make it more efficient.
m1 <- matrix(rnorm(100000), ncol=100)
m2 <- matrix(rnorm(10000000), ncol=100)
cor.pvalues <- apply(m1, 1, function(x) { apply(m2, 1, function(y) { cor.test(x,y)$p.value
2008 Mar 13
3
fast way to compare two matrices of combinations
I have a list (length 750), each element containing a vector of unique
strings (unique gene ids), with length up to ~40 (median 15). I want to
compile a matrix of all possible triplets and their frequency within
gene elements. Using combn and a lot of looping, I am accomplishing this
but it is VERY slow.
I've tried to figure out a way to vectorize this, using "match" and
2012 Nov 05
3
Error message
Dear R users,
I have this problem with memory i guess
AA<-array(rep(0,96096000),dim=c(16,5,3003,400))
Error: cannot allocate vector of size 733.2 Mb
can anyone help me,
Thanks in advance...
[[alternative HTML version deleted]]
2007 Mar 27
2
Newbie: Combn and scripting
Hello All,
I have just installed my R 2.4 (windows) as a test trying to load a data
frame and run combn() for each line into another file. How do I do this?
data.csv:
a,b,c,d
1,2,3.4
g,3,6,t
etc
x=data.csv, m=3
Thank you
Zam
_________________________________________________________________________________
This email contains confidential information intended only for the person named
2009 Mar 20
2
A category reduction problem
I am trying to print out a list of strings of length 11 based on
integers 0 through 10. The rules as given to me for the ordering are:
The first digit must be 0.
The 2nd digit must be 0 or 1.
The 3rd digit must equal the 2nd digit or the 2nd digit +1.
...
Given the final digit, n, all digits 0 through n must appear in a given
sequence.
So the final 1024 item list should look like
0 1 2 3 4 5
2010 Jan 30
2
parsing files for plot
Hi,
I have many files containing one column of data. I like to use the scan
function to parse the data. Next I like to bind to a large vector.
I try this like:
count<-1
files <- list.files() # all files in the working directory
for(i in files) {
tmp <- scan(i)
assign(files[count], tmp)
count<-count+1
}
This part works!
Now I like to plot the data in a boxplot.