trouble adding geom_vline to ggplot2 - r

I have a large time series data set, which I've used xts to summarize in 30 second periods. Not sure how to make this set easily reproducible but it looks like this
> str(taonedf)
'data.frame': 480 obs. of 2 variables:
$ time : POSIXct, format: "2013-01-06 13:00:29" "2013-01-06 13:00:59" "2013-01-06 13:01:29" ...
$ count: int 20763 12030 22188 12183 21112 11628 21543 12609 20095 12992 ...
> head(taonedf)
time count
1 2013-01-06 13:00:29 20763
2 2013-01-06 13:00:59 12030
3 2013-01-06 13:01:29 22188
4 2013-01-06 13:01:59 12183
5 2013-01-06 13:02:29 21112
6 2013-01-06 13:02:59 11628
I've plotted a normal line plot of this and it works fine.
ggplot(data=taonedf, aes(x=time, y=count/30)) + #
geom_line(color="#009E73") +
scale_y_continuous(name="requests per second", labels = format_format(scientific=FALSE, big.mark=",")) +
scale_x_datetime(name="",labels = date_format("%b %d\n%H:%M") ) +
labs(title=paste("Requests per Second - All Requests",count,sep="\n")) +
theme(legend.position = "none")
I want to add some vline annotations. I've created a second dataframe called EV, it looks like this:
> str(ev)
'data.frame': 10 obs. of 2 variables:
$ dt : POSIXct, format: "2013-01-06 13:45:00" "2013-01-06 14:18:00" "2013-01-06 14:49:00" ...
$ event: Factor w/ 9 levels "Event 1",..: 7 8 3 2 5 6 1 4 2 9
> head(ev)
dt event
1 2013-01-06 13:45:00 Event 1
Now, when I add the vline option I get odd results. I'm using the same date time format between the two so the scale should align.
ggplot(data=taonedf, aes(x=time, y=count/30)) +
geom_line(color="#009E73") +
geom_vline(data=ev,aes(xtintercept=dt))+
scale_y_continuous(name="requests per second", labels = format_format(scientific=FALSE, big.mark=",")) +
scale_x_datetime(name="",labels = date_format("%b %d\n%H:%M") ) +
labs(title=paste("Requests per Second - All Requests",count,sep="\n")) +
theme(legend.position = "none")
What am I missing? This doesn't appear to be that hard. All of the documentation and examples show simple numeric X axis so I'm assuming there is some issue with dates in the X axis but I can't pinpoint it. Any help would be appreciated.
> dput(taonedf)
structure(list(time = structure(c(1357506029.996, 1357506059.999,
1357506089.997, 1357506119.998, 1357506149.998, 1357506179.996,
1357506209.996, 1357506239.993, 1357506269.999, 1357506299.996,
1357506329.998, 1357506359.998, 1357506389.999, 1357506419.998,
1357506449.986, 1357506479.996, 1357506509.99, 1357506539.988,
1357506569.996, 1357506599.999, 1357506629.991, 1357506659.998,
1357506689.999, 1357506719.995, 1357506749.996, 1357506779.998,
1357506809.998, 1357506839.997, 1357506869.996, 1357506899.996,
1357506929.997, 1357506959.994, 1357506989.998, 1357507019.999,
1357507049.999, 1357507079.998, 1357507109.998, 1357507139.999,
1357507169.998, 1357507199.99, 1357507229.999, 1357507259.999,
1357507289.999, 1357507319.998, 1357507349.997, 1357507379.997,
1357507409.999, 1357507439.998, 1357507469.994, 1357507499.996,
1357507529.996, 1357507559.996, 1357507589.995, 1357507619.988,
1357507649.999, 1357507679.994, 1357507709.996, 1357507739.996,
1357507769.994, 1357507799.991, 1357507829.999, 1357507859.999,
1357507889.999, 1357507919.999, 1357507949.999, 1357507979.999,
1357508009.999, 1357508039.999, 1357508069.998, 1357508099.999,
1357508129.999, 1357508159.999, 1357508189.999, 1357508219.998,
1357508249.999, 1357508279.999, 1357508309.999, 1357508339.999,
1357508369.999, 1357508399.999, 1357508429.998, 1357508459.999,
1357508489.999, 1357508519.999, 1357508549.999, 1357508579.999,
1357508609.999, 1357508639.999, 1357508669.999, 1357508699.999,
1357508729.999, 1357508759.998, 1357508789.999, 1357508819.998,
1357508849.999, 1357508879.998, 1357508909.999, 1357508939.996,
1357508969.999, 1357508999.999, 1357509029.999, 1357509059.999,
1357509089.999, 1357509119.999, 1357509149.999, 1357509179.999,
1357509209.999, 1357509239.999, 1357509269.999, 1357509299.999,
1357509329.999, 1357509359.999, 1357509389.999, 1357509419.999,
1357509449.999, 1357509479.999, 1357509509.999, 1357509539.999,
1357509569.976, 1357509599.999, 1357509629.999, 1357509659.999,
1357509689.999, 1357509719.999, 1357509749.996, 1357509779.999,
1357509809.999, 1357509839.999, 1357509869.999, 1357509899.999,
1357509929.999, 1357509959.996, 1357509989.999, 1357510019.997,
1357510049.998, 1357510079.997, 1357510109.999, 1357510139.999,
1357510169.999, 1357510199.999, 1357510229.999, 1357510259.999,
1357510289.999, 1357510319.999, 1357510349.999, 1357510379.999,
1357510409.999, 1357510439.999, 1357510469.999, 1357510499.999,
1357510529.999, 1357510559.999, 1357510589.999, 1357510619.999,
1357510649.999, 1357510679.999, 1357510709.999, 1357510739.983,
1357510769.999, 1357510799.999, 1357510829.999, 1357510859.999,
1357510889.999, 1357510919.999, 1357510949.999, 1357510979.999,
1357511009.997, 1357511039.999, 1357511069.999, 1357511099.999,
1357511129.999, 1357511159.999, 1357511189.999, 1357511219.999,
1357511249.999, 1357511279.999, 1357511309.999, 1357511339.999,
1357511369.999, 1357511399.999, 1357511429.999, 1357511459.999,
1357511489.999, 1357511519.999, 1357511549.999, 1357511579.999,
1357511609.999, 1357511639.999, 1357511669.999, 1357511699.999,
1357511729.999, 1357511759.999, 1357511789.996, 1357511819.999,
1357511849.999, 1357511879.999, 1357511909.999, 1357511939.993,
1357511969.999, 1357511999.998, 1357512029.999, 1357512059.999,
1357512089.999, 1357512119.999, 1357512149.999, 1357512179.998,
1357512209.999, 1357512239.999, 1357512269.999, 1357512299.999,
1357512329.997, 1357512359.993, 1357512389.997, 1357512419.999,
1357512449.999, 1357512479.998, 1357512509.999, 1357512539.999,
1357512569.999, 1357512599.999, 1357512629.999, 1357512659.995,
1357512689.999, 1357512719.999, 1357512749.999, 1357512779.995,
1357512809.999, 1357512839.999, 1357512869.999, 1357512899.999,
1357512929.999, 1357512959.999, 1357512989.997, 1357513019.996,
1357513049.999, 1357513079.999, 1357513109.999, 1357513139.999,
1357513169.999, 1357513199.993, 1357513229.999, 1357513259.999,
1357513289.999, 1357513319.999, 1357513349.998, 1357513379.999,
1357513409.999, 1357513439.999, 1357513469.999, 1357513499.999,
1357513529.999, 1357513559.999, 1357513589.999, 1357513619.999,
1357513649.999, 1357513679.999, 1357513709.999, 1357513739.999,
1357513769.999, 1357513799.998, 1357513829.997, 1357513859.999,
1357513889.999, 1357513919.999, 1357513949.999, 1357513979.998,
1357514009.999, 1357514039.996, 1357514069.999, 1357514099.999,
1357514129.999, 1357514159.999, 1357514189.999, 1357514219.999,
1357514249.999, 1357514279.999, 1357514309.999, 1357514339.993,
1357514369.999, 1357514399.999, 1357514429.999, 1357514459.999,
1357514489.999, 1357514519.999, 1357514549.988, 1357514579.997,
1357514609.999, 1357514639.998, 1357514669.984, 1357514699.999,
1357514729.999, 1357514759.999, 1357514789.999, 1357514819.999,
1357514849.999, 1357514879.999, 1357514909.999, 1357514939.996,
1357514969.999, 1357514999.999, 1357515029.999, 1357515059.998,
1357515089.999, 1357515119.97, 1357515149.998, 1357515179.999,
1357515209.999, 1357515239.999, 1357515269.999, 1357515299.999,
1357515329.999, 1357515359.999, 1357515389.999, 1357515419.999,
1357515449.999, 1357515479.999, 1357515509.999, 1357515539.999,
1357515569.999, 1357515599.999, 1357515629.995, 1357515659.999,
1357515689.999, 1357515719.999, 1357515749.999, 1357515779.999,
1357515809.995, 1357515839.999, 1357515869.999, 1357515899.999,
1357515929.999, 1357515959.999, 1357515989.999, 1357516019.999,
1357516049.999, 1357516079.999, 1357516109.999, 1357516139.999,
1357516169.999, 1357516199.999, 1357516229.999, 1357516259.998,
1357516289.998, 1357516319.999, 1357516349.999, 1357516379.999,
1357516409.999, 1357516439.999, 1357516469.999, 1357516499.999,
1357516529.999, 1357516559.999, 1357516589.999, 1357516619.999,
1357516649.999, 1357516679.999, 1357516709.999, 1357516739.999,
1357516769.999, 1357516799.999, 1357516829.999, 1357516859.999,
1357516889.999, 1357516919.999, 1357516949.999, 1357516979.999,
1357517009.999, 1357517039.999, 1357517069.999, 1357517099.999,
1357517129.999, 1357517159.998, 1357517189.999, 1357517219.999,
1357517249.999, 1357517279.999, 1357517309.999, 1357517339.999,
1357517369.999, 1357517399.998, 1357517429.999, 1357517459.999,
1357517489.999, 1357517519.999, 1357517549.999, 1357517579.999,
1357517609.999, 1357517639.999, 1357517669.999, 1357517699.999,
1357517729.999, 1357517759.999, 1357517789.999, 1357517819.999,
1357517849.999, 1357517879.999, 1357517909.999, 1357517939.999,
1357517969.999, 1357517999.999, 1357518029.999, 1357518059.976,
1357518089.999, 1357518119.998, 1357518149.998, 1357518179.999,
1357518209.987, 1357518239.999, 1357518269.998, 1357518299.991,
1357518329.998, 1357518359.999, 1357518389.994, 1357518419.994,
1357518449.995, 1357518479.999, 1357518509.999, 1357518539.998,
1357518569.983, 1357518599.999, 1357518629.998, 1357518659.994,
1357518689.999, 1357518719.988, 1357518749.999, 1357518779.999,
1357518809.999, 1357518839.999, 1357518869.999, 1357518899.999,
1357518929.999, 1357518959.999, 1357518989.999, 1357519019.999,
1357519049.999, 1357519079.998, 1357519109.999, 1357519139.999,
1357519169.999, 1357519199.999, 1357519229.999, 1357519259.999,
1357519289.999, 1357519319.999, 1357519349.999, 1357519379.999,
1357519409.999, 1357519439.999, 1357519469.999, 1357519499.999,
1357519529.999, 1357519559.999, 1357519589.999, 1357519619.999,
1357519649.999, 1357519679.999, 1357519709.999, 1357519739.999,
1357519769.999, 1357519799.999, 1357519829.997, 1357519859.999,
1357519889.999, 1357519919.999, 1357519949.999, 1357519979.999,
1357520009.999, 1357520039.999, 1357520069.999, 1357520099.999,
1357520129.999, 1357520159.999, 1357520189.999, 1357520219.999,
1357520249.999, 1357520279.999, 1357520309.999, 1357520339.999,
1357520369.999, 1357520399.999), tzone = "", tclass = c("POSIXct",
"POSIXt"), class = c("POSIXct", "POSIXt")), count = c(20763L,
12030L, 22188L, 12183L, 21112L, 11628L, 21543L, 12609L, 20095L,
12992L, 21552L, 12447L, 21113L, 12236L, 21705L, 12018L, 21140L,
11820L, 21571L, 12803L, 21146L, 12081L, 21171L, 12440L, 21353L,
11708L, 21476L, 12210L, 21364L, 12041L, 21907L, 11934L, 22207L,
12403L, 21629L, 12676L, 21046L, 12196L, 21673L, 12190L, 21830L,
11652L, 20943L, 12350L, 20848L, 11800L, 21085L, 12367L, 21519L,
12325L, 22217L, 12195L, 22405L, 11869L, 21380L, 12145L, 21842L,
12224L, 21793L, 12856L, 34934L, 24073L, 41005L, 33964L, 46240L,
41287L, 52697L, 62618L, 78594L, 68193L, 76617L, 63747L, 90556L,
75830L, 104609L, 51063L, 67046L, 66977L, 82513L, 87228L, 107474L,
141878L, 127290L, 70953L, 98879L, 87814L, 117309L, 113463L, 150979L,
198271L, 170456L, 108325L, 119583L, 111803L, 117067L, 186768L,
226191L, 235546L, 228039L, 165570L, 159472L, 161707L, 137614L,
180049L, 254616L, 302166L, 336723L, 234902L, 202560L, 210679L,
173053L, 162839L, 262536L, 306859L, 249385L, 300646L, 219594L,
209819L, 166758L, 173716L, 268453L, 310940L, 264778L, 289798L,
202234L, 236882L, 217502L, 181157L, 196976L, 201901L, 228233L,
221241L, 220140L, 122623L, 76699L, 105589L, 381687L, 264571L,
187083L, 175972L, 202483L, 198547L, 196964L, 206402L, 181260L,
189319L, 162374L, 160412L, 186897L, 184529L, 160056L, 177326L,
184240L, 160864L, 156540L, 150392L, 157610L, 138447L, 148423L,
147318L, 148463L, 114389L, 163761L, 126624L, 167519L, 138240L,
133005L, 120187L, 155814L, 132751L, 140000L, 120323L, 124415L,
129450L, 116635L, 125364L, 108176L, 118877L, 143640L, 132457L,
118641L, 114330L, 135960L, 148066L, 130787L, 130230L, 130436L,
107109L, 129405L, 116093L, 135293L, 119048L, 147364L, 127028L,
145576L, 139960L, 139896L, 139433L, 127806L, 124845L, 141319L,
132821L, 129279L, 111905L, 130898L, 133135L, 138201L, 121460L,
143846L, 92964L, 100614L, 85637L, 139594L, 124302L, 106071L,
128247L, 120788L, 176300L, 144378L, 126209L, 117886L, 111001L,
105855L, 122387L, 152357L, 103217L, 134069L, 106021L, 91796L,
103335L, 99422L, 115839L, 147787L, 128868L, 123416L, 109312L,
129782L, 109397L, 130418L, 113709L, 103774L, 133272L, 137311L,
138079L, 132308L, 119744L, 164226L, 149361L, 135044L, 110185L,
151246L, 141811L, 160525L, 128407L, 159161L, 142969L, 150370L,
128705L, 151884L, 171663L, 150428L, 154910L, 165016L, 163729L,
169727L, 144913L, 163476L, 159984L, 155767L, 142334L, 177964L,
169230L, 135086L, 139350L, 174013L, 164427L, 154289L, 143392L,
187156L, 139426L, 159207L, 187435L, 198519L, 132559L, 163582L,
179069L, 150413L, 161463L, 173357L, 162457L, 136248L, 144086L,
151073L, 130237L, 144066L, 179840L, 135843L, 147757L, 206373L,
140734L, 177374L, 176168L, 154999L, 136136L, 187568L, 142357L,
152180L, 168528L, 131228L, 140622L, 145363L, 93070L, 58613L,
82024L, 86640L, 77493L, 71205L, 87641L, 89232L, 99214L, 89311L,
87948L, 90790L, 91326L, 106916L, 97318L, 89452L, 91658L, 82069L,
92559L, 89194L, 81721L, 83490L, 96388L, 90145L, 79861L, 90301L,
77676L, 262966L, 227355L, 256477L, 238905L, 241260L, 206168L,
229477L, 215515L, 245217L, 232026L, 225308L, 223537L, 198524L,
237840L, 233483L, 193081L, 216570L, 212949L, 203150L, 240861L,
209596L, 200673L, 180099L, 187726L, 187642L, 188402L, 176871L,
216090L, 203310L, 184723L, 195702L, 204137L, 276952L, 313717L,
323208L, 308448L, 321638L, 378236L, 352163L, 413678L, 395997L,
354317L, 366915L, 339465L, 346781L, 394895L, 355176L, 349618L,
417590L, 335474L, 405686L, 362581L, 356525L, 354142L, 383487L,
334305L, 327489L, 336201L, 374153L, 341485L, 321473L, 308773L,
15709L, 8870L, 15563L, 8944L, 15941L, 9342L, 16303L, 8951L, 14969L,
9385L, 14537L, 9963L, 15676L, 9011L, 16552L, 9587L, 16802L, 9693L,
15267L, 8946L, 14189L, 9067L, 14359L, 9776L, 167922L, 337364L,
350941L, 362928L, 364922L, 319641L, 348687L, 321356L, 400161L,
334171L, 332829L, 323842L, 397809L, 375694L, 384432L, 356825L,
350846L, 395942L, 359471L, 296926L, 418481L, 322144L, 335658L,
347212L, 334421L, 375769L, 364300L, 317370L, 373192L, 346713L,
356341L, 327225L, 305538L, 347815L, 276914L, 322149L, 303627L,
292363L, 284724L, 305082L, 373363L, 304386L, 438592L, 403579L,
430549L, 450536L, 432445L, 389779L, 434888L, 375010L, 456096L,
577393L, 451122L, 432354L, 425547L, 417729L)), .Names = c("time",
"count"), row.names = c(NA, -480L), class = "data.frame")
> dput(ev)
structure(list(dt = structure(c(1357508700, 1357510680, 1357512540,
1357515360, 1357517220, 1357517700, 1357518000, 1357518000, 1357519140,
1357519140), class = c("POSIXct", "POSIXt"), tzone = ""), event = structure(c(7L,
8L, 3L, 2L, 5L, 6L, 1L, 4L, 2L, 9L), .Label = c("Event 1",
"Event 2", "Event 3",
"Event 4", "Event 5",
"Event 6", "Event 7",
"Event 8", "Event 9"
), class = "factor")), .Names = c("dt", "event"), row.names = c(NA,
-10L), class = "data.frame")
Library Versions:
> sessionInfo()
R version 2.15.1 (2012-06-22)
Platform: x86_64-redhat-linux-gnu (64-bit)
attached base packages:
[1] grid stats graphics grDevices utils datasets methods base
other attached packages:
[1] reshape2_1.2.2 xts_0.9-1 zoo_1.7-9 gdata_2.12.0 data.table_1.8.6 caTools_1.14
[7] scales_0.2.3 ggplot2_0.9.3
Simplied code - this still doesnt work
library(scales)
library(ggplot2)
taonedf<-dget("taonedf") #in this thread
ev<-dget("ev") #in this thread
ggplot(data=taonedf, aes(x=time, y=count/30)) +
geom_line() +
geom_vline(data=ev,aes(xtintercept=as.numeric(dt)))

