similar to: matrix subset

Displaying 20 results from an estimated 20000 matches similar to: "matrix subset"

2005 Dec 06
2
how to extract row& col names from a matrix
Dear all, I like to extract row names & column names from the named matrix...... like...... a<-matrix(1:6,2) ro<-c("aa","bb") co<-c("dd","ee","ff") dimnames(a)<-list(ro,co) a > dd ee ff aa 1 3 5 bb 2 4 6 from the above matrix "a" I like to extract rownames separately like
2005 Dec 04
4
Construct a data.frame in a FOR-loop
Say I have a FOR-loop for computing powers (just a trivial example) for(i in 1:5) { x<-i^2 y<-i^3 } How can I create a data.frame and a 3D plot of (i,x(i),y(i)), i.e. for each iteration Thanks, Serguei Kaniovski -- ___________________________________________________________________ ??sterreichisches Institut f??r Wirtschaftsforschung (WIFO) Name: Serguei Kaniovski
2005 Dec 17
1
How to reverse the sequence of axis Y ??
Hello R-users! My (simple?) doubt: How to reverse the sequence of axis Y ?? the diagram below illustrate my idea... (default) | | . | . | . | 3 | 2 | 1 | 0 +---------------------------- 0 1 2 3 ... like I want... 0 | 1 | 2 | 3 | . | . | . | | +---------------------------- 0 1 2 3 ... thanks in advance klebyn
2005 Dec 06
4
R newbie...
Hello, I'm a new user... I have a function : calculate <- function(x,y) { z <- x + y } I would like to use the result (z) with another function : recalculate <- function(...) { a <- z^2 } But R says that z does not exist... How can I use z in an another function ? Thank you for your answer... -- David [[alternative HTML version deleted]]
2005 Dec 09
3
R-how to group the data
Hello R - users, This may sound simple to may people: I have a list of data as follows type value y 7 y 7 y 8 y 8 y 8 y 9 y 9 y 9 y 9 y 10 y 10 y 10 y 10 y 11 y 11 y 12 y 12 y 14 y 14 y 14 y 15 y 17 y 20 y 20 y 20 y 20 y 25
2005 Nov 04
2
Simplify iterative programming
Dear, I am looking for the simplification of a formula to improve the calculation speed of my program. Therefore I want to simplify the following formula: H = sum{i=0..n-1 , [ sum {j=0..m-1 , sqrt ( (Ai - Bj)^2 + (Ci - Dj)^2) } ] } where: A, C = two vectors (with numerical data) of length n B, D = two vectors (with numerical data) of length m sqrt = square root Ai = element of A with index
2005 Dec 06
2
Writing a list to a file !
Hi All, This may be trivial in R but I have been trying with out any success. I have a list of 100 elements each having a sub list of different length. I would like to write the list to a ASCII file. I tried with write.table(), after converting my list to a matrix. Now it looks like Robert c("90", "50", "30") John c("91", "20",
2005 Dec 15
5
How to simulate correlated data
Hello there, I would like to simulate X --Normal (20, 5) Y-- Normal (40, 10) and the correlation between X and Y is 0.6. How do I do it in R? Thank you very much Lisa Wang Msc. Princess Margaret Hospital Toronto, Ca
2005 Nov 28
6
How define global Variable?
Hello, I try to define a global variable. My example: R> a <- "old" R> test <- function () { a <- "new" } R> test() R> a # shoud be "new" This doesn't work. I would like to modify the variable "a" in a procedure. How can I do that. Thank you for helping. Sven Kn侟ppel (Germany-Berlin)
2005 Sep 16
2
fusion of rows (as in merge()) but from only 1 matrix
Dear all, Once again I need your help ; I fond a way to do what I want but I am sure there is a better way.. maybe you can help me. I have a matrix, for example mat.tot : > mat.tot ID Desc M1 M2 1 1 gene1 0.5 0.2 2 2 gene2 -0.4 -0.1 3 3 gene3 1.0 1.2 4 4 gene1 0.6 0.3 5 5 gene2 -0.3 0.0 and I want to merge line 1 with line 4, and line 2 with line 5 because this is the same gene. I can
2009 Jul 09
1
Converting indices of a matrix subset
-----BEGIN PGP SIGNED MESSAGE----- Hash: SHA1 I have two matrices: > m1 <- matrix(1,4,4) > m1 [,1] [,2] [,3] [,4] [1,] 1 1 1 1 [2,] 1 1 1 1 [3,] 1 1 1 1 [4,] 1 1 1 1 > m2 <- matrix(0,3,3) > diag(m2) <- 1 > m2 [,1] [,2] [,3] [1,] 1 0 0 [2,] 0 1 0 [3,] 0 0 1 I want to get indicies from m2
2006 Jun 15
3
matrix selection return types
Dear Rusers, I would like some comments about the following results (under R-2.2.0) > m = matrix(1:6 , 2 , 3) > m [,1] [,2] [,3] [1,] 1 3 5 [2,] 2 4 6 > z1 = m[(m[,1]==2),] > z1 [1] 2 4 6 > is.matrix(z1) [1] FALSE > z2 = m[(m[,1]==0),] > z2 [,1] [,2] [,3] > is.matrix(z2) [1] TRUE Considered together, I'm a bit surprised about
2010 Aug 27
1
Error: package/namespace load failed for 'IlluminaHumanMethylation27k.db'
Hello everyone, I have a problem when loading the library: IlluminaHumanMethylation27k.db I installed the package from zip (from the Bioconductor website), and also installed all the packages it asked for. It went all succesfull: "package 'IlluminaHumanMethylation27k.db' successfully unpacked and MD5 sums checked" But when I am trying to load this library I get an error:
2012 Apr 25
1
Strange behavior of model.frame() when given subset
Dear R-devel, I recent got a bug report from a locfit user about the use of the subset argument when calling locfit(). Basically the symptom is that the following two calls should produce the same result, but they don't: locfit(y ~ lp(x, h=1), data=subset(dat, x > 1)) locfit(y ~ lp(x, h=1), data=dat, subset= x > 1) I've tracked the problem down to something shown in the following
2006 Jul 04
5
removing for loop
Dear Rusers, Trying to reduce my for loops addiction, could somebody tell me if there are ways to simplify (and perhaps accelerate ?) the following line for (i in 1:N) for (j in 1:N) m[i,j] = b[i]-b[j]; (where m is a NxN matrix and b a vector of length N) Thanks for any hint.
2012 Mar 08
4
Correlation between 2 matrices but with subset of variables
Dear All, I have two matrices A (40 x 732) and B (40 x 1230) and would like to calculate correlation between them.  I can use: cor(A,B, method="pearson") to calculate correlation between all possible pairs. But the issue is that there is one-many specific mappings between A and B and I just need to calculate correlations for those pairs (not all). Some variables in A (proteins, say p1)
2020 Aug 11
2
M[cbind()] <- assignment with Matrix object loses attributes
? Does this constitute a bug, or is there something I'm missing? assigning sub-elements of a sparse Matrix via M[X]<-..., where X is a 2-column matrix, appears to drop user-assigned attributes. I dug around in the R code for Matrix trying to find the relevant machinery but my brain started to hurt too badly ... ?? Will submit this as a bug if it seems warranted. library(Matrix) m1
2005 Aug 22
3
read a table ignoring specific rows ?
Dear R users, First of all sorry for this question, surely quite naive. (I searched on the R site but was unable to find by myself). I have a table, called infile : 1 2 3 4 5 6 7 8 9 I would like to read it and ignore the rows with 1st element > 3 I do it now with a for loop, and it's ok, but I was expecting something simpler, like : intable = read.table(infile); newtable =
2009 Oct 29
2
fast cumulative matrix multiplication
Hi all, I am looking for a function like cumprod() that works for matrix multiplication. In other words, I have matrices [M1, M2, ..., Mn], and I want to calculate [M1, M1%*%M2, M1%*%M2%*%M3, ..., M1%*%...%*%Mn] as quickly as possible. Right now I'm using a for() loop but it seems like there should be a faster way. Any help is appreciated! Thanks, Todd Schneider todd.w.schneider@gmail.com
2012 Nov 06
1
Filling matrix elements with a function
Hi all, I have a matrix simulating migration in a spatial model. I want to be able to define movement (the values of m1, m2 and m3) as only != 0 between adjacent patches and contingent on certain conditions as defined in the function. Here is the code: WET<-function(t) {everglades$precipitation[t]} #simply reads precipitation data from a csv, value is numeric AB<-function(WET,t)