[R] categorize a character column

2011-01-05 Thread Tan, Richard
Sorry I should have included the r code for the dataframes for ease of test: input <- rbind(data.frame(item="item 1.1: earnings item 1.2: w2 ", loc="shelf 1"), data.frame(item="item 1.3: deductions ", loc="drawer 1"), data.frame(item="item 1.1: earnings ", loc="shelf 2")) lst

[R] categorize a character column

2011-01-05 Thread Tan, Richard
Hi, I know I can do this with a for loop with strsplit and grep, but is there more efficient way? Given a data dataframe (input) and a category column (lst), > input item loc 1 item 1.1: earnings item 1.2: w2 shelf 1 2