[R] Help with line graph
Jim Lemon
jim at mail.bitwrit.com.au
Fri Jun 21 03:43:14 CEST 2013
Hi Tinus,
Given your read.csv commands, the names of the seamounts will be read as
factors, so col=as.numeric(All$Seamount) should get you started.
Jim
> Hi
>
> Struggling to get this correct today. There is 6 seamounts and I would
> like
> each seamount to be a different line colour.
>
> The part of data set looks like this
>
> Seamount Group.1 Depthm NO3 SiO4 PO4 NO2
> 1 Atlantis Below 177.257182 4.90729821 4.402966 0.4059566 0.06988687
> 2 Atlantis Fmax 59.687077 0.91698665 3.275964 0.3092102 0.08840281
> 3 Atlantis Deep 50.612571 0.07528409 2.941385 0.1900287 0.05543472
> 4 Atlantis Shallow 25.467875 0.54261259 2.604665 0.2801735 0.07639043
> 5 Atlantis Surface 4.429333 0.63933469 3.897832 0.2377492 0.08753721
> 6 Sapmer Below 176.621000 3.39728310 4.481637 0.2970078 0.14552190
> 7 Sapmer Fmax 30.986270 0.82713310 3.324292 0.2625740 0.15888890
> 8 Sapmer Shallow 21.623250 0.47957940 2.370052 0.2627357 0.10683190
> 9 Sapmer Surface 4.872000 0.80187680 2.643195 0.2581714 0.16521010
>
> The code that I am using looks like this. It makes to different colour
> points but line is
>
> setwd("C:\\Users\\Tinus\\Documents\\NMMU\\R\\Seamounts")
> All <- read.csv("Book1.csv")
>
> # Column headers
> colnames(All)
>
> # Get the unique seamounts
> as.character(unique(All$Seamount))
> sm <- as.character(unique(All$Seamount))
>
> # Use a loop to loop through each of the seamounts
> for( i in sm[1:2]) {
> NO3 <- All[i%in%sm,4]
> Depth <- -All[i%in%sm,3]
> plot(NO3, Depth,pch=1,col = 1:2) #plot
> lines(NO3, Depth,pch=1,col = 1:2) #plot
> }
>
> Thanks for helping me.
>
> Regards,
> Tinus
>
> --
> M.J. Sonnekus
> PhD Candidate (The Phytoplankton of the southern Agulhas Current Large
> Marine Ecosystem (ACLME))
> Department of Botany
> South Campus
> Nelson Mandela Metropolitan University
> PO Box 77000
> Port Elizabeth
> South Africa
> 6031
>
> Cell: 082 080 9638
> E-mail: tsonnekus at gmail.com
>
> [[alternative HTML version deleted]]
>
> ______________________________________________
> R-help at r-project.org mailing list
> https://stat.ethz.ch/mailman/listinfo/r-help
> PLEASE do read the posting guide
> http://www.R-project.org/posting-guide.html
> and provide commented, minimal, self-contained, reproducible code.
>
More information about the R-help
mailing list