search for: newtst_len

Displaying 2 results from an estimated 2 matches for "newtst_len".

2017 Jul 14
0
Help with R script
...me: fname1", "Fval: Fval1.name1", "FName: fname2", "Fval: Fval2.name2", "FName: fname3", "FName: fname4", "Fval: fval4.fname4") newtst_new <- vector(mode = "character", length = sum(grepl("FName", newtst)) * 2) newtst_len <- length(newtst) i <- 1 j <- 1 while(i <= newtst_len){ if(grepl("FName", newtst[i]) & grepl("Fval", newtst[i + 1])){ newtst_new[c(j, j + 1)] <- newtst[c(i, i + 1)] i <- i + 2 }else{ newtst_new[c(j, j + 1)] <- c(newtst[c(i)], "Fval:...
2017 Jul 13
2
Help with R script
Using Ulrik?s example data (and assuming I understand what is wanted), here is what I would do: ex.dat <- c("FName: fname1", "Fval: Fval1.name1", "Fval: ", "FName: fname2", "Fval: Fval2.name2", "FName: fname3") tst <- data.frame(x = ex.dat, stringsAsFactors=FALSE) sp <- strsplit(tst$x, ':', fixed=TRUE) chk <-