I am using ggplot2 to create vertical profiles of the ocean. My raw data set creates "spikes" so to make smooth curves. I am hoping to use geom_smooth(). I also want the line to progress according to the order of the observations (and not according to the x axis). When I use geom_path(), it works for the original plot, but not for the resulting geom_smooth() (see picture below).
melteddf = Storfjorden %>% melt(id.vars = "Depth")
ggplot(melteddf, aes(y = Depth, x = value)) + 
  facet_wrap(~ variable, nrow = 1, scales = "free_x") + 
  scale_y_reverse() +
  geom_smooth(span = 0.5,se = FALSE) + 
  geom_path()
 Therefore is there a way to make sure the smooth curve progress according to the order of observations, instead of the a axis?
Therefore is there a way to make sure the smooth curve progress according to the order of observations, instead of the a axis?
Subset of my data:
head(Storfjorden)
      Depth Salinity Temperature Fluorescence
    1  0.72    34.14       3.738         0.01
    2  0.92    34.14       3.738         0.02
    3  1.10    34.13       3.739         0.03
    4  1.80    34.14       3.740         0.06
    5  2.80    34.13       3.739         0.02
    6  3.43    34.14       3.739         0.05
 
     
    
 
    