Average of data and creation of a dataset

Welcome to R and to the RStudio Community Raffaello. It would be helpful if you provide your data and the code you've tried in reproducible form. For now, here's a made-up example that I hope will address your problem. I've assumed that you've already loaded your data into R, but if you need help with that, please let us know.

library(tidyverse)

# Fake data
set.seed(2)
d = data.frame(Year=runif(50, 2010, 2015),
               Sodium=runif(50),
               Ammonium=runif(50))

ion.means = d %>% 
  # Reshape data to "long" format
  gather(ion, value, -Year) %>% 
  # Round to integer year and group by year and ion
  group_by(Year=round(Year), ion) %>% 
  # Calculate mean concentration by year and ion
  summarise(mean = mean(value, na.rm=TRUE)) %>% 
  # Reshape back to "wide" format
  spread(ion, mean)
ion.means 

          Year Ammonium Sodium
1         2010    0.388  0.208
2         2011    0.566  0.470
3         2012    0.473  0.488
4         2013    0.352  0.543
5         2014    0.559  0.414
6         2015    0.534  0.535