To get geom_vline() display lines as intended, first, library scales should be loaded. Then use as.numeric() in geom_vline().
library(scales)
+ geom_vline(data=ev,aes(xintercept=as.numeric(dt)))

Two things
You need to wrap the datetimes for the vline in as.numeric
You misspelled xintercept
Fixing those:
library("ggplot2")
library("scales")
ggplot(data=taonedf, aes(x=time, y=count/30)) +
geom_line(color="#009E73") +
geom_vline(data=ev,aes(xintercept=as.numeric(dt)))+
scale_y_continuous(name="requests per second", labels = format_format(scientific=FALSE, big.mark=",")) +
scale_x_datetime(name="",labels = date_format("%b %d\n%H:%M") ) +
labs(title=paste("Requests per Second - All Requests")) +
theme(legend.position = "none")

Related

permanova betadisper: missing observations due to 'group' removed Error in eigen(-x/2, symmetric = TRUE) : 0 x 0 matrix

I tried to adapt a code from an earlier version of R to process some data. I got most of it working again but ran into an issue.... I am trying to use vegan to run a permanova and permdisp, however when I get to the betadisper part I get the error "missing observations due to 'group' removed
Error in eigen(-x/2, symmetric = TRUE) : 0 x 0 matrix" I am not the best at R.... but I have tried to futz with it and don't know where I went wrong....
Thank you for reading and any Help would be appreciated.
require (vegan)
require (ggplot2)
require (gridExtra)
require (pals)
require (ape)
require (RColorBrewer)
legpro<- read.table('legpro.txt', sep='\t', header=T,row.names = 1)
legpro.std<-legpro[,3:ncol(legpro)]/legpro$Overall.body.Size.Estimator
legpro.std<-cbind(legpro$Code,legpro.std)
names(legpro.std)[1]<- 'Code'
legpro.std<-cbind(legpro$Species.Name,legpro.std)
names(legpro.std)[1]<- 'Species.Name'
#legpro.std<-legpro.std[-54]
#excluding body size from data
legpro.std<-legpro.std[-54]
#-6,-7,-8,-9,-10,-11,-12,-13,-14,-15,-16,-17,-21,-22,-23,-29,-35,-41,-45,-46,-48,-49,-51,-52, can eliminate
head(legpro.std)
tail(legpro.std)
plot(legpro.std$claw1,legpro.std$claw2)
plot(legpro.std$claw1,legpro.std$claw3)
plot(legpro.std$Forewing.width,legpro.std$Forewing.length)
plot(legpro$Overall.body.Size.Estimator,legpro$Forewing.length)
legpro.std$Code <- factor(legpro.std$Code,levels = c('A.adnixa','A.modesta','A.bicolor','A.plomleyi','C.rastricornis','S.itasca','S.mohri','C.fitchi','C.simplicior','S.flinti','S.vicaria','C.areolaris','O.fulvicephalus','D.macleodi','N.americanus','D.binocula','H.costalis','H.stigma','S.angustus','M.tasmaniae','L.banksi','L.squamosa','S.pavida','D.sayi','C.tenuistriga','C.cincta','A.eureka','C.collaris','P.prasinus','C.coloradensis','N.myrmeleonoides','A.occidens','P.capicola','P.immensus','P.libelluloides','U.macleayanus','U.floridanus','U.quadripunctatus','U.bicolor','L.longicornis','L.coccajus','D.speciosus','C.pusillus','B.mexicanus','B.californicus','B.abdominalis','C.abdominalis','C.schwarzi','M.trigrammus','M.californicus','M.exitialis','P.hageni','V.fallax','S.carrizonus','S.dissimilis','S.eiseni','B.furcatus','B.lethalis','E.sinuatum','E.ornatum','E.arizonense','G.luniger','M.bilineatus','C.plumbeus','D.tetragrammicus'))#for setting species order
###Permanova
permanova<-adonis2(log10(legpro.std[,3:ncol(legpro.std)])~legpro.std$Species.Name,method='euclidean')
permanova
###Permdisp
Name.Code<- as.factor(legpro.std$Code)
legpro.dis<- vegdist(log10(legpro.std[,3:ncol(legpro.std)]),'euclidean')
perm.legpro <- betadisper (legpro.dis,Name.Code,type=c('median'))
perm.legpro2<- permutest(perm.legpro,pairwise=T, permutations=9999)
anova(perm.legpro)
TukeyHSD(perm.legpro)
pcoa<- pcoa(vegdist(log10(legpro.std[,3:ncol(legpro.std)]),'euclidean'))
print(pcoa)#Cumum_eig or
pcoa.cm<-cmdscale(vegdist(log10(legpro.std[,3:ncol(legpro.std)]),'euclidean'),add = F)
print(pcoa.cm) #% explanation of each axis is given by the variance of the axis/total pcoa variance or check above
The data from head is:
head(legpro.std)
Species.Name Code claw1 claw2 claw3 Totleglength1 Totleglength2 Totleglength3 Coxa1.anterior
1 Sialis.itasca.Ross 0.04570004 0.04528458 0.05359368 2.080806 2.397590 3.108226 0.3477358
2 Sialis.itasca.Ross 0.04510309 0.05111684 0.05025773 2.026632 2.348797 2.907216 0.3311856
3 Sialis.itasca.Ross 0.04593070 0.05116841 0.04472200 1.904915 2.350322 2.831184 0.2912973
4 Sialis.itasca.Ross 0.04196933 0.04237288 0.04640840 1.945924 2.228612 2.730024 0.2824859
5 Sialis.itasca.Ross 0.04725473 0.05220522 0.05445545 2.048830 2.428218 2.951395 0.3280828
6 Sialis.itasca.Ross 0.04471005 0.05046481 0.05002213 2.318504 2.488490 3.011067 0.3333333
coxa1.posterior Coxa1average Coxa2.anterior coxa2.posterior Coxa2.average Coxa3.anterior coxa3.posterior
1 0.3169921 0.3323639 0.3402576 0.3485667 0.3444121 0.2937266 0.3223930
2 0.3144330 0.3228093 0.3784364 0.3625429 0.3704897 0.2916667 0.3487972
3 0.2538275 0.2725624 0.3352135 0.3231265 0.3291700 0.2828364 0.3227236
4 0.2861178 0.2843019 0.2744149 0.2836965 0.2790557 0.2655367 0.2869250
5 0.3352835 0.3316832 0.2812781 0.3096310 0.2954546 0.2736274 0.3105311
6 0.3196104 0.3264719 0.3430721 0.3413015 0.3421868 0.3005755 0.3594511
Coxa3.average femur1 femur2 femur3 Forewing.length Forewing.width Forewingsurice.area tarsi1_1 tarsi1_2
1 0.3080598 0.5334441 0.6248442 0.7714998 3.905692 1.140839 10.72503 0.1479020 0.08516826
2 0.3202319 0.5945017 0.6224227 0.7096220 3.717354 1.240550 10.73572 0.1271478 0.08161512
3 0.3027800 0.5302175 0.6877518 0.7304593 3.708702 1.221595 11.24479 0.1373892 0.07775987
4 0.2762308 0.5145279 0.5952381 0.7094431 3.672720 1.142454 10.39747 0.1323648 0.07627119
5 0.2920792 0.5234024 0.6710172 0.7178218 3.894690 1.299730 11.24786 0.1314131 0.08190819
6 0.3300133 0.7242143 0.6573705 0.7312970 3.911022 1.100044 9.71889 0.1496237 0.08632138
tarsi1_3 tarsi1_4 tarsi1_5 tarsi1tot tarsi2_1 tarsi2_2 tarsi2_3 tarsi2_4 tarsi2_5 tarsi2tot tarsi3_1
1 0.05899460 0.03406730 0.07810552 0.4042376 0.1798920 0.09056917 0.08890735 0.03199003 0.1574574 0.5488159 0.3103448
2 0.06185567 0.03006873 0.09235395 0.3930412 0.1859966 0.12113402 0.08376288 0.03565292 0.1245704 0.5511168 0.2843643
3 0.06124093 0.02739726 0.08622079 0.3900080 0.1833199 0.11724416 0.07534246 0.03424657 0.1446414 0.5547945 0.2123288
4 0.06133979 0.02986279 0.09604520 0.3958838 0.1949153 0.10895885 0.07506054 0.02945924 0.1142050 0.5225989 0.2566586
5 0.05940594 0.02880288 0.09180918 0.3933394 0.1908191 0.10531054 0.08235824 0.03915392 0.1345635 0.5522052 0.2808281
6 0.05843293 0.03320053 0.09871625 0.4262948 0.2173528 0.12926073 0.09606020 0.03231518 0.1372289 0.6122178 0.2855246
tarsi3_2 tarsi3_3 tarsi3_4 tarsi3_5 tarsi3tot tibia1 tibia2 tibia3 Trochanter1.anterior
1 0.1458247 0.12172829 0.04154549 0.1728292 0.7922725 0.6726215 0.7349398 1.0793519 0.14291649
2 0.1658076 0.10438144 0.03651203 0.1507732 0.7418385 0.6065292 0.6808419 0.9746564 0.09879725
3 0.1305399 0.07896857 0.03505237 0.1543110 0.6112006 0.6176470 0.6458501 1.0209508 0.08944399
4 0.1513317 0.09564165 0.04317999 0.1452785 0.6920904 0.6432607 0.7171106 0.9196933 0.10290557
5 0.1588659 0.09675968 0.04095410 0.1332133 0.7106211 0.7011701 0.7803781 1.0756077 0.09315932
6 0.1651173 0.10358565 0.03497123 0.1412129 0.7304117 0.7348384 0.7290836 1.0624170 0.09517486
Trochanter1.posterior Trochanter1.average Trochanter2.anterior Trochanter2.posterior Trochanter2.average
1 0.13336103 0.13813876 0.15828833 0.1308683 0.1445783
2 0.12070446 0.10975085 0.12070446 0.1271478 0.1239261
3 0.09951651 0.09448025 0.10999194 0.1555197 0.1327558
4 0.11299435 0.10794996 0.09483455 0.1343826 0.1146086
5 0.10531054 0.09923493 0.10711072 0.1512151 0.1291629
6 0.11819388 0.10668437 0.14121292 0.1540505 0.1476317
Trochanter3.anterior Trochanter3.posterior Trochanter3.average
1 0.1819692 0.1321147 0.1570420
2 0.1503436 0.1713917 0.1608677
3 0.1651894 0.1663981 0.1657937
4 0.1315577 0.1335755 0.1325666
5 0.1480648 0.1624663 0.1552655
6 0.1460823 0.1677733 0.1569278
dput
structure(list(Species.Name = c("Sialis.itasca.Ross", "Sialis.itasca.Ross",
"Sialis.itasca.Ross", "Sialis.itasca.Ross", "Sialis.itasca.Ross",
"Sialis.itasca.Ross"), Code = structure(c(6L, 6L, 6L, 6L, 6L,
6L), levels = c("A.adnixa", "A.modesta", "A.bicolor", "A.plomleyi",
"C.rastricornis", "S.itasca", "S.mohri", "C.fitchi", "C.simplicior",
"S.flinti", "S.vicaria", "C.areolaris", "O.fulvicephalus", "D.macleodi",
"N.americanus", "D.binocula", "H.costalis", "H.stigma", "S.angustus",
"M.tasmaniae", "L.banksi", "L.squamosa", "S.pavida", "D.sayi",
"C.tenuistriga", "C.cincta", "A.eureka", "C.collaris", "P.prasinus",
"C.coloradensis", "N.myrmeleonoides", "A.occidens", "P.capicola",
"P.immensus", "P.libelluloides", "U.macleayanus", "U.floridanus",
"U.quadripunctatus", "U.bicolor", "L.longicornis", "L.coccajus",
"D.speciosus", "C.pusillus", "B.mexicanus", "B.californicus",
"B.abdominalis", "C.abdominalis", "C.schwarzi", "M.trigrammus",
"M.californicus", "M.exitialis", "P.hageni", "V.fallax", "S.carrizonus",
"S.dissimilis", "S.eiseni", "B.furcatus", "B.lethalis", "E.sinuatum",
"E.ornatum", "E.arizonense", "G.luniger", "M.bilineatus", "C.plumbeus",
"D.tetragrammicus"), class = "factor"), claw1 = c(0.0457000398959275,
0.045103090158027, 0.0459306989564186, 0.0419693321653473, 0.0472547265893557,
0.0447100492179136), claw2 = c(0.045284584153096, 0.0511168382615714,
0.051168411852526, 0.042372881410651, 0.0522052218973023, 0.050464806029534
), claw3 = c(0.0535936807297095, 0.050257730039612, 0.0447219967552032,
0.0464083960590078, 0.0544554479373681, 0.0500221314070853),
Totleglength1 = c(2.080805936746, 2.02663219508693, 1.90491528797122,
1.94592417110508, 2.04882996069499, 2.31850370337949), Totleglength2 = c(2.3975902975308,
2.3487971821018, 2.35032225197969, 2.22861185065265, 2.42821795709869,
2.48849039363661), Totleglength3 = c(3.10822595137736, 2.90721641469161,
2.83118434974866, 2.7300243220427, 2.95139534984782, 3.0110667765838
), Coxa1.anterior = c(0.347735766263887, 0.331185569221734,
0.291297323563015, 0.282485879299417, 0.328082812807204,
0.333333333333333), coxa1.posterior = c(0.316992102366229,
0.314432977364315, 0.253827544849914, 0.286117841877611,
0.335283548106612, 0.31961043951507), Coxa1average = c(0.332363934522785,
0.322809273078248, 0.272562434407915, 0.28430186079029, 0.33168318068193,
0.326471886424202), Coxa2.anterior = c(0.340257575356567,
0.378436407168337, 0.335213529057563, 0.27441486170569, 0.281278142496969,
0.343072135629241), coxa2.posterior = c(0.348566665701357,
0.362542936849028, 0.323126490526473, 0.283696541563174,
0.309630989611699, 0.341301463699871), Coxa2.average = c(0.344412120321235,
0.370489672008682, 0.329170009993469, 0.279055701634432,
0.295454566279356, 0.342186799664556), Coxa3.anterior = c(0.293726629791346,
0.291666666612973, 0.282836418227029, 0.2655367278651, 0.273627368020151,
0.300575476345173), coxa3.posterior = c(0.32239302120667,
0.348797230641319, 0.322723594896146, 0.286924958124474,
0.310531068416563, 0.359451064344658), Coxa3.average = c(0.308059825499008,
0.320231948412369, 0.302780006360137, 0.276230843196563,
0.292079218218357, 0.330013270123579), femur1 = c(0.53344412311015,
0.594501676537536, 0.530217536295495, 0.514527850716328,
0.523402362157819, 0.724214250276451), femur2 = c(0.624844166341973,
0.62242266239383, 0.687751788591478, 0.595238122698798, 0.67101716194329,
0.657370505792677), femur3 = c(0.771499768530334, 0.709621950616875,
0.73045925924984, 0.709443126916381, 0.71782183270357, 0.731296991557455
), Forewing.length = c(3.90569163653097, 3.71735396284475,
3.70870245967632, 3.67271997731286, 3.89468979918273, 3.91102248411048
), Forewing.width = c(1.14083920932507, 1.24054979613491,
1.22159545808208, 1.1424536620426, 1.29973004580049, 1.10004419021568
), Forewingsurice.area = c(10.7250294361749, 10.7357182857541,
11.2447860996532, 10.3974705849124, 11.2478641830568, 9.71889046379367
), tarsi1_1 = c(0.14790195113684, 0.127147764272682, 0.137389192375109,
0.132364817915656, 0.131413146374404, 0.149623723140197),
tarsi1_2 = c(0.0851682561130301, 0.0816151169968028, 0.0777598691430841,
0.0762711871041436, 0.0819081932949372, 0.086321375636013
), tarsi1_3 = c(0.05899459957015, 0.0618556656924223, 0.0612409299273872,
0.0613397899673706, 0.0594059432453148, 0.0584329328546814
), tarsi1_4 = c(0.0340673036084858, 0.0300687276311245, 0.0273972594295365,
0.0298627938699947, 0.0288028831418247, 0.0332005316106093
), tarsi1_5 = c(0.0781055209485422, 0.0923539508709525, 0.0862207865660963,
0.0960452026260472, 0.0918091839108305, 0.0987162455869307
), tarsi1tot = c(0.404237631377048, 0.393041225034431, 0.390008037038313,
0.395883791483213, 0.393339350417356, 0.426294808828432),
tarsi2_1 = c(0.179891974784803, 0.185996557201992, 0.183319900195347,
0.194915264093515, 0.190819089619718, 0.217352803588656),
tarsi2_2 = c(0.0905691687216469, 0.121134019176011, 0.117244156225387,
0.108958845465276, 0.10531053520073, 0.129260729462848),
tarsi2_3 = c(0.0889073519821446, 0.0837628811084026, 0.0753424647406533,
0.0750605365433736, 0.0823582392230224, 0.0960601978522388
), tarsi2_4 = c(0.0319900282179677, 0.0356529186168164, 0.0342465741861955,
0.0294592417998321, 0.039153916085443, 0.032315182365712),
tarsi2_5 = c(0.157457414941948, 0.124570439606804, 0.144641410417212,
0.114205004217583, 0.134563461120325, 0.137228859386712),
tarsi2tot = c(0.548815938233055, 0.551116815710026, 0.554794505764795,
0.522598892523131, 0.552205241699284, 0.612217772213493),
tarsi3_1 = c(0.310344810480925, 0.284364252740063, 0.212328761485435,
0.256658594428061, 0.280828103319559, 0.285524552019457),
tarsi3_2 = c(0.145824678654506, 0.165807558229931, 0.130539881647459,
0.151331723647517, 0.158865888131613, 0.165117302168043),
tarsi3_3 = c(0.12172829459396, 0.104381440634743, 0.0789685681210926,
0.0956416505558846, 0.0967596828191374, 0.103585653153654
), tarsi3_4 = c(0.0415454916076207, 0.0365120268387758, 0.0350523743106695,
0.0431799855509762, 0.0409540966474686, 0.0349712270016878
), tarsi3_5 = c(0.172829247098504, 0.150773196132581, 0.154311026818233,
0.145278460351334, 0.133213330086744, 0.141212924791317),
tarsi3tot = c(0.792272522435516, 0.741838474576093, 0.61120061278579,
0.692090414533774, 0.710621101004522, 0.730411659134159),
tibia1 = c(0.672621484952058, 0.606529166301326, 0.617647027480212,
0.64326070605379, 0.701170139665048, 0.734838388979717),
tibia2 = c(0.734939761208523, 0.680841920542057, 0.645850109596671,
0.717110574280138, 0.780378064142149, 0.729083625085317),
tibia3 = c(1.07935188194521, 0.974656351266629, 1.02095076737815,
0.9196933462701, 1.07560766416314, 1.06241701109683), Trochanter1.anterior = c(0.142916494686509,
0.0987972496490506, 0.0894439939133073, 0.102905570062555,
0.0931593216950861, 0.0951748552474476), Trochanter1.posterior = c(0.133361030881401,
0.120704458621732, 0.0995165119881685, 0.112994354060364,
0.10531053520073, 0.118193883379276), Trochanter1.average = c(0.138138762783955,
0.109750854135391, 0.0944802527492875, 0.10794996206146,
0.0992349286729306, 0.106684369313362), Trochanter2.anterior = c(0.158288326427611,
0.120704458621732, 0.109991937780383, 0.0948345464155595,
0.107110718913071, 0.141212924791317), Trochanter2.posterior = c(0.130868296424412,
0.127147764272682, 0.155519737883267, 0.1343825722132, 0.151215127156145,
0.154050456084472), Trochanter2.average = c(0.144578311426012,
0.123926111447207, 0.132755838033276, 0.114608559516156,
0.129162923034608, 0.147631690437894), Trochanter3.anterior = c(0.181969248928957,
0.150343635578303, 0.165189354284288, 0.131557713775331,
0.148064812410224, 0.146082338998146), Trochanter3.posterior = c(0.132114657421083,
0.171391742772324, 0.166398053665197, 0.133575468072875,
0.162466255556294, 0.167773349902735), Trochanter3.average = c(0.157041952967292,
0.16086768939009, 0.165793703974743, 0.132566591125879, 0.155265534208282,
0.156927844671778), Overall.body.Size.Estimator = c(1, 1,
1, 1, 1, 1)), row.names = c(NA, 6L), class = "data.frame")

