similar to: which() and value replacement in a matrix

Displaying 20 results from an estimated 40000 matches similar to: "which() and value replacement in a matrix"

2005 Feb 21
5
Compare rows of two matrices
Hello, #I have two matrices, eg.: y <- matrix( c(20, NA, NA, 45, 50, 19, 32, 101, 10, 22, NA, NA, 80, 49, 61, 190), ncol=4 ) x <- matrix( c(20, NA, NA, NA, 50, 19, 32, 101, 10, 22, NA, NA, 80, 49, 61, 190), ncol=4 ) #Whereas x contains all NA?s from y plus some additional NA?s. #I want to find the index of these additional NA?s. I think, there must be a very
2006 Nov 03
3
identify extremes positions of values into matrix
Um texto embutido e sem conjunto de caracteres especificado associado... Nome: n?o dispon?vel Url: https://stat.ethz.ch/pipermail/r-help/attachments/20061103/39e6883b/attachment.pl
1999 Jul 15
1
which() does not handle NAs in named vectors. (PR#226)
Version: platform = sparc-sun-solaris2.6 arch = sparc os = solaris2.6 system = sparc, solaris2.6 status = status.rev = 0 major = 0 minor = 64.2 year = 1999 month = July day = 3 language = R -- It is unclear to me that the handling of NAs is desirable, and it has problems with names: > z <- c(T,T,NA,F,T) > names(z) <- letters[1:5] > which(z) Error: names attribute
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
2007 Aug 17
1
[BioC] function to find coodinates in an array
The arr.ind in the which function does the job very nicely!!! Thank you everyone for the suggestions! Ana > > >---- Mensaje Original ---- >De: marc_schwartz at comcast.net >Para: m_olshansky at yahoo.com >Asunto: Re: [BioC] [R] function to find coodinates in an array >Fecha: Thu, 16 Aug 2007 21:53:44 -0500 > >>If I am correctly understanding the problem, I think
2003 Jul 30
6
reverse array indexing
Hi, Suppose I have a multidimensional array: tmp <- array(1:8, c(2,2,2)) is there a function out there that, given a one-dimensional array index, will return the separate indices for each array dimension? for instance, tmp[8] is equivalent to tmp[2,2,2]. I'd like to derive the vector (2,2,2) from the index 8. thanks, Brad Buchsbaum
2001 Jul 06
1
Inverse function to 'which'?
Is there an inverse function to 'which' available, which creates a logical vector/matrix from indices? I wrote my own, but if there is a standard function I would like to use that instead. Example: x <- c(TRUE, TRUE, FALSE, TRUE, FALSE, FALSE) unwhich(which(x)) # [1] TRUE TRUE FALSE TRUE unwhich(which(x), length(x)) # [1] TRUE TRUE FALSE TRUE FALSE FALSE y <- matrix(x,
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,
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]]
2011 Jul 15
1
searching and replacing in a data frame.
Dear R helpers, Please have a look at the following : - Note : My goal is to find and replace all Inf's in a data array with 0. > t<-data.frame(A=c(Inf,0,0),B=c(1,2,3)) > t A B 1 Inf 1 2 0 2 3 0 3 >str(t) 'data.frame': 3 obs. of 2 variables: $ A: num Inf 0 0 $ B: num 1 2 3 > t[which(t==Inf,arr.ind=T)] [1] Inf > t[which(t==Inf,arr.ind=T)]<-0
2007 Oct 15
2
Variable which has the maximum value of DF
Hi, Suppose I have a data.frame like this Lines <- "var1 var2 var3 var4 var5 var6 0 2 1 2 0 0 2 3 7 6 0 1 1.5 4 9 9 6 0 1.0 6 10 22 3 3 " DF <- read.table(textConnection(Lines), skip=1) names(DF) <- scan(textConnection(Lines), what = "", nlines = 1) How do I find the
2008 Sep 17
1
Re adout row and column of a matrix value
Hello R users, I want to readout the row and column postion from a certain matrix value into a csv file. I have only found this syntax "which(a == b, arr.ind = T)" so I get a = matrix [,1] [,2] [,3] [,4] [,5] [,6] [,7] [,8] [1,] 1 1 2 2 2 1 1 2 [2,] 1 2 3 3 3 4 4 3 [3,] 3 3 3 5 5 6 5 4 [4,] 4 4 4 3
2006 Dec 17
2
X11 fonts and Ubuntu
Hi, I am moving from Windows XP to Ubuntu 6.10 and installed R 2.4.0. When I run eg plot.lm (things work fine with plot.default - eg plot(rnorm(30),rnorm(30))) plot(lmobject) I can get the first plot and then this message: Hit <Return> to see next plot: Error in text.default(x, y, labels.id[ind],cex=cex, xpd=TRUE, : could not find any X11 fonts Check that the Font Path is correct
2006 Dec 10
4
sample "n" random positions from a matrix
Hi there, I have a binary matrix (dim 100x100) filled with values 0 and 1. I need select a record "n" positions of that matrix when values are 1. How can I do that? Thanks for all, Miltinho Brazil --------------------------------- [[alternative HTML version deleted]]
2011 Jun 20
2
Replace selected columns of a dataframe with NA
I am using the following command to replace all the missing values and assorted typos in a dataframe with NA: mydata[mydata>80]=NA The problem is that the first column contains values which should be more than 80, so really I want to do it just for mydata[,2:length(mydata)] I can't seem to re-write the code to fit: mydata[,2:length(mydata)>80]=NA # no error message, but doesn't
2010 Apr 22
3
using which to select range of values
Hi all, I would like to get the array index for a range of values, say 0 < x < 1.5. I'm wondering if there is an alternative for the following which I've done x0 <- rnorm(100) x1 <- ifelse(x0 > 0 & x0 < 1.5,"t","f") x2 <- which(x1=="t",arr.ind=TRUE) x0[x2] Thanks. -- Muhammad
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 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,
2005 Sep 19
2
how to extract the column name or value from the numerical value of the matrix
Dear sir, i have a matrix like x<-c(1:20) A<-matrix(x,4,5) > A [,1] [,2] [,3] [,4] [,5] [1,] 1 5 9 13 17 [2,] 2 6 10 14 18 [3,] 3 7 11 15 19 [4,] 4 8 12 16 20 I want to extract the column value for the matrix value 11... or the row value for 14.. how it is possible? thanks for your help.... with regards, boopathy. Thirumalai
2005 Sep 19
2
how to extract the column name or value from the numerical value of the matrix
Dear sir, i have a matrix like x<-c(1:20) A<-matrix(x,4,5) > A [,1] [,2] [,3] [,4] [,5] [1,] 1 5 9 13 17 [2,] 2 6 10 14 18 [3,] 3 7 11 15 19 [4,] 4 8 12 16 20 I want to extract the column value for the matrix value 11... or the row value for 14.. how it is possible? thanks for your help.... with regards, boopathy. Thirumalai