Summarise data into monthly counts by year - r

I'm not used to working with time series data in R, and I'm a bit stuck with this. I have a data frame of event references and the data the event was recorded. The data runs over a period of 7 years and want to summarise it into the number of event per month over the 7 year period and plot that with ggplot2.
I can't seem to get the date conversions to work together so I end up with a count and a date I can feed to ggplot2's scale_x_date() function
Here's an example of the data:
df <- structure(list(Ref = structure(c(127L, 33L, 232L, 392L, 490L,
242L, 437L, 346L, 443L, 560L, 598L, 568L, 103L, 262L, 463L, 17L,
114L, 276L, 361L, 422L), .Label = c("01090013", "0109005", "0109006",
"0109007", "0109009", "0109010", "0109011", "0109012", "0109014",
"0109016", "0109022", "0110001", "0110004", "0110007", "0110009",
"0110011", "0111001", "0111002", "0111012", "0111016", "0111017",
"0112001", "0112003", "0112008", "0112010", "015004", "015006",
"015008", "015010", "015013", "016002", "016003", "016004", "016005",
"016006", "016008", "016009", "016010", "016011", "016013", "016014",
"016016", "017001", "018001", "018004", "018005", "018007", "018008",
"018009", "020626", "0209024", "0209025", "0209026", "0209027",
"0209029", "0209031", "0209035", "0209037", "02100020", "0210017",
"0210018", "0210023", "0210026", "0210030", "0211018", "0211019",
"0211020", "0211022", "0211024", "0211025", "0211026", "0212018",
"0212021", "0212025", "0212027", "025018", "025021", "025022",
"025023", "025024", "025025", "025026", "025030", "026019", "026020",
"026021", "026023", "026025", "026027", "026030", "026032", "0270010",
"027010", "027012", "027013", "027014", "027016", "027017", "0309038",
"0309039", "0309041", "0309046", "0309050", "0309052", "0309053",
"0310035", "0310037", "0310041", "0310043", "0310044", "0311028",
"0311032", "0311035", "0311038", "0312031", "0312036", "0312037",
"0312043", "0312045", "0312047", "0312056", "0312058", "0312059",
"0312062", "035033", "035034", "035036", "035037", "035038",
"035040", "035041", "035042", "035043", "035045", "035049", "036036",
"036038", "036039", "036041", "036042", "036044", "036045", "036046",
"036047", "036048", "036050", "036051", "037021", "037026", "037029",
"038026", "038032", "038034", "038035", "038036", "0409056",
"0409057", "0409062", "0410046", "0410049", "0410050", "0410051",
"0410054", "0410055", "0410056", "0410057", "0410058", "0410060",
"0410062", "0410064", "0411047", "0411051", "0411052", "0411055",
"0412070", "0412074", "0412075", "0412076", "045054", "045056",
"045058", "045063", "045064", "045065", "045072", "046054", "046055",
"046058", "046060", "047035", "047036", "047037", "047038", "047041",
"047042", "047044", "047045", "047046", "048040", "048043", "048044",
"048045", "048048", "048050", "048051", "0509073", "0509080",
"0510066", "0510067", "0510082", "0511062", "0511065", "0511068",
"0511069", "0511072", "0512084", "0512088", "0512089", "0512091",
"055073", "055075", "055080", "055086", "055089", "055091", "055093",
"055094", "055095", "056064", "056066", "056067", "056068", "056070",
"056071", "056073", "056074", "057049", "057052", "057053", "057054",
"057058", "057059", "057060", "057061", "057063", "057065", "057066",
"057067", "057068", "057069", "058053", "058055", "058056", "058059",
"058062", "058064", "0609082", "0609086", "0609088", "0609089",
"0609090", "0609093", "0609095", "0609096", "0609097", "0609098",
"0609103", "0610086", "0610089", "0610095", "0610096", "0610098",
"0611073", "0611074", "0611080", "0611081", "0612109", "0612115",
"065096", "065099", "065103", "065105", "065106", "065109", "065114",
"066075", "066076", "066077", "066078", "066081", "066083", "067080",
"067081", "067084", "068065", "068070", "068074", "0709106",
"0709108", "0709113", "0709115", "0709116", "0709117", "0709120",
"0710104", "0710105", "0710107", "0710108", "0710110", "0710115",
"0710116", "0710117", "0710123", "0711083", "0711084", "0711085",
"0711086", "0711087", "0711088", "0711092", "0712122", "0712126",
"0712127", "0712128", "0712129", "075118", "075119", "075123",
"075124", "075125", "075126", "075127", "075130", "075132", "075133",
"076084", "076087", "076088", "076090", "076092", "076093", "076094",
"077103", "077105", "078079", "078080", "078081", "078082", "078085",
"078086", "0809126", "0809134", "0809137", "0809141", "0809143",
"0810125", "0810137", "0811099", "0811101", "0811106", "0811108",
"0811112", "0811113", "0811114", "0812142", "0812145", "0812150",
"0812152", "0814143", "085139", "085143", "085145", "085148",
"085149", "085150", "085154", "085156", "085160", "085163", "086098",
"086099", "086100", "086101", "086102", "086104", "086107", "086108",
"086109", "086110", "086111", "086112", "086114", "086115", "087106",
"087107", "087109", "087112", "088094", "088096", "088097", "088098",
"0909145", "0909155", "0909158", "0910145", "0910146", "0910147",
"0910149", "0910150", "0910153", "0910154", "0911116", "0911117",
"0911120", "0911121", "0911122", "0911123", "0911124", "0911130",
"0911131", "0912161", "0912163", "0912168", "0912171", "0912172",
"095166", "095167", "095170", "095171", "095172", "095178", "095180",
"096116", "096117", "096121", "097120", "097124", "097125", "097126",
"097132", "097133", "097136", "098110", "098115", "098116", "098119",
"100006825", "100006830", "1009160", "1009161", "1009162", "1009164",
"1009165", "1009166", "1009169", "1009170", "1009172", "1009173",
"1009174", "1010160", "1010162", "1010163", "1010164", "1010166",
"1010168", "1011133-A", "1011134", "1011140", "1011142", "1012179",
"1012184", "1012185", "1012194", "105185", "105186", "105187",
"105188", "105189", "105191", "105192", "105196", "105197", "105198",
"105199", "105201", "105202", "105207", "105208", "105211", "106127",
"106130", "106131", "107138", "107140", "107143", "107147", "107148",
"107149", "107153", "107155", "107156", "108122", "108123", "108127",
"108129", "108130", "108131", "108132", "108134", "108135", "108136",
"1109175", "1109176", "1109180", "1109182", "1110173", "1110176",
"1110177", "1110178", "1110185", "1110186", "1111145", "1111150",
"1111151", "1112196", "1112197", "1112201", "1112202", "1112206",
"1112208", "1112209", "1112212", "1112218", "1112220", "1112223",
"1112225", "1112226", "1112227", "115215", "115216", "115217",
"115218", "115219", "115223", "115225", "115226", "116139", "116143",
"116144", "116145", "117161", "117162", "117164", "117165", "117168",
"117175", "117180", "118139", "118140", "118143", "118147", "118148",
"118150", "118152", "118154", "118157", "118160", "118161", "1209188",
"1209189", "1209191", "1209193", "1209199", "1210191", "1210193",
"1211157", "1211158", "1211168", "1211169", "1211170", "1211171",
"1211173", "1212233", "1212235", "1212240", "125231", "125238",
"125241", "126147", "126149", "127182", "127183", "127186", "127187",
"127192", "127194", "128165", "128168", "128169", "128171", "128172",
"128175", "128176", "128177", "128182", "128183", "128184", "128186",
"128189", "128193"), class = "factor"), Date = structure(c(12846,
13154, 13284, 13391, 13434, 13655, 13766, 14067, 14119, 14183,
14209, 14211, 14322, 14412, 14897, 14960, 15049, 15155, 15201,
15597), class = "Date")), .Names = c("Ref", "Date"), row.names = c(NA,
-20L), class = "data.frame")
This is driving me crazy!
Thanks
H

I believe you are looking for this:
df <- transform(df, month = format(Date,"%m"), year = format(Date, "%Y"))
counts <- ddply(df,.(month,year),nrow)
Then to plot the date:
# make a new monthly date
counts <- transform(counts, new_date = as.Date(paste(year,month,'01',sep="-")))
# now plot
ggplot(counts,aes(x=new_date,y=V1)) + geom_point() + scale_x_date()

xts package is very handy for time series manipulations.
First I create the xts object :
library(xts)
dat.xts <- xts(df$Ref,order.by=as.POSIXct(df$Date))
Then I use apply.monthly to get the count by day, and plot it as xts object
count.month <- apply.monthly(dat.xts,FUN=length)
plot(count.month, type='b')
If you want to use ggplot2, you can transform the result to a data.frame.
as.data.frame(count.month)

Another option:
data$Month <- format(as.POSIXct(data$Date), "%Y-%m")
by.month.count <- data.frame(with(data, table(Month)))

Related

data frame sorting using column and row characters to match taxa annotations to different samples

