0

How to find subscript index number when we use strsplit() function in R. My output is

N712SW|2008      8 
N772SW|2008      19 
N428WN|2008      8 

what will be my output if I split by tab first next split by |

I want to know subscript after using

split <- unlist(strsplit(line, "\t"))
  key <- split[[1]]
  deptDelay <- as.numeric(split[[2]])
 if (!(identical(lastKey, "")) & (!(identical(lastKey, key)))) {
    keySplit <- unlist(strsplit(lastKey, "\\|"))
matzone
  • 5,703
  • 3
  • 17
  • 20
Rehoboth
  • 43
  • 2
  • 6
  • What is `lastKey`? You are missing a `}` to close the `if` statement. What is your expected output given the sample data? Please make a [small reproducible example](http://stackoverflow.com/q/5963269/1478381). – Simon O'Hanlon May 17 '13 at 11:44
  • The double brackets on `split[[1]]` and `split[[2]]` are not needed, as you have already unlisted it. Also, I guess this doesn't require expertise on `mapreduce` or `bigdata`...? – Frank May 17 '13 at 13:20

0 Answers0