I am not able to get my data frame to pivot_wider into one row per recordset (Forward Template and Reverse Template values from prim).
The code below creates a separate column for each value of prim.
df <-
tibble(
"prim" = c("601881 .................... 601900", "601973 ...................... 601952", "331595 .................... 331614", "331687 ...................... 331666", "196557 .................... 196576", "196649 ...................... 196628", "153933 .................... 153952", "154025 ...................... 154004", "2100939 .................... 2100920", "2100847 ...................... 2100868"),
"Accession" = c("CP042983.1", "CP042983.1", "CP042983.1", "CP042983.1", "CP042983.1", "CP042983.1", "CP042983.1", "CP042983.1", "CP042983.1", "CP042983.1"),
"Genus" = c("Histophilus", "Histophilus", "Histophilus", "Histophilus", "Histophilus", "Histophilus", "Histophilus", "Histophilus", "Histophilus", "Histophilus"),
"Species" = c("somni", "somni", "somni", "somni", "somni", "somni", "somni", "somni", "somni", "somni"),
"Metric" = c("Forward Template", "Reverse Template", "Forward Template", "Reverse Template", "Forward Template", "Reverse Template", "Forward Template", "Reverse Template", "Forward Template", "Reverse Template")
)
tmp <-
df %>%
group_by(Accession) %>%
mutate(AccessID = row_number()) %>%
pivot_wider(names_from = Metric, values_from = prim)
Can I generate a data frame where both the Reverse Template and Forward Template columns are populated, and only one row per record is created?