similar to: how do I find the row index number, or row name, of a given value in a vector?

Displaying 20 results from an estimated 90000 matches similar to: "how do I find the row index number, or row name, of a given value in a vector?"

2012 Mar 29
1
Retrieving matrix column and row names by index value
Hi all, So let's say I have a matrix, mdat and I only know the index number. How do I retrieve the column and row names? For example, > mdat <- matrix(c(1,2,3, 11,12,13), nrow = 2, ncol=3, byrow=TRUE, dimnames = list(c("row1", "row2"), c("C.1", "C.2", "C.3"))) > mdat[4] [1] 12 >
2008 Aug 07
1
re order vector in order given by another vector
So imagine I have a vector: zz = c("a","c","d","b") and another vector: xx = c("d","c","a","b") I need to get xx in the same order as zz. I am sure this is very simple but I can't figure it out from the help pages for order or sort. Perhaps I'm not trying hard enough but its been bugging me for a while....
2008 Jul 31
4
Identifying common prefixes from a vector of words, and delete those prefixes
For example, c("dog.is.an.animal", "cat.is.an.animal", "rat.is.an.animal"). How can I identify the common prefix is ".is.an.animal" and delete it to give c("dog", "cat", "rat") ? Thanks _________________________________________________________________ [[alternative HTML version deleted]]
2012 Apr 03
1
Compare by row and insert previous row value (Or non Time Series Lag)
I have the following sample dataset (CSV input here:http://goo.gl/YR8LP. CSV output here: http://goo.gl/EFCC8) which I want to transform as follows. For each person in a household I want to create two new variables OrigTAZ and DestTAZ. It should take the value in TripendTAZ and put that in DestTAZ. For OrigTAZ it should put value of TripendTAZ from the previous row. For the first trip of every
2012 Dec 02
2
finding index of maximum value in vector
I found: max.col(matrix(c(1,3,2),nrow=1)) Is there a more concise/elegant way? Thanks, ----- TO GET MORE DETAILS CLICK HERE -- View this message in context: http://r.789695.n4.nabble.com/finding-index-of-maximum-value-in-vector-tp4651663.html Sent from the R help mailing list archive at Nabble.com.
2010 Aug 01
3
finding max value in a row and reporting colum name
Hi, Hopefully someone can point me in the right direction on how I would go about solving the following. I have some data and need to find the column name of the maximum value in each row. This could be the data... > a <- data.frame(x = rnorm(4), y = rnorm(4), z = rnorm(4)) > a x y z 1 1.6534561 0.11523404 0.2261730 2 -1.2274320 -0.24096054 1.5096028
2008 Apr 29
2
function to generate weights for lm?
Hi, I would like to use a weighted lm model to reduce heteroscendasticity. I am wondering if the only way to generate the weights in R is through the laborious process of trial and error by hand. Does anyone know if R has a function that would automatically generate the weights need for lm? Thanks, -- Tom [[alternative HTML version deleted]]
2009 Apr 15
3
Extending a vector to length n
In general, how can I increase a vector of length m (< n) to length n by padding it with m - n missing values, without losing attributes? The two approaches I've tried, using length<- and adding missings with c, do not work in general: > a <- as.Date("2008-01-01") > c(a, NA) [1] "2008-01-01" NA > length(a) <- 2 > a [1] 13879 NA > b <-
2009 Jul 01
3
Multiple Internet facing Nics - Gateway issue
I have a server with 4 nics. Two are using different internet connections, both with static IP's, and two are connected to our private network. The two internet facing nics seem to be battling over the gateway designation. Which ever I designate as the gateway the other stops responding to incoming traffic. I need both to listen to inbound traffic. One for our main web page and the other
2008 May 09
1
Which gls models to use?
Hi, I need to correct for ar(1) behavior of my residuals of my model. I noticed that there are multiple gls models in R. I am wondering if anyone has experience in choosing between gls models. For example, how should one decide whether to use lm.gls in MASS, or gls in nlme for correcting ar(1)? Does anyone have a preference? Any advice is appreciated! Thanks, -- Tom [[alternative HTML
2011 Apr 15
1
[Rcpp-devel] Find number of elements less than some number: Elegant/fastsolution needed
On Thu, Apr 14, 2011 at 7:02 PM, <rcpp-devel-request at r-forge.wu-wien.ac.at> wrote: > I was able to write a very short C++ function using the Rcpp package > that provided about a 1000-fold increase in speed relative to the best > I could do in R. ?I don't have the script on this computer so I will > post it tomorrow when I am back on the computer at the office. > >
2011 Apr 23
1
How to delete an entire row, if a specific colum has the value of "#VALUE!"
I am importing CSV data with thousands of rows, if any row contains an error from excel, the whole program crashes, so i need to delete all rows with the value of #VALUE!, all other values are non-numeric... I've tried a bunch of strategies, but nothing seems to work. Thanks ahead of time guys, Best, Cody -- View this message in context:
2009 Jun 23
4
vector and NA
Hi, I've a vector like this: ------------------------------------------------------ > inc[,5] [1] NA NA NA NA NA NA NA [8] NA NA NA NA NA NA NA [15] NA NA NA NA NA NA NA [22] NA NA NA NA NA NA
2008 Mar 09
2
format numbers into percentages
Hi, I am currently using the following to formate numbers into percentages: x=0.00112 paste(round(x*100,2),"%",sep="") I am wondering if there is a built in R function that does the same. Does anyone know? Thanks, -- Tom [[alternative HTML version deleted]]
2012 Nov 03
8
Can you turn a string into a (working) symbol?
Dear folks-- Suppose I have an expression that evaluates to a string, and that that string, were it not a character vector, would be a symbol. I would like a function, call it doppel(), that will take that expression as an argument and produce something that functions exactly like the symbol would have if I typed it in the place of the function of the expression. It should go as far along the
2013 Nov 11
2
[LLVMdev] basic block missing after MachineInstr packetizing
Hi, all, When I schedule machine instructions in a VLIW way and packetize them, a problem is encountered, and I will show it use a simplified case as follows. ############ original instruction sequence ... insn1 ... jump LBB0_xx ... LBB0_xx: ... ############ expected instruction sequence after scheduling and packetizing insn1; jump LBB0_xx ... LBB0_xx: ... ############ generated instruction
2007 Nov 30
1
how to find critical values of t in R
Hi, I am trying to find a function in R that would calculate the critical value of t for a given probability and df. For example, if p=5% and df=20, then does R have a function to calculate the t value? I tried: > dt(0.05,df=20) [1] 0.3934718 That doesn't look right to me. Could someone tell me what I was missing? Thanks, -- Tom [[alternative HTML version deleted]]
2009 Jan 28
2
help with plot layout
It takes a lot of sweat to generate a composite plot with R ... sigh. I though I was almost done when I met the umpteenth hurdle. I cannot place a nice title on the 2nd plot (raw signal) on the layout. I do not have control on where either the "main" option of "plot" function, or "title", place the text string which keeps dysplaying chopped from above. I also tried
2007 May 03
2
Parsing data with an uneven number of delimiters
I have a list of data that is delimited by a / and, as long as there is an equal number of delimiters, I can parse the data and put it into a data frame: > t1<-c("a/a/a","b/bb/bbb","ccc/cc/c") > t2<-strsplit(t1,"/") > t3<-data.frame(t2) > t3 c..a....a....a.. c..b....bb....bbb.. c..ccc....cc....c.. 1 a
2013 Oct 04
2
Automatically assign static ipv4 via dhcp to new VMs
Hi guys, I'm running a KVM/libvirt host in a datacenter and got a fancy IPv4 subnet from my provider. I'm able to assign IPs from that subnet via dhcp to my VMs: host01 ~ # virsh net-dumpxml internet <network connections='3'> <name>internet</name> <uuid>37b888cc-510f-46f1-9246-346da96222ed</uuid> <forward dev='enp5s0f0'