I have a data frame in R called cryptdeltact that contains sample information as follows
# A tibble: 2,293 x 7 # Groups: Name [72] Name Detector N Value sd se ci <fct> <fct> <dbl> <dbl> <dbl> <dbl> <dbl> 1 VG 2H 1 SB1 C ATM 6 11.4 0.653 0.267 0.686 2 VG 2H 1 SB1 C BetaActin 6 0.0199 0.588 0.240 0.617 3 VG 2H 1 SB1 C BMPR1a 6 6.49 0.591 0.241 0.620 4 VG 2H 1 SB1 C BMPR2 6 7.19 0.614 0.251 0.645 5 VG 2H 1 SB1 C Brca1 6 11.5 0.640 0.261 0.672 6 VG 2H 1 SB1 C Brca2 6 11.9 0.840 0.343 0.882 7 VG 2H 1 SB1 C cmyc 6 8.20 0.580 0.237 0.608 8 VG 2H 1 SB1 C DNAPKCs 6 11.5 0.651 0.266 0.683 9 VG 2H 1 SB1 C Ercc1 6 11.4 0.783 0.320 0.822 10 VG 2H 1 SB1 C Fen1 6 9.05 0.629 0.257 0.660 # … with 2,283 more rows I want to add three new columns to this data frame: Model, Time and Region. All of the info for these new columns is contained somewhere in the existing 'Name' column. Time is the second piece of information in 'Name' ie. '0h', '2h' or '5h'. Region is the second last ie 'SB1', 'SB2', 'SB3' or 'SB4'. But Model is a combination of the first two letters and the last letter ie. 'VG C' or 'VG V' or 'WT C' or 'WT V'. I know the answer lies in extracting the appropriate info from the Name string and putting it into a new column but I am struggling with the syntax.
The final table columns would ideally look like this (once extracted I can change 'VG V' to 'VG Villus' and remove the Name column entirely)
Model Time Region Detector N sd se ci <chr> <dbl> <chr> <chr> <dbl> <dbl> <dbl> <dbl> 1 VG Villus 0 SB1 Fen1 1 NA NA NA 2 VG Villus 0 SB1 Lig3 1 NA NA NA 3 VG Villus 0 SB1 PARP1 1 NA NA NA 4 VG Villus 0 SB1 PolTheta 1 NA NA NA 5 VG Villus 0 SB1 WRN 1 NA NA NA 6 VG Villus 2 SB1 Fen1 3 1.22 0.706 3.04 7 VG Villus 2 SB1 Lig3 3 2.11 1.22 5.25 8 VG Villus 2 SB1 Mre11a 3 0.601 0.347 1.49 9 VG Villus 2 SB1 PARP1 3 1.94 1.12 4.82 10 VG Villus 2 SB1 PolTheta 3 2.74 1.58 6.82 Apologies for the base question but I'm sure this could take up far less time than it currently is!
sd, 0.706 forseand 3.04 forci?