First of all thank you, because I've never seen how to paste my data frame to make it available to other users and then make easier help me out
h<-structure(list(time = structure(c(1L, 1L, 1L, 1L, 1L, 1L, 1L,
1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 2L, 2L, 2L,
2L, 2L, 2L, 2L, 2L, 2L, 2L, 2L, 2L, 2L, 2L, 2L, 2L, 2L, 2L, 2L,
2L, 3L, 3L, 3L, 3L, 3L, 3L, 3L, 3L, 3L, 3L, 3L, 3L, 3L, 3L, 3L,
3L, 3L, 3L, 3L, 3L), .Label = c("00", "01", "66"), class = "factor"),
peso1 = c(95.9, NA, 103.4, NA, 88.9, 125.9, NA, 93.4, 77.3,
NA, 100.7, 88, 69.7, NA, NA, 74.6, 69.4, 86.8, 83.1, NA,
85, NA, 74.6, NA, 92.6, NA, 75, 82.8, 93, 114.7, 95.9, NA,
86.8, NA, 59.5, 99, 94.5, 92.9, NA, 74.3, 77.8, 102.6, 116,
NA, 105.5, NA, 63.2, NA, 70.3, 90.2, 89, NA, 79, 75.2, 116,
79, 80.9, NA, 76.3, NA), cintura1 = c(113, NA, 119, NA, 108,
131.8, NA, 110, 104, NA, 116.2, 103, 102.5, NA, NA, 101.5,
95, 107, 110, NA, 103.5, NA, 100, NA, 115, NA, 98, 108, 110,
120, 113, NA, 118, NA, 88, NA, 120, 114, NA, 104, 100, 120,
122, NA, 117, NA, 88, NA, 98, 112.5, 113, NA, 108, 105.5,
122, 103, 106.8, NA, 104.5, NA), tasis2_e = c(131, NA, 137,
NA, 138, 161, NA, 138, 146, NA, 117, 115, 176, NA, NA, 146,
131, 145, 146, NA, 114, NA, 121, NA, 138, NA, 137, 115, 152,
100, 128, NA, 135, NA, 122, NA, 124, 154, NA, 123, 105, 139,
144, NA, 145, NA, 130, NA, 111, 107, NA, NA, 122, 145, 144,
131, 138, NA, 145, NA)), row.names = c(NA, -60L), class = c("tbl_df",
"tbl", "data.frame"))
Then, I have numerical variables (NAs present), including the ID variable (paciente). I have the time variable as a factor, to compare the quantitative columns (peso1 (weight), cintura1 (waist), tasis2_e (systolic pressure)..) along time. The time variable has 3 factors:
- 00: basal measurement
- 66: + 6 months
-01: 12 months
Then I tried several actions to perform iteratively (preferrably with map functions) statistical analysis comparing variables within time.
t.test- iterative
h %>% filter(time == "00" | time== "01") %>% map2_dbl(.x = .x$time = 00, .y == .y$time = 01, .f = t.test( , na.rm = TRUE))
I don't know how to make the syntax work, I've read all the suggerence about placeholders with map and tidyverse packages, but I do not find an example like mine, and sticking to the theory is not working. How to tell that I need to execute from column3 to column50 t.test between all the combinations (00vs 01, 00 vs 66, 66 vs01)
I am trying with aov as well, thiniking that not having to name the levels of time here is going to be easy to make it work
h %>%
map_dbl(is.numeric, .f = ~aov(.x ~ time))
Error: .x must be a vector, not a primitive function
However it is working with more simple functions such a mean
h %>% map_dfr(is.numeric, .f = ~ mean(.x, na.rm = TRUE))
Thanks in advance for all the effort in helping me out