I am looking to sort my taxonomic annotations (16S dataset) based off of columns 'sample', 'Family', and 'taxa'. Briefly, there are two sample types; m3ofair and m3NC, and I wish to know the unique ASV identifier in column 'taxa' if the annotation in 'Family' are identical across both sample types.
For example, the annotation 'f__Beijerinckiaceae' in column 'Family' is present in both samples, m3ofair and m3NC. Since this is the case, I would like to know the ASV taxa identifier for all three annotations of 'f__Beijerinckiaceae', which are 2ca928ad9749bb9726c35d6528fefec1, bcc8b318ede81a8b211e7bdd1531baec, and e31f3d32519dc9021ff790f87d76114c.
Thank you in advance!
> dput(example)
structure(list(taxa = structure(c(203L, 150L, 150L, 202L, 175L
), .Label = c("8c54f0af4445cdb1a6a36304a80b5a6d", "e6ff53b2675c61cf25ad3d79917b318e",
"38bbf752453c1c64f2e61966016d45c5", "903bcbbcb2ac130bb32d847ca7d191ed",
"7fc0ccbd86b09190f44369a934b3456c", "03c095b4239af5a7f63d39522b34186b",
"513c1bcb314fbf047f366f84a646c4a2", "0d3dca27868f7cfabbdbe1eb90657340",
"4b36fd18a35f063166412a83379bf797", "a6a6601f3a675697e92bc24d32042929",
"c46477febff8e68314f5baa81f4c082f", "f8753b9f13abb306b57aedce2cf6e7d0",
"230363069727610f8f1546cb314f2d1a", "100f4d61f5eaf8fb7369d9583b32ba46",
"69a70c343722f6851fc2191d4b3c3a1b", "0f222d9f6f748209e5d39cbbbb704c3e",
"06b8e39b562a2b31643b4f2c00d5dec7", "51141f001e298a5e44d99f7d7bdb78e2",
"56c98126dde3abb2d263088db55e12c8", "d8adf2a20249cefe6c627f9c17abb202",
"4e3acf7a1c4dddbc3f68097207cacb66", "fadd6b74d7cc847716a19679be001724",
"9815d07f1b564c9be5aab03db01608da", "bdd1f036611254ef872b334f7da681e6",
"028ecb2ed02be346c5f0347a9a3fba2a", "0310f41e594c49368dde5c5993a7a5d0",
"f510252f2eef402050f8169436cb4501", "3cb9f6500275fabe7c87a599a8c31749",
"f148144695ed0a63b976ea05243aba8c", "9ed070c666e12720a6bb6d3df1b09e45",
"e54bcf1c8ec24811e7c355b8d82fa59e", "c6608772f41c7d2202f2504190f2af8a",
"78732fda4b5a16d2bdddcd553953752c", "46271ec11fc9f127649526834a9fd805",
"dd0eaf58cb0b5378f465b4f59adf79d2", "585ab9ce79a8c90d675a66b9678b2137",
"4ef5dabd754e48c26c66c55b3615e69f", "bc3043f80a5fe9e5faa189fa7b050f61",
"f570f293e6b304776e5dce910a0b96e8", "432f8ae2390df378d7bab37a0026ff03",
"0d959da770b454f90e53757f8ab0893f", "0bc8e7f6bf04c1e745749edeb6d6628d",
"c78a82f200050febc553de67fffef578", "da36821195d462457b39c41aeb611ba1",
"2de266b1ffa8e9ec6383c98096caf8f0", "3845a467d4d557e0f035d045d0d86f70",
"630afd8b62db24d65410329610383a4f", "bfbf3b84b315e741c4345ebb43e2b9cc",
"c85df4c87e8960b573d8ae4bf7f65e15", "6c46511a89ec2a070fef341371ad02b7",
"6307431a0a1a9d90045dc5dccbfc5fe9", "0d1bf49752cd0c9211d28bc8577a9145",
"11630fb56d652f032964d7567e083d40", "04caec30dc35c55d62d69e6125cec2c1",
"854aeab59d32bfddbea09ed0571ca007", "f6436e7085d15342388e67b55d692fb6",
"ecbf086d6ccbe5e8c2a69d0afb144662", "da247df6fe91b74bf38d3ecc1c05b4b0",
"d4c4725af861d3daa18bddefb558cf50", "c06b07ff323a7b0bccf5d0e604b0afab",
"ec8bf881537838f56323ada7de070b19", "1d6f8731081df8944cd50ae875fb9b28",
"8101da5193e402ec2741419cd0515110", "381f3c0f833ce81483700d6dc0b940ef",
"d0484307102691e2482cb79f8784827c", "d0c9e10ee52d3c93502663df3328e2c6",
"2f09559bc1ffcc3ea06ae2766194920b", "3bb215c036a5b86e071708ce88665689",
"d8a6777829870b41d1544fb173608685", "10a4a0714d1b0063c37636f2ec22bbae",
"5740f0ff513cc2099d6beacec9336f45", "763f0806ad9068d1f4092259a970c925",
"50e96bbd1a8267119529843a1acb43a5", "500d6b485cef4c52aad211d6d6e6dbc7",
"4ea5683e2c2a183c11c45dc8fbd0c67c", "7e598ad34909a3fb8ff1623f1ede11a6",
"8659c05e82a2d1399cbc3fd26ab938e4", "9c886b1c9e3e2ec63e0dbbd085996334",
"8da02c7114ba0d9ee40312926e037a8f", "5cb28bd0b2eea6847a6328712217c141",
"a049763053c277b16c2a318f41eb23b4", "0ce84d495f51f4e5997076bddebe65a5",
"576fd9e4a384474af1d78a589118b213", "e74212c56f84c309729e86ad3b126716",
"095249b545f554a6a66a4e378eed9c23", "12f69cdd5a43e9c04fa76fe778493dbc",
"6eaaffd8bd37b95220a3bebdf503be32", "78d6bb358b0ec0c94a8caa7c7a28171c",
"57799c0748039c006705cb9c46ace954", "b335608a8c2309ce02373311b7737b55",
"ff4bc2548279113788b4bf164d2db0d0", "254ba9ed4527552e061da0653ae95392",
"2480590c44af81ddbc2f34d381864702", "e4b865c957d0d23766a0e8e87f6d153d",
"f98cc8f203873fd4078c589a6332e72e", "4eb88a4d445e0987c56d0197301bd4e7",
"c5f7ff7e9d319f880b2c41c4ce6d52de", "15e687c6e5701e1b3b10fc0223d96c59",
"5c3138b23334b1d6b4bf3943db5eae74", "e22be263cc3a006762b66711df3d6a23",
"e209a5a9add3e7a68f273a2f17942555", "b19efe6ae9dabd64b44e12f4f1b88643",
"ea0c2938cf670cfcec8bd497e1767ae8", "ea794ad075da6b9b427ecf13244a6e97",
"414cb56f046e21beb8cf72b9285ab2bd", "6f318147a66f5851564f04aba9092057",
"32b53bb775ee918b4b75ee4c87ecdb55", "f467d11f3c1a16ea55e2ab7ab88a85c2",
"dfb69af34af0dcc91f9596d47ea6882b", "db4c51d23607a40db2843c49a38ee271",
"02047d2e2da6d0e73846b63774619e77", "cb2fe0146e2fbcb101050edb996a0ee2",
"4b88b52dd068a7d432309dec77813d29", "d2da0518d0f3ac5dd8d7df770389fee5",
"5f86daf7f135fee1745dba9e874fe013", "9a2740e3bc27419a895dfb6e0b986854",
"3a2e70f61b311dc0cd2261732a9cb627", "313402c6104b2605890eda8d9fa89fba",
"e33cca4021036f12a70132aed9f9c52d", "d29fe3c70564fc0f69f2c03e0d1e5561",
"eb5f185c6ab0e5f7953654a2a5d12ce7", "89fa7b79c6b2c5019ca0d1bc2f509f0b",
"fcd4f95c05b868060121ff709085bf21", "7c14b01c89686b9e327fc7d3dee3af30",
"0161e22acf37955da1e4b8bafe9f54e6", "ac70e87927f15bf812e8cad1cd9003cb",
"bfbed36e63b69fec4627424163d20118", "3f0ecac3d878543cf67dae94e6309453",
"0b607a251255e7aa0ef0c4e242b3e87c", "3d28edbfcb341fbf3d2fd87056633569",
"fa2102f32f8f05f458f0833df8c78500", "3b588d7e9f41b7e5ea9539d52ccda834",
"646eeb6a205282fe7afb5d73d1af30be", "a3e8652354170f4ddc4b96f65ff42aaf",
"09b2620539f4861b9b2e6d271d4bb319", "a301810850607af459b6de0b8a6dfcfb",
"ee2babc92e666c2593d83df7ad086362", "1054403160f296f2f44fbdf81f31b32c",
"b62d8ace7310a137d1ff25156b20b881", "4043cc4801dcf236434002ac21298d76",
"feb46b2df4fc3958ccd80e768b79502b", "c2dfc10913176eda134cd88ed68e0a72",
"668584d4ca79707c62229c2b9a520634", "b48eec9298fe8ed0fdf2e968ee6cc4af",
"a75e4ea5f1add4aa39f660dd13084fd0", "2a8bd6428138528c12a10c06b52954db",
"e6922be77906565e6bae2a89da15d175", "e21e4030f895965d1846404a94ebcb11",
"d03ede724dcc3efd39db449fd5bced6e", "6639f71cd3265109c47115f4a5913958",
"8c08537b3e07c84c47eb29e4de593a02", "8c1456c47986f85320cdfe1c515ffb4c",
"3e00fb174071bfc76c017d666f43af65", "1f70bd0eeef30f2afcd750b70f7e7066",
"c1efd1322ab8cef2a84ace9e85e37467", "b18b389447d758e7cb173b4b4f2ad960",
"9af604229897c70de75a7740fe13e80d", "c9a7a8206f0d8eda7576e0bb44b058a7",
"ae65f0c53471069e8a19b8d38ffcd3e7", "b19b302de47cc21f8f4cf1464a10b2b3",
"8b9a8bca0a4a02cde893f0bf550e4b68", "2492e30becb2716ccd9557e27900a56d",
"997d9c1623cbaab34cdb0668950d5a08", "1c77f5f31494131fcbb21fd9f52c7618",
"bfbd7ffe99a84ab5d92dc545d1a5a3c7", "e91fee71ae5261d22530ee9afa22dae5",
"59988344137e8b4b1c56e5f886bc294d", "3a4d3ac6f2aeecdba4936b18e28d04e5",
"e48dc10d2f3df1f6795902f9d53625ee", "9259758b55aa71398e2cafd0db077fcd",
"61f0d618a9ccef240bf7f6b65ac3cd64", "955d8fcbb35e8bc04c8df0c6aae34d34",
"35a7084609b22c35a5162738624ef6d0", "bc2942a64ee2fa191613f41f7e0134df",
"e31f3d32519dc9021ff790f87d76114c", "594a57ff90b7936ce2cd8036ad681cef",
"a64788b07ff4d444a278dbdd45b9cda4", "ef1e892b6e84a8b51d80eb7d6037167f",
"ce036ee8825f6a2f95a01b9488144638", "5a4979556bf389cd5ba711b146417234",
"ac809fd715cced98911f73f1dfb1ffb9", "e206fe2391a57543027d38d4ab4355e5",
"780d57e7f37aba0e43ea58166978f258", "9995306be33bb6a067fbd14fd12ab247",
"d867858df4524fe62a46ed814274aaa4", "12c0941446564e8d3cb6c3fb07bebed8",
"d174fd25211450a7f7b6dbae6db61e2c", "491e6acf93836613376f546052749de2",
"be94715fa59eebb39dae561eee3e2f3a", "21bc9a5af6203656e6d1066a13121fb0",
"0b925631436d3775231b60f9d0011cae", "47c2b089e44e1baab72de03674f2526e",
"c4d8bbf6d24dd9c56321087cc3936763", "147f2c2c24c7e1b1c371d42a36816214",
"7c999fc012772119e945f6e87a941e92", "3423114aff9da85e4989c2c268769033",
"82eab43c427e6afb5bf1fd10be00cc4b", "f637087afddcd520f0691150409f4d26",
"54edafdb5df25d839fa4696a3d8a08d9", "bfa4fe32a85423441482e307c7ed5e65",
"34d0e4410278fca5bbc2eac3de76feac", "bcc8b318ede81a8b211e7bdd1531baec",
"2ca928ad9749bb9726c35d6528fefec1", "959a178855242ad3833af85d38ccff45",
"3830e37a7ac6cf83a20dc9b8f225bb69", "9205f49b7a5898bf9dec93aa53ff96ec",
"bf2b830db0f89f72b4bf68394b70fbf5", "cba5161b7eb1f07a14ca874577e69cf3",
"179e215ab39a0a69ca15100615efae28", "beb5157c4f4ffcb17a5aa73fb6efd009",
"38401e17915bca5aab62c763930d1cfb", "1fc7138b0d9568c4588eb34dabc430d3",
"d2c5f354da4c7a6e78626761b1801770", "68089dfb5a592ef9b73c307c746a940e",
"f8e8cca8fe936d9be35ed4fcf790d35b", "e68f3ead96583e125709c8a5ecf20a63",
"06b48070c8d8e4ad997399e958871cea", "aff65597908099c9ee322aff6bec0a68",
"c802baf89ae3088ec5027d645223e3d1", "59afa99ca520b0db55db192cf8be4edb",
"e131d6b9e4f997788460a450a69c3a99", "1b448e00c078f81e49a61933072345d2",
"0f48376fe94d49cef9a1ee1b46af7a4a", "79e9e337b10e2d298bb1b3bde946782d",
"1868b3eae7d694c939f6ee777c98ee82", "909755d7142ea53c7f61c97c3586f26c",
"c1bee78e8c05c7d1abd7122bff925e54", "3cdd97ba69a504117de24626ba790e96",
"bfd74cfd3e6c2b27cffc14334ee55878", "e2603d057e6cc94b2b3c774e5b24c09c",
"a7b2fd6bf0b1c028de90c11becdc1b39", "8bf361e85f0f9dbff5b9d6951fdae8c6",
"0c7b675ddf75b3a6ad648b004352b8c1", "f3ed29d9b4cd4e1ea7861fbe19314125",
"4aafbcb8ea0c9be6130d630345116249", "1d926e22515426e147f62e2d27fb25d5",
"6357497de4b956c00e393b9cbebaf228", "c8c6649cf27d3428a978248cb233b4ea",
"6013a4618dd16c1f100b084d722a817d", "fd188dccbbfa7e8d7aa3b6abe7fe59c4",
"c04b4c2c12d6408b4e741b3b91e91354", "4a43d5d77936e5dc6536931101c8d814",
"55982fe768843d5432c485e19f3ca7ae", "498128a80a796620b238d8ad5cd1d2f9",
"8c2d1b95d59fa2a627dd63d7a36c7483", "2ea78aa082eeffffc40ad0ac7e84dbb8",
"b8b381bb5c8bfaf50f1916a102161d01", "fe6a40c9234f9a57e1db10d0d87e3fa0",
"71727d41e7a3452a196977be7f013cb0"), class = "factor"), sample = c("m3ofair",
"m3NC", "m3ofair", "m3NC", "m3NC"), value = c(0.00110121133246571,
0, 0.00200220242266493, 0.00943847890021202, 0), Kingdom = structure(c(2L,
2L, 2L, 2L, 2L), .Label = c("d__Archaea", "d__Bacteria"), class = "factor"),
Phylum = structure(c(15L, 15L, 15L, 15L, 15L), .Label = c("p__Acidobacteriota",
"p__Actinobacteriota", "p__Armatimonadota", "p__Bacteroidota",
"p__Chloroflexi", "p__Cyanobacteria", "p__Deinococcota",
"p__Desulfobacterota", "p__Firmicutes", "p__Fusobacteriota",
"p__Gemmatimonadota", "p__Myxococcota", "p__Patescibacteria",
"p__Planctomycetota", "p__Proteobacteria", "p__SAR324_clade(Marine_group_B)",
"p__Synergistota", "p__Thermoplasmatota", "p__Verrucomicrobiota",
"p__WPS-2"), class = "factor"), Class = structure(c(4L, 4L,
4L, 4L, 4L), .Label = c("c__Acidimicrobiia", "c__Acidobacteriae",
"c__Actinobacteria", "c__Alphaproteobacteria", "c__Bacilli",
"c__Bacteroidia", "c__Chloroflexia", "c__Clostridia", "c__Coriobacteriia",
"c__CPR2", "c__Cyanobacteriia", "c__Deinococci", "c__Desulfitobacteriia",
"c__Desulfotomaculia", "c__Fimbriimonadia", "c__Fusobacteriia",
"c__Gammaproteobacteria", "c__Gemmatimonadetes", "c__KD4-96",
"c__Ktedonobacteria", "c__Myxococcia", "c__Phycisphaerae",
"c__Planctomycetes", "c__Polyangia", "c__Rhodothermia", "c__SAR324_clade(Marine_group_B)",
"c__Sericytochromatia", "c__Synergistia", "c__Syntrophia",
"c__Thermoanaerobacteria", "c__Thermoanaerobaculia", "c__Thermoleophilia",
"c__Thermoplasmata", "c__TK10", "c__Verrucomicrobiae", "c__Vicinamibacteria",
"c__WPS-2"), class = "factor"), Order = structure(c(72L,
7L, 7L, 72L, 72L), .Label = c("o__Acetobacterales", "o__Acidobacteriales",
"o__Actinomarinales", "o__Actinomycetales", "o__Alteromonadales",
"o__Arctic97B-4_marine_group", "o__Azospirillales", "o__Bacillales",
"o__Bacteroidales", "o__Balneolales", "o__Bifidobacteriales",
"o__Burkholderiales", "o__C0119", "o__Caulobacterales", "o__Chitinophagales",
"o__Chthoniobacterales", "o__Clostridia", "o__Clostridiales",
"o__Corynebacteriales", "o__CPR2", "o__Cyanobacteriales",
"o__Cytophagales", "o__Deinococcales", "o__Desulfitobacteriales",
"o__Desulfotomaculales", "o__Elsterales", "o__Enterobacterales",
"o__Eubacteriales", "o__Fimbriimonadales", "o__Flavobacteriales",
"o__Frankiales", "o__Fusobacteriales", "o__Gaiellales", "o__Gemmatales",
"o__Gemmatimonadales", "o__Haliangiales", "o__Halothiobacillales",
"o__IMCC26256", "o__Isosphaerales", "o__KD4-96", "o__Kiloniellales",
"o__Kineosporiales", "o__Ktedonobacterales", "o__Lachnospirales",
"o__Lactobacillales", "o__Legionellales", "o__Marine_Group_II",
"o__Methylococcales", "o__Micrococcales", "o__Micromonosporales",
"o__Micropepsales", "o__Microtrichales", "o__Myxococcales",
"o__Nitriliruptorales", "o__Nitrococcales", "o__Nitrosococcales",
"o__Oceanospirillales", "o__OPB41", "o__Oscillospirales",
"o__Paenibacillales", "o__Parvibaculales", "o__PeM15", "o__Peptostreptococcales-Tissierellales",
"o__Phycisphaerales", "o__Pirellulales", "o__Polyangiales",
"o__Propionibacteriales", "o__Proteinivoracales", "o__Pseudomonadales",
"o__Pseudonocardiales", "o__Puniceispirillales", "o__Rhizobiales",
"o__Rhodobacterales", "o__Rhodospirillales", "o__Rhodothermales",
"o__Rickettsiales", "o__Salinisphaerales", "o__SAR324_clade(Marine_group_B)",
"o__SAR86_clade", "o__Sericytochromatia", "o__Solibacterales",
"o__Solirubrobacterales", "o__Sphingobacteriales", "o__Sphingomonadales",
"o__Staphylococcales", "o__Streptomycetales", "o__Streptosporangiales",
"o__Synechococcales", "o__Synergistales", "o__Syntrophales",
"o__Thalassobaculales", "o__Thermales", "o__Thermoanaerobacterales",
"o__Thermoanaerobaculales", "o__Thermomicrobiales", "o__Tistrellales",
"o__TK10", "o__Vicinamibacterales", "o__WPS-2", "o__Xanthomonadales"
), class = "factor"), Family = structure(c(17L, 13L, 13L,
17L, 17L), .Label = c("f__67-14", "f__Acetobacteraceae",
"f__Acidobacteriaceae_(Subgroup_1)", "f__Actinomarinaceae",
"f__Actinomycetaceae", "f__Aerococcaceae", "f__Alcaligenaceae",
"f__Alcanivoracaceae1", "f__Algiphilaceae", "f__Alkalibacteraceae",
"f__Anaeromyxobacteraceae", "f__Arctic97B-4_marine_group",
"f__Azospirillaceae", "f__Bacillaceae", "f__Bacteroidetes_vadinHA17",
"f__Balneolaceae", "f__Beijerinckiaceae", "f__Beutenbergiaceae",
"f__Bifidobacteriaceae", "f__Bogoriellaceae", "f__Brevibacteriaceae",
"f__C0119", "f__Carnobacteriaceae", "f__Caulobacteraceae",
"f__Cellulomonadaceae", "f__Chitinophagaceae", "f__Chroococcidiopsaceae",
"f__Chthoniobacteraceae", "f__Clostridiaceae", "f__Comamonadaceae",
"f__Corynebacteriaceae", "f__CPR2", "f__Crocinitomicaceae",
"f__Cyanobiaceae", "f__Cyclobacteriaceae", "f__Deinococcaceae",
"f__Demequinaceae", "f__Dermabacteraceae", "f__Dermacoccaceae",
"f__Desulfitobacteriaceae", "f__Desulfotomaculales", "f__Devosiaceae",
"f__Dietziaceae", "f__Dysgonomonadaceae", "f__Endozoicomonadaceae",
"f__Enterobacteriaceae", "f__Eubacteriaceae", "f__Family_III",
"f__Fimbriimonadaceae", "f__Flavobacteriaceae", "f__Fodinicurvataceae",
"f__Frankiaceae", "f__Fusobacteriaceae", "f__Geminicoccaceae",
"f__Gemmataceae", "f__Gemmatimonadaceae", "f__Geodermatophilaceae",
"f__Haliangiaceae", "f__Halomonadaceae", "f__Halorhodospiraceae",
"f__Hungateiclostridiaceae", "f__Hymenobacteraceae", "f__Hyphomicrobiaceae",
"f__Hyphomonadaceae", "f__Idiomarinaceae", "f__IMCC26256",
"f__Intrasporangiaceae", "f__Isosphaeraceae", "f__JG30-KF-CM45",
"f__Jonesiaceae", "f__Kangiellaceae", "f__KD4-96", "f__Kineosporiaceae",
"f__Ktedonobacteraceae", "f__Labraceae", "f__Lachnospiraceae",
"f__Lactobacillaceae", "f__Legionellaceae", "f__Marine_Group_II",
"f__Marinilabiliaceae", "f__Marinobacteraceae", "f__Marinococcaceae",
"f__Methylomonadaceae", "f__Methylophagaceae", "f__Methylophilaceae",
"f__Methylopilaceae", "f__Microbacteriaceae", "f__Micrococcaceae",
"f__Micromonosporaceae", "f__Micropepsaceae", "f__Microscillaceae",
"f__Moraxellaceae", "f__Morganellaceae", "f__Mycobacteriaceae",
"f__Myxococcaceae", "f__Nakamurellaceae", "f__Nitriliruptoraceae",
"f__Nitrosomonadaceae", "f__Nocardiaceae", "f__Nocardioidaceae",
"f__Nocardiopsaceae", "f__Nostocaceae", "f__Oceanibaculaceae",
"f__OPB41", "f__Oscillospiraceae", "f__Oxalobacteraceae",
"f__Paenibacillaceae", "f__Parvibaculaceae", "f__PeM15",
"f__Peptostreptococcales-Tissierellales", "f__Phaselicystidaceae",
"f__Phycisphaeraceae", "f__Pirellulaceae", "f__Planococcaceae",
"f__Prevotellaceae", "f__Prolixibacteraceae", "f__Promicromonosporaceae",
"f__Proteinivoracales", "f__Pseudomonadaceae", "f__Pseudonocardiaceae",
"f__Rhizobiaceae", "f__Rhizobiales_Incertae_Sedis", "f__Rhodobacteraceae",
"f__Rhodobiaceae", "f__Rhodothermaceae", "f__Rickettsiaceae",
"f__Ruminococcaceae", "f__S25-593", "f__Salisediminibacteriaceae",
"f__SAR116_clade", "f__SAR324_clade(Marine_group_B)", "f__SAR86_clade",
"f__SC-I-84", "f__Sedimentibacteraceae", "f__Sericytochromatia",
"f__Solibacteraceae", "f__Solirubrobacteraceae", "f__Sphingobacteriaceae",
"f__Sphingomonadaceae", "f__Spirosomaceae", "f__Staphylococcaceae",
"f__Stappiaceae", "f__Streptococcaceae", "f__Streptomycetaceae",
"f__Streptosporangiaceae", "f__Synergistaceae", "f__Syntrophaceae",
"f__Syntrophobotulaceae", "f__Thalassospiraceae", "f__Thermaceae",
"f__Thermoanaerobaculaceae", "f__Thermotaleaceae", "f__Thioalkalibacteraceae",
"f__Tistrellaceae", "f__TK10", "f__TRA3-20", "f__uncultured",
"f__Vicinamibacteraceae", "f__Weeksellaceae", "f__WPS-2",
"f__Xanthobacteraceae", "f__Xanthomonadaceae"), class = "factor"),
Genus = structure(c(125L, 28L, 28L, 125L, NA), .Label = c("g__67-14",
"g__Acetobacterium", "g__Acidiphilium", "g__Acinetobacter",
"g__Actinomyces", "g__Actinotalea", "g__Advenella", "g__Aerococcus",
"g__Alcanivorax", "g__Algiphilus", "g__Algoriphagus", "g__Aliidiomarina",
"g__Aliihoeflea", "g__Aliterella", "g__Alkalibacter", "g__Allorhizobium-Neorhizobium-Pararhizobium-Rhizobium",
"g__Altererythrobacter", "g__Amorphus", "g__Amycolatopsis",
"g__Anaerobacillus", "g__Anaerobranca", "g__Anaeromyxobacter",
"g__Aquibacillus", "g__Arctic97B-4_marine_group", "g__Arenimonas",
"g__Arthrobacter", "g__Aureimonas", "g__Azospirillum", "g__Bacillus",
"g__Bacteroidetes_vadinHA17", "g__Bauldia", "g__Bifidobacterium",
"g__Blastococcus", "g__Blastopirellula", "g__Bosea", "g__Brachybacterium",
"g__Bradyrhizobium", "g__Brevibacterium", "g__Brevundimonas",
"g__C0119", "g__Candidatus_Actinomarina", "g__Candidatus_Alysiosphaera",
"g__Candidatus_Solibacter", "g__Candidatus_Udaeobacter",
"g__Cecembia", "g__Chromohalobacter", "g__Chryseobacterium",
"g__Chthoniobacter", "g__Citricoccus", "g__Cloacibacterium",
"g__Clostridium_sensu_stricto_9", "g__Conexibacter", "g__Corynebacterium",
"g__CPR2", "g__Craurococcus-Caldovatus", "g__Curtobacterium",
"g__Dehalobacter", "g__Deinococcus", "g__Demequina", "g__Dermacoccus",
"g__Desulfohalotomaculum", "g__Desulfosporosinus", "g__Devosia",
"g__Dietzia", "g__DSSD61", "g__Dyadobacter", "g__Egicoccus",
"g__Ellin6067", "g__Endozoicomonas", "g__Enhydrobacter",
"g__Ercella", "g__Escherichia-Shigella", "g__Faecalibacterium",
"g__Fermentimonas", "g__Fimbriiglobus", "g__Fimbriimonadaceae",
"g__Finegoldia", "g__Flaviflexus", "g__Flavobacterium", "g__Fluviicola",
"g__Fusicatenibacter", "g__Fusobacterium", "g__Gardnerella",
"g__Gemmatimonas", "g__Geobacillus", "g__Georgenia", "g__Glutamicibacter",
"g__Gracilibacillus", "g__Gracilimonas", "g__Guyparkeria",
"g__Haematobacter", "g__Haliangium", "g__Halolactibacillus",
"g__Halomonas", "g__Henriciella", "g__HIMB11", "g__HSB_OF53-F07",
"g__Hymenobacter", "g__Hyphomicrobium", "g__IMCC26256", "g__Janibacter",
"g__Jatrophihabitans", "g__JCM_18997", "g__Jeotgalibacillus",
"g__JG30-KF-CM45", "g__JG30a-KF-32", "g__JGI-0000079-D21",
"g__Jiella", "g__Jonesia", "g__KD4-96", "g__Kineococcus",
"g__Labrys", "g__Lactobacillus", "g__Lawsonella", "g__Leeuwenhoekiella",
"g__Legionella", "g__Marine_Group_II", "g__Marinilabiliaceae",
"g__Marinobacter", "g__Marinococcus", "g__Martelella", "g__Massilia",
"g__Meiothermus", "g__Methylobacillus", "g__Methylobacterium-Methylorubrum",
"g__Methylophaga", "g__Methylotenera", "g__Micrococcus",
"g__Microvirga", "g__Modestobacter", "g__Mucilaginibacter",
"g__Muricauda", "g__Mycobacterium", "g__Nakamurella", "g__Nesterenkonia",
"g__Nitratireductor", "g__Nitriliruptor", "g__Nitriliruptoraceae",
"g__Nocardia", "g__Nocardioides", "g__Nocardiopsis", "g__Novosphingobium",
"g__NS5_marine_group", "g__Oceanibaculum", "g__Oceanobacillus",
"g__OPB41", "g__Oricola", "g__Ornithinimicrobium", "g__Oryzihumus",
"g__P3OB-42", "g__Paenibacillus", "g__Paludisphaera", "g__Paracoccus",
"g__Paraliobacillus", "g__Parvibaculum", "g__Patulibacter",
"g__Pediococcus", "g__Pedomicrobium", "g__Pelagibacterium",
"g__Pelotomaculum", "g__PeM15", "g__Phaselicystis", "g__Phenylobacterium",
"g__Pir4_lineage", "g__Polaromonas", "g__Prevotella", "g__Prochlorococcus_MIT9313",
"g__Promicromonospora", "g__Proteiniclasticum", "g__Pseudolabrys",
"g__Pseudomonas", "g__Pseudonocardia", "g__Psychrobacter",
"g__Psychroglaciecola", "g__Pusillimonas", "g__Quadrisphaera",
"g__Rhodococcus", "g__Rhodopirellula", "g__Roseisolibacter",
"g__Roseovarius", "g__Rubrivirga", "g__Rummeliibacillus",
"g__S25-593", "g__Saccharomonospora", "g__Saccharopolyspora",
"g__Salegentibacter", "g__Salimesophilobacter", "g__Salinicola",
"g__Salipaludibacillus", "g__SAR116_clade", "g__SAR324_clade(Marine_group_B)",
"g__SAR86_clade", "g__SC-I-84", "g__Scytonema_UTEX_2349",
"g__Sedimentibacter", "g__Sediminibacterium", "g__Sericytochromatia",
"g__SM1A02", "g__Solirubrobacter", "g__Sphingobium", "g__Sphingomonas",
"g__Sporobacter", "g__Staphylococcus", "g__Stappia", "g__Streptococcus",
"g__Streptomyces", "g__Subgroup_10", "g__Synechococcus_CC9902",
"g__Syntrophus", "g__Terrabacter", "g__Thalassospira", "g__Thermoanaerobacterium",
"g__Thermopolyspora", "g__Thermus", "g__Tistrella", "g__TK10",
"g__TRA3-20", "g__uncultured", "g__Vicinamibacteraceae",
"g__Virgibacillus", "g__WCHB1-32", "g__WPS-2", "g__Xanthobacter"
), class = "factor"), Species = structure(c(NA, 55L, 55L,
NA, NA), .Label = c("s__Acetobacteraceae_bacterium", "s__Acinetobacter_venetianus",
"s__Actinomycetales_bacterium", "s__Alcanivorax_pacificus",
"s__Amorphus_suaedae", "s__Aquibacillus_sp.", "s__Bacillus_alcalophilus",
"s__bacterium_Ellin6515", "s__bacterium_enrichment", "s__bacterium_QTYC46b",
"s__Bifidobacterium_bifidum", "s__Blastopirellula_cremea",
"s__Brevibacterium_samyangense", "s__Cellulomonas_sp.", "s__Corynebacterium_glaucum",
"s__Deinococcus_geothermalis", "s__Desulfohalotomaculum_halophilum",
"s__Desulfosporosinus_youngiae", "s__Endozoicomonas_acroporae",
"s__Ercella_succinigenes", "s__Flavobacterium_qiangtangense",
"s__Fluviicola_sp.", "s__Gardnerella_vaginalis", "s__iron-reducing_bacterium",
"s__Jonesia_denitrificans", "s__Lactobacillus_iners", "s__Leeuwenhoekiella_sp.",
"s__marine_sediment", "s__Mesorhizobium_sp.", "s__metagenome",
"s__Nitriliruptor_alkaliphilus", "s__Oryzihumus_terrae",
"s__Pedomicrobium_ferrugineum", "s__Phyllobacteriaceae_bacterium",
"s__planctomycete_str.", "s__Prevotella_histicola", "s__Prevotella_pallens",
"s__Psychrobacter_pulmonis", "s__Rhodobacteraceae_bacterium",
"s__Rhodococcus_sp.", "s__rock_porewater", "s__Saccharopolyspora_rectivirgula",
"s__Sedimentibacter_acidaminivorans", "s__Sphingomonas_metalli",
"s__Streptomyces_specialis", "s__Streptosporangiaceae_str.",
"s__Tistrella_bauzanensis", "s__Triticum_aestivum", "s__uncultured_Acidobacteriaceae",
"s__uncultured_actinobacterium", "s__uncultured_Actinomycetales",
"s__uncultured_Alcaligenes", "s__uncultured_Anaerobacillus",
"s__uncultured_Anaerolineaceae", "s__uncultured_Azospirillum",
"s__uncultured_bacterium", "s__uncultured_Bacteroidetes",
"s__uncultured_Chloroflexi", "s__uncultured_Conexibacter",
"s__uncultured_cyanobacterium", "s__uncultured_Ferrimicrobium",
"s__uncultured_Fimbriimonas", "s__uncultured_Ktedobacteria",
"s__uncultured_Methylocystaceae", "s__uncultured_Nitriliruptorales",
"s__uncultured_planctomycete", "s__uncultured_Porphyromonadaceae",
"s__uncultured_prokaryote", "s__uncultured_Rhodospirillaceae",
"s__uncultured_soil"), class = "factor")), row.names = c(86L,
209L, 210L, 333L, 431L), class = "data.frame")
Assuming you are working with a phyloseq object called physeq you can do the following:
Agglomerate the OTU table to Family level:
p <- tax_glom(physeq, "Family")
Then you can select families that are present in both samples:
families <- tax_table(p)[otu_table(p)[,"m3ofair"] > 0 & otu_table(p)[,"m3NC"] > 0, "Family"]
Now you can select the ASVs with the families you want:
pout <- prune_taxa(tax_table(physeq)[, "Family"] %in% families, physeq)