Stratigraphic plot of geochemical data using ggplot2 and tidypaleo

I am trying to create a stratigraphic plot of geochemical element data which should be possible using package tidypaleo.
I want multiple plots of the different element data with Depth (cm) downcore set as the y axis. The data look as follows.
Image of data
I am using this code:
ggplot(wapITRAX, aes(x =BrTi , y = wapITRAX$Depth))+
labs(y = "Depth (cm)")+
geom_lineh()+
theme_classic()+
scale_y_reverse()
However, this only plots one element and I am trying to achieve a plot like this Image of plot
> dput(head(wapITRAX))
structure(list(Depth = 0:5, IncCoh = c(6.049230907, 5.975282432,
5.736199822, 5.658584418, 5.659008377, 5.597103404), BrTi =
c(50.50197628,
22.09236453, 23.48370927, 18.62638581, 14.36924414, 17.48777896
), AlIncCOh = c(16.69633736, 8.200449193, 23.70907643, 20.32310407,
28.62692352, 26.44224866), BrCl = c(8.04090623, 4.306048968,
3.417836951, 3.156895904, 2.787628518, 2.059316731), FeTi =
c(332.715415,
235.9371921, 372.726817, 390.7871397, 396.986099, 495.2624867
), CaTi = c(4.071146245, 3.27955665, 4.395989975, 3.677383592,
3.028670721, 4.523910733), ZrRb = structure(c(363L, 447L, 407L,
395L, 450L, 410L), .Label = c("#DIV/0!", "0.447638604",
"0.478169284",
"0.54554134", "0.548501778", "0.561420163", "0.579454254",
"0.579498861",
"0.580801291", "0.589758019", "0.590194076", "0.590277778",
"0.591357754",
"0.592870544", "0.593851133", "0.598519653", "0.599931082",
"0.600979737",
"0.601426307", "0.611710677", "0.617065868", "0.618499405",
"0.621310093",
"0.627720871", "0.63775246", "0.64005168", "0.643958869",
"0.644371941",
"0.645605974", "0.645661658", "0.646672915", "0.647348952",
"0.651578947",
"0.652401176", "0.656186383", "0.657906264", "0.658835905",
"0.662074554",
"0.662361624", "0.669589393", "0.67103429", "0.671371769",
"0.674335863",
"0.674781688", "0.676097561", "0.676639083", "0.677849462",
"0.680497925",
"0.680610514", "0.680725971", "0.683906537", "0.68855859",
"0.689067202",
"0.692353115", "0.692732291", "0.695411392", "0.696067091",
"0.696794872",
"0.699376436", "0.701762744", "0.702015197", "0.702432938",
"0.70361991",
"0.705235754", "0.705426357", "0.708084164", "0.708258528",
"0.708925221",
"0.715226656", "0.715263314", "0.717828827", "0.718975706",
"0.719799305",
"0.720363636", "0.72476489", "0.725426857", "0.725461098",
"0.726030739",
"0.7267645", "0.726998188", "0.727170554", "0.727533265",
"0.730362368",
"0.731182796", "0.735042735", "0.735849057", "0.736184046",
"0.737214792",
"0.738692342", "0.742223591", "0.742639327", "0.742714724",
"0.744126167",
"0.745790081", "0.746207701", "0.746606335", "0.747041077",
"0.749019608",
"0.751204307", "0.751326495", "0.752443737", "0.752994012",
"0.753398969",
"0.754587869", "0.755151515", "0.755466053", "0.756316411",
"0.757107679",
"0.759175941", "0.76070965", "0.761635833", "0.763760166",
"0.763861189",
"0.764076577", "0.765001936", "0.765509391", "0.765795207",
"0.76598579",
"0.767080745", "0.767225748", "0.767262192", "0.770291777",
"0.771194699",
"0.772540984", "0.774533358", "0.77486376", "0.777252364",
"0.778319123",
"0.778445883", "0.779076739", "0.779310345", "0.782186577",
"0.78238342",
"0.782541093", "0.785497178", "0.787594824", "0.788230584",
"0.788916736",
"0.789033068", "0.789052737", "0.789177605", "0.789596048",
"0.790439133",
"0.791078234", "0.792993631", "0.794899978", "0.795265235",
"0.795432921",
"0.798130469", "0.79861957", "0.798894446", "0.799410029",
"0.799679487",
"0.800096223", "0.800119868", "0.800280899", "0.800947004",
"0.80293448",
"0.804118993", "0.804120112", "0.805092452", "0.806161301",
"0.81631016",
"0.816337149", "0.81638756", "0.81827622", "0.818899466",
"0.81993865",
"0.821925431", "0.825329202", "0.825608077", "0.826135414",
"0.826325411",
"0.827108292", "0.829798658", "0.832460733", "0.832814584",
"0.833845295",
"0.833908046", "0.833980583", "0.83741705", "0.837604457",
"0.838292367",
"0.838860231", "0.839741935", "0.846485664", "0.846740374",
"0.84679304
1",
"0.84734599", "0.850027518", "0.850077882", "0.854863613",
"0.85565883",
"0.85591192", "0.857095047", "0.858967536", "0.85897779",
"0.859192457",
"0.859239235", "0.860408412", "0.860505166", "0.8609918",
"0.862821134",
"0.867779204", "0.872207328", "0.872918493", "0.873888706",
"0.874140666",
"0.877452229", "0.879856851", "0.88003663", "0.880155093",
"0.881013197",
"0.882190156", "0.882319978", "0.883029342", "0.883316008",
"0.884908053",
"0.885431692", "0.885849846", "0.889082969", "0.89763062",
"0.898384089",
"0.898527865", "0.9", "0.900719424", "0.904636261", "0.904913848",
"0.905223479", "0.908485273", "0.911212059", "0.916470588",
"0.917162698",
"0.917470525", "0.917952884", "0.918054256", "0.918781726",
"0.922268448",
"0.925987182", "0.926287744", "0.933958724", "0.939701616",
"0.940987438",
"0.941196465", "0.943041526", "0.946832078", "0.947419907",
"0.948080043",
"0.949085366", "0.950099404", "0.950502912", "0.950704225",
"0.953596288",
"0.954868709", "0.95505992", "0.955361596", "0.956422018",
"0.95671509",
"0.959064327", "0.96165309", "0.964232489", "0.965528048",
"0.965874467",
"0.968717195", "0.970270821", "0.971573209", "0.973415133",
"0.974608081",
"0.974986972", "0.978223496", "0.97935022", "0.980142566",
"0.981730052",
"0.982819606", "0.987483236", "0.989587207", "0.991002571",
"0.991932655",
"0.995306859", "0.997555012", "1.001706485", "1.002357873",
"1.005146199",
"1.010493827", "1.011544012", "1.013038906", "1.013469577",
"1.015357613",
"1.01541976", "1.015544041", "1.015937059", "1.016162826",
"1.019393939",
"1.019529957", "1.019994873", "1.028932491", "1.029518072",
"1.030101225",
"1.032310705", "1.03344968", "1.036769138", "1.037322515",
"1.041150092",
"1.041459782", "1.041961577", "1.042347697", "1.047411444",
"1.048390581",
"1.057811121", "1.060218978", "1.065395654", "1.06921167",
"1.071509648",
"1.073730469", "1.076014602", "1.077266637", "1.079983072",
"1.083003953",
"1.086196504", "1.086445657", "1.0867266", "1.0905", "1.092152628",
"1.094730942", "1.095692666", "1.1074142", "1.109534807",
"1.111154446",
"1.111188325", "1.113985094", "1.114045618", "1.128810226",
"1.129375525",
"1.132705479", "1.154833837", "1.155201819", "1.158940397",
"1.161348047",
"1.162953533", "1.175788329", "1.178036097", "1.179280397",
"1.18116463",
"1.198506534", "1.203134068", "1.207592892", "1.208610568",
"1.212525667",
"1.212841855", "1.214403157", "1.216756112", "1.228462377",
"1.23305986",
"1.241758242", "1.258212878", "1.265571914", "1.265707797",
"1.272666444",
"1.279325988", "1.289559543", "1.291191103", "1.296541003",
"1.305111821",
"1.315201411", "1.342263532", "1.344827586", "1.347944377",
"1.352831595",
"1.377717391", "1.37771934", "1.385440181", "1.403358682",
"1.411889597",
"1.412269549", "1.412544902", "1.433843384", "1.444088526",
"1.473706353",
"1.50172117", "1.508521601", "1.53030303", "1.532658694",
"1.537642783",
"1.54340949", "1.558746736", "1.595342983", "1.596774194",
"1.596969697",
"1.630653266", "1.702558635", "1.70468948", "1.718568102",
"1.740819711",
"1.760157274", "1.775510204", "1.804859813", "1.814081408",
"1.816513761",
"1.849050827", "1.870188679", "1.880195599", "1.887061404",
"1.91858679",
"1.929152149", "1.944140197", "1.946996466", "1.986547085",
"2.007683864",
"2.070983811", "2.099778271", "2.156359393", "2.159613059",
"2.163963964", "2.25951087", "2.261603376", "2.329896907",
"2.402555911", "2.414500684",
"2.444075305", "2.450268817", "2.484520124", "2.51119403",
"2.515064562",
"2.526086957", "2.554", "2.609715243", "2.61965812", "2.643854749",
"2.704166667", "2.883275261", "3.013186813", "3.02739726",
"3.206896552",
"3.320930233", "3.411627907", "3.688931298", "3.709677419",
"3.748267898",
"3.878865979", "3.936440678", "3.994230769", "33.15909091",
"4.095854922",
"4.29330254", "4.390957447", "4.514634146", "4.6367713",
"4.847665848",
"5.284023669", "5.387755102", "6.171339564", "6.183908046",
"6.36121673",
"6.847826087", "7.003496503", "7.193220339", "8.160550459",
"8.751879699"
), class = "factor"), MnFe = c(0.012176723, 0.010329834,
0.009460859,
0.004488071, 0.0033725, 0.003435313), MnIncCoh = c(169.4430276,
331.1977339, 490.5686845, 279.5752228, 272.3091921, 286.0408118
), CuRb = c(0.392971246, 1.484304933, 0.735426009, 0.491651206,
1.142857143, 0.4345898)), row.names = c(NA, 6L), class =
"data.frame")
Using your posted data. This should approximate the desired design.
First step, Transform the data from a wide format to a long format using the pivot_longer function from tidyr.
Then plot the data using "depth" as the independent variable and the parameters' values as the dependent variables.
Then use facet_wrap() to separate the plots. coord_flip() will make the independent variable (Depth) appear on the y-axis.
#fixed 1 column of data.
originaldata$ZrRb <- as.numeric(as.character(originaldata$ZrRb))
library(tidyr)
#Make wide
wapITRAX<-pivot_longer(originaldata, -1, names_to="parameter", values_to = "value")
library(ggplot2)
ggplot(wapITRAX, aes(x = Depth , y = value))+
labs(x = "Depth (cm)")+
geom_line() +
theme_classic() +
coord_flip() +
scale_x_reverse() +
facet_wrap(vars(parameter), nrow=1, scales = "free_x")

