Loop Through Column and Rows of a Dataframe in R