Fitting tau(time constant) over a specific period using ggplot2

I apologize in advance for the specificity of this question, I'm hoping my neuroscience jargon doesn't confuse things.
I have current traces from single cell recordings and I need to fit a tau from the peak to 4 seconds after the peak out on each trace. In reality, this is just an exponential decay.
So what I'm looking for is a ggplot overlay of the fit (so really a fit line over the period requested.) something along the lines of stat_smooth()
My data looks like follow:
dput(stackover_data)
structure(list(Time = c(0.09990001, 0.19990001, 0.29990001, 0.39990001,
0.49990001, 0.59990001, 0.69990001, 0.79990001, 0.89990001, 0.99990001,
1.09990001, 1.19990001, 1.29990001, 1.39990001, 1.49990001, 1.59990001,
1.69990001, 1.79990001, 1.89990001, 1.99990001, 2.09990001, 2.19990001,
2.29990001, 2.39990001, 2.49990001, 2.59990001, 2.69990001, 2.79990001,
2.89990001, 2.99990001, 3.09990001, 3.19990001, 3.29990001, 3.39990001,
3.49990001, 3.59990001, 3.69990001, 3.79990001, 3.89990001, 3.99990001,
4.09990001, 4.19990001, 4.29990001, 4.39990001, 4.49990001, 4.59990001,
4.69990001, 4.79990001, 4.89990001, 4.99990001, 5.09990001, 5.19990001,
5.29990001, 5.39990001, 5.49990001, 5.59990001, 5.69990001, 5.79990001,
5.89990001, 5.99990001, 6.09990001, 6.19990001, 6.29990001, 6.39990001,
6.49990001, 6.59990001, 6.69990001, 6.79990001, 6.89990001, 6.99990001,
7.09990001, 7.19990001, 7.29990001, 7.39990001, 7.49990001, 7.59990001,
7.69990001, 7.79990001, 7.89990001, 7.99990001, 8.09990001, 8.19990001,
8.29990001, 8.39990001, 8.49990001, 8.59990001, 8.69990001, 8.79990001,
8.89990001, 8.99990001, 9.09990001, 9.19990001, 9.29990001, 9.39990001,
9.49990001, 9.59990001, 9.69990001, 9.79990001, 9.89990001, 9.99990001,
10.09990001, 10.19990001, 10.29990001, 10.39990001, 10.49990001,
10.59990001, 10.69990001, 10.79990001, 10.89990001, 10.99990001,
11.09990001, 11.19990001, 11.29990001, 11.39990001, 11.49990001,
11.59990001, 11.69990001, 11.79990001, 11.89990001, 11.99990001,
12.09990001, 12.19990001, 12.29990001, 12.39990001, 12.49990001,
12.59990001, 12.69990001, 12.79990001, 12.89990001, 12.99990001,
13.09990001, 13.19990001, 13.29990001, 13.39990001, 13.49990001,
13.59990001, 13.69990001, 13.79990001, 13.89990001, 13.99990001,
14.09990001, 14.19990001, 14.29990001, 14.39990001, 14.49990001,
14.59990001, 14.69990001, 14.79990001, 14.89990001, 14.99990001,
15.09990001, 15.19990001, 15.29990001, 15.39990001, 15.49990001,
15.59990001, 15.69990001, 15.79990001, 15.89990001, 15.99990001,
16.09990001, 16.19990001, 16.29990001, 16.39990001, 16.49990001,
16.59990001, 16.69990001, 16.79990001, 16.89990001, 16.99990001,
17.09990001, 17.19990001, 17.29990001, 17.39990001, 17.49990001,
17.59990001, 17.69990001, 17.79990001, 17.89990001, 17.99990001,
18.09990001, 18.19990001, 18.29990001, 18.39990001, 18.49990001,
18.59990001, 18.69990001, 18.79990001, 18.89990001, 18.99990001,
19.09990001, 19.19990001, 19.29990001, 19.39990001, 19.49990001,
19.59990001, 19.69990001, 19.79990001, 19.89990001, 19.99990001
), `Trace 1` = c(-3.08656892325052, 9.36821982641837, 8.13806079083122,
10.7039590839898, 7.25670468903547, 4.31122291688919, 1.77905971163193,
-6.27606834721828, -8.65955381985049, -10.1445673910916, -10.6649772153892,
-6.52301948183154, -11.9757817854835, -0.976254254762154, 0.237467076202677,
-11.8114896779541, -11.0022757370468, -16.1845427042923, 2.70565927469852,
-18.9048281652216, -22.153682283437, -4363.32044948884, -3470.59111611883,
-2877.51064886248, -2253.51505229908, -1876.62974792002, -1541.14546478629,
-1288.26617158403, -1232.52313999354, -1042.98549163259, -938.795146277054,
-810.913567086442, -736.390770574588, -682.044521632168, -638.575324886466,
-596.587948389699, -629.282103146111, -569.200610245336, -587.387817942122,
-521.939307772762, -533.776693538631, -514.782451411908, -445.949395199026,
-451.026618716539, -461.669600651513, -442.372477296489, -426.132547857502,
-452.471101919398, -449.377497412324, -436.817659066873, -487.464805660851,
-442.915455035179, -458.666741489705, -454.990437793055, -455.173154690614,
-426.885702219019, -456.985443835707, -408.869318611773, -442.418742303429,
-407.42593099033, -414.538253423006, -316.036755461507, -248.395118743017,
-198.708015370115, -183.88480278352, -160.041754268138, -139.020785864805,
-123.701641615743, -137.253323547789, -124.240619047461, -121.512859107349,
-113.719386521321, -102.98429740535, -118.721098087137, -109.789471870234,
-122.145399997255, -109.542467905009, -96.6725326170008, -108.16233877188,
-94.1092968366083, -88.0987495250118, -89.2245425850472, -96.3495439993499,
-110.340434956898, -98.8777265479938, -88.0674013452629, -102.755317774957,
-91.0752842494157, -107.959830375198, -78.8424385901398, -93.7743443479161,
-98.3591889757604, -72.3214090579355, -85.6296201608712, -112.596656084088,
-115.518068650615, -110.973655632476, -78.8021307215932, -85.6443070182152,
-93.1744356389988, -100.483987323044, -87.6672104421484, -83.6481077757535,
-82.1465876740715, -86.7838666454595, -75.9066755520263, -86.6416980998645,
-88.9405806921788, -74.0592581080291, -86.3433338300531, -93.5114839187431,
-91.1875849041866, -82.7018083540351, -102.859075734953, -82.1494206590809,
-79.2197323780198, -78.1558787387238, -86.2649418863144, -93.5271994290692,
-84.6678528566242, -71.4828270654073, -69.5618263581887, -67.2920558863641,
-58.1490330439793, -59.8163238740351, -73.6957797622946, -61.7673947702343,
-63.6492255747164, -64.043638367468, -73.8301991524909, -69.3055992018769,
-65.9342860783478, -74.9891521715357, -74.5779808619617, -69.9029875902787,
-69.746935396023, -71.35455530782, -73.5279471991205, -77.8000626250279,
-74.6065254864801, -64.0834786591292, -45.1346212136811, -43.1615385011179,
-42.554841323715, -50.276566542849, -56.1940469314277, -49.6368473019083,
-53.9842269565738, -54.1480156577708, -48.2160751112714, -43.2902743874793,
-46.4358385791469, -58.4459814967147, -49.0443619038303, -56.8007684056415,
-56.3345802020277, -40.1704617527471, -38.2624410086947, -39.9339279963857,
-27.7637250414188, -40.8686520798649, -30.9246406597275, -32.70021580322,
-28.7536071219405, -32.4403271637661, -30.3389870650563, -23.2866770834185,
-40.349370835336, -39.7478049410975, -38.4648592612063, -37.4191914226093,
-52.1259539643142, -38.0993644763616, -37.5493511061199, -25.0794144286873,
-32.6165749053184, -17.2616237291667, -32.1515419380766, -27.0814392288745,
-26.2440551871993, -17.5882979851251, -19.852012057918, -22.1408312947152,
-21.3395092026716, -28.0789344732281, -19.6443281019371, -26.6585778398899,
-24.2994817465722, -27.847437388783, -22.0565059455712, -24.8747905836351,
-30.7544250721296, -29.9924061105416, -22.5728855329732, -24.9767037068316,
-18.8208568928653, -10.7306087216159, -16.4281210876173, -19.3057174287183,
-15.9745523586581), `Trace 2` = c(5.94927992143286, 1.42121402161905,
6.78788136514507, 3.33970424403748, -3.73956433922802, -7.3097330836793,
-9.18242380095097, 3.29952017048882, 5.17208246028, 1.53238537592179,
6.90832098860733, 3.16748380079213, 5.49988319742749, 3.86758484926656,
11.981378748128, -0.208159377585758, -7.2781503569274, 1.71389537416221,
-4.77614396689646, -0.561115871778583, -14.5385068323377, -4944.63006397872,
-3891.23141079918, -3065.66300899921, -2527.61853791531, -2060.05223709386,
-1763.27814995793, -1451.77884853301, -1368.42409410389, -1115.3385743493,
-990.942590410893, -852.951182088994, -920.516421149141, -860.486324532349,
-751.257935697359, -768.757880984424, -713.935725464811, -715.011716140783,
-616.355633698422, -672.133827760044, -629.418857335266, -607.342562427532,
-599.657392949772, -553.265193759536, -572.878306401819, -583.153736972572,
-589.661926862833, -527.552306430313, -553.672277977987, -539.906254466276,
-525.491319968336, -564.876755897633, -505.363603776286, -575.649358123809,
-497.897048596953, -544.360501913781, -483.501835830955, -533.085516954168,
-478.007776808595, -453.333986756674, -447.125338584774, -380.268661132557,
-253.127091546528, -227.877427383931, -191.488369613846, -166.799480062655,
-171.446527550207, -156.775073739292, -148.804014388301, -151.79670303645,
-152.599645619669, -113.40778617347, -133.161498039771, -129.929086626311,
-156.827022418459, -146.618934465797, -94.20997521855, -124.514491421933,
-89.8538131075507, -91.6500841191965, -113.887119052802, -109.971138752404,
-122.532101557384, -107.714865018275, -120.258046104427, -133.296582343699,
-111.726093380577, -121.533575165211, -93.2177144160483, -97.3820468959891,
-111.294540122284, -100.913019601926, -90.8456358331201, -94.143801546019,
-89.9179990101121, -79.3197988311624, -87.0020882554621, -103.315348613102,
-92.6091563297179, -87.3900461813473, -106.61173718685, -117.18534688083,
-106.417237368758, -114.977458547258, -101.759575332149, -93.2156781534656,
-79.4452885332048, -83.8035016923155, -85.7770898942133, -80.151862850598,
-72.4787832080729, -75.4887322569144, -70.8074563945233, -76.9714115362765,
-74.2305756099668, -72.7994824773122, -86.4890002605112, -68.5241155035978,
-76.723559709657, -60.5721619300473, -64.185161607482, -81.0777473166996,
-59.7023719535658, -48.0615168793405, -63.7668096308392, -69.0412888697281,
-70.9894443873153, -48.8366672284658, -43.1003899300401, -50.5591327356918,
-65.184353265464, -52.2850955061746, -66.0074402595226, -69.3081002474696,
-69.3876079446205, -53.0919105504865, -69.3289906081927, -63.5198462609014,
-70.9316181916525, -68.753726760587, -57.1360889764902, -45.7297495037924,
-45.0225501894778, -45.7487568762369, -46.486850874694, -46.7437348684622,
-41.1396209831975, -38.5056250833188, -49.8076229939374, -46.9868446480308,
-38.4639795698766, -40.8336417843587, -49.9810721301961, -58.7820616810459,
-51.4348042554539, -56.9132093579117, -53.527642322397, -49.7620292214747,
-54.6821412367706, -66.7962460110546, -52.0791798888695, -43.3022792658504,
-47.5584813904168, -36.3352478868053, -39.8699383685185, -43.9973042247199,
-49.3191665577514, -42.0818922168797, -37.7538461067954, -29.1591142899914,
-31.6815992654018, -35.3664789321372, -29.6435427630652, -45.5528322348158,
-37.0568327299924, -29.6739001502498, -37.0952936191428, -44.1786405275305,
-50.929131558954, -31.7842698176079, -31.4300485665082, -33.960404707688,
-34.0566040705914, -41.2299273666286, -30.1094672132779, -28.6802701495622,
-37.1973277887207, -31.7114680610898, -32.5450840790921, -28.5823680785893,
-27.5268500574853, -15.2389866754792, -19.2079199191329, -28.9156878395334,
-16.5863741697772, -31.6638747515138, -34.679018047114, -32.6358481677933,
-26.3463300811612, -18.542719903123), `Trace 3` = c(4.74984904312473,
-6.83237755613888, -4.15774846489683, 0.0116753456567835, 4.3974208810568,
8.56175743226069, -0.271281722577697, -10.7982854290066, -18.31704442037,
-15.7577103721081, -20.5775487342614, -17.7307614062074, -14.2844531791322,
-5.43267691733291, 2.52755064598145, -0.79977817636393, -8.07074631773528,
-14.6631228094247, -9.70657043283029, -11.4521183354252, -10.8401698276907,
-5495.45466682125, -4324.53856178012, -3525.03574657791, -2774.37269062517,
-2175.8494069729, -1790.54797875842, -1574.71991002551, -1342.90235937345,
-1212.59715782746, -1042.56659527622, -1006.18885759924, -962.27473179716,
-870.459562514915, -847.89784200018, -770.205392585522, -709.279500982242,
-740.484104629636, -739.054108223511, -645.039948927494, -712.347389757369,
-609.734365947307, -613.120930696929, -630.805982834916, -581.828460576409,
-608.843958294059, -602.432567890874, -547.023947351376, -571.475614300591,
-561.707380041648, -535.094375334464, -578.783728464712, -535.290908514374,
-489.922390143035, -522.824368605682, -520.322259788742, -556.271028784585,
-536.474251127913, -546.811709881227, -541.304029428261, -563.702125503968,
-460.326259578172, -348.718859066443, -261.740363110507, -244.084411205067,
-182.533320181224, -205.356578064485, -157.759947570376, -162.214202634405,
-180.011654146528, -176.904445787135, -167.116794266109, -163.416234638164,
-155.821745831568, -134.760994564946, -131.702791057298, -138.598664148971,
-139.818370538306, -134.700400696581, -137.275258643317, -119.921721377143,
-118.187525264885, -118.490007264421, -130.391338033262, -138.05114734155,
-127.505366899025, -132.636233878671, -123.490111075107, -113.42942794286,
-122.40925776411, -114.48254277334, -122.78054774327, -90.9528981496313,
-96.9508488566491, -107.842237007564, -91.0521871208113, -91.0347011279681,
-85.7054147126896, -89.7363815316723, -77.6588521980595, -76.6733051688234,
-85.821987540449, -90.3216600489126, -66.1137192454051, -77.7157754909198,
-89.8637060331546, -80.9149315468257, -71.7434481475478, -97.6600776026528,
-103.405900069071, -83.7502802699966, -77.4600968679799, -77.8705250264031,
-78.9012879762878, -87.4698127883497, -92.9587198547098, -96.1222986385502,
-91.1990314226718, -83.8744116889207, -61.7720026226848, -83.6616594930646,
-91.3899042204887, -74.2552104995002, -94.3117384183545, -81.130091800586,
-87.6638514042855, -79.061763018934, -78.7472359255489, -72.9642062301352,
-83.5759889935287, -74.066505526926, -62.6191749912397, -75.7150349466975,
-71.8704211546101, -68.4798935028027, -77.0470926055507, -76.6024078920054,
-66.5760393943856, -77.8848130194484, -77.5151449198185, -65.5482413040489,
-47.6087884294611, -35.6865291924552, -47.9648700291328, -62.8176093048552,
-48.969044800301, -46.853228499419, -52.562083189922, -58.7677963803543,
-63.6615259259388, -51.7351340481719, -54.5967510836755, -54.1294816023731,
-47.7621427567758, -40.9244974392914, -50.5286026229961, -45.9961132210891,
-43.143208905187, -43.8395623054062, -49.3326618452772, -48.308625153823,
-44.9833219970479, -32.4206723427767, -45.6628898472981, -41.4748918817457,
-43.6438737242104, -42.9844450147366, -30.3729810016378, -44.9519080631137,
-45.8241111308495, -40.4766896430523, -40.3007872752484, -46.4770136239361,
-49.3759491415156, -46.0844075639024, -34.3090862431636, -26.6047381016158,
-28.9119815377167, -33.1619464253006, -37.3813739690468, -46.5001186141503,
-54.5235621985407, -44.5233400090119, -55.2272273265567, -48.088333647706,
-55.3522589332341, -52.8146474401922, -60.1877313269088, -48.2512741329643,
-34.8540879147507, -55.2019332852645, -50.8488894007021, -49.9600753927381,
-48.5654335180739, -47.8918651630979, -45.1405419376454, -40.8504490169926,
-38.5815843253789, -45.001677748311, -43.0547862406721)), .Names = c("Time",
"Trace 1", "Trace 2", "Trace 3"), row.names = c(1000L, 2000L,
3000L, 4000L, 5000L, 6000L, 7000L, 8000L, 9000L, 10000L, 11000L,
12000L, 13000L, 14000L, 15000L, 16000L, 17000L, 18000L, 19000L,
20000L, 21000L, 22000L, 23000L, 24000L, 25000L, 26000L, 27000L,
28000L, 29000L, 30000L, 31000L, 32000L, 33000L, 34000L, 35000L,
36000L, 37000L, 38000L, 39000L, 40000L, 41000L, 42000L, 43000L,
44000L, 45000L, 46000L, 47000L, 48000L, 49000L, 50000L, 51000L,
52000L, 53000L, 54000L, 55000L, 56000L, 57000L, 58000L, 59000L,
60000L, 61000L, 62000L, 63000L, 64000L, 65000L, 66000L, 67000L,
68000L, 69000L, 70000L, 71000L, 72000L, 73000L, 74000L, 75000L,
76000L, 77000L, 78000L, 79000L, 80000L, 81000L, 82000L, 83000L,
84000L, 85000L, 86000L, 87000L, 88000L, 89000L, 90000L, 91000L,
92000L, 93000L, 94000L, 95000L, 96000L, 97000L, 98000L, 99000L,
100000L, 101000L, 102000L, 103000L, 104000L, 105000L, 106000L,
107000L, 108000L, 109000L, 110000L, 111000L, 112000L, 113000L,
114000L, 115000L, 116000L, 117000L, 118000L, 119000L, 120000L,
121000L, 122000L, 123000L, 124000L, 125000L, 126000L, 127000L,
128000L, 129000L, 130000L, 131000L, 132000L, 133000L, 134000L,
135000L, 136000L, 137000L, 138000L, 139000L, 140000L, 141000L,
142000L, 143000L, 144000L, 145000L, 146000L, 147000L, 148000L,
149000L, 150000L, 151000L, 152000L, 153000L, 154000L, 155000L,
156000L, 157000L, 158000L, 159000L, 160000L, 161000L, 162000L,
163000L, 164000L, 165000L, 166000L, 167000L, 168000L, 169000L,
170000L, 171000L, 172000L, 173000L, 174000L, 175000L, 176000L,
177000L, 178000L, 179000L, 180000L, 181000L, 182000L, 183000L,
184000L, 185000L, 186000L, 187000L, 188000L, 189000L, 190000L,
191000L, 192000L, 193000L, 194000L, 195000L, 196000L, 197000L,
198000L, 199000L, 200000L), class = "data.frame")
If you
plot(stackover_data$Time,stackover_data$'Trace 1',type='l'
you can see from time = 2 is where the peak is and I'm looking to fit it from 2 seconds to 6 seconds in ggplot. ( yes I know I used base graphics for the example, its just easier to plot one graph in that vs ggplot2.
Thanks all!
library(ggplot)
# rename the variables, so there's no space in them (is easier in aes())
names(neurons)[2:4] <- paste0('Trace', 1:3)
Now we make a plot, where we use a selection of the data based on the lowest point in the trace:
ggplot(neurons, aes(x = Time, y = Trace1)) +
geom_line() +
geom_smooth(data = subset(neurons, Time >= Time[which.min(Trace1)] &
Time < Time[which.min(Trace1)] + 4)) +
theme_classic() +
xlim(0, 10)
Results in:
Note that the ggplot equivalent of your simple base plot is this:
qplot(neurons$Time, neurons$Trace1, geom = 'line')
Basically, just as easy ;)

