Displaying 3 results from an estimated 3 matches for "patrn".
Did you mean:
patern
2012 Feb 15
7
matching a sequence in a vector?
...tation and listserv archives on this topic -- but
as yet have not found a solution. I'm sure this is pretty simple with R, but I cannot work out how without
resorting to ugly nested loops.
As far as I can tell, grep, match, and %in% are not the correct tools.
Question:
given these vectors --
patrn <- c(1,2,3,4)
exmpl <- c(3,3,4,2,3,1,2,3,4,8,8,23,1,2,3,4,4,34,4,3,2,1,1,2,3,4)
how do I get the desired answer by finding the occurence of the pattern and returning the starting indices:
6, 13, 23
Suggestions very much appreciated!
Kind regards,
Matt Redding, Ph.D.
Principal Scientist...
2012 Aug 28
4
Search for locations of subsequences?
Is there a function to efficiently search for a subsequence within a vector?
For example, with
x <- 1:100
I'd like to search for the sequence c(49,50,51), and be told that it
occurs exactly once, starting at location 49. (The items in the vectors
might be numeric or character, and there might be repetitions within the
search pattern or within the vector I'm searching.)
Duncan
2013 Jan 18
4
cambiar ciertos nombres de data.frame
Hola todos.
Tengo un data. frame al que le quiero cambiar el nombra a alguna de sus
columnas.
Por ejemplo:
>seba <- data.frame("constante"=1,"numeros"=1:10, "letras"=LETTERS[A:Z])
Listo sus nombres:
>names(seba)
[1] "constante" "numeros" "letras"
Quiero que la columna que tiene el nombre "constante" pase a