I am trying to group data by numbers in a column, I have tried different versions of group_by, cut, group etc but I have not been able to get it. I have a lot of data that looks like this:
position variants
3 snv
5 snv
12 snv
17 mnv
22 deletion
27 snv
33 snv
35 snv
42 snv
46 mnv
50 snv
53 deletion
60 snv
62 snv
65 snv
70 snv
variants <- c(rep("snv", 3),rep("mnv", 1),rep("deletion", 1),rep("snv", 4), "mnv", rep("snv"), "deletion", rep("snv", 4))
variants
position = c(3, 5, 12, 17, 22, 27, 33, 35, 42, 46, 50, 53, 60, 62, 65, 70)
position
patient1 = data.frame(position, variants)
patient1
I would like to be able to group the data something like this:
group tally
1-10 2snv
11-20 1snv 1mnv
21-30 1deletion 1snv
31-40 2snv
etc
so that i can run further downstream analysis. And be able to change it to groups of 1-5 or 1-2 etc. thank you very much