Before you get into analysis and visualizing data with R, you need to know the basics. Steve Haroz wrote a guide on getting started:
This book is a short introduction to the R language. It covers the basics of R that are not covered by analysis and visualization guides like R for Data Science. Consider it a quick way to get up to speed on R before diving into the analysis and visualization aspects.
This example-focused guide assumes you are familiar with programming concepts but want to learn the R language. It offers more examples than an “R cheat sheet” without the verbosity of a language spec or an introduction to programming.