Using a column entry as a "selector" for datasets in R -
my array looks this:
slide index b c dosegroup 482 778 l 0 0 2 13gy_p_75_42wk 483 778 r 0 0 2 13gy_p_75_42wk 484 779 l 0 0 2 13gy_p_75_42wk 485 779 r 0 0 2 13gy_p_75_42wk 486 4700 l 2 2 2 14.25gy_c_50pl_42wk 487 4700 r 0 0 1 14.25gy_c_50pl_42wk 488 4701 l 0 0 1 14.25gy_c_50pl_42wk
i use dosegroup
column's entries able select respective entries in other columns. able tell r, e.g., "do wilcox.test
between 13gy_p_75_42wk
, 14.25gy_c_50pl_42wk
datasets using column c
."
how can r? there kind of way select columns having entry 14.25gy_c_50pl_42wk
?
i modified data add third level in dosegroup make more realistic.
txt <- "slide index b c dosegroup 778 l 0 0 2 13gy_p_75_42wk 778 r 0 0 2 13gy_p_75_42wk 779 l 0 0 2 13gy_p_75_42wk 779 r 0 0 2 13gy_p_75_42wk 4700 l 2 2 2 14.25gy_c_50pl_42wk 4700 r 0 0 1 14.25gy_c_50pl_42wk 4701 l 0 0 1 14.25gy_c_50pl_42wk 4702 l 0 0 10 15gy_c_50pl_42wk" dat <- read.table(text = txt, header = true) wilcox.test(c ~ dosegroup, data = dat, subset = dosegroup %in% c("13gy_p_75_42wk", "14.25gy_c_50pl_42wk")) ## wilcoxon rank sum test continuity correction ## data: c dosegroup ## w = 10, p-value = 0.1175 ## alternative hypothesis: true location shift not equal 0
to select data, can use 1 of these 2 command.
dat[dat$dosegroup == "14.25gy_c_50pl_42wk", ] subset(dat, dosegroup == "14.25gy_c_50pl_42wk")
those commands basics in r
, if read introduction r
, you'll able same.
so urge so, want enjoy r
.