Plotting more than one linear regression line in ggplot

I am trying to plot, using ggplot, a series of scatter plots with regression lines for several datasets. I started with the following dataset, "onepectCO2MEDIAN". The data for this dataset is as follows:
onepctCO2MEDIAN
x y
layer.1 0.000000000 0.0000000
layer.2 0.006794447 4.9002490
layer.3 0.014288058 0.1608000
layer.4 0.022087920 6.6349133
layer.5 0.030797357 -1.2429506
layer.6 0.038451072 1.5643374
layer.7 0.048087904 -2.2659035
layer.8 0.058677729 2.2070045
layer.9 0.069261406 -2.3677001
layer.10 0.080524530 -1.0913506
layer.11 0.092760246 0.4099940
layer.12 0.103789609 -0.1259727
layer.13 0.116953168 -2.4138253
layer.14 0.129253298 7.0890257
layer.15 0.141710050 -0.7593539
layer.16 0.156002052 0.0454416
layer.17 0.170648172 -1.5349683
layer.18 0.185318425 6.5524201
layer.19 0.199463055 -0.8312563
layer.20 0.213513337 -2.5099183
layer.21 0.228839271 0.1365968
layer.22 0.246981293 -1.3719845
layer.23 0.263012767 -0.8712988
layer.24 0.278505564 0.6632584
layer.25 0.293658361 0.7938036
layer.26 0.310747266 3.4880637
layer.27 0.325990349 -4.4612208
layer.28 0.342517540 0.0871734
layer.29 0.362751633 -1.4171578
layer.30 0.380199537 -0.9956508
layer.31 0.394992948 0.3215526
layer.32 0.414373398 3.1403866
layer.33 0.430690214 -0.7376099
layer.34 0.449738145 -2.4860541
layer.35 0.470167458 -3.4235858
layer.36 0.489019871 0.4824748
layer.37 0.507242471 -0.9785386
layer.38 0.524314284 8.5359684
layer.39 0.543750525 5.4844742
layer.40 0.564234197 3.2149367
layer.41 0.583679616 3.9168916
layer.42 0.601459444 4.4907020
layer.43 0.619924664 6.5410410
layer.44 0.639932007 4.8068650
layer.45 0.661347181 8.1510170
layer.46 0.684117317 0.2697413
layer.47 0.704829752 -0.1807501
layer.48 0.725045770 9.7181249
layer.49 0.745165825 1.5406466
layer.50 0.765016139 -1.6476041
layer.51 0.783461511 4.8024603
layer.52 0.806382924 4.0421516
layer.53 0.829241335 9.3756512
layer.54 0.849924415 5.3305050
layer.55 0.871352434 7.5445803
layer.56 0.893632233 6.4679547
layer.57 0.916052133 2.8096065
layer.58 0.938579470 5.3921661
layer.59 0.959907651 7.2043689
layer.60 0.981643587 3.3350806
layer.61 1.004116774 8.8690707
layer.62 1.028363466 1.7861299
layer.63 1.054009140 6.2555038
layer.64 1.072440803 7.6079236
layer.65 1.094457805 7.6871483
layer.66 1.123176277 4.7787764
layer.67 1.149430871 12.7110502
layer.68 1.170912921 -0.7156284
layer.69 1.196743071 1.6490899
layer.70 1.218625903 3.0363024
layer.71 1.241868377 4.2974769
layer.72 1.267941594 1.9543778
layer.73 1.290708780 3.9986964
layer.74 1.313222289 4.5179472
layer.75 1.339045882 0.9337905
layer.76 1.362803459 3.3050770
layer.77 1.384450197 3.5422970
layer.78 1.409720302 5.9973660
layer.79 1.435851157 0.5081869
layer.80 1.455592215 7.9661630
layer.81 1.479495347 9.9460496
layer.82 1.506051958 3.7908372
layer.83 1.525728464 2.5735847
layer.84 1.549362063 10.1404974
layer.85 1.573440671 13.7408304
layer.86 1.600278735 0.9335771
layer.87 1.623879492 9.7588742
layer.88 1.650029302 1.2769395
layer.89 1.672362328 13.4970906
layer.90 1.700221121 10.2087502
layer.91 1.724793375 1.6811275
layer.92 1.751070559 6.1178992
layer.93 1.778022110 -0.1567626
layer.94 1.803022087 3.8237479
layer.95 1.830668867 4.4331468
layer.96 1.855736911 5.9790707
layer.97 1.882615030 11.3104333
layer.98 1.909218490 8.2142607
layer.99 1.938130021 15.3209674
layer.100 1.963727593 5.8178217
layer.101 1.993271947 9.6004907
layer.102 2.022548139 3.4063646
layer.103 2.050679922 4.7375010
layer.104 2.078064442 3.0133019
layer.105 2.104113460 5.5659522
layer.106 2.133597612 12.0346333
layer.107 2.164026260 -0.4028320
layer.108 2.194852829 10.5996780
layer.109 2.224257946 5.4479584
layer.110 2.252194643 4.7052374
layer.111 2.277335048 14.0962019
layer.112 2.304058313 5.7149016
layer.113 2.330930233 3.7780072
layer.114 2.357022762 4.4120620
layer.115 2.386489272 4.1866085
layer.116 2.417503953 6.9078802
layer.117 2.448524356 2.7825739
layer.118 2.478698969 7.6171786
layer.119 2.510175705 10.2410603
layer.120 2.539697886 8.1820711
layer.121 2.567915559 4.8275494
layer.122 2.597463250 19.1624883
layer.123 2.627518773 16.0677109
layer.124 2.658759236 12.5897081
layer.125 2.692401528 9.2907988
layer.126 2.721903205 7.4262502
layer.127 2.753021359 9.3902518
layer.128 2.786313415 12.6193550
layer.129 2.819564104 11.1121040
layer.130 2.850823164 15.7907100
layer.131 2.880394101 10.7425287
layer.132 2.911391258 7.7971430
layer.133 2.942965150 8.8060858
layer.134 2.974468350 17.5606266
layer.135 3.008983612 17.3088605
layer.136 3.040015221 13.4500543
layer.137 3.072668672 14.6377884
layer.138 3.105982423 8.0798552
dput(onepctCO2MEDIAN)
dput(onepctCO2MEDIAN)
structure(list(x = c(0, 0.00679444684647024, 0.014288058038801,
0.0220879195258021, 0.0307973567396402,0.0384510718286037,0.0480879042297602,
0.0586777292191982, 0.0692614056169987, 0.080524530261755,0.0927602462470531,
0.103789608925581, 0.116953168064356, 0.129253298044205, 0.141710050404072,
0.156002052128315, 0.170648172497749, 0.185318425297737, 0.199463054537773,
0.21351333707571, 0.22883927077055, 0.246981292963028, 0.263012766838074,
0.278505563735962, 0.29365836083889, 0.310747265815735, 0.325990349054337,
0.342517539858818, 0.362751632928848, 0.380199536681175, 0.39499294757843,
0.414373397827148, 0.430690214037895, 0.449738144874573, 0.470167458057404,
0.489019870758057, 0.507242470979691, 0.524314284324646, 0.543750524520874,
0.56423419713974, 0.583679616451263, 0.601459443569183, 0.619924664497375,
0.639932006597519, 0.661347180604935, 0.684117317199707, 0.704829752445221,
0.725045770406723, 0.745165824890137, 0.765016138553619, 0.783461511135101,
0.806382924318314, 0.829241335391998, 0.84992441534996, 0.871352434158325,
0.893632233142853, 0.916052132844925, 0.938579469919205, 0.959907650947571,
0.981643587350845, 1.00411677360535, 1.02836346626282, 1.05400913953781,
1.07244080305099, 1.09445780515671, 1.12317627668381, 1.14943087100983,
1.17091292142868, 1.19674307107925, 1.21862590312958, 1.24186837673187,
1.26794159412384, 1.2907087802887, 1.31322228908539, 1.33904588222504,
1.36280345916748, 1.38445019721985, 1.40972030162811, 1.43585115671158,
1.45559221506119, 1.47949534654617, 1.50605195760727, 1.52572846412659,
1.5493620634079, 1.5734406709671, 1.60027873516083, 1.62387949228287,
1.65002930164337, 1.67236232757568, 1.70022112131119, 1.72479337453842,
1.75107055902481, 1.77802211046219, 1.80302208662033, 1.83066886663437,
1.85573691129684, 1.88261502981186, 1.90921849012375, 1.93813002109528,
1.96372759342194, 1.99327194690704, 2.02254813909531, 2.05067992210388,
2.07806444168091, 2.1041134595871, 2.13359761238098, 2.16402626037598,
2.19485282897949, 2.2242579460144, 2.25219464302063, 2.27733504772186,
2.30405831336975, 2.33093023300171, 2.35702276229858, 2.38648927211761,
2.41750395298004, 2.44852435588837, 2.47869896888733, 2.51017570495605,
2.53969788551331, 2.567915558815, 2.59746325016022, 2.62751877307892,
2.65875923633575, 2.69240152835846, 2.72190320491791, 2.75302135944366,
2.78631341457367, 2.8195641040802, 2.85082316398621, 2.88039410114288,
2.91139125823975, 2.94296514987946, 2.97446835041046, 3.00898361206055,
3.04001522064209, 3.07266867160797, 3.10598242282867), y = c(0,
4.90024901723162, 0.160799993152722, 6.63491326258641, -1.24295055804536,
1.56433744259162, -2.26590352245208, 2.20700446463354, -2.36770012911069,
-1.09135061899174, 0.409993989292701, -0.125972681525582, -2.41382533818026,
7.08902570153028, -0.759353880417294, 0.0454415959640926, -1.53496826259972,
6.55242014096194, -0.831256280861552, -2.50991825629084, 0.136596820654013,
-1.37198445498419, -0.871298832596736, 0.663258363762466, 0.793803634291308,
3.48806373666998, -4.46122081238949, 0.0871733966938564, -1.41715777257774,
-0.995650815648318, 0.32155262317503, 3.14038657369241, -0.737609879885404,
-2.48605406511292, -3.423585843908, 0.482474753780281, -0.978538630093809,
8.53596837794201, 5.48447420320695, 3.21493665820644, 3.91689160157513,
4.49070195980797, 6.54104103157039, 4.80686500146557, 8.15101701282067,
0.26974132191657, -0.180750068063062, 9.71812491230244, 1.54064657400204,
-1.64760408795688, 4.80246028991894, 4.04215159914344, 9.37565121768513,
5.33050496938428, 7.54458026088508, 6.46795470819342, 2.80960651433971,
5.39216613235986, 7.20436888038562, 3.3350806460997, 8.86907069895943,
1.78612988613659, 6.25550382050395, 7.60792364896564, 7.68714830528144,
4.77877638957615, 12.7110501777314, -0.715628443181046, 1.64908991824022,
3.03630240714679, 4.29747688442346, 1.95437780501881, 3.99869636910933,
4.51794724689848, 0.933790484492299, 3.30507700050003, 3.5422970157433,
5.99736597322524, 0.508186860060022, 7.96616300581067, 9.94604963036295,
3.79083717222623, 2.57358468532258, 10.1404974171776, 13.7408303595752,
0.933577123801399, 9.75887417074129, 1.27693947132921, 13.4970905965787,
10.2087501765735, 1.68112753028756, 6.1178991508927, -0.156762622680077,
3.82374791691426, 4.43314678736265, 5.97907067167507, 11.3104332518482,
8.21426074201525, 15.320967360602, 5.81782169471483, 9.6004907412354,
3.40636455909704, 4.73750103921864, 3.0133019468806, 5.56595224859066,
12.0346332527215, -0.40283199827104, 10.5996779538754, 5.44795836991128,
4.70523736412729, 14.096201892183, 5.71490161813391, 3.77800720810782,
4.41206200639436, 4.18660847858423, 6.90788020044911, 2.78257393345915,
7.61717857379431, 10.2410602647684, 8.18207106836167, 4.82754943871433,
19.1624882857155, 16.0677109398509, 12.589708067017, 9.29079879799404,
7.42625019725314, 9.39025179806185, 12.6193550331438, 11.1121039747257,
15.7907099734986, 10.7425286789233, 7.79714300307344, 8.80608578166101,
17.5606266346039, 17.3088604929222, 13.4500543478523, 14.6377884248645,
8.07985518296064)), class = "data.frame", row.names = c("layer.1",
"layer.2", "layer.3", "layer.4", "layer.5", "layer.6", "layer.7",
"layer.8", "layer.9", "layer.10", "layer.11", "layer.12", "layer.13",
"layer.14", "layer.15", "layer.16", "layer.17", "layer.18", "layer.19",
"layer.20", "layer.21", "layer.22", "layer.23", "layer.24", "layer.25",
"layer.26", "layer.27", "layer.28", "layer.29", "layer.30", "layer.31",
"layer.32", "layer.33", "layer.34", "layer.35", "layer.36", "layer.37",
"layer.38", "layer.39", "layer.40", "layer.41", "layer.42", "layer.43",
"layer.44", "layer.45", "layer.46", "layer.47", "layer.48", "layer.49",
"layer.50", "layer.51", "layer.52", "layer.53", "layer.54", "layer.55",
"layer.56", "layer.57", "layer.58", "layer.59", "layer.60", "layer.61",
"layer.62", "layer.63", "layer.64", "layer.65", "layer.66", "layer.67",
"layer.68", "layer.69", "layer.70", "layer.71", "layer.72", "layer.73",
"layer.74", "layer.75", "layer.76", "layer.77", "layer.78", "layer.79",
"layer.80", "layer.81", "layer.82", "layer.83", "layer.84", "layer.85",
"layer.86", "layer.87", "layer.88", "layer.89", "layer.90", "layer.91",
"layer.92", "layer.93", "layer.94", "layer.95", "layer.96", "layer.97",
"layer.98", "layer.99", "layer.100", "layer.101", "layer.102",
"layer.103", "layer.104", "layer.105", "layer.106", "layer.107",
"layer.108", "layer.109", "layer.110", "layer.111", "layer.112",
"layer.113", "layer.114", "layer.115", "layer.116", "layer.117",
"layer.118", "layer.119", "layer.120", "layer.121", "layer.122",
"layer.123", "layer.124", "layer.125", "layer.126", "layer.127",
"layer.128", "layer.129", "layer.130", "layer.131", "layer.132",
"layer.133", "layer.134", "layer.135", "layer.136", "layer.137",
"layer.138"))
I started with the following to generate the first regression line and scatter plot:
lm<-ggplot(onepctCO2MEDIAN) +
geom_jitter(aes(RCP1pctCO2cumulativeMedian[1:138], departurea),
colour="blue") + geom_smooth(aes(RCP1pctCO2cumulativeMedian[1:138],
departurea), method=lm)
But I receive this error:
Warning message:
Computation failed in `stat_smooth()`:
'what' must be a function or character string
A blue scatter plot is successfully generated, but the problem is that the regression line does not appear, presumably related to the above warning.
Is there a reason for this? I would appreciate any assistance!
You should be able to get a scatter plot with a regression line by doing the following:
library(tidyverse)
#> Registered S3 methods overwritten by 'ggplot2':
#> method from
#> [.quosures rlang
#> c.quosures rlang
#> print.quosures rlang
onepctCO2MEDIAN <- structure(list(x = c(0, 0.00679444684647024, 0.014288058038801,
0.0220879195258021, 0.0307973567396402,0.0384510718286037,0.0480879042297602,
0.0586777292191982, 0.0692614056169987, 0.080524530261755,0.0927602462470531,
0.103789608925581, 0.116953168064356, 0.129253298044205, 0.141710050404072,
0.156002052128315, 0.170648172497749, 0.185318425297737, 0.199463054537773,
0.21351333707571, 0.22883927077055, 0.246981292963028, 0.263012766838074,
0.278505563735962, 0.29365836083889, 0.310747265815735, 0.325990349054337,
0.342517539858818, 0.362751632928848, 0.380199536681175, 0.39499294757843,
0.414373397827148, 0.430690214037895, 0.449738144874573, 0.470167458057404,
0.489019870758057, 0.507242470979691, 0.524314284324646, 0.543750524520874,
0.56423419713974, 0.583679616451263, 0.601459443569183, 0.619924664497375,
0.639932006597519, 0.661347180604935, 0.684117317199707, 0.704829752445221,
0.725045770406723, 0.745165824890137, 0.765016138553619, 0.783461511135101,
0.806382924318314, 0.829241335391998, 0.84992441534996, 0.871352434158325,
0.893632233142853, 0.916052132844925, 0.938579469919205, 0.959907650947571,
0.981643587350845, 1.00411677360535, 1.02836346626282, 1.05400913953781,
1.07244080305099, 1.09445780515671, 1.12317627668381, 1.14943087100983,
1.17091292142868, 1.19674307107925, 1.21862590312958, 1.24186837673187,
1.26794159412384, 1.2907087802887, 1.31322228908539, 1.33904588222504,
1.36280345916748, 1.38445019721985, 1.40972030162811, 1.43585115671158,
1.45559221506119, 1.47949534654617, 1.50605195760727, 1.52572846412659,
1.5493620634079, 1.5734406709671, 1.60027873516083, 1.62387949228287,
1.65002930164337, 1.67236232757568, 1.70022112131119, 1.72479337453842,
1.75107055902481, 1.77802211046219, 1.80302208662033, 1.83066886663437,
1.85573691129684, 1.88261502981186, 1.90921849012375, 1.93813002109528,
1.96372759342194, 1.99327194690704, 2.02254813909531, 2.05067992210388,
2.07806444168091, 2.1041134595871, 2.13359761238098, 2.16402626037598,
2.19485282897949, 2.2242579460144, 2.25219464302063, 2.27733504772186,
2.30405831336975, 2.33093023300171, 2.35702276229858, 2.38648927211761,
2.41750395298004, 2.44852435588837, 2.47869896888733, 2.51017570495605,
2.53969788551331, 2.567915558815, 2.59746325016022, 2.62751877307892,
2.65875923633575, 2.69240152835846, 2.72190320491791, 2.75302135944366,
2.78631341457367, 2.8195641040802, 2.85082316398621, 2.88039410114288,
2.91139125823975, 2.94296514987946, 2.97446835041046, 3.00898361206055,
3.04001522064209, 3.07266867160797, 3.10598242282867),
y = c(0,
4.90024901723162, 0.160799993152722, 6.63491326258641, -1.24295055804536,
1.56433744259162, -2.26590352245208, 2.20700446463354, -2.36770012911069,
-1.09135061899174, 0.409993989292701, -0.125972681525582, -2.41382533818026,
7.08902570153028, -0.759353880417294, 0.0454415959640926, -1.53496826259972,
6.55242014096194, -0.831256280861552, -2.50991825629084, 0.136596820654013,
-1.37198445498419, -0.871298832596736, 0.663258363762466, 0.793803634291308,
3.48806373666998, -4.46122081238949, 0.0871733966938564, -1.41715777257774,
-0.995650815648318, 0.32155262317503, 3.14038657369241, -0.737609879885404,
-2.48605406511292, -3.423585843908, 0.482474753780281, -0.978538630093809,
8.53596837794201, 5.48447420320695, 3.21493665820644, 3.91689160157513,
4.49070195980797, 6.54104103157039, 4.80686500146557, 8.15101701282067,
0.26974132191657, -0.180750068063062, 9.71812491230244, 1.54064657400204,
-1.64760408795688, 4.80246028991894, 4.04215159914344, 9.37565121768513,
5.33050496938428, 7.54458026088508, 6.46795470819342, 2.80960651433971,
5.39216613235986, 7.20436888038562, 3.3350806460997, 8.86907069895943,
1.78612988613659, 6.25550382050395, 7.60792364896564, 7.68714830528144,
4.77877638957615, 12.7110501777314, -0.715628443181046, 1.64908991824022,
3.03630240714679, 4.29747688442346, 1.95437780501881, 3.99869636910933,
4.51794724689848, 0.933790484492299, 3.30507700050003, 3.5422970157433,
5.99736597322524, 0.508186860060022, 7.96616300581067, 9.94604963036295,
3.79083717222623, 2.57358468532258, 10.1404974171776, 13.7408303595752,
0.933577123801399, 9.75887417074129, 1.27693947132921, 13.4970905965787,
10.2087501765735, 1.68112753028756, 6.1178991508927, -0.156762622680077,
3.82374791691426, 4.43314678736265, 5.97907067167507, 11.3104332518482,
8.21426074201525, 15.320967360602, 5.81782169471483, 9.6004907412354,
3.40636455909704, 4.73750103921864, 3.0133019468806, 5.56595224859066,
12.0346332527215, -0.40283199827104, 10.5996779538754, 5.44795836991128,
4.70523736412729, 14.096201892183, 5.71490161813391, 3.77800720810782,
4.41206200639436, 4.18660847858423, 6.90788020044911, 2.78257393345915,
7.61717857379431, 10.2410602647684, 8.18207106836167, 4.82754943871433,
19.1624882857155, 16.0677109398509, 12.589708067017, 9.29079879799404,
7.42625019725314, 9.39025179806185, 12.6193550331438, 11.1121039747257,
15.7907099734986, 10.7425286789233, 7.79714300307344, 8.80608578166101,
17.5606266346039, 17.3088604929222, 13.4500543478523, 14.6377884248645,
8.07985518296064)),
class = "data.frame", row.names = c("layer.1",
"layer.2", "layer.3", "layer.4", "layer.5", "layer.6", "layer.7",
"layer.8", "layer.9", "layer.10", "layer.11", "layer.12", "layer.13",
"layer.14", "layer.15", "layer.16", "layer.17", "layer.18", "layer.19",
"layer.20", "layer.21", "layer.22", "layer.23", "layer.24", "layer.25",
"layer.26", "layer.27", "layer.28", "layer.29", "layer.30", "layer.31",
"layer.32", "layer.33", "layer.34", "layer.35", "layer.36", "layer.37",
"layer.38", "layer.39", "layer.40", "layer.41", "layer.42", "layer.43",
"layer.44", "layer.45", "layer.46", "layer.47", "layer.48", "layer.49",
"layer.50", "layer.51", "layer.52", "layer.53", "layer.54", "layer.55",
"layer.56", "layer.57", "layer.58", "layer.59", "layer.60", "layer.61",
"layer.62", "layer.63", "layer.64", "layer.65", "layer.66", "layer.67",
"layer.68", "layer.69", "layer.70", "layer.71", "layer.72", "layer.73",
"layer.74", "layer.75", "layer.76", "layer.77", "layer.78", "layer.79",
"layer.80", "layer.81", "layer.82", "layer.83", "layer.84", "layer.85",
"layer.86", "layer.87", "layer.88", "layer.89", "layer.90", "layer.91",
"layer.92", "layer.93", "layer.94", "layer.95", "layer.96", "layer.97",
"layer.98", "layer.99", "layer.100", "layer.101", "layer.102",
"layer.103", "layer.104", "layer.105", "layer.106", "layer.107",
"layer.108", "layer.109", "layer.110", "layer.111", "layer.112",
"layer.113", "layer.114", "layer.115", "layer.116", "layer.117",
"layer.118", "layer.119", "layer.120", "layer.121", "layer.122",
"layer.123", "layer.124", "layer.125", "layer.126", "layer.127",
"layer.128", "layer.129", "layer.130", "layer.131", "layer.132",
"layer.133", "layer.134", "layer.135", "layer.136", "layer.137",
"layer.138"))
# Create scatterplot from dataframe "onepctCO2MEDIAN" with "x" and "y" variables and add "lm"
onepctCO2MEDIAN %>%
ggplot(aes(x = x, y = y)) +
geom_point() +
xlab("x") +
ylab("y") +
geom_smooth(method = "lm")
Created on 2019-06-07 by the reprex package (v0.3.0)