R keep rows based on list

I'm trying to figure out how to keep rows of my dataframe based on a list I created from another dataframe. I've looked at several other questions that tackled this issue and tried the codes suggested ( R- keep dataframe rows only if the row name is in a list , Select rows in a dataframe in r based on values in one row ) but the codes aren't working for me. I'm sure it's a simple error on my part, but I can't figure out what it is.
One code I tried:
A <- AllSiteBA[AllSiteBA$Cofecha %in% keeps,]
Output (doesn't have any matches......there SHOULD be 76 matches when I run the entire AllSiteBA data.frame):
> A
[1] Cofecha DBHinBark RBHinBark BAtotal MeanBAww PercentBAww
[7] Plot
<0 rows> (or 0-length row.names)
Another code I tried:
A <- subset(AllSiteBA, Cofecha %in% keeps)
Had exact same output as the first code I tried.
Any help on how to fix the code would be greatly appreciated. Below are reproducible sections of my data.frame and list.
List of names to "keep":
keeps <- list(structure(c(69L, 166L, 50L, 232L, 252L, 234L, 148L, 307L,
194L, 240L, 245L, 297L, 248L, 221L, 257L, 218L, 265L, 45L, 208L,
216L, 223L, 258L, 205L, 269L, 270L, 142L, 4L, 58L, 207L, 220L,
231L, 256L, 206L, 268L, 203L, 267L, 111L, 144L, 290L, 74L, 36L,
266L, 169L, 78L, 143L, 186L, 272L, 185L, 312L, 73L, 150L, 129L,
225L, 131L, 123L, 12L, 300L, 302L, 264L, 284L, 128L, 130L, 1L,
3L, 10L, 124L, 303L, 56L, 51L, 55L, 108L, 2L, 11L, 298L, 310L,
121L), .Label = c("LB1A002", "LB1A003", "LB1A101", "LB1A102",
"LB1A103", "LB1A212", "LB1A228", "LB1A231", "LB1A233", "LB1B001",
"LB1B002", "LB1B003", "LB1B210", "LB1B216", "LB2A001", "LB2A002",
"LB2A003", "LB2A004", "LB2A008", "LB2A009", "LB2A011", "LB2B001",
"LB2B005", "LB2B008", "LB2B101", "LB2B102", "LB2B103", "LB2C003",
"LB2C004", "LB2C008", "LB2C009", "LB2C010", "LB2C001", "LB2D005",
"LB2D006", "LB2D007", "LB2D008", "LB2D009", "LB2D010", "LB2D101",
"SM1A005", "SM1A101", "SM1A301", "SM1A302", "SM1B003", "SM1C005",
"SM1C302", "SM1D006", "SM2A004", "SM2A005", "SM2A007", "SM2A210",
"SM2A301", "SM2B001", "SM2B005", "SM2B006", "SM2B101", "SM2C005",
"SM2C101", "SM2C301", "SM2D006", "SM2D101", "SM2D221", "IR1A004",
"IR1A009", "IR1A206", "IR1B001", "IR1B004", "IR1B005", "IR1B301",
"IR1B302", "IR1C005", "IR1C006", "IR1C007", "IR1C008", "IR1C204",
"IR1C205", "IR1D002", "IR1D101", "IR2A003", "IR2A101", "IR2A211",
"IR2A234", "IR2B002", "IR2B005", "IR2B101", "IR2B201", "IR2B210",
"IR2B229", "IR2C230", "IR2C256", "IR2C301", "IR2C302", "IR2C002",
"IR2C009", "IR2C101", "IR2C204", "IR2C215", "IR2D227", "IR2D228",
"IR2D237", "IR2D254", "IR2D301", "IR2D302", "IR2D003", "IR2D006",
"IR2D009", "IR2D011", "IR2D207", "IR2D216", "JA1A101", "JA1A224",
"JA1A301", "JA1B004", "JA1B101", "JA1B102", "JA1B219", "JA1B233",
"JA1C002", "JA1C232", "JA1D001", "JA1D101", "JA2A101", "JA2A102",
"JA2A206", "JA2A209", "JA2A210", "JA2A004", "JA2A005", "JA2A006",
"JA2A007", "JA2A008", "JA2B005", "JA2B206", "JA2C001", "JA2C002",
"JA2C007", "JA2C101", "JA2C202", "JA3N007", "JA3N008", "JA3N009",
"JA3N010", "JA3N011", "JA3N012", "JA3N001", "JA3N002", "JA3N003",
"JA3N004", "JA3N005", "JA3N006", "SF5A007", "SF5B223", "SF5B227",
"SF5B228", "SF5B301", "SF5B302", "SF5C201", "SF5C214", "SF5C216",
"SF5C301", "SF5C303", "SF5D004", "SF5D101", "SF5D207", "AP1A001",
"AP1A004", "AP1A005", "AP1A006", "AP1A008", "AP1A009", "AP1A010",
"AP1A101", "AP1B005", "AP1B007", "AP1B011", "AP1B101", "AP1B102",
"AP1C006", "AP1C007", "AP1C010", "AP1C011", "AP1C001", "AP1C002",
"AP1D001", "AP1D005", "AP1D007", "AP1D008", "AP1D009", "AP1D010",
"AP1D011", "AP1D012", "AP1D013", "AP1D101", "AP1D102", "AP1D103",
"AP1D104", "AP1C004", "AP1C005", "AP2A001", "AP2A002", "AP2A003",
"AP2B001", "AP2B003", "AP2B004", "AP2B101", "AP2B102", "AP2C001",
"AP2C002", "AP2C003", "AP2C004", "AP2C005", "AP2C007", "AP2C008",
"AP2C102", "AP2C103", "AP2C104", "AP2D001", "AP2D002", "AP2D005",
"AP2D006", "AP2D009", "AP2D101", "AP2D102", "AP2D103", "AP3A003",
"AP3A005", "AP3A008", "AP3A014", "AP3A015", "AP3A101", "AP3A102",
"AP3B101", "AP3B102", "AP3B103", "AP3B104", "AP3B003", "AP3B007",
"AP3B010", "AP3B012", "AP3C003", "AP3C004", "AP3C006", "AP3C007",
"AP3C009", "AP3C011", "AP3C101", "AP3C102", "AP3C103", "AP3C104",
"AP3C105", "AP3D006", "AP3D011", "AP3D101", "AP3D102", "BF1A101",
"BF1A102", "BF1A103", "BF1A104", "BF1B003", "BF1B005", "BF1B006",
"BF1B007", "BF1B101", "BF1C007", "BF1C101", "BF1C102", "BF1D003",
"BF1D007", "BF1D010", "BF1D101", "BF1D102", "BF1D103", "BF1D210",
"BF2A001", "BF2A002", "BF2B001", "BF2B214", "BF2B219", "BF2C001",
"BF2C004", "BF2C008", "BF2C101", "BF2C102", "BF2C201", "BF2C205",
"BF2C213", "BF2C219", "BF2C301", "BF2D004", "BF2D013", "BF2D014",
"BF2D015", "BF3A001", "BF3A002", "BF3A004", "BF3A005", "BF3A007",
"BF3A008", "BF3A009", "BF3A101", "BF3B003", "BF3B101", "BF3C002",
"BF3C003", "BF3C007", "BF3C009", "BF3C010", "BF3D002", "BF3D003",
"BF3D004", "BF3D009", "BF3D010"), class = "factor"))
Small portion of data.frame I'm trying to select rows from:
AllSiteBA <- structure(list(Cofecha = structure(30:45, .Label = c("LB1A002",
"LB1A003", "LB1A101", "LB1A102", "LB1A103", "LB1A212", "LB1A228",
"LB1A231", "LB1A233", "LB1B001", "LB1B002", "LB1B003", "LB1B210",
"LB1B216", "LB2A001", "LB2A002", "LB2A003", "LB2A004", "LB2A008",
"LB2A009", "LB2A011", "LB2B001", "LB2B005", "LB2B008", "LB2B101",
"LB2B102", "LB2B103", "LB2C001", "LB2C003", "LB2C004", "LB2C008",
"LB2C009", "LB2C010", "LB2D005", "LB2D006", "LB2D007", "LB2D008",
"LB2D009", "LB2D010", "LB2D101", "SM1A005", "SM1A101", "SM1A301",
"SM1A302", "SM1B003", "SM1C005", "SM1C302", "SM1D006", "SM2A004",
"SM2A005", "SM2A007", "SM2A210", "SM2A301", "SM2B001", "SM2B005",
"SM2B006", "SM2B101", "SM2C005", "SM2C101", "SM2C301", "SM2D006",
"SM2D101", "SM2D221", "IR1A004", "IR1A009", "IR1A206", "IR1B001",
"IR1B004", "IR1B005", "IR1B301", "IR1B302", "IR1C005", "IR1C006",
"IR1C007", "IR1C008", "IR1C204", "IR1C205", "IR1D002", "IR1D101",
"IR2A003", "IR2A101", "IR2A211", "IR2A234", "IR2B002", "IR2B005",
"IR2B101", "IR2B201", "IR2B210", "IR2B229", "IR2C002", "IR2C009",
"IR2C101", "IR2C204", "IR2C215", "IR2C230", "IR2C256", "IR2C301",
"IR2C302", "IR2D003", "IR2D006", "IR2D009", "IR2D011", "IR2D207",
"IR2D216", "IR2D227", "IR2D228", "IR2D237", "IR2D254", "IR2D301",
"IR2D302", "JA1A101", "JA1A224", "JA1A301", "JA1B004", "JA1B101",
"JA1B102", "JA1B219", "JA1B233", "JA1C002", "JA1C232", "JA1D001",
"JA1D101", "JA2A004", "JA2A005", "JA2A006", "JA2A007", "JA2A008",
"JA2A101", "JA2A102", "JA2A206", "JA2A209", "JA2A210", "JA2B005",
"JA2B206", "JA2C001", "JA2C002", "JA2C007", "JA2C101", "JA2C202",
"JA3N001", "JA3N002", "JA3N003", "JA3N004", "JA3N005", "JA3N006",
"JA3N007", "JA3N008", "JA3N009", "JA3N010", "JA3N011", "JA3N012",
"SF5A007", "SF5B223", "SF5B227", "SF5B228", "SF5B301", "SF5B302",
"SF5C201", "SF5C214", "SF5C216", "SF5C301", "SF5C303", "SF5D004",
"SF5D101", "SF5D207", "AP1A001", "AP1A004", "AP1A005", "AP1A006",
"AP1A008", "AP1A009", "AP1A010", "AP1A101", "AP1B005", "AP1B007",
"AP1B011", "AP1B101", "AP1B102", "AP1C001", "AP1C002", "AP1C004",
"AP1C005", "AP1C006", "AP1C007", "AP1C010", "AP1C011", "AP1D001",
"AP1D005", "AP1D007", "AP1D008", "AP1D009", "AP1D010", "AP1D011",
"AP1D012", "AP1D013", "AP1D101", "AP1D102", "AP1D103", "AP1D104",
"AP2A001", "AP2A002", "AP2A003", "AP2B001", "AP2B003", "AP2B004",
"AP2B101", "AP2B102", "AP2C001", "AP2C002", "AP2C003", "AP2C004",
"AP2C005", "AP2C007", "AP2C008", "AP2C102", "AP2C103", "AP2C104",
"AP2D001", "AP2D002", "AP2D005", "AP2D006", "AP2D009", "AP2D101",
"AP2D102", "AP2D103", "AP3A003", "AP3A005", "AP3A008", "AP3A014",
"AP3A015", "AP3A101", "AP3A102", "AP3B003", "AP3B007", "AP3B010",
"AP3B012", "AP3B101", "AP3B102", "AP3B103", "AP3B104", "AP3C003",
"AP3C004", "AP3C006", "AP3C007", "AP3C009", "AP3C011", "AP3C101",
"AP3C102", "AP3C103", "AP3C104", "AP3C105", "AP3D006", "AP3D011",
"AP3D101", "AP3D102", "BF1A101", "BF1A102", "BF1A103", "BF1A104",
"BF1B003", "BF1B005", "BF1B006", "BF1B007", "BF1B101", "BF1C007",
"BF1C101", "BF1C102", "BF1D003", "BF1D007", "BF1D010", "BF1D101",
"BF1D102", "BF1D103", "BF1D210", "BF2A001", "BF2A002", "BF2B001",
"BF2B214", "BF2B219", "BF2C001", "BF2C004", "BF2C008", "BF2C101",
"BF2C102", "BF2C201", "BF2C205", "BF2C213", "BF2C219", "BF2C301",
"BF2D004", "BF2D013", "BF2D014", "BF2D015", "BF3A001", "BF3A002",
"BF3A004", "BF3A005", "BF3A007", "BF3A008", "BF3A009", "BF3A101",
"BF3B003", "BF3B101", "BF3C002", "BF3C003", "BF3C007", "BF3C009",
"BF3C010", "BF3D002", "BF3D003", "BF3D004", "BF3D009", "BF3D010"
), class = "factor"), DBHinBark = c(144, 147.6, 135.9, 144, 163.8,
119.7, 234.9, 180.9, 144.9, 202.5, 152.1, 180, 184.5, 68.4, 88.2,
231.3), RBHinBark = c(72, 73.8, 67.95, 72, 81.9, 59.85, 117.45,
90.45, 72.45, 101.25, 76.05, 90, 92.25, 34.2, 44.1, 115.65),
BAtotal = c(16286.0163162095, 17110.4958922176, 14505.3694541364,
16286.0163162095, 21072.5782991454, 11253.2555709933, 43336.7077139261,
25702.0056715304, 16490.2276926745, 32206.2334378166, 18169.7231252836,
25446.9004940773, 26735.14983159, 3674.53243134477, 6109.80080862797,
42018.5582683328), MeanBAww = c(7287.19846816407, 3511.25221054135,
5836.77552643544, 3226.29613334421, 6580.83174422834, 1240.15336040198,
15513.5106521598, 4648.51222574233, 4555.16310970877, 4909.94773909597,
1791.58819676346, 6095.75422479859, 2391.72518367973, 3568.38437887589,
3398.70860742085, 7723.82631584503), PercentBAww = c(44.7451256751543,
20.5210429473197, 40.2387236318961, 19.8102228973765, 31.2293619262301,
11.0203962984599, 35.7976216249915, 18.0861847326233, 27.6234094192182,
15.2453336357263, 9.86029442721902, 23.9548004135802, 8.9459950617284,
97.1112500854964, 55.62715895126, 18.3819403476917), Plot = c("LB2",
"LB2", "LB2", "LB2", "LB2", "LB2", "LB2", "LB2", "LB2", "LB2",
"LB2", "SM1", "SM1", "SM1", "SM1", "SM1")), .Names = c("Cofecha",
"DBHinBark", "RBHinBark", "BAtotal", "MeanBAww", "PercentBAww",
"Plot"), row.names = 30:45, class = "data.frame")
I get two rows, but only after I subset the first element of keeps, which is a list.
> AllSiteBA[AllSiteBA$Cofecha %in% keeps[[1]],]
Cofecha DBHinBark RBHinBark BAtotal MeanBAww PercentBAww Plot
36 LB2D007 234.9 117.45 43336.71 15513.511 35.79762 LB2
45 SM1B003 231.3 115.65 42018.56 7723.826 18.38194 SM1

How to use Seq_along for multiple dates from a list in a loop

I have been fiddling around with a R project and have hit a roadblock. Ill explain what the goal is, It is to make a set of plots that show points plotted on a map based on their measurement time (water_level_date) and plot accordingly over a pre-selected time period.
The roadblock is that I have hit is that the loop creates other plots but doesn't apply the date restriction. so it produces the same plot 12 times. the loop I am currently using is
for (i in c(1:length(date)))
filename=paste(sprintf('%05d', i), ".png", sep="")
I just was a bit confused about what I should be using for the loop as I am using for() for dates and I think that its wrong, I think I have to use seq_along but I'm unsure how to get it to loop for a sequence say 01/01/1985 to 01/01/1986.
The dates are retrieved from a data frame but the issue is that it ignores the dates completely. Any help would be well appreciated. Yes, and I know I don't have a repeatable example just wondering how to properly use seq_along for a list of dates which loops between a start and end date.
DATA
structure(list(neg_decimal_lat = c(-35.9580624, -36.0270162,
-35.9505656, -35.9492215, -35.97803, -35.9766841, -35.9855039,
-35.98203, -35.984858, -36.0272577, -36.0048864, -35.9731485,
-35.9701733, -36.0034897, -36.0036909), decimal_long = c(140.3021648,
140.360413, 140.2858737, 140.2650201, 140.287947, 140.2547256,
140.2625761, 140.268055, 140.277901, 140.2702671, 140.2628329,
140.2857832, 140.2663454, 140.2683559, 140.2898351), max_drill_depth = c(67.5,
27.43, 38.4, 21.3, 18, 22, 67.1, 34, 34, 10.67, 40, 20, 16, 24,
40), water_level_date = structure(c(120L, 120L, 982L, 1320L,
1294L, 762L, 1320L, 592L, 729L, 817L, 90L, 1320L, 1320L, 202L,
631L), .Label = c("", "1/02/1972", "1/02/1985", "1/02/1996",
"1/02/2006", "1/03/2007", "1/03/2013", "1/04/1976", "1/04/1978",
"1/04/1985", "1/04/1992", "1/04/1998", "1/04/1999", "1/04/2011",
"1/05/2013", "1/06/1979", "1/06/1982", "1/06/1983", "1/06/1995",
"1/06/2000", "1/06/2006", "1/07/1985", "1/07/1986", "1/07/2003",
"1/07/2004", "1/07/2008", "1/07/2013", "1/08/1972", "1/08/1980",
"1/08/1983", "1/08/1993", "1/09/1978", "1/09/1998", "1/10/1974",
"1/10/1975", "1/10/1992", "1/10/1995", "1/10/2008", "1/10/2010",
"1/11/1974", "1/11/1991", "1/11/1999", "1/12/1971", "1/12/1976",
"1/12/1983", "1/12/2000", "1/12/2003", "1/12/2009", "10/01/1980",
"10/01/1997", "10/01/2012", "10/02/1970", "10/02/1980", "10/02/1982",
"10/03/2011", "10/04/1986", "10/04/1989", "10/04/1991", "10/04/1996",
"10/04/2002", "10/04/2013", "10/05/1969", "10/05/1988", "10/05/1989",
"10/06/1998", "10/07/1979", "10/07/1987", "10/07/2002", "10/07/2013",
"10/08/1976", "10/08/2012", "10/09/1975", "10/09/1979", "10/09/1981",
"10/09/1988", "10/09/2012", "10/10/1985", "10/10/2005", "10/10/2012",
"10/11/1969", "10/11/1970", "10/11/1981", "10/11/1988", "10/11/2000",
"10/11/2004", "10/12/1998", "10/12/2003", "10/12/2004", "10/12/2009",
"11/01/2008", "11/01/2012", "11/02/1974", "11/03/1970", "11/03/1977",
"11/03/1983", "11/03/1985", "11/03/1991", "11/03/2003", "11/04/1973",
"11/04/1975", "11/04/1991", "11/04/1994", "11/04/2013", "11/05/1973",
"11/05/1982", "11/05/1988", "11/05/2004", "11/05/2011", "11/06/1979",
"11/06/1981", "11/06/1999", "11/06/2010", "11/06/2013", "11/07/2005",
"11/07/2013", "11/08/1978", "11/08/1982", "11/08/2004", "11/09/1974",
"11/09/1978", "11/09/1981", "11/09/1996", "11/09/1997", "11/09/2006",
"11/10/1978", "11/10/1984", "11/10/1985", "11/10/1989", "11/10/2006",
"11/10/2008", "11/10/2011", "11/10/2012", "11/11/1981", "11/11/1991",
"11/12/1967", "11/12/1971", "11/12/1985", "11/12/2001", "11/12/2009",
"12/01/1979", "12/02/1975", "12/02/1979", "12/03/1971", "12/03/1981",
"12/03/1997", "12/03/1998", "12/03/2001", "12/03/2003", "12/04/1973",
"12/04/1977", "12/04/1983", "12/04/2013", "12/05/1982", "12/06/1977",
"12/06/1987", "12/06/2001", "12/06/2007", "12/06/2013", "12/07/1974",
"12/07/1983", "12/07/2010", "12/07/2013", "12/08/1991", "12/08/2002",
"12/08/2013", "12/09/1975", "12/09/1978", "12/09/1980", "12/09/1988",
"12/09/1997", "12/10/1982", "12/10/1999", "12/10/2000", "12/10/2004",
"12/10/2006", "12/11/1969", "12/11/1979", "12/11/1997", "12/12/1979",
"12/12/1988", "12/12/2003", "13/01/1989", "13/01/2013", "13/02/1981",
"13/02/1985", "13/02/1990", "13/03/1974", "13/03/1998", "13/03/2001",
"13/03/2003", "13/03/2013", "13/04/1988", "13/04/2004", "13/05/1981",
"13/05/1983", "13/06/2013", "13/07/1971", "13/07/1987", "13/07/1999",
"13/07/2010", "13/08/1974", "13/08/1998", "13/08/2013", "13/09/1974",
"13/09/1978", "13/09/1979", "13/09/1983", "13/09/1984", "13/09/1989",
"13/09/1990", "13/09/1993", "13/09/1994", "13/09/2000", "13/09/2010",
"13/10/1998", "13/10/2004", "13/10/2006", "13/10/2008", "13/10/2011",
"13/11/1996", "13/12/1996", "13/12/1999", "13/12/2001", "13/12/2004",
"14/01/1977", "14/02/1984", "14/02/1990", "14/03/1994", "14/03/2000",
"14/03/2001", "14/03/2002", "14/03/2008", "14/03/2012", "14/03/2013",
"14/04/1980", "14/04/1989", "14/05/1982", "14/05/1983", "14/05/1985",
"14/05/2002", "14/05/2010", "14/06/1967", "14/06/1968", "14/06/1989",
"14/06/1996", "14/06/2002", "14/06/2013", "14/07/1983", "14/08/1973",
"14/08/2013", "14/09/1973", "14/09/1978", "14/09/1993", "14/09/1994",
"14/09/1998", "14/09/2000", "14/09/2009", "14/10/1986", "14/10/1988",
"14/10/1997", "14/11/1962", "14/11/1984", "14/11/1986", "14/11/1996",
"14/11/2000", "14/12/1987", "14/12/1998", "14/12/1999", "14/12/2000",
"14/12/2001", "15/02/1968", "15/03/1977", "15/03/1979", "15/03/1989",
"15/03/1991", "15/03/1994", "15/03/1995", "15/03/1996", "15/03/1999",
"15/03/2000", "15/03/2001", "15/03/2003", "15/03/2010", "15/04/1999",
"15/04/2009", "15/05/1991", "15/07/1980", "15/07/1982", "15/07/2010",
"15/07/2013", "15/08/2013", "15/09/1971", "15/09/1975", "15/09/1978",
"15/09/1989", "15/09/1992", "15/09/1994", "15/09/1995", "15/09/1997",
"15/09/2000", "15/09/2003", "15/09/2009", "15/10/1993", "15/10/1996",
"15/10/2002", "15/10/2006", "15/11/1994", "15/11/1996", "15/12/1977",
"15/12/1983", "15/12/1989", "15/12/1994", "15/12/2000", "15/12/2008",
"16/01/1979", "16/01/2012", "16/02/1971", "16/02/1978", "16/02/2008",
"16/03/1977", "16/03/1979", "16/03/1989", "16/03/1991", "16/03/1993",
"16/03/1998", "16/03/2000", "16/03/2003", "16/03/2007", "16/03/2010",
"16/04/2008", "16/04/2013", "16/05/1979", "16/05/1996", "16/06/1989",
"16/06/1992", "16/06/1997", "16/06/2008", "16/07/1974", "16/07/1977",
"16/07/1982", "16/07/1996", "16/07/2008", "16/07/2013", "16/08/1988",
"16/08/1995", "16/08/2013", "16/09/1969", "16/09/1976", "16/09/1979",
"16/09/1993", "16/09/2005", "16/10/1970", "16/10/1986", "16/10/1995",
"16/10/2001", "16/10/2006", "16/10/2008", "16/11/1981", "16/12/1971",
"16/12/1979", "16/12/1980", "16/12/2003", "17/01/1974", "17/01/1980",
"17/01/1985", "17/01/2008", "17/02/1979", "17/03/1972", "17/03/1977",
"17/03/1998", "17/03/1999", "17/03/2002", "17/03/2010", "17/04/1998",
"17/04/2007", "17/04/2013", "17/05/1977", "17/05/2002", "17/05/2012",
"17/06/1977", "17/06/1986", "17/06/2002", "17/06/2013", "17/07/1996",
"17/07/2008", "17/07/2013", "17/08/1989", "17/08/1990", "17/08/1994",
"17/09/1969", "17/09/1974", "17/09/1975", "17/09/1984", "17/09/1992",
"17/09/1993", "17/09/1996", "17/09/1998", "17/09/2008", "17/10/1991",
"17/10/1994", "17/11/1983", "17/11/1997", "17/12/1985", "17/12/1986",
"17/12/1991", "17/12/1997", "17/12/1999", "17/12/2009", "17/12/2012",
"18/01/1972", "18/01/1977", "18/01/1984", "18/01/1995", "18/01/2005",
"18/01/2007", "18/02/1975", "18/02/2008", "18/03/1973", "18/03/1977",
"18/03/1996", "18/03/1998", "18/03/2009", "18/03/2010", "18/03/2013",
"18/04/1996", "18/04/2000", "18/04/2013", "18/05/1990", "18/06/2002",
"18/06/2008", "18/06/2010", "18/06/2013", "18/07/1973", "18/07/2000",
"18/08/1979", "18/08/1983", "18/09/1978", "18/09/1991", "18/09/1992",
"18/09/1996", "18/09/2000", "18/09/2012", "18/10/1991", "18/10/2001",
"18/10/2005", "18/10/2012", "18/12/1981", "18/12/1992", "18/12/2008",
"19/01/1957", "19/01/1971", "19/01/1974", "19/01/1984", "19/02/1975",
"19/02/1985", "19/03/1972", "19/03/1984", "19/03/1999", "19/03/2010",
"19/03/2013", "19/04/1971", "19/04/1996", "19/04/2000", "19/04/2006",
"19/04/2013", "19/05/1999", "19/05/2009", "19/06/1985", "19/06/1989",
"19/06/2002", "19/06/2006", "19/06/2008", "19/06/2013", "19/07/1980",
"19/07/1982", "19/07/1985", "19/07/2013", "19/08/1969", "19/08/2013",
"19/09/1973", "19/09/1975", "19/09/1977", "19/09/1978", "19/09/1979",
"19/09/1988", "19/09/2001", "19/09/2002", "19/09/2003", "19/11/1996",
"2/01/1975", "2/01/1986", "2/01/1996", "2/01/2007", "2/02/1973",
"2/02/1977", "2/02/1989", "2/03/1982", "2/03/1995", "2/04/1974",
"2/04/1976", "2/04/1980", "2/04/1984", "2/04/1985", "2/04/1996",
"2/04/2003", "2/04/2004", "2/04/2013", "2/05/1981", "2/05/2008",
"2/05/2011", "2/06/1982", "2/06/1992", "2/06/1997", "2/06/2009",
"2/06/2010", "2/07/1974", "2/07/1985", "2/07/1986", "2/07/1987",
"2/07/1999", "2/07/2008", "2/08/1971", "2/08/1993", "2/08/1996",
"2/08/2004", "2/09/1977", "2/09/1998", "2/09/2013", "2/10/1986",
"2/10/1987", "2/10/2008", "2/11/1971", "2/11/1981", "2/12/1939",
"2/12/1959", "2/12/1974", "2/12/1982", "2/12/1986", "2/12/1992",
"2/12/1998", "2/12/2011", "20/01/1983", "20/01/1984", "20/03/1974",
"20/03/1998", "20/03/1999", "20/03/2001", "20/03/2003", "20/03/2006",
"20/03/2009", "20/03/2013", "20/04/1993", "20/04/2012", "20/05/1982",
"20/05/1989", "20/06/1988", "20/06/1991", "20/06/2001", "20/06/2002",
"20/06/2005", "20/06/2007", "20/06/2008", "20/06/2013", "20/07/1973",
"20/07/1989", "20/08/1980", "20/08/1991", "20/09/1971", "20/09/1974",
"20/09/1978", "20/09/1988", "20/09/1993", "20/09/1994", "20/09/1996",
"20/09/2000", "20/09/2005", "20/09/2012", "20/10/1981", "20/10/1999",
"20/10/2000", "20/11/1995", "20/11/1996", "20/12/1983", "20/12/1991",
"20/12/2012", "21/02/2001", "21/03/1969", "21/03/1975", "21/03/1977",
"21/03/1979", "21/03/1984", "21/03/1987", "21/03/1988", "21/03/1995",
"21/03/2000", "21/03/2001", "21/03/2003", "21/03/2007", "21/03/2013",
"21/04/1980", "21/04/1981", "21/04/1990", "21/04/1999", "21/05/2012",
"21/06/2007", "21/06/2010", "21/06/2013", "21/07/1977", "21/08/1985",
"21/08/1992", "21/09/1973", "21/09/1978", "21/09/1989", "21/09/1992",
"21/09/2009", "21/10/1993", "21/11/1981", "21/11/1985", "21/11/1990",
"21/12/1953", "21/12/1981", "21/12/1990", "21/12/1995", "21/12/2000",
"21/12/2009", "21/12/2012", "22/02/1973", "22/02/1974", "22/02/1979",
"22/02/1983", "22/02/1999", "22/02/2000", "22/03/1977", "22/03/1983",
"22/03/1985", "22/03/1987", "22/03/1993", "22/03/2000", "22/03/2001",
"22/03/2004", "22/03/2011", "22/03/2012", "22/03/2013", "22/04/1969",
"22/04/1985", "22/04/1998", "22/04/2013", "22/05/1968", "22/05/1972",
"22/05/1978", "22/05/2002", "22/05/2012", "22/06/1972", "22/06/1978",
"22/06/1982", "22/06/2004", "22/06/2010", "22/07/1981", "22/07/1988",
"22/07/2010", "22/07/2013", "22/08/1973", "22/08/2001", "22/08/2013",
"22/09/1983", "22/09/1992", "22/09/1996", "22/09/1998", "22/09/1999",
"22/09/2004", "22/10/1974", "22/10/1976", "22/10/1985", "22/10/1986",
"22/10/1991", "22/10/2012", "22/11/1967", "22/11/1983", "22/11/1984",
"22/11/1995", "22/11/2012", "22/12/1982", "22/12/1983", "22/12/2011",
"23/01/1976", "23/02/1978", "23/02/1982", "23/02/2000", "23/03/1977",
"23/03/1984", "23/03/1994", "23/03/1998", "23/03/1999", "23/03/2000",
"23/03/2001", "23/03/2006", "23/03/2009", "23/03/2011", "23/04/1981",
"23/04/2007", "23/04/2013", "23/06/1998", "23/06/2005", "23/07/1979",
"23/07/2002", "23/07/2013", "23/08/1974", "23/08/1982", "23/08/1985",
"23/08/2005", "23/09/1974", "23/09/1975", "23/09/1985", "23/09/1986",
"23/09/1992", "23/09/1994", "23/09/1996", "23/09/2003", "23/09/2009",
"23/09/2010", "23/10/1979", "23/10/1986", "23/10/1989", "23/10/1991",
"23/11/1973", "23/12/1977", "23/12/1982", "24/01/1967", "24/02/2000",
"24/03/1988", "24/03/1993", "24/03/1997", "24/03/2000", "24/03/2005",
"24/04/1978", "24/04/2012", "24/04/2013", "24/05/1977", "24/05/1982",
"24/05/2002", "24/05/2006", "24/06/1974", "24/06/1981", "24/06/1982",
"24/06/1983", "24/06/1992", "24/06/2009", "24/06/2013", "24/07/1972",
"24/07/1992", "24/07/2008", "24/07/2013", "24/08/1978", "24/08/1983",
"24/09/1984", "24/09/1986", "24/09/1992", "24/09/1996", "24/09/1997",
"24/09/2008", "24/09/2009", "24/09/2011", "24/10/1973", "24/10/1979",
"24/10/1984", "24/10/1985", "24/11/1986", "24/11/1994", "25/01/1977",
"25/02/1994", "25/02/2013", "25/03/1969", "25/03/1975", "25/03/1977",
"25/03/1986", "25/03/1993", "25/03/2010", "25/03/2013", "25/04/2013",
"25/05/2002", "25/05/2007", "25/06/1984", "25/06/1985", "25/06/1999",
"25/06/2002", "25/06/2008", "25/06/2013", "25/07/1972", "25/07/1977",
"25/07/1980", "25/07/1987", "25/08/1969", "25/08/1980", "25/09/1974",
"25/09/1980", "25/09/1985", "25/09/1992", "25/09/1995", "25/09/1996",
"25/10/1976", "25/10/1980", "25/10/1984", "25/10/1991", "25/10/2005",
"25/10/2007", "25/10/2010", "25/11/1971", "25/11/1985", "26/02/1994",
"26/02/2013", "26/03/1977", "26/03/1978", "26/03/1980", "26/03/1985",
"26/03/1992", "26/03/2001", "26/04/2011", "26/05/2010", "26/06/1969",
"26/06/1985", "26/06/2001", "26/06/2002", "26/06/2003", "26/06/2013",
"26/07/1990", "26/07/1999", "26/07/2002", "26/07/2013", "26/08/1977",
"26/08/1980", "26/08/1996", "26/08/2013", "26/09/1974", "26/09/1978",
"26/09/1989", "26/09/1995", "26/09/2001", "26/09/2005", "26/09/2011",
"26/10/1978", "26/10/1985", "26/10/1993", "26/10/2005", "26/10/2010",
"26/11/1971", "26/11/1984", "27/01/1988", "27/02/1984", "27/02/2003",
"27/02/2013", "27/03/1984", "27/03/1992", "27/03/1995", "27/03/1998",
"27/03/2001", "27/03/2003", "27/03/2012", "27/03/2013", "27/04/1971",
"27/05/1976", "27/06/1978", "27/06/1982", "27/06/1985", "27/06/1986",
"27/06/2006", "27/06/2013", "27/07/1971", "27/07/1983", "27/07/1995",
"27/08/2012", "27/09/1973", "27/09/1985", "27/09/1988", "27/09/1993",
"27/09/1995", "27/09/1999", "27/09/2002", "27/09/2005", "27/09/2011",
"27/10/2006", "27/11/1997", "28/01/1976", "28/01/1983", "28/02/2002",
"28/02/2013", "28/03/1977", "28/03/1982", "28/03/1983", "28/03/1990",
"28/03/2000", "28/03/2003", "28/03/2006", "28/03/2012", "28/04/1976",
"28/04/1977", "28/04/1978", "28/04/1983", "28/04/1987", "28/04/2002",
"28/05/1980", "28/06/1977", "28/06/1985", "28/06/2006", "28/06/2013",
"28/07/1982", "28/08/1978", "28/08/1991", "28/08/2012", "28/09/1992",
"28/09/2000", "28/09/2006", "28/09/2011", "28/10/1985", "28/10/1986",
"28/10/1991", "28/10/1993", "28/11/1976", "28/11/1979", "28/11/2001",
"29/01/1953", "29/01/1969", "29/01/1998", "29/03/1974", "29/03/1977",
"29/03/1979", "29/03/1993", "29/03/1999", "29/03/2011", "29/03/2012",
"29/04/1977", "29/04/1978", "29/04/2002", "29/04/2009", "29/05/1978",
"29/05/2013", "29/06/1984", "29/06/2005", "29/07/1975", "29/07/1980",
"29/07/1996", "29/07/2013", "29/08/1978", "29/08/1985", "29/09/1978",
"29/09/1983", "29/09/1992", "29/09/1999", "29/09/2009", "29/10/1976",
"29/10/1985", "29/10/1986", "29/10/1987", "29/10/1995", "29/10/2002",
"29/10/2004", "29/11/1995", "3/01/1975", "3/01/2007", "3/02/1976",
"3/02/1989", "3/02/1992", "3/02/1997", "3/02/1999", "3/03/1969",
"3/03/1982", "3/03/2003", "3/03/2004", "3/03/2008", "3/03/2010",
"3/04/1992", "3/04/1996", "3/04/1997", "3/04/2002", "3/04/2003",
"3/04/2012", "3/04/2013", "3/05/1973", "3/05/1990", "3/06/1976",
"3/06/1982", "3/06/1993", "3/07/1986", "3/07/1996", "3/07/2002",
"3/08/1975", "3/09/1975", "3/09/1985", "3/09/1992", "3/09/1996",
"3/09/2007", "3/10/1973", "3/10/1975", "3/10/1979", "3/10/1980",
"3/10/1988", "3/10/1989", "3/10/1990", "3/10/2006", "3/11/1968",
"3/11/1970", "3/11/1986", "3/12/1981", "3/12/1982", "3/12/1993",
"3/12/1997", "3/12/2002", "30/01/1999", "30/01/2006", "30/01/2007",
"30/03/1977", "30/03/1992", "30/03/2001", "30/03/2011", "30/03/2012",
"30/04/1956", "30/04/1980", "30/04/1998", "30/04/2001", "30/04/2004",
"30/04/2010", "30/04/2011", "30/05/1995", "30/05/2000", "30/06/1976",
"30/06/2004", "30/06/2009", "30/07/1980", "30/07/1982", "30/07/1984",
"30/07/2001", "30/07/2013", "30/08/1976", "30/08/1978", "30/08/1982",
"30/08/1985", "30/08/1989", "30/08/2002", "30/09/1971", "30/09/1974",
"30/09/1980", "30/09/1992", "30/09/1998", "30/09/2011", "30/10/1978",
"30/10/1986", "30/10/1991", "30/10/1995", "30/10/2001", "30/10/2003",
"30/10/2006", "30/11/1978", "30/11/1995", "30/11/2010", "30/11/2012",
"31/01/1980", "31/01/1991", "31/01/1997", "31/01/2006", "31/01/2013",
"31/03/1977", "31/03/1992", "31/03/1995", "31/03/1998", "31/07/1986",
"31/07/2013", "31/08/1978", "31/08/1979", "31/08/1982", "31/08/1983",
"31/08/1993", "31/08/1999", "31/08/2012", "31/10/1984", "31/10/1986",
"31/10/2006", "31/12/1982", "4/01/1982", "4/01/1990", "4/02/1970",
"4/02/1980", "4/03/1971", "4/03/1994", "4/03/1996", "4/03/1998",
"4/03/1999", "4/03/2013", "4/04/1974", "4/04/1991", "4/04/2003",
"4/04/2005", "4/05/1981", "4/05/1982", "4/05/1985", "4/05/2004",
"4/05/2010", "4/06/1993", "4/06/1997", "4/06/1998", "4/06/1999",
"4/06/2002", "4/06/2003", "4/06/2013", "4/07/1985", "4/07/1986",
"4/07/2002", "4/07/2005", "4/08/1977", "4/08/1982", "4/08/1983",
"4/08/1986", "4/09/1978", "4/10/1968", "4/10/1971", "4/10/1974",
"4/10/1977", "4/10/1982", "4/10/1996", "4/10/2001", "4/10/2012",
"4/11/1977", "4/12/1976", "4/12/2000", "4/12/2006", "4/12/2007",
"4/12/2008", "5/01/1983", "5/02/1965", "5/02/2009", "5/03/1974",
"5/03/1981", "5/03/1987", "5/03/2002", "5/03/2010", "5/03/2013",
"5/04/2001", "5/05/1981", "5/05/2010", "5/06/1969", "5/06/1985",
"5/06/2013", "5/07/1975", "5/07/2007", "5/07/2012", "5/07/2013",
"5/08/1986", "5/08/2002", "5/08/2004", "5/09/1977", "5/09/1978",
"5/09/1991", "5/10/1993", "5/10/2005", "5/10/2011", "5/11/1969",
"5/11/1979", "5/11/1981", "5/12/1972", "5/12/1973", "5/12/2006",
"5/12/2012", "6/01/1994", "6/01/2012", "6/02/1970", "6/02/2006",
"6/03/1989", "6/03/2000", "6/03/2001", "6/03/2003", "6/03/2012",
"6/04/1978", "6/04/1994", "6/04/1998", "6/04/2000", "6/04/2009",
"6/05/1969", "6/05/2003", "6/06/1984", "6/06/2013", "6/07/1977",
"6/07/2007", "6/08/1967", "6/08/1973", "6/08/1982", "6/08/2013",
"6/09/1973", "6/09/1977", "6/09/1978", "6/09/1988", "6/09/1999",
"6/09/2005", "6/09/2011", "6/10/1983", "6/10/1985", "6/10/1986",
"6/10/1987", "6/10/1988", "6/10/1993", "6/10/2004", "6/10/2011",
"6/11/1976", "6/11/1981", "6/12/1977", "7/01/1986", "7/02/1995",
"7/02/2006", "7/03/1974", "7/03/1978", "7/03/1979", "7/03/1983",
"7/03/1985", "7/03/1989", "7/03/1991", "7/03/1997", "7/03/2000",
"7/03/2005", "7/03/2011", "7/04/1976", "7/04/1979", "7/04/1986",
"7/04/1987", "7/04/1998", "7/04/1999", "7/04/2005", "7/04/2006",
"7/04/2008", "7/05/1975", "7/05/2010", "7/05/2012", "7/06/1971",
"7/06/1995", "7/07/1977", "7/07/1982", "7/07/1986", "7/07/2010",
"7/08/1980", "7/09/1978", "7/09/1989", "7/09/1999", "7/10/1971",
"7/10/1977", "7/10/1987", "7/10/1993", "7/10/2003", "7/10/2008",
"7/11/1970", "7/11/1980", "7/11/1984", "7/11/2000", "7/11/2001",
"7/11/2002", "7/11/2006", "7/12/1976", "7/12/1978", "7/12/2000",
"7/12/2005", "7/12/2012", "8/02/1968", "8/02/1990", "8/03/1974",
"8/03/1978", "8/03/1979", "8/03/1988", "8/03/1989", "8/03/1993",
"8/03/1994", "8/03/1995", "8/03/2001", "8/03/2003", "8/03/2013",
"8/04/1981", "8/04/1982", "8/04/2008", "8/04/2009", "8/04/2010",
"8/04/2013", "8/05/1981", "8/05/1986", "8/06/1979", "8/06/2001",
"8/07/1975", "8/07/1982", "8/07/2010", "8/07/2013", "8/08/1990",
"8/08/2009", "8/08/2013", "8/09/1978", "8/09/1988", "8/09/1997",
"8/09/2000", "8/09/2006", "8/10/1985", "8/10/1986", "8/10/2002",
"8/10/2003", "8/10/2009", "8/10/2012", "8/11/1970", "8/11/1996",
"8/11/2000", "8/11/2002", "8/12/1977", "8/12/1987", "8/12/1988",
"8/12/1995", "9/01/1971", "9/01/1985", "9/01/2012", "9/02/1970",
"9/02/1982", "9/02/1990", "9/02/1996", "9/03/1982", "9/03/1988",
"9/03/2009", "9/03/2010", "9/04/1986", "9/04/1991", "9/04/1996",
"9/04/2013", "9/05/2012", "9/07/2008", "9/07/2013", "9/08/1991",
"9/08/2002", "9/08/2013", "9/09/1975", "9/09/1982", "9/09/1993",
"9/09/1997", "9/09/1998", "9/09/2008", "9/10/1991", "9/10/1996",
"9/10/2003", "9/10/2012", "9/11/1976", "9/11/1992", "9/11/1999",
"9/12/1988", "9/12/1997"), class = "factor")), .Names = c("neg_decimal_lat",
"decimal_long", "max_drill_depth", "water_level_date"), row.names = c(NA,
15L), class = "data.frame")
The code is as follows
require(ggplot2)
require('ggmap')
plotdata <- plotdata[1:15, c("neg_decimal_lat", "decimal_long",
"max_drill_depth", "water_level_date")]
date <- factor(plotdata$water_level_date,
levels=plotdata$water_level_date[!duplicated(plotdata$water_level_date)])
colormap <- c("darkblue","blue","lightblue", "green",
"yellow", "orange","darkorange", "red", "darkred")
depth <- c(1, 5, 10, 15, 20, 25, 30, 35, 40, 45, 50,60,70,80,90,100,110, #legendrange
120,130,140,150,160,170,180,190, 200, 300, 400,500,600, 700,
800,900, 1000,1100,1200,1300,1400, 1500, 2400)
# static map drawn based on min max of latlong
map.plot<- get_map(location = c(min(plotdata$decimal_long),
min(plotdata$neg_decimal_lat),
max(plotdata$decimal_long),
max(plotdata$neg_decimal_lat)),
source = "osm", zoom=6)
theme_set(theme_bw(base_size = 8))
static.map <- ggmap(map.plot) %+% plotdata +
aes(x = decimal_long,
y = neg_decimal_lat,
z = max_drill_depth) +
stat_summary2d(fun = median, binwidth = c(.01, .01),alpha = 1) +
scale_fill_gradientn(name = "Drill Depth",colours = colormap, breaks=depth,
labels = format(depth), space = "Lab") +
labs(x = "Longitude",y = "Latitude" )+ coord_map()
Dates <- seq(as.Date("1985/1/1"), as.Date("1995/1/1"), "years")
#current loop for date
for (i in seq_along(Dates)){
filename=paste(sprintf('%05d', i), ".png", sep="")
print(static.map)
ggsave(filename=filename,
plot = static.map,
scale = 4,
width = 5, height = 3,
dpi = 300)
}
The overall aim is to get it for example to draw all points that were recorded in 1985-1986 and exclude all others, but also showing each month and the points are drawn at their specific month. These would be made into 12 images. Also watch out as the loop is bugged and keeps printing more of the same map so don't forget to stop it.
A reproducible example would help. It is not clear what the problem is.
This seems to work:
Dates <- seq(as.Date("1985/1/1"), as.Date("1995/1/1"), "years")
for (i in seq_along(Dates)) {
filename=paste(sprintf('%05d', i), ".png", sep="")
print(filename)
}

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