R4DS is an excellent book to learn from. For you chapters 5 and 16 are most relevant to your task.
If you get stuck or would like more specific help to your issue, then a reprex would help. -->