How to specify a certain csv in the errorbar line

Sophie Williams

I am trying to make a plot with three different csvs. In 2 of them, the columns are the same i.e. Year, GMSL and GMSLerror.

In the Frederikse file the columns are Year, GMSL, GMSLerrorlow and GMSLerrorup. How can I tell R to plot the Frederikse error using the columns GMSLerrorlow and GMSLerrorup? I tried the following but it did not work. Thanks.

p1<-files <- c("Frederikse.csv", "ChurchandWhite.csv","Hay.csv")
map_dfr(files, ~ read_csv(.x) %>% 
          mutate(Author = .x)) %>%
  ggplot(aes(x = Time, y = GMSL, color = Author,fill=Author)) +
  geom_line(size=0.6)+
  theme_bw(12)+
  theme(panel.grid.major = element_blank())+
  theme(panel.grid.minor = element_blank())+
  labs(x = "Year", y = "GMSL (mm)",color="Author")+
  geom_errorbar(aes(ymin=GMSL-GMSLerror, ymax =GMSL+GMSLerror,alpha=Author))+
  geom_errorbar("Frederikse.csv",(aes(ymin=GMSL-GMSLerrorlow, ymax =GMSL+GMSLerrorup,alpha=Author)))
  scale_alpha_manual(values = c(0.3, 0.3, 0.8))+
  scale_colour_manual(values=c("#BAB3F0","#1D3E72","#201641"))
  
p1


structure(list(Year = 1900:1905, GMSLerrorlow = c(-203.5572666, 
-201.0185091, -212.0740442, -202.6975639, -200.1670151, -192.1312551
), GMSL = c(-173.2614421, -168.8016753, -180.389967, -170.2678322, 
-168.7200709, -160.9814287), GMSLerrorup = c(-141.002807, -135.8976091, 
-148.213824, -138.9305182, -137.4501224, -130.3514508)), row.names = c(NA, 
6L), class = "data.frame")

structure(list(Time = 1900:1905, GMSL = c(-131.15, -130.5, -129.77, 
-128.85, -128.1, -127.56), GMSLerror = c(25.32, 25.17, 25.01, 
24.86, 24.7, 24.55)), row.names = c(NA, 6L), class = "data.frame")


structure(list(Time = c(1880.0417, 1880.125, 1880.2083, 1880.2917, 
1880.375, 1880.4583), GMSL = c(-183, -171.1, -164.3, -158.2, 
-158.7, -159.6), GMSLerror = c(24.2, 24.2, 24.2, 24.2, 24.2, 
24.2)), row.names = c(NA, 6L), class = "data.frame")````
Richard Telford

You can do this with mutate to make GMSLerrorlow column for all datasets

p1<-files <- c("Frederikse.csv", "ChurchandWhite.csv","Hay.csv")

set_names(files) %>% # give names - can use str_remove to drop `.csv` from names

map_dfr( ~ read_csv(.x), .id = "Author") %>% #use .id argument
mutate(
   GMSLerrorlow = if_else(Author != "Frederikse.csv", GMSLerror, GMSLerrorlow),
   GMSLerrorup = if_else(Author != "Frederikse.csv", GMSLerror, GMSLerrorup)
) %>%

  ggplot(aes(x = Time, y = GMSL, color = Author,fill=Author)) +
  geom_line(size=0.6)+
  theme_bw(12)+
  theme(panel.grid.major = element_blank())+
  theme(panel.grid.minor = element_blank())+
  labs(x = "Year", y = "GMSL (mm)",color="Author")+
  geom_errorbar(aes(ymin=GMSL-GMSLerrorlow, ymax =GMSL+GMSLerrorup,alpha=Author))+
  scale_alpha_manual(values = c(0.3, 0.3, 0.8))+
  scale_colour_manual(values=c("#BAB3F0","#1D3E72","#201641"))

Collected from the Internet

Please contact [email protected] to delete if infringement.

edited at
0

Comments

0 comments
Login to comment

Related

From Dev

JMeter: How to specify the users.csv file in the command line

From Dev

How to remove a line from a csv if it contains a certain word?

From Dev

How to specify relationship type in CSV?

From Dev

How to specify relationship type in CSV?

From Dev

How to specify a flex item to be of certain minimum width?

From Dev

How to specify a certain number of fft points in a frequency

From Dev

how to specify /schedule a certain task in laravel based on certain day

From Dev

How to set different legends for MATLAB errorbar plot's dot and vertical line?

From Dev

How to set different legends for MATLAB errorbar plot's dot and vertical line?

From Dev

How to read a certain line with a BufferedWriter

From Dev

How to show certain part of line?

From Dev

How to write to a CSV line by line?

From Dev

How to write to a CSV line by line?

From Dev

how to detect the third line before certain line

From Dev

Top and bottom line on errorbar with python and seaborn

From Dev

errorbar, but not line, as marker symbol in python matplotlib legend

From Dev

How to separate color errorbar matlab

From Dev

how to specify an command line argument with a variable in bash

From Dev

How to specify new line OR the end of string in regex?

From Dev

How to specify number of characters in each line in python?

From Dev

FindBugs command line: how to specify the project to be analyzed?

From Dev

How to specify the end of the line with the dotall modifier in PHP?

From Dev

How to specify new line OR the end of string in regex?

From Dev

How to specify the end of the line with the dotall modifier in PHP?

From Dev

How to specify initSQL in Flyways command line tool?

From Dev

vlc : how to specify playlist on command line

From Dev

how to specify the datetime format in read_csv

From Java

How to specify line breaks in a multi-line flexbox layout?

From Dev

How to change color of line above or below specify curve line in Highcharts?

Related Related

  1. 1

    JMeter: How to specify the users.csv file in the command line

  2. 2

    How to remove a line from a csv if it contains a certain word?

  3. 3

    How to specify relationship type in CSV?

  4. 4

    How to specify relationship type in CSV?

  5. 5

    How to specify a flex item to be of certain minimum width?

  6. 6

    How to specify a certain number of fft points in a frequency

  7. 7

    how to specify /schedule a certain task in laravel based on certain day

  8. 8

    How to set different legends for MATLAB errorbar plot's dot and vertical line?

  9. 9

    How to set different legends for MATLAB errorbar plot's dot and vertical line?

  10. 10

    How to read a certain line with a BufferedWriter

  11. 11

    How to show certain part of line?

  12. 12

    How to write to a CSV line by line?

  13. 13

    How to write to a CSV line by line?

  14. 14

    how to detect the third line before certain line

  15. 15

    Top and bottom line on errorbar with python and seaborn

  16. 16

    errorbar, but not line, as marker symbol in python matplotlib legend

  17. 17

    How to separate color errorbar matlab

  18. 18

    how to specify an command line argument with a variable in bash

  19. 19

    How to specify new line OR the end of string in regex?

  20. 20

    How to specify number of characters in each line in python?

  21. 21

    FindBugs command line: how to specify the project to be analyzed?

  22. 22

    How to specify the end of the line with the dotall modifier in PHP?

  23. 23

    How to specify new line OR the end of string in regex?

  24. 24

    How to specify the end of the line with the dotall modifier in PHP?

  25. 25

    How to specify initSQL in Flyways command line tool?

  26. 26

    vlc : how to specify playlist on command line

  27. 27

    how to specify the datetime format in read_csv

  28. 28

    How to specify line breaks in a multi-line flexbox layout?

  29. 29

    How to change color of line above or below specify curve line in Highcharts?

HotTag

Archive