How to plot the forecasted values against actual values observed later in R?

We used the R library forecast to make predictions for the next 24 hours. We have the following:
fore_cast=forecast.tbats(model,h=24,level=90)
fore_cast
Point Forecast Lo 90 Hi 90
5.380952 6270.778 5389.089 7296.643
5.386905 5458.096 4557.375 6536.743
5.392857 5219.995 4248.967 6412.814
5.398810 5187.102 4126.390 6520.328
Now we have 2 problems:
We need 'time' (in hour e.g. 01,23,19 etc) instead of 'point'.
We wish to plot the trendline against time showing the actual observed
values against these predicted values. We have loaded actual observed
values from a CSV file.
We tried:
actual_data = read.csv('actualdata.csv')
plot(actual_data,fore_cast)
Doesn't work, and using plot(actual_data) just shows some points in a straight line instead of curved trendline.
EDIT:
Sample output of fore_cast from dput:
structure(list(model = structure(list(lambda = 0.000438881055939422,
alpha = 0.65694875480321, beta = -0.0983972877836753, damping.parameter = 0.800419363290521,
gamma.one.values = c(-0.00150031474145603, -0.00124696854910294
), gamma.two.values = c(0.0023600487982342, -0.002465549595849
), ar.coefficients = NULL, ma.coefficients = NULL, likelihood = 13202.294346586,
optim.return.code = 0L, variance = 0.00855092137349485, AIC = 13258.294346586,
parameters = structure(list(vect = c(0.000438881055939422,
0.65694875480321, 0.800419363290521, -0.0983972877836753,
-0.00150031474145603, -0.00124696854910294, 0.0023600487982342,
-0.002465549595849), control = structure(list(use.beta = TRUE,
use.box.cox = TRUE, use.damping = TRUE, length.gamma = 4L,
p = 0, q = 0), .Names = c("use.beta", "use.box.cox",
"use.damping", "length.gamma", "p", "q"))), .Names = c("vect",
"control")), seed.states = structure(c(7.44188559667267,
0.00357069100887873, -0.0664300680553579, 0.0229067500159256,
0.00460111570469819, -0.00772324725408007, -0.000610110386029883,
0.00568378752162509, -0.0084050648066819, -0.0324093004247092,
-0.000720936399990958, -0.00705790547321605, -0.00738992950838566,
0.00180424326179638, -0.00107745502434416, 0.00242014705705761,
-0.01824679745657, 0.0123019701003545, -0.0245935735677402,
0.0181321397860132), .Dim = c(20L, 1L)), fitted.values = structure(c(1598.57443298879,
1435.74973092922, 1397.92464316794, 1296.90202189518, 1440.3201303663,
1544.11695101118, 1777.97079874181, 1766.50571671645, 1925.27360388028,
1863.26963233038, 1773.08363764691, 1887.26580055295, 1887.48006609474,
1841.66200850472, 1991.90290660363, 2233.04775631848, 2081.30246965768,
1872.12639817609, 1899.38583561568, 2213.43437455052, 2214.00832820531,
1745.36311914995, 1678.67975050944, 1502.35472259274, 1512.27350460399,
1456.14165844166, 1464.3803467642, 1517.99443293857, 1484.54280422369,
1382.37041287489, 1452.43700910726, 1545.16934543365, 1440.50974319508,
1475.59742668699, 1544.88546424501, 1790.95280713647, 1916.4267023671,
1928.72804180587, 1819.15839770808, 1916.43079357329, 1836.80043977753,
1720.25638746452, 1730.03629161412, 1614.6048115754, 1599.23641723244,
1635.86950932066, 1543.46360784778, 1641.35066985679, 1608.60556151299,
1651.47649465456, 1475.15006990464, 1403.67294742438, 1507.58932406857,
1666.3170708439, 1696.06132797576, 1543.32187293056, 1704.58043626911,
1914.72424191575, 2109.33624862625, 2092.98934458578, 2222.13355258602,
2084.68677709368, 1962.9230489947, 2045.61547393981, 2140.30565941261,
2097.46130996426, 2126.07936955385, 2226.18935508502, 2269.54492801286,
2300.37314952852, 2398.48786829541, 2303.31270702723, 2332.74139979969,
2146.51487558643, 2101.27480789243, 2111.61910899422, 2053.57840714969,
2046.56606362537, 2073.82870990658, 2094.88831798868, 2334.85185938782,
2541.72156227893, 2502.36031483721, 2398.12240784327, 2266.35832277135,
2151.05248890962, 2266.88803633019, 2366.19453856405, 2399.97570044332,
2341.74959623409, 2144.33465155869, 2102.91952061083, 2214.48622101851,
2179.48115699957, 2288.28092735955, 2224.55218736155, 2195.1506809087,
2163.94619334319, 2161.41843642149, 2134.75060670667, 2138.77895768654,
2142.84680080931, 2258.55072549978, 2297.90237035988, 2314.94197015208,
2300.99928929609, 2277.39754662665, 2291.06980363364, 2487.04257346235,
2381.05768214413, 2509.40078456481, 2657.61336243367, 2528.65026804303,
2434.2722174014, 2366.04811963942, 2270.6647135766, 2231.33965004538,
2376.51043520344, 2249.42861599343, 2193.98771109322, 2252.12327312365,
2210.76969838623, 2180.50451255189, 2221.92898123682, 2537.84678083006,
2329.57350097532, 2252.82349908982, 2143.92033677754, 2092.3142840022,
2084.70304624685, 2111.18929138546, 2160.05383108999, 2280.94409931504,
2118.22029344747, 2214.65738250204, 2269.05911898631, 2084.26658709038,
2016.04764576402, 2095.57091797435, 2161.07354463394, 2427.77607700887,
2333.91103594967, 2234.23838054763, 2250.71557301013, 2186.97925802073,
2129.51096829218, 2115.40228652934, 2094.89231085691, 2086.41044567131,
2180.94542608489, 2105.38187642016, 2459.45788915933, 2292.36325639374,
2410.75372754831, 2375.56640249604, 2491.11938114866, 2470.51372278037,
2464.95765202085, 2600.85929020727, 2709.48518695182, 2779.77558137814,
2518.29927341458, 2344.06621605191, 2391.56719713269, 2368.68842788795,
2199.93530349068, 2113.92970206565, 2458.96718445444, 3121.97852988865,
2559.40932439262, 2331.12829078836, 2238.54586985577, 2241.91440620202,
2225.29804576634, 2154.14147781021, 2060.57980596908, 2037.30100544426,
2215.93410789353, 2364.42668160056, 2518.72871618042, 2537.34279365294,
2473.76096855791, 2623.63387707374, 2589.08335304697, 2577.0563838788,
2349.53279218826, 2305.52193868551, 2232.63712180453, 2167.50003597208,
2320.23187534213, 2281.86365949586, 2281.21119271599, 2323.2014703372,
2185.94404743238, 2140.21863271207, 2011.67723856012, 1966.52063119589,
2002.67344212857, 1952.41101080662, 1988.37461163105, 2126.75137749373,
2239.14722292367, 2320.98046489603, 2444.91847853015, 2431.69548763034,
2514.73820659393, 2505.85249387343, 2888.19773974179, 2853.20690693738,
2502.20865871069, 2524.56894781003, 2659.52271740553, 2615.9025930681,
2923.69327019152, 2754.76074569658, 2784.59488335761, 2874.24378479002,
2683.41908597168, 2733.83011888159, 2774.1325162997, 2906.41593326865,
2726.06821502751, 2460.21579967528, 2450.8035097605, 2547.39389733175,
2625.60323572861, 2827.94083526683, 2971.92012845614, 3042.90981987278,
2835.00811374845, 2846.98066660519, 2871.21876763166, 2901.99696373824,
2627.47532996657, 2583.75084300313, 2602.68041642846, 2632.8054092953,
2667.85374690972, 2639.10586730146, 2466.95799545022, 2381.06823502402,
2531.32611053776, 2407.14812148706, 2342.75701798463, 2401.73791085847,
2365.50645844524, 2404.50408575777, 2452.57343738519, 2613.15332739214,
2665.50965844576, 2723.8237337447, 2915.09266385617, 2890.17498445896,
2853.6278331055, 2868.1228183545, 2917.07803535669, 2876.59409770233,
2577.82035337979, 2581.91435020803, 2520.20342021937, 2603.37973251208,
2536.03988578365, 2510.83398648802, 2472.80606784857, 2425.51212342113,
2442.02863541673, 2465.73405821711, 2384.42988766816, 2555.51500549788,
2737.77091706275, 2425.00224845814, 2460.17325671183, 2639.16650619329,
2816.37024420397, 2755.69999167982, 2802.64991688288, 2685.12803367301,
2521.77568128564, 2500.99980614696, 2620.41659854805, 2529.25134423133,
2590.14804885984, 2318.80485234464, 2341.88940012276, 2460.21008281205,
2513.70688167177, 2437.71670675479, 2383.29782281743, 2499.36244454453,
2472.98602901478, 2491.10649022417, 2350.1405559119, 2362.78308814045,
2431.3911847573, 2321.15216823049, 2355.74203614213, 2429.60523843166,
2355.61947983433, 2346.3751018515, 2453.82214513707, 2542.98125962684,
2342.43364707529, 2302.17741211575, 2388.93541944219, 2435.41878657221, ....
Sample output from dput for actual observed values:
structure(list(index12 = c(6297.416944, 5406.865556, 4718.355556,
5304.729167, 4968.014722, 5081.130833, 5544.955, 4655.009444,
4269.023056, 4346.588333, 4511.455833, 5102.57, 4818.673333,
4862.343056, 4785.176667, 5385.005278, 6469.080833, 7166.025278,
7010.708333, 511.114167)), .Names = "index12", class = "data.frame", row.names = c(NA,
-20L))
The value of Point is unusual in spite of hour unit data. I think you failed to make a model.
Here is my example:
actual_data <- structure(list(index12 = c(6297.416944, 5406.865556, 4718.355556,
5304.729167, 4968.014722, 5081.130833, 5544.955, 4655.009444,
4269.023056, 4346.588333, 4511.455833, 5102.57, 4818.673333,
4862.343056, 4785.176667, 5385.005278, 6469.080833, 7166.025278,
7010.708333, 511.114167)),
.Names = "index12", class = "data.frame", row.names = c(NA, -20L))
# I suppose that actual_data was taken per hour.
num_actual <- as.numeric(actual_data[,1])
model <- bats(num_actual)
fore_cast <- forecast(model, h=24, level=90)
fore_cast # Point is from 21 to 44 because of length(actual_data)=20 and demanding predictions for the next 24 hours
# Point Forecast Lo 90 Hi 90
# 21 5063.207 2902.187 7224.226
# 22 5108.114 2946.988 7269.241
# :
# 44 5108.114 2944.629 7271.600
# plot() has forecast method. It draws actual_data and prediction, and paints Lo90-Hi90.
plot(fore_cast, main="")

GGPlot - how to format x-axis for stopwatch like times

This seems relatively straightforward and possibly doable with scale_x_datetime or scale_x_discrete.
I have a column with time increments like on a stopwatch:
[1] 0:00:01 0:00:02 0:00:03 0:00:04 0:00:05 0:00:06
1800 Levels: 0:00:01 0:00:02 0:00:03 0:00:04 0:00:05 0:00:06 0:00:07 ... 0:30:00
Using ggplot how can I set the x-axis labels for 30 second intervals?
Reproducible data:
structure(list(`somedata$Time` = structure(1:4, .Label = c("0:00:01",
"0:00:02", "0:00:03", "0:00:04", "0:00:05", "0:00:06", "0:00:07",
"0:00:08", "0:00:09", "0:00:10", "0:00:11", "0:00:12", "0:00:13",
"0:00:14", "0:00:15", "0:00:16", "0:00:17", "0:00:18", "0:00:19",
"0:00:20", "0:00:21", "0:00:22", "0:00:23", "0:00:24", "0:00:25",
"0:00:26", "0:00:27", "0:00:28", "0:00:29", "0:00:30", "0:00:31",
"0:00:32", "0:00:33", "0:00:34", "0:00:35", "0:00:36", "0:00:37",
"0:00:38", "0:00:39", "0:00:40", "0:00:41", "0:00:42", "0:00:43",
"0:00:44", "0:00:45", "0:00:46", "0:00:47", "0:00:48", "0:00:49",
"0:00:50", "0:00:51", "0:00:52", "0:00:53", "0:00:54", "0:00:55",
"0:00:56", "0:00:57", "0:00:58", "0:00:59", "0:01:00", "0:01:01",
"0:01:02", "0:01:03", "0:01:04", "0:01:05", "0:01:06", "0:01:07",
"0:01:08", "0:01:09", "0:01:10", "0:01:11", "0:01:12", "0:01:13",
"0:01:14", "0:01:15", "0:01:16", "0:01:17", "0:01:18", "0:01:19",
"0:01:20", "0:01:21", "0:01:22", "0:01:23", "0:01:24", "0:01:25",
"0:01:26", "0:01:27", "0:01:28", "0:01:29", "0:01:30", "0:01:31",
"0:01:32", "0:01:33", "0:01:34", "0:01:35", "0:01:36", "0:01:37",
"0:01:38", "0:01:39", "0:01:40", "0:01:41", "0:01:42", "0:01:43",
"0:01:44", "0:01:45", "0:01:46", "0:01:47", "0:01:48", "0:01:49",
"0:01:50", "0:01:51", "0:01:52", "0:01:53", "0:01:54", "0:01:55",
"0:01:56", "0:01:57", "0:01:58", "0:01:59", "0:02:00", "0:02:01",
"0:02:02", "0:02:03", "0:02:04", "0:02:05", "0:02:06", "0:02:07",
"0:02:08", "0:02:09", "0:02:10", "0:02:11", "0:02:12", "0:02:13",
"0:02:14", "0:02:15", "0:02:16", "0:02:17", "0:02:18", "0:02:19",
"0:02:20", "0:02:21", "0:02:22", "0:02:23", "0:02:24", "0:02:25",
"0:02:26", "0:02:27", "0:02:28", "0:02:29", "0:02:30", "0:02:31",
"0:02:32", "0:02:33", "0:02:34", "0:02:35", "0:02:36", "0:02:37",
"0:02:38", "0:02:39", "0:02:40", "0:02:41", "0:02:42", "0:02:43",
"0:02:44", "0:02:45", "0:02:46", "0:02:47", "0:02:48", "0:02:49",
"0:02:50", "0:02:51", "0:02:52", "0:02:53", "0:02:54", "0:02:55",
"0:02:56", "0:02:57", "0:02:58", "0:02:59", "0:03:00", "0:03:01",
"0:03:02", "0:03:03", "0:03:04", "0:03:05", "0:03:06", "0:03:07",
"0:03:08", "0:03:09", "0:03:10", "0:03:11", "0:03:12", "0:03:13",
"0:03:14", "0:03:15", "0:03:16", "0:03:17", "0:03:18", "0:03:19",
"0:03:20", "0:03:21", "0:03:22", "0:03:23", "0:03:24", "0:03:25",
"0:03:26", "0:03:27", "0:03:28", "0:03:29", "0:03:30", "0:03:31",
"0:03:32", "0:03:33", "0:03:34", "0:03:35", "0:03:36", "0:03:37",
"0:03:38", "0:03:39", "0:03:40", "0:03:41", "0:03:42", "0:03:43",
"0:03:44", "0:03:45", "0:03:46", "0:03:47", "0:03:48", "0:03:49",
"0:03:50", "0:03:51", "0:03:52", "0:03:53", "0:03:54", "0:03:55",
"0:03:56", "0:03:57", "0:03:58", "0:03:59", "0:04:00", "0:04:01",
"0:04:02", "0:04:03", "0:04:04", "0:04:05", "0:04:06", "0:04:07",
"0:04:08", "0:04:09", "0:04:10", "0:04:11", "0:04:12", "0:04:13",
"0:04:14", "0:04:15", "0:04:16", "0:04:17", "0:04:18", "0:04:19",
"0:04:20", "0:04:21", "0:04:22", "0:04:23", "0:04:24", "0:04:25",
"0:04:26", "0:04:27", "0:04:28", "0:04:29", "0:04:30", "0:04:31",
"0:04:32", "0:04:33", "0:04:34", "0:04:35", "0:04:36", "0:04:37",
"0:04:38", "0:04:39", "0:04:40", "0:04:41", "0:04:42", "0:04:43",
"0:04:44", "0:04:45", "0:04:46", "0:04:47", "0:04:48", "0:04:49",
"0:04:50", "0:04:51", "0:04:52", "0:04:53", "0:04:54", "0:04:55",
"0:04:56", "0:04:57", "0:04:58", "0:04:59", "0:05:00", "0:05:01",
"0:05:02", "0:05:03", "0:05:04", "0:05:05", "0:05:06", "0:05:07",
"0:05:08", "0:05:09", "0:05:10", "0:05:11", "0:05:12", "0:05:13",
"0:05:14", "0:05:15", "0:05:16", "0:05:17", "0:05:18", "0:05:19",
"0:05:20", "0:05:21", "0:05:22", "0:05:23", "0:05:24", "0:05:25",
"0:05:26", "0:05:27", "0:05:28", "0:05:29", "0:05:30", "0:05:31",
"0:05:32", "0:05:33", "0:05:34", "0:05:35", "0:05:36", "0:05:37",
"0:05:38", "0:05:39", "0:05:40", "0:05:41", "0:05:42", "0:05:43",
"0:05:44", "0:05:45", "0:05:46", "0:05:47", "0:05:48", "0:05:49",
"0:05:50", "0:05:51", "0:05:52", "0:05:53", "0:05:54", "0:05:55",
"0:05:56", "0:05:57", "0:05:58", "0:05:59", "0:06:00", "0:06:01",
"0:06:02", "0:06:03", "0:06:04", "0:06:05", "0:06:06", "0:06:07",
"0:06:08", "0:06:09", "0:06:10", "0:06:11", "0:06:12", "0:06:13",
"0:06:14", "0:06:15", "0:06:16", "0:06:17", "0:06:18", "0:06:19",
"0:06:20", "0:06:21", "0:06:22", "0:06:23", "0:06:24", "0:06:25",
"0:06:26", "0:06:27", "0:06:28", "0:06:29", "0:06:30", "0:06:31",
"0:06:32", "0:06:33", "0:06:34", "0:06:35", "0:06:36", "0:06:37",
"0:06:38", "0:06:39", "0:06:40", "0:06:41", "0:06:42", "0:06:43",
"0:06:44", "0:06:45", "0:06:46", "0:06:47", "0:06:48", "0:06:49",
"0:06:50", "0:06:51", "0:06:52", "0:06:53", "0:06:54", "0:06:55",
"0:06:56", "0:06:57", "0:06:58", "0:06:59", "0:07:00", "0:07:01",
"0:07:02", "0:07:03", "0:07:04", "0:07:05", "0:07:06", "0:07:07",
"0:07:08", "0:07:09", "0:07:10", "0:07:11", "0:07:12", "0:07:13",
"0:07:14", "0:07:15", "0:07:16", "0:07:17", "0:07:18", "0:07:19",
"0:07:20", "0:07:21", "0:07:22", "0:07:23", "0:07:24", "0:07:25",
"0:07:26", "0:07:27", "0:07:28", "0:07:29", "0:07:30", "0:07:31",
"0:07:32", "0:07:33", "0:07:34", "0:07:35", "0:07:36", "0:07:37",
"0:07:38", "0:07:39", "0:07:40", "0:07:41", "0:07:42", "0:07:43",
"0:07:44", "0:07:45", "0:07:46", "0:07:47", "0:07:48", "0:07:49",
"0:07:50", "0:07:51", "0:07:52", "0:07:53", "0:07:54", "0:07:55",
"0:07:56", "0:07:57", "0:07:58", "0:07:59", "0:08:00", "0:08:01",
"0:08:02", "0:08:03", "0:08:04", "0:08:05", "0:08:06", "0:08:07",
"0:08:08", "0:08:09", "0:08:10", "0:08:11", "0:08:12", "0:08:13",
"0:08:14", "0:08:15", "0:08:16", "0:08:17", "0:08:18", "0:08:19",
"0:08:20", "0:08:21", "0:08:22", "0:08:23", "0:08:24", "0:08:25",
"0:08:26", "0:08:27", "0:08:28", "0:08:29", "0:08:30", "0:08:31",
"0:08:32", "0:08:33", "0:08:34", "0:08:35", "0:08:36", "0:08:37",
"0:08:38", "0:08:39", "0:08:40", "0:08:41", "0:08:42", "0:08:43",
"0:08:44", "0:08:45", "0:08:46", "0:08:47", "0:08:48", "0:08:49",
"0:08:50", "0:08:51", "0:08:52", "0:08:53", "0:08:54", "0:08:55",
"0:08:56", "0:08:57", "0:08:58", "0:08:59", "0:09:00", "0:09:01",
"0:09:02", "0:09:03", "0:09:04", "0:09:05", "0:09:06", "0:09:07",
"0:09:08", "0:09:09", "0:09:10", "0:09:11", "0:09:12", "0:09:13",
"0:09:14", "0:09:15", "0:09:16", "0:09:17", "0:09:18", "0:09:19",
"0:09:20", "0:09:21", "0:09:22", "0:09:23", "0:09:24", "0:09:25",
"0:09:26", "0:09:27", "0:09:28", "0:09:29", "0:09:30", "0:09:31",
"0:09:32", "0:09:33", "0:09:34", "0:09:35", "0:09:36", "0:09:37",
"0:09:38", "0:09:39", "0:09:40", "0:09:41", "0:09:42", "0:09:43",
"0:09:44", "0:09:45", "0:09:46", "0:09:47", "0:09:48", "0:09:49",
"0:09:50", "0:09:51", "0:09:52", "0:09:53", "0:09:54", "0:09:55",
"0:09:56", "0:09:57", "0:09:58", "0:09:59", "0:10:00", "0:10:01",
"0:10:02", "0:10:03", "0:10:04", "0:10:05", "0:10:06", "0:10:07",
"0:10:08", "0:10:09", "0:10:10", "0:10:11", "0:10:12", "0:10:13",
"0:10:14", "0:10:15", "0:10:16", "0:10:17", "0:10:18", "0:10:19",
"0:10:20", "0:10:21", "0:10:22", "0:10:23", "0:10:24", "0:10:25",
"0:10:26", "0:10:27", "0:10:28", "0:10:29", "0:10:30", "0:10:31",
"0:10:32", "0:10:33", "0:10:34", "0:10:35", "0:10:36", "0:10:37",
"0:10:38", "0:10:39", "0:10:40", "0:10:41", "0:10:42", "0:10:43",
"0:10:44", "0:10:45", "0:10:46", "0:10:47", "0:10:48", "0:10:49",
"0:10:50", "0:10:51", "0:10:52", "0:10:53", "0:10:54", "0:10:55",
"0:10:56", "0:10:57", "0:10:58", "0:10:59", "0:11:00", "0:11:01",
"0:11:02", "0:11:03", "0:11:04", "0:11:05", "0:11:06", "0:11:07",
"0:11:08", "0:11:09", "0:11:10", "0:11:11", "0:11:12", "0:11:13",
"0:11:14", "0:11:15", "0:11:16", "0:11:17", "0:11:18", "0:11:19",
"0:11:20", "0:11:21", "0:11:22", "0:11:23", "0:11:24", "0:11:25",
"0:11:26", "0:11:27", "0:11:28", "0:11:29", "0:11:30", "0:11:31",
"0:11:32", "0:11:33", "0:11:34", "0:11:35", "0:11:36", "0:11:37",
"0:11:38", "0:11:39", "0:11:40", "0:11:41", "0:11:42", "0:11:43",
"0:11:44", "0:11:45", "0:11:46", "0:11:47", "0:11:48", "0:11:49",
"0:11:50", "0:11:51", "0:11:52", "0:11:53", "0:11:54", "0:11:55",
"0:11:56", "0:11:57", "0:11:58", "0:11:59", "0:12:00", "0:12:01",
"0:12:02", "0:12:03", "0:12:04", "0:12:05", "0:12:06", "0:12:07",
"0:12:08", "0:12:09", "0:12:10", "0:12:11", "0:12:12", "0:12:13",
"0:12:14", "0:12:15", "0:12:16", "0:12:17", "0:12:18", "0:12:19",
"0:12:20", "0:12:21", "0:12:22", "0:12:23", "0:12:24", "0:12:25",
"0:12:26", "0:12:27", "0:12:28", "0:12:29", "0:12:30", "0:12:31",
"0:12:32", "0:12:33", "0:12:34", "0:12:35", "0:12:36", "0:12:37",
"0:12:38", "0:12:39", "0:12:40", "0:12:41", "0:12:42", "0:12:43",
"0:12:44", "0:12:45", "0:12:46", "0:12:47", "0:12:48", "0:12:49",
"0:12:50", "0:12:51", "0:12:52", "0:12:53", "0:12:54", "0:12:55",
"0:12:56", "0:12:57", "0:12:58", "0:12:59", "0:13:00", "0:13:01",
"0:13:02", "0:13:03", "0:13:04", "0:13:05", "0:13:06", "0:13:07",
"0:13:08", "0:13:09", "0:13:10", "0:13:11", "0:13:12", "0:13:13",
"0:13:14", "0:13:15", "0:13:16", "0:13:17", "0:13:18", "0:13:19",
"0:13:20", "0:13:21", "0:13:22", "0:13:23", "0:13:24", "0:13:25",
"0:13:26", "0:13:27", "0:13:28", "0:13:29", "0:13:30", "0:13:31",
"0:13:32", "0:13:33", "0:13:34", "0:13:35", "0:13:36", "0:13:37",
"0:13:38", "0:13:39", "0:13:40", "0:13:41", "0:13:42", "0:13:43",
"0:13:44", "0:13:45", "0:13:46", "0:13:47", "0:13:48", "0:13:49",
"0:13:50", "0:13:51", "0:13:52", "0:13:53", "0:13:54", "0:13:55",
"0:13:56", "0:13:57", "0:13:58", "0:13:59", "0:14:00", "0:14:01",
"0:14:02", "0:14:03", "0:14:04", "0:14:05", "0:14:06", "0:14:07",
"0:14:08", "0:14:09", "0:14:10", "0:14:11", "0:14:12", "0:14:13",
"0:14:14", "0:14:15", "0:14:16", "0:14:17", "0:14:18", "0:14:19",
"0:14:20", "0:14:21", "0:14:22", "0:14:23", "0:14:24", "0:14:25",
"0:14:26", "0:14:27", "0:14:28", "0:14:29", "0:14:30", "0:14:31",
"0:14:32", "0:14:33", "0:14:34", "0:14:35", "0:14:36", "0:14:37",
"0:14:38", "0:14:39", "0:14:40", "0:14:41", "0:14:42", "0:14:43",
"0:14:44", "0:14:45", "0:14:46", "0:14:47", "0:14:48", "0:14:49",
"0:14:50", "0:14:51", "0:14:52", "0:14:53", "0:14:54", "0:14:55",
"0:14:56", "0:14:57", "0:14:58", "0:14:59", "0:15:00", "0:15:01",
"0:15:02", "0:15:03", "0:15:04", "0:15:05", "0:15:06", "0:15:07",
"0:15:08", "0:15:09", "0:15:10", "0:15:11", "0:15:12", "0:15:13",
"0:15:14", "0:15:15", "0:15:16", "0:15:17", "0:15:18", "0:15:19",
"0:15:20", "0:15:21", "0:15:22", "0:15:23", "0:15:24", "0:15:25",
"0:15:26", "0:15:27", "0:15:28", "0:15:29", "0:15:30", "0:15:31",
"0:15:32", "0:15:33", "0:15:34", "0:15:35", "0:15:36", "0:15:37",
"0:15:38", "0:15:39", "0:15:40", "0:15:41", "0:15:42", "0:15:43",
"0:15:44", "0:15:45", "0:15:46", "0:15:47", "0:15:48", "0:15:49",
"0:15:50", "0:15:51", "0:15:52", "0:15:53", "0:15:54", "0:15:55",
"0:15:56", "0:15:57", "0:15:58", "0:15:59", "0:16:00", "0:16:01",
"0:16:02", "0:16:03", "0:16:04", "0:16:05", "0:16:06", "0:16:07",
"0:16:08", "0:16:09", "0:16:10", "0:16:11", "0:16:12", "0:16:13",
"0:16:14", "0:16:15", "0:16:16", "0:16:17", "0:16:18", "0:16:19",
"0:16:20", "0:16:21", "0:16:22", "0:16:23", "0:16:24", "0:16:25",
"0:16:26", "0:16:27", "0:16:28", "0:16:29", "0:16:30", "0:16:31",
"0:16:32", "0:16:33", "0:16:34", "0:16:35", "0:16:36", "0:16:37",
"0:16:38", "0:16:39", "0:16:40", "0:16:41", "0:16:42", "0:16:43",
"0:16:44", "0:16:45", "0:16:46", "0:16:47", "0:16:48", "0:16:49",
"0:16:50", "0:16:51", "0:16:52", "0:16:53", "0:16:54", "0:16:55",
"0:16:56", "0:16:57", "0:16:58", "0:16:59", "0:17:00", "0:17:01",
"0:17:02", "0:17:03", "0:17:04", "0:17:05", "0:17:06", "0:17:07",
"0:17:08", "0:17:09", "0:17:10", "0:17:11", "0:17:12", "0:17:13",
"0:17:14", "0:17:15", "0:17:16", "0:17:17", "0:17:18", "0:17:19",
"0:17:20", "0:17:21", "0:17:22", "0:17:23", "0:17:24", "0:17:25",
"0:17:26", "0:17:27", "0:17:28", "0:17:29", "0:17:30", "0:17:31",
"0:17:32", "0:17:33", "0:17:34", "0:17:35", "0:17:36", "0:17:37",
"0:17:38", "0:17:39", "0:17:40", "0:17:41", "0:17:42", "0:17:43",
"0:17:44", "0:17:45", "0:17:46", "0:17:47", "0:17:48", "0:17:49",
"0:17:50", "0:17:51", "0:17:52", "0:17:53", "0:17:54", "0:17:55",
"0:17:56", "0:17:57", "0:17:58", "0:17:59", "0:18:00", "0:18:01",
"0:18:02", "0:18:03", "0:18:04", "0:18:05", "0:18:06", "0:18:07",
"0:18:08", "0:18:09", "0:18:10", "0:18:11", "0:18:12", "0:18:13",
"0:18:14", "0:18:15", "0:18:16", "0:18:17", "0:18:18", "0:18:19",
"0:18:20", "0:18:21", "0:18:22", "0:18:23", "0:18:24", "0:18:25",
"0:18:26", "0:18:27", "0:18:28", "0:18:29", "0:18:30", "0:18:31",
"0:18:32", "0:18:33", "0:18:34", "0:18:35", "0:18:36", "0:18:37",
"0:18:38", "0:18:39", "0:18:40", "0:18:41", "0:18:42", "0:18:43",
"0:18:44", "0:18:45", "0:18:46", "0:18:47", "0:18:48", "0:18:49",
"0:18:50", "0:18:51", "0:18:52", "0:18:53", "0:18:54", "0:18:55",
"0:18:56", "0:18:57", "0:18:58", "0:18:59", "0:19:00", "0:19:01",
"0:19:02", "0:19:03", "0:19:04", "0:19:05", "0:19:06", "0:19:07",
"0:19:08", "0:19:09", "0:19:10", "0:19:11", "0:19:12", "0:19:13",
"0:19:14", "0:19:15", "0:19:16", "0:19:17", "0:19:18", "0:19:19",
"0:19:20", "0:19:21", "0:19:22", "0:19:23", "0:19:24", "0:19:25",
"0:19:26", "0:19:27", "0:19:28", "0:19:29", "0:19:30", "0:19:31",
"0:19:32", "0:19:33", "0:19:34", "0:19:35", "0:19:36", "0:19:37",
"0:19:38", "0:19:39", "0:19:40", "0:19:41", "0:19:42", "0:19:43",
"0:19:44", "0:19:45", "0:19:46", "0:19:47", "0:19:48", "0:19:49",
"0:19:50", "0:19:51", "0:19:52", "0:19:53", "0:19:54", "0:19:55",
"0:19:56", "0:19:57", "0:19:58", "0:19:59", "0:20:00", "0:20:01",
"0:20:02", "0:20:03", "0:20:04", "0:20:05", "0:20:06", "0:20:07",
"0:20:08", "0:20:09", "0:20:10", "0:20:11", "0:20:12", "0:20:13",
"0:20:14", "0:20:15", "0:20:16", "0:20:17", "0:20:18", "0:20:19",
"0:20:20", "0:20:21", "0:20:22", "0:20:23", "0:20:24", "0:20:25",
"0:20:26", "0:20:27", "0:20:28", "0:20:29", "0:20:30", "0:20:31",
"0:20:32", "0:20:33", "0:20:34", "0:20:35", "0:20:36", "0:20:37",
"0:20:38", "0:20:39", "0:20:40", "0:20:41", "0:20:42", "0:20:43",
"0:20:44", "0:20:45", "0:20:46", "0:20:47", "0:20:48", "0:20:49",
"0:20:50", "0:20:51", "0:20:52", "0:20:53", "0:20:54", "0:20:55",
"0:20:56", "0:20:57", "0:20:58", "0:20:59", "0:21:00", "0:21:01",
"0:21:02", "0:21:03", "0:21:04", "0:21:05", "0:21:06", "0:21:07",
"0:21:08", "0:21:09", "0:21:10", "0:21:11", "0:21:12", "0:21:13",
"0:21:14", "0:21:15", "0:21:16", "0:21:17", "0:21:18", "0:21:19",
"0:21:20", "0:21:21", "0:21:22", "0:21:23", "0:21:24", "0:21:25",
"0:21:26", "0:21:27", "0:21:28", "0:21:29", "0:21:30", "0:21:31",
"0:21:32", "0:21:33", "0:21:34", "0:21:35", "0:21:36", "0:21:37",
"0:21:38", "0:21:39", "0:21:40", "0:21:41", "0:21:42", "0:21:43",
"0:21:44", "0:21:45", "0:21:46", "0:21:47", "0:21:48", "0:21:49",
"0:21:50", "0:21:51", "0:21:52", "0:21:53", "0:21:54", "0:21:55",
"0:21:56", "0:21:57", "0:21:58", "0:21:59", "0:22:00", "0:22:01",
"0:22:02", "0:22:03", "0:22:04", "0:22:05", "0:22:06", "0:22:07",
"0:22:08", "0:22:09", "0:22:10", "0:22:11", "0:22:12", "0:22:13",
"0:22:14", "0:22:15", "0:22:16", "0:22:17", "0:22:18", "0:22:19",
"0:22:20", "0:22:21", "0:22:22", "0:22:23", "0:22:24", "0:22:25",
"0:22:26", "0:22:27", "0:22:28", "0:22:29", "0:22:30", "0:22:31",
"0:22:32", "0:22:33", "0:22:34", "0:22:35", "0:22:36", "0:22:37",
"0:22:38", "0:22:39", "0:22:40", "0:22:41", "0:22:42", "0:22:43",
"0:22:44", "0:22:45", "0:22:46", "0:22:47", "0:22:48", "0:22:49",
"0:22:50", "0:22:51", "0:22:52", "0:22:53", "0:22:54", "0:22:55",
"0:22:56", "0:22:57", "0:22:58", "0:22:59", "0:23:00", "0:23:01",
"0:23:02", "0:23:03", "0:23:04", "0:23:05", "0:23:06", "0:23:07",
"0:23:08", "0:23:09", "0:23:10", "0:23:11", "0:23:12", "0:23:13",
"0:23:14", "0:23:15", "0:23:16", "0:23:17", "0:23:18", "0:23:19",
"0:23:20", "0:23:21", "0:23:22", "0:23:23", "0:23:24", "0:23:25",
"0:23:26", "0:23:27", "0:23:28", "0:23:29", "0:23:30", "0:23:31",
"0:23:32", "0:23:33", "0:23:34", "0:23:35", "0:23:36", "0:23:37",
"0:23:38", "0:23:39", "0:23:40", "0:23:41", "0:23:42", "0:23:43",
"0:23:44", "0:23:45", "0:23:46", "0:23:47", "0:23:48", "0:23:49",
"0:23:50", "0:23:51", "0:23:52", "0:23:53", "0:23:54", "0:23:55",
"0:23:56", "0:23:57", "0:23:58", "0:23:59", "0:24:00", "0:24:01",
"0:24:02", "0:24:03", "0:24:04", "0:24:05", "0:24:06", "0:24:07",
"0:24:08", "0:24:09", "0:24:10", "0:24:11", "0:24:12", "0:24:13",
"0:24:14", "0:24:15", "0:24:16", "0:24:17", "0:24:18", "0:24:19",
"0:24:20", "0:24:21", "0:24:22", "0:24:23", "0:24:24", "0:24:25",
"0:24:26", "0:24:27", "0:24:28", "0:24:29", "0:24:30", "0:24:31",
"0:24:32", "0:24:33", "0:24:34", "0:24:35", "0:24:36", "0:24:37",
"0:24:38", "0:24:39", "0:24:40", "0:24:41", "0:24:42", "0:24:43",
"0:24:44", "0:24:45", "0:24:46", "0:24:47", "0:24:48", "0:24:49",
"0:24:50", "0:24:51", "0:24:52", "0:24:53", "0:24:54", "0:24:55",
"0:24:56", "0:24:57", "0:24:58", "0:24:59", "0:25:00", "0:25:01",
"0:25:02", "0:25:03", "0:25:04", "0:25:05", "0:25:06", "0:25:07",
"0:25:08", "0:25:09", "0:25:10", "0:25:11", "0:25:12", "0:25:13",
"0:25:14", "0:25:15", "0:25:16", "0:25:17", "0:25:18", "0:25:19",
"0:25:20", "0:25:21", "0:25:22", "0:25:23", "0:25:24", "0:25:25",
"0:25:26", "0:25:27", "0:25:28", "0:25:29", "0:25:30", "0:25:31",
"0:25:32", "0:25:33", "0:25:34", "0:25:35", "0:25:36", "0:25:37",
"0:25:38", "0:25:39", "0:25:40", "0:25:41", "0:25:42", "0:25:43",
"0:25:44", "0:25:45", "0:25:46", "0:25:47", "0:25:48", "0:25:49",
"0:25:50", "0:25:51", "0:25:52", "0:25:53", "0:25:54", "0:25:55",
"0:25:56", "0:25:57", "0:25:58", "0:25:59", "0:26:00", "0:26:01",
"0:26:02", "0:26:03", "0:26:04", "0:26:05", "0:26:06", "0:26:07",
"0:26:08", "0:26:09", "0:26:10", "0:26:11", "0:26:12", "0:26:13",
"0:26:14", "0:26:15", "0:26:16", "0:26:17", "0:26:18", "0:26:19",
"0:26:20", "0:26:21", "0:26:22", "0:26:23", "0:26:24", "0:26:25",
"0:26:26", "0:26:27", "0:26:28", "0:26:29", "0:26:30", "0:26:31",
"0:26:32", "0:26:33", "0:26:34", "0:26:35", "0:26:36", "0:26:37",
"0:26:38", "0:26:39", "0:26:40", "0:26:41", "0:26:42", "0:26:43",
"0:26:44", "0:26:45", "0:26:46", "0:26:47", "0:26:48", "0:26:49",
"0:26:50", "0:26:51", "0:26:52", "0:26:53", "0:26:54", "0:26:55",
"0:26:56", "0:26:57", "0:26:58", "0:26:59", "0:27:00", "0:27:01",
"0:27:02", "0:27:03", "0:27:04", "0:27:05", "0:27:06", "0:27:07",
"0:27:08", "0:27:09", "0:27:10", "0:27:11", "0:27:12", "0:27:13",
"0:27:14", "0:27:15", "0:27:16", "0:27:17", "0:27:18", "0:27:19",
"0:27:20", "0:27:21", "0:27:22", "0:27:23", "0:27:24", "0:27:25",
"0:27:26", "0:27:27", "0:27:28", "0:27:29", "0:27:30", "0:27:31",
"0:27:32", "0:27:33", "0:27:34", "0:27:35", "0:27:36", "0:27:37",
"0:27:38", "0:27:39", "0:27:40", "0:27:41", "0:27:42", "0:27:43",
"0:27:44", "0:27:45", "0:27:46", "0:27:47", "0:27:48", "0:27:49",
"0:27:50", "0:27:51", "0:27:52", "0:27:53", "0:27:54", "0:27:55",
"0:27:56", "0:27:57", "0:27:58", "0:27:59", "0:28:00", "0:28:01",
"0:28:02", "0:28:03", "0:28:04", "0:28:05", "0:28:06", "0:28:07",
"0:28:08", "0:28:09", "0:28:10", "0:28:11", "0:28:12", "0:28:13",
"0:28:14", "0:28:15", "0:28:16", "0:28:17", "0:28:18", "0:28:19",
"0:28:20", "0:28:21", "0:28:22", "0:28:23", "0:28:24", "0:28:25",
"0:28:26", "0:28:27", "0:28:28", "0:28:29", "0:28:30", "0:28:31",
"0:28:32", "0:28:33", "0:28:34", "0:28:35", "0:28:36", "0:28:37",
"0:28:38", "0:28:39", "0:28:40", "0:28:41", "0:28:42", "0:28:43",
"0:28:44", "0:28:45", "0:28:46", "0:28:47", "0:28:48", "0:28:49",
"0:28:50", "0:28:51", "0:28:52", "0:28:53", "0:28:54", "0:28:55",
"0:28:56", "0:28:57", "0:28:58", "0:28:59", "0:29:00", "0:29:01",
"0:29:02", "0:29:03", "0:29:04", "0:29:05", "0:29:06", "0:29:07",
"0:29:08", "0:29:09", "0:29:10", "0:29:11", "0:29:12", "0:29:13",
"0:29:14", "0:29:15", "0:29:16", "0:29:17", "0:29:18", "0:29:19",
"0:29:20", "0:29:21", "0:29:22", "0:29:23", "0:29:24", "0:29:25",
"0:29:26", "0:29:27", "0:29:28", "0:29:29", "0:29:30", "0:29:31",
"0:29:32", "0:29:33", "0:29:34", "0:29:35", "0:29:36", "0:29:37",
"0:29:38", "0:29:39", "0:29:40", "0:29:41", "0:29:42", "0:29:43",
"0:29:44", "0:29:45", "0:29:46", "0:29:47", "0:29:48", "0:29:49",
"0:29:50", "0:29:51", "0:29:52", "0:29:53", "0:29:54", "0:29:55",
"0:29:56", "0:29:57", "0:29:58", "0:29:59", "0:30:00"), class = "factor"),
student = c("bob", "bob", "bob", "bob"), somemeasure = c(0L,
0L, 1L, 1L)), .Names = c("somedata$Time", "student", "somemeasure"
), row.names = c(NA, 4L), class = "data.frame")
Assuming that your data frame is named df. First, create new column which is POSIXct by pasting together some arbitrary date and original Time column and then converting with as.POSIXct().
Then use function scale_x_datetime() to set breaks and format for labels you want to see.
df$Time2<-as.POSIXct(paste("1960-01-01 ",df$Time))
library(scales)
ggplot(df,aes(Time2,somemeasure))+geom_point()+
scale_x_datetime(breaks=date_breaks("30 sec"),labels = date_format("%M:%S"))

Resources