Some simple code that uses the ‘raster’ R library to calculate the areas of individual polygons in a polygon shapefile.
#import raster library
library(raster)
#read-in shapefile as SpatialPolygonsDataFrame
shape <- shapefile("./Path/To/Shape/polygons.shp")
#run area calc and add output to attribute table as new column
shape$Area_sqm <- area(shape)
#if you need to know the coordinate reference system and distance units in order to interpret the results...
#get the CRS
crs(shape)