Displaying 14 results from an estimated 14 matches for "str_sub".
2020 Sep 20
2
expresiones regulares
Hola a tod en s
?alquien sabria como convertir estas frases con expresiones regulares?
1.3ptd -> 1.3 ptd
1.3ptdm -> 1.3 ptdm
4.4ptdm23j -> 4.4 ptdm 23j
7.716s -> 7.7 16s
1.4hola -> 1.4 hola
1.4hola.hola -> 1.4 hola.hola
5.5v6 -> 5.5 v6
5.5v6sdp -> 5.5 v6 sdp
5.5v10sdp -> 5.5 v10 sdp
de forma que esta frase
"hola 1.3ptd 1.3ptdm 4.4ptdm23j 7.716s 1.4hola pepe
2023 Jan 26
2
Resumen de R-help-es, Vol 167, Envío 10
...;,"0"), 10, TRUE)
, V4b = sample(c("1","0"), 10, TRUE))
dt[,":="(seq=.I)]
setcolorder(dt,"seq")
dt1 <- melt(dt,id.vars=1,measure.vars=2:ncol(dt),variable.name="vrb",
value.name="vl")
dt1[,":="(vrb_nm=str_sub(vrb,end=2),vrb_tp=str_sub(vrb,start=-1))]
dt2 <- dcast(dt1,seq+vrb_nm~vrb_tp,fun.aggregate=\(x)
paste0(x,collapse="|"),value.var="vl")
dt2[,":="(c=fifelse(a=="1"|b=="1","1","0"))]
dt3 <-dcast(dt2,seq~vrb_nm,fun.aggregate=\(...
2013 Mar 13
5
string split at xth position
Hi,
I have a vector of strings like:
c("a1b1","a2b2","a1b2") which I want to spilt into two parts like:
c("a1","a2","a2") and c("b1","b2,"b2"). So there is
always a first part with a+number and a second part with b+number.
Unfortunately there is no separator I could use to directly split
the vectors.. Any idea
2010 Aug 25
0
stringr: version 0.4
...the regular expression. Should improve performance for
large vectors.
* new ignore.case() modifier tells stringr functions to ignore case of
pattern.
* str_replace renamed to str_replace_all and new str_replace function added.
This makes str_replace consistent with all functions.
* new str_sub<- function (analogous to substring<-) for substring replacement
* str_sub now understands negative positions as a position from the end of
the string. -1 replaces Inf as indicator for string end.
* str_pad side argument can be left, right, or both (instead of center)
* str_trim gains si...
2010 Aug 25
0
stringr: version 0.4
...the regular expression. Should improve performance for
large vectors.
* new ignore.case() modifier tells stringr functions to ignore case of
pattern.
* str_replace renamed to str_replace_all and new str_replace function added.
This makes str_replace consistent with all functions.
* new str_sub<- function (analogous to substring<-) for substring replacement
* str_sub now understands negative positions as a position from the end of
the string. -1 replaces Inf as indicator for string end.
* str_pad side argument can be left, right, or both (instead of center)
* str_trim gains si...
2015 Jan 14
3
Abreviado de especies
Hola,
Vaya desastre al mandar la cabecera de la base de datos. Al enviarlo, se veía bien, pero está visto que por el camino la cosa se torció.
Siguiendo el consejo de Javier, he subido un pequeño fragmento al DropBox. He quitado algunas especies para no hacerlo muy largo. Espero que ésta vez no haya problemas.
https://www.dropbox.com/s/q7zla50oq7owg8k/CPUE.csv?dl=0
Un saludo y gracias
Juan
2023 Jan 27
0
Resumen de R-help-es, Vol 167, Envío 10
..., 10, TRUE))
> > > dt[,":="(seq=.I)]
> > > setcolorder(dt,"seq")
> > >
> > > dt1 <- melt(dt,id.vars=1,measure.vars=2:ncol(dt),variable.name="vrb",
> > > value.name="vl")
> > > dt1[,":="(vrb_nm=str_sub(vrb,end=2),vrb_tp=str_sub(vrb,start=-1))]
> > > dt2 <- dcast(dt1,seq+vrb_nm~vrb_tp,fun.aggregate=\(x)
> > > paste0(x,collapse="|"),value.var="vl")
> > > dt2[,":="(c=fifelse(a=="1"|b=="1","1","0"))]
&...
2023 Jan 28
0
Resumen de R-help-es, Vol 167, Envío 10
..., 10, TRUE))
> > > dt[,":="(seq=.I)]
> > > setcolorder(dt,"seq")
> > >
> > > dt1 <- melt(dt,id.vars=1,measure.vars=2:ncol(dt),variable.name="vrb",
> > > value.name="vl")
> > > dt1[,":="(vrb_nm=str_sub(vrb,end=2),vrb_tp=str_sub(vrb,start=-1))]
> > > dt2 <- dcast(dt1,seq+vrb_nm~vrb_tp,fun.aggregate=\(x)
> > > paste0(x,collapse="|"),value.var="vl")
> > > dt2[,":="(c=fifelse(a=="1"|b=="1","1","0"))]
&...
2015 Jul 28
2
función cantidad mayor de valores
Hola Javier,
Intenta los siguientes cambios
g4 <- function(codigo_llega, n_caracteres){
codigo_llega <- as.character(codigo_llega)
if(n_caracteres == 6) res <- substr(codigo_llega, start=0, stop=4)
else res <- codigo_llega
res
}
g4 <- Vectorize(g4)
x <- c('Jorge Velez','Javier Marcuzzi','Daniel Merino','Susana deus
Alvarez', 'Carlos
2024 Apr 10
1
Exceptional slowness with read.csv
...t's basically what I did
1. Get text lines using readLines
2. use tryCatch to parse each line using read.csv(text=...)
3. in the catch, use?gregexpr to find any quotes not adjacent to a comma
(gregexpr("[^,]\"[^,]",...)
4. escape any quotes found by adding a second quote (using str_sub from
stringr)
6. parse the patched text using read.csv(text=...)
7. write out the parsed fields as I go along using write.table(...,
append=TRUE) so I'm not keeping too much in memory.
I went directly to tryCatch because there were 3.5 million records, and
I only expected a few to have erro...
2013 Apr 23
1
Extract part of a numer
Hi,
May be this helps:
set.seed(25)
dat1<- data.frame(ID=c("1001#01","1001#02","1001#03","1002#01","1002#02"),val=rnorm(5),stringsAsFactors=FALSE)
?dat1$ID<-as.numeric(gsub("#.*","",dat1$ID))
?dat1
#??? ID??????? val
#1 1001 -0.2118336
#2 1001 -1.0415911
#3 1001 -1.1533076
#4 1002? 0.3215315
#5 1002 -1.5001299
A.K.
2011 Apr 03
4
replace last 3 characters of string
Hi,
I would like to replace the last tree characters of the values of a certain
column in a dataframe.
This replacement should only take place if the last three characters
correspond to the value "/:/" and they should be replaced with ""(blank)
I cannot perform a simple gsub because the characters /:/ might also be
present somewhere else in the string values and then they
2024 Apr 10
2
Exceptional slowness with read.csv
?s 06:47 de 08/04/2024, Dave Dixon escreveu:
> Greetings,
>
> I have a csv file of 76 fields and about 4 million records. I know that
> some of the records have errors - unmatched quotes, specifically.
> Reading the file with readLines and parsing the lines with read.csv(text
> = ...) is really slow. I know that the first 2459465 records are good.
> So I try this:
>
2015 Jan 14
3
Abreviar nombres ciéntificos
Hola a todos,
Gracias por las respuestas.
Los nombres ciéntificos son los nombres de las columnas de un csv. Usando vuestros comentarios y sugerencias, estoy tratando de "automatizarlo", ya que tengo unas 40 especies.
De momento sin mucho éxito por que no consigo dar con la forma de que me abrevie las especies correctamente y mezclo campos
La aproximación de Jorge me valdría (y he