I have a data frame that has the 14 columns. 2 of those 14 columns are "Region" and "Population Density." Lets say that I want to find all instances when region is 4 and print out what the value of the population density is for each instance of region = 4.
here I am going to add a new column in the data frame called "PopDens" this new column will take the total population and divided it by the land region
cdi.df$PopDens= cdi.df$TotalPop/cdi.df$LandArea
dim(cdi.df) #here I verify the columns are now 14 and not 13
head(cdi.df) #here I verify that the name and calculations are correct
head(cdi.df$PopDens, 3) #here I return only the first three values
Is there a way to return only values of pop dens when region is =4?