Displaying 20 results from an estimated 20000 matches similar to: "matrix evaluation using if function"
2009 Jul 15
4
Extract pairs (rowname, columname) from a matrix where value is 0
Dear sir,
I have a matrix like
a<-matrix(c(0,2,0,4,0,6,5,8,0),nrow=3)
colnames(a)<-c("F1","F2","F3")
rownames(a)<-c("A1","A2","A3")
a
F1 F2 F3
A1 0 4 5
A2 2 0 8
A3 0 6 0
I want to extract all pairs (rownames, columnames) from which the value in
the matrix is 0
The result should be something like this
A1, F1
A2,
2008 Jun 11
4
Matrix transformation problem
ng,
I have a matrix (x) with binary content. Each row of the matrix holds exactly one 1, and the rest of the row is zeros. The thing is that I need to 'collapse' the matrix to one column where each row holds the original column index of the 1's (y). Sometimes, the matrix is quite large, so I have a perfomance problem.
x <- matrix(c(1,0,0, 0,0,1, 0,1,0, 0,0,1, 0,1,0,
2011 Nov 23
9
which en un data.frame de caracteres?
Hola a todos,
Tengo un "data.frame" de algunas columnas, el cual contiene objetos de tipo
"character". Me interesa encontrar las coordendas de un cierto objeto
dentro del "data.frame". Eso para arrays o para matrices lo hago con la
función which(). Pero no consigo hacerlo para esta caso ¿alguna sugerencia
para realizarlo sin tener que utilizar bucles?
Gracias por
2009 Oct 27
2
column names of a correlation matrix
Hi! All,
I am working on a correlation matrix of 4217x4217 named 'cor_expN'. I wish
to obtain pairs with highest correlation values. So, I did this
> b=matrix(data=NA,nrow=4217,ncol=1)
> rownames(b)=rownames(cor_expN)
> for(i in 1:4217){b[i,]=max(cor_expN[i,])}
> head(b)
[,1]
aaeA_b3241_14 0.7181912
aaeB_b3240_15 0.7513084
aaeR_b3243_15 0.7681684
2005 Feb 03
9
subset data.frame with value != in all columns
I am trying to extract rows from a data.frame based on the
presence/absence of a single value in any column. I've figured out how
to do get the positive matches, but the remainder (rows without this
value) eludes me. Mining the help pages and archives brought me,
frustratingly, very close, as you'll see below.
My goal: two data frames, one with -99 in at least one column in each
row,
2010 Oct 08
3
Efficiency Question - Nested lapply or nested for loop
My data looks like this:
> data
name G_hat_0_0 G_hat_1_0 G_hat_2_0 G_0 G_hat_0_1 G_hat_1_1 G_hat_2_1 G_1
1 rs0 0.488000 0.448625 0.063375 1 0.480875 0.454500 0.064625 1
2 rs1 0.002375 0.955375 0.042250 1 0.000000 0.062875 0.937125 2
3 rs2 0.050375 0.835875 0.113750 1 0.877250 0.115875 0.006875 0
4 rs3 0.000000 0.074750 0.925250 2 0.897750 0.102000
2009 Aug 27
5
Help on efficiency/vectorization
Dear R users,
I am trying to extract the rownames of a data set for which each columns
meet a certain criteria. (condition - elements of each column to be equal
1)
I have the correct result, however I am seeking for more efficient (desire
vectorization) way in implementing such problem as it can get quite messy if
there are hundreds of columns.
Arbitrary data set and codes are shown below for
2003 Aug 12
4
print points from a huge matrix
Hi All,
I have a 8000*8000 matrix and I want to print out a file with the row name,
column name and the value for those point with values satisfying a condition.
I tried using a for loop, however, it took me forever to get the result. Is
there a fast way to do this? Thanks!
Bing
---------------------------------
1060 Commerce Park
Oak Ridge National Laboratory
P.O. Box 2008, MS 6480
Oak
2001 Oct 09
3
find indices of nonzero elements
Hi,
Is there a function func(x) where x is an array such that it
returns a list of the indices of all non-zero elements of the array?
for example:
a:
1 0 0
0 0 1
0 1 0
func(a) returns two vectors r and c:
r c
1 1
2 3
3 2
daver
+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
|David Richmond It works on a |
+ Dept. of Sociology complex scientific
2007 Nov 08
6
Extract correlations from a matrix
Dear R users,
suppose I have a matrix of observations for which I calculate all
pair-wise correlations:
m=matrix(sample(1:100,replace=T),10,10)
w=cor(m,use="pairwise.complete.obs")
How do I extract only those correlations that are >0.6?
w[w>0.6] #obviously doesn?t work,
and I can?t find a way around it.
I would very much appreciate any help!
Best wishes
Christoph
(using R
2008 Jul 07
5
Basic Vector and Matrix Operations
I am wondering if it is possible to perform the following two basic
functions with primitive R functions. I know I could write functions for
either, but it seems as though they are probably built-in somewhere.
1) Fill out a vector to a desired length with missing values or zeros. So,
x<-c(3,4,5)
f(x,5)
3,4,5,NA,NA
2) Find the [row,col] location of a particular value in a matrix, eg
2011 Jan 18
3
error message
I was running a sampling syntax based on a data frame (ago) of 160 rows and
25 columns. Below are the column names:
> names(ago)
[1] "SubID" "AGR1" "AGR2" "AGR3" "AGR4" "AGR5" "AGR6" "AGR7"
"AGR8"
[10] "AGR9" "AGR10" "WAGR1" "WAGR2"
2009 Sep 10
2
index of min elements in matrix
Hi, All,
How can I get the indices of the minimum elements in a matrix without using
a loop?
For example, if the matrix is
4 5 2
2 8 9
5 2 3
Then I want to output (1,3), (2,1), (3,2).
Thanks,
Annie
[[alternative HTML version deleted]]
2007 Aug 01
2
Simple table with frequency variable
Hallo,
Im trying to find out how to tabulate frequencies
of factors when the data have a frequency variable.
e,g:
i<-rep(1:5,2)
j<-rep(1:2,5)
N<-10*i+j
table(i,j) gives a table of ones
as each combination occurs only once.
How does one get a table with the corresponding N's?
Thanks!
Gerrit.
--
Gerrit Draisma
Department of Public Health
Erasmus MC, University Medical Center
2008 Jun 12
1
Data.matrix fail to convert data.frame into matrix
Hi,
With the following codes, I attempt to convert
the data.frame into a matrix.
However I notice that data.matrix function doesn't
seem to work.
__ BEGIN__
dat <- read.table("mydata", comment.char = "!" , na.strings = "null");
# Select n-genes by random sample
# n = 1
nosamp <- 1
geneid <- sequence(nrow(dat))
geneid.samp <- sample(geneid,nosamp)
2018 Feb 28
1
Missed opportunity in the midend, unsigned comparison
Hi everybody, I see a missed optimization opportunity in LLVM that GCC
catches and I'd love to hear community's input.
Here's the original C code:
1 char arr[2];
2 char *get(unsigned ind) {
3 if (ind >= 1) {
4 return 0;
5 }
6 return &(arr[ind]);
7 }
The variable `ind` is unsigned so, based on the comparison, if it is not
greater or equals to one, than it is
2003 Apr 02
7
Index of item in matrix
Hello All,
Is there a fast way to find the index(row and column) of a point in a
matrix?
Thanks,
John.
--
--------------------------------------------------------------------------
Dr. John Janmaat
Department of Economics, Acadia University, Wolfville, NS, B4P 2R6
E-mail: jjanmaat at acadiau.ca Web: http://ace.acadiau.ca/~jjanmaat
Tel: 902-585-1461 Fax: 902-585-1070
2009 May 18
1
Predicting complicated GAMMs on response scale
Hi,
I am using GAMMs to show a relationship of temperature differential over
time with a model that looks like this:-
gamm(Diff~s(DaysPT)+AirToC,method="REML")
where DaysPT is time in days since injury and Diff is repeat measures of
temperature differentials with regards to injury sites compared to
non-injured sites in individuals over the course of 0-24 days. I use the
following
2012 Jun 19
2
how to use by function
hi all,
Assume I have data like
data<-rbind(c(1,2),c(1,3),c(2,1),c(3,2),c(3,4))
I want to get some matrix like
1,2,3
2,NA,NA
3,2,4
I'm using by
mat<-matrix(NA,3,3)
by(data,data[,1],mat[data[,1],]<-c(data[,2]))
but it doesn't work.
Any ideas?
thanks,
cowboy
2009 Apr 21
4
search through a matrix
Hi. I have a 925 by 925 correlation matrix corM. I want to identify all
variables that have correlation greater than 0.9. Can anyone suggest an "R
way" of doing this?
Thank you.
--
View this message in context: http://www.nabble.com/search-through-a-matrix-tp23153538p23153538.html
Sent from the R help mailing list archive at Nabble.com.