search for: str_split_fix

Displaying 8 results from an estimated 8 matches for "str_split_fix".

Did you mean: str_split_fixed
2013 Jun 08
1
splitting a string column into multiple columns faster
Hello! I have a column in my data frame that I have to split: I have to distill the numbers from the text. Below is my example and my solution. x<-data.frame(x=c("aaa1_bbb1_ccc3","aaa2_bbb3_ccc2","aaa3_bbb2_ccc1")) x library(stringr) out<-as.data.frame(str_split_fixed(x$x,"aaa",2)) out2<-as.data.frame(str_split_fixed(out$V2,"_bbb",2)) out3<-as.data.frame(str_split_fixed(out2$V2,"_ccc",2)) result<-cbind(x,out2[1],out3) result My problem is: str_split.fixed is relatively slow. In my real data frame I have over 80,000 rows s...
2015 Jul 13
2
Crear datos aleatorios con restriciones
...pairs <- as.data.frame(t(combn(EsGraDivTmp, 2))) >>> AllpairsTmp <- paste(Allpairs$V1, Allpairs$V2, sep=" ") >>> >>> #Aqui tengo las parejas en la misma fila y separadas en columnas >>> library(stringr) >>> separoPairs <- as.data.frame(str_split_fixed(AllpairsTmp, " ", 6)) >>> >>> #de este data.frame escojo filas donde V1=V4 y V2=V5 : misma escuela + >>> mismo grado >>> separoPairs$valid <- ifelse(separoPairs$V1 == separoPairs$V4 & >>> separoPairs$V2 == separoPairs$V5, "Valid&q...
2011 Jan 18
2
dataframe: string operations on columns
Dear all, how can I perform a string operation like strsplit(x," ") on a column of a dataframe, and put the first or the second item of the split into a new dataframe column? (so that on each row it is consistent) Thanks Boris
2013 Apr 10
3
Stringr Package
Hi Group, I have a question on Stringr package I have a table like this X Y ab su - di ac pi - tu ad tu - tu I want output like this X Y ab su ab di ac pi ac tu ad tu ad tu I am wondering if this operation can be done using stringr package (only) ? [[alternative HTML version deleted]]
2015 Jul 13
2
Crear datos aleatorios con restriciones
...del mismo grado y misma escuela > Allpairs <- as.data.frame(t(combn(EsGraDivTmp, 2))) > AllpairsTmp <- paste(Allpairs$V1, Allpairs$V2, sep=" ") > > #Aqui tengo las parejas en la misma fila y separadas en columnas > library(stringr) > separoPairs <- as.data.frame(str_split_fixed(AllpairsTmp, " ", 6)) > > #de este data.frame escojo filas donde V1=V4 y V2=V5 : misma escuela + > mismo grado > separoPairs$valid <- ifelse(separoPairs$V1 == separoPairs$V4 & > separoPairs$V2 == separoPairs$V5, "Valid", "Invalid") > > #Re...
2012 Aug 27
4
?nchar ?strsplit
Hi, my data frame is x<-data.frame(ID=c("abc/def","abc/def/ghi","abc","mno/pqr/st/ab")) I want to split my column ID using "/" as the place to split. How can I do that without telling the code how many sub-columns. I could use nchar(gsub("[^/]","",x$ID)) to get how many "/" are in each row of the column, but could
2015 Jul 13
2
Crear datos aleatorios con restriciones
Hola, 0. La falta de 'elegancia' hace que sea mas dificil hacer cambios al codigo. Por ejemplo cambiar n.classrooms <- 4 a n.classrooms <- 20 1. Cuando tengo solo 4 puedo hacer esto: schoolGrade$A <- Teachers$Teacher.ID[1:cuttoff1] schoolGrade$B <- Teachers$Teacher.ID[1:cuttoff1] schoolGrade$C <- Teachers$Teacher.ID[(cuttoff1+1):n.teachers] schoolGrade$D <-
2013 Apr 18
6
count each answer category in each column
Hey, Is it possible that R can calculate each options under each column and return a summary table? Suppose I have a table like this: Gender Age Rate Female 0-10 Good Male 0-10 Good Female 11-20 Bad Male 11-20 Bad Male >20 N/A I want to have a summary table including the information that how many answers in each category, sth like this: X