Viome Recommendations
viome
microbiome
I have several years worth of Viome results (located here), but how can I easily tell which recommendations have changed from test to test?
This is some R code to calculate the differences.
You have an Excel table of previous Viome food recommendations and you’d like to see which ones have changed.
The table looks like this:
Food | Oct-22 | Oct-20 | May-20 |
---|---|---|---|
Abalone | Enjoy | Enjoy | Enjoy |
Anchovies | Superfood | Superfood | Enjoy |
Apple | Enjoy | Avoid | Enjoy |
I want to generate a table showing just those rows that changed. Ideally, I’ll turn this into a simple plot showing how specific food recommendations change over time.
Foods with changed recommendations since the last test
Code
# Remove non-Viome columns and any rows where results haven't changed for the last three tests.
%>% count() viome_file_df
Code
%>% filter(`Oct-22`==`Oct-20`) %>% select(1:3) viome_file_df
Foods whose recommendation has changed since the last test
Code
%>% filter(`Oct-22`!=`Oct-20`) %>% select(1:3) viome_file_df
Food recommendation counts per test
Code
<- rbind(viome_file_df %>% count(`Oct-22`) %>% t() %>% as_tibble() %>% slice(2),
x %>% count(`Oct-20`) %>% (t) %>% as_tibble() %>% slice(2)) viome_file_df
Warning: The `x` argument of `as_tibble.matrix()` must have unique column names if
`.name_repair` is omitted as of tibble 2.0.0.
ℹ Using compatibility `.name_repair`.
Code
names(x) <- c(c("Avoid","Minimize","Enjoy","Superfood"),"NA")
$date <- c("Oct-22","Oct-20")
x<- x %>% relocate(1:5,.after = last_col())
x %>% knitr::kable() x
date | Avoid | Minimize | Enjoy | Superfood | NA |
---|---|---|---|---|---|
Oct-22 | 31 | 160 | 25 | 27 | 2 |
Oct-20 | 14 | 149 | 40 | 31 | 11 |