Depth/Temp Geom_line

I would like to plot my Temp according to my depth using a geom_line with each line = an Area
y = depth and x = temp

df <- tribble(
  ~Area, ~station, ~depth, ~Temp, 
  "A1","St1",10, 2.5,
  "A1","St1",20, 2.8, 
  "A1","St1",30, 2.6, 
  "A1","St2",10, 2.6,  
  "A1","St2",20, 2.48, 
  "A1","St2",30, 2.54, 
  "A2","St3",10, 2.8, 
  "A2","St3",20, 2.74,  
  "A2","St3",30, 3.05,  
  "A2","St4",10, 3.18,  
  "A2","St4",20, 1.05,  
  "A2","St4",30, 2.06, 
  "A3","St5",10, 1.26,  
  "A3","St5",20, 3.15,  
  "A3","St5",30, 2.87,  

I did this but it's doesn't work.. I think it's because in my area I have station with the same depth

df %>% 
  ggplot(aes( x=Temp,y=depth, color=Area)) +
  geom_line() +  
  ylab(label = "Depth(m)") + 
  xlab(label = "Temperature(°C)") + 

How can I do ?

What do you want the graph to look like? Maybe a facet wrap - if you had more data for each station?

ggplot(df, aes(x=Temp, y=depth, color=Area)) +
  geom_line() +  
  labs(x = "Depth(m)",
       y = "Temperature(°C)") + 
  facet_wrap(~station) + 
  scale_y_reverse() +
  theme(legend.position = "bottom")


I want on plot with all my area line in it. I don't care about my station, so I just want to sea my each area the evolution of the temperature with the depth.
Like I want only one 10meter depth per area, only one 20meter depth etc
Do you see what I mean ?

Thanks for your response and time !

How do you want to deal with multiple values?

For example, these both are A1 and a depth of 10:

# A tibble: 2 × 4
  Area  station depth  Temp
  <chr> <chr>   <dbl> <dbl>
1 A1    St1        10   2.5
2 A1    St2        10   2.6

Yes I know it's exactly what I was wondering, if it's was possible to do a mean of temperature per depth per area and without considering the station.
I could use this and it did something but I don't know if it's representative of my data

  group_by(Area, depth) %>% 
            n = n(),
            across(Temp, mean))

This topic was automatically closed 21 days after the last reply. New replies are no longer allowed.

If you have a query related to it or one of the replies, start a new topic and refer back with a link.