search for: fval2

Displaying 4 results from an estimated 4 matches for "fval2".

Did you mean: val2
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 <- unlist(lapply(sp, function(txt) txt[2] != ' ')) newtst <- tst[chk,,drop=FALSE] This both assumes and requires that ALL of the row...
2017 Jul 14
0
Help with R script
@Don your solution does not solve Vijayan's scenario 2. I used spread and gather for that. An alternative solution to insert mising Fval - picking up with Don's newtst - is newtst <- c("FName: 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(&qu...
2017 Jul 13
0
Help with R script
Hi Vijayan, one way going about it *could* be this: library(dplyr) library(tidyr) library(purrr) ex_dat <- c("FName: fname1", "Fval: Fval1.name1", "Fval: ", "FName: fname2", "Fval: Fval2.name2", "FName: fname3") data.frame(x = ex_dat) %>% separate(x, c("F1", "F2"), sep = ": ") %>% filter(F2 != "") %>% group_by(F1) %>% mutate(indx = row_number()) %>% spread(F1, F2, fill = "") %>% gather(F...
2017 Jul 13
2
Help with R script
Dear R-help Group Scenario 1: I have a text file running to 1000 of lines...that is like as follows: [922] "FieldName: Wk3PackSubMonth" [923] "FieldValue: Apr" [924] "FieldName: Wk3PackSubYear" [925] "FieldValue: 2017" [926] "FieldName: Wk3Code1" [927] "FieldValue: " [928] "FieldValue: K4" [929] "FieldName: