Crop mapping using R programming after a processing did it with snap

I am an engineer student, i do an internship in crop mapping, i did a classification using random forest in snap but my supervisor asked me to split a data into training and validation data
Moreover he told me to compare accuracy of different models of machine learning
Finally i decided to move to R in order to split the data and do the classification but i dont know how to began and how to extract and read my polygons that i did in snap
In this case i write this message to ask for help, and if someone did already this program can he share it with us ?
Sincerely yours

You might use a command line alternatives such as gdalwarp:

gdalwarp -cutline polygon.kml -crop_to_cutline band_image.jp2 tmp.tif

Extract the pixels as text values using ImageMagick ImageMagick convert
/usr/bin/convert -quiet tmp.tif tmp.txt

That gets you the pixels per polygon in text format - I’ve done it myself.

i want first to thank you for helping me, i discover how to extract different value of each pixel using extract() and after i combine them using rbind() function.
Sincerely yours