Subset data.frame with subset command
This time subseting data.frame with subset fuction. The structure of the data can be checked with str function.
First example subsets one processing type (Baseline), second extracts only wavenumbers from the list by using X %in% lines1 declaration.
str(result_long)
'data.frame': 205344 obs. of 6 variables:
$ X : int 900 904 908 912 916 920 924 928 932 936 ...
$ mean : num 0.01164 0.00846 0.00604 0.00437 0.00356 ...
$ sd : num 0.00606 0.00536 0.00478 0.00431 0.00399 ...
$ Evaluation: Factor w/ 6 levels "BCN","De-tail 1548",..: 1 1 1 1 1 1 1 1 1 1 ...
$ Sample : Factor w/ 16 levels "SC-glyb3.0.img",..: 1 1 1 1 1 1 1 1 1 1 ...
$ Processing: Factor w/ 3 levels "Amide 2 Normalization",..: 1 1 1 1 1 1 1 1 1 1 ...
result_long1<-subset(result_long, Processing == "Baseline")
str(result_long1)
'data.frame': 68448 obs. of 6 variables:
$ X : int 900 904 908 912 916 920 924 928 932 936 ...
$ mean : num 0.01588 0.01152 0.0082 0.00592 0.00482 ...
$ sd : num 0.00895 0.0078 0.00691 0.00623 0.00576 ...
$ Evaluation: Factor w/ 6 levels "BCN","De-tail 1548",..: 1 1 1 1 1 1 1 1 1 1 ...
$ Sample : Factor w/ 16 levels "SC-glyb3.0.img",..: 1 1 1 1 1 1 1 1 1 1 ...
$ Processing: Factor w/ 3 levels "Amide 2 Normalization",..: 3 3 3 3 3 3 3 3 3 3 ...
lines1=c(3742, 3484, 3404, 3295, 2960, 2920, 2852, 1739, 1652, 1548, 1460, 1405, 1300, 1245,1084, 1045)
result_long3<-subset(result_long1, X %in% lines1)
str(result_long3)
'data.frame': 960 obs. of 6 variables:
$ X : int 1084 1300 1460 1548 1652 2852 2920 2960 3404 3484 ...
$ mean : num 0.203 0.419 0.553 1.374 2.149 ...
$ sd : num 0.0475 0.0928 0.1178 0.2867 0.2823 ...
$ Evaluation: Factor w/ 6 levels "BCN","De-tail 1548",..: 1 1 1 1 1 1 1 1 1 1 ...
$ Sample : Factor w/ 16 levels "SC-glyb3.0.img",..: 1 1 1 1 1 1 1 1 1 1 ...
$ Processing: Factor w/ 3 levels "Amide 2 Normalization",..: 3 3 3 3 3 3 3 3 3 3 ...