Problem with correlog function in pgirness - r

I am trying to produce an autocorrelogram using output from the correlog function in pgirmess as is described here.
My UTM coordinate data are: structure(list(V1 = c(698073L, 698095L, 698274L, 697806L, 698602L,
698632L, 697425L, 698272L, 698125L, 697935L, 698681L, 699287L,
698687L, 698042L, 698052L, 697477L, 698096L, 698782L, 698203L,
698113L, 698046L, 697923L, 699398L, 698143L, 698555L, 697973L,
698042L, 698080L, 697918L, 698253L, 698687L, 698719L, 698079L,
697982L, 698273L, 698995L, 698267L, 700678L, 698087L, 698887L,
698599L, 698883L, 697947L, 698159L, 697464L, 697897L, 698867L,
697775L, 698071L, 698043L, 698115L, 697979L, 697976L, 698064L,
698024L, 698048L, 698200L, 698092L, 698328L, 697998L, 697772L,
697957L, 698590L, 698789L, 698060L, 698071L, 699316L, 699094L,
698633L, 699289L, 698089L, 697819L, 697894L, 698000L, 700218L,
700004L, 699684L, 699743L, 726256L, 724864L, 725175L, 725438L,
725778L, 700386L, 700740L, 700701L, 724204L, 724049L, 723872L,
722994L, 698150L, 698197L, 698064L, 698285L, 698685L, 698716L,
698316L, 698170L, 698920L, 699335L, 698273L, 698100L, 698605L,
698089L, 697784L, 697693L, 697990L, 697809L, 697945L, 698108L,
697945L, 697736L, 698567L, 699035L, 697651L, 698062L, 699035L
), V2 = c(1853363L, 1853581L, 1853596L, 1854098L, 1853795L, 1853764L,
1853338L, 1853684L, 1853627L, 1853540L, 1853912L, 1853399L, 1853897L,
1853236L, 1853744L, 1853505L, 1853458L, 1853926L, 1853736L, 1853858L,
1853783L, 1853586L, 1853612L, 1853498L, 1853834L, 1853269L, 1853528L,
1853639L, 1853533L, 1853503L, 1853897L, 1853704L, 1853685L, 1853638L,
1853595L, 1853602L, 1853530L, 1852898L, 1853424L, 1853770L, 1853792L,
1853859L, 1853586L, 1853708L, 1853603L, 1852869L, 1853973L, 1853898L,
1853608L, 1853762L, 1853695L, 1853586L, 1853617L, 1853775L, 1853251L,
1853162L, 1853693L, 1853603L, 1853654L, 1853463L, 1853532L, 1853392L,
1853853L, 1853843L, 1853550L, 1853587L, 1853509L, 1853461L, 1853724L,
1853506L, 1853535L, 1853643L, 1853807L, 1853556L, 1852417L, 1852815L,
1853113L, 1852880L, 1785260L, 1786479L, 1786054L, 1785839L, 1785467L,
1852514L, 1852029L, 1852391L, 1787745L, 1787746L, 1787926L, 1788326L,
1853416L, 1853437L, 1853409L, 1853531L, 1853848L, 1853734L, 1853660L,
1853465L, 1854071L, 1853365L, 1853577L, 1853698L, 1853878L, 1853286L,
1853532L, 1853503L, 1853423L, 1854024L, 1854096L, 1853483L, 1853798L,
1853664L, 1853804L, 1852806L, 1853503L, 1853304L, 1852806L)), class = "data.frame", row.names = c(NA,
-117L))
My response variable data are: c(44.172, 43.975, 43.338, 43.854, 41.475, 42.414, 45.035, 44.025,
43.278, 44.116, 44.606, 44.242, 45.682, 44.495, 42.732, 44.02,
44.626, 43.535, 44.025, 43.409, 43.207, 43.46, 42.505, 45.348,
42.495, 44.505, 43.636, 42.879, 42.086, 43.364, 43.667, 43.005,
43.939, 44.813, 45.364, 42.475, 43.768, 42.909, 43.535, 44.949,
43.187, 42.5, 43.495, 43.318, 42.561, 43.747, 42.005, 44.293,
44.808, 43.702, 42.677, 44.566, 45.237, 43.859, 44.237, 43.909,
44.596, 44.667, 44.04, 44, 42.192, 44.929, 42.949, 43.944, 43.53,
43.298, 43.025, 43.424, 43.712, 42.51, 44.152, 44.01, 41.833,
43.505, 44.646, 44.566, 42.929, 43.636, 44.54, 43.232, 43.182,
42.217, 43.904, 42.864, 43.475, 42.323, 43.025, 43.429, 43.298,
44.914, 42.884, 43.601, 44.475, 42.505, 41.268, 44.227, 42.955,
42.833, 46.056, 44.293, 42.556, 43.717, 43.283, 43.086, 42.707,
43.859, 42.884, 44.682, 41.551, 42.803, 45.242, 42.929, 42.848,
44.288, 43.283, 43.288, 44.444)
I tried:
pgi.cor <- correlog(coords=coords, z=sp.rich$mean], method="Moran",nbclass=11), but this appears to have cause problem calculating distances between the duplicate coordinates:
Error in dnearneigh(coords[-zero, ], breaks[i, 1], breaks[i, 2]) : non-positive number of rows in x
Therefore, I tried: pgi.cor <- correlog(coords=unique(coords), z=sp.rich$mean[-c(31,117)], method="Moran",nbclass=11) (because rows 31 and 117 are duplicates of other rows). However this gives me the same error result. Any ideas? Thanks!

Related

radius in nn2() function in RANN r-package

I was trying to use the solution offered here to find all the location from df which are within the 70 km distance from my point of interest userLocation=c(6.9,55.2), but it does not work properly !
df = structure(list(lng = c(6.2694184, 6.25737207, 6.23839104, 6.25844252,
6.22595901, 6.21351832, 6.2010845, 6.1886414, 6.1762058, 6.1637609,
6.15132287, 6.13887619, 6.12643637, 6.14361895, 6.16332364, 6.18302157,
6.2027276, 6.22242688, 6.24213488, 6.26842752, 6.26745135, 6.24518597,
6.26645948, 6.24420242, 6.22357831, 6.26548171, 6.24321746, 6.2226023,
6.20041884, 6.18070459, 6.16099845, 6.16716672, 6.17960629, 6.18686265,
6.2078525, 6.19203657, 6.20447434, 6.21691835, 6.2293537, 6.24179593,
6.26009321, 6.26448764, 6.2422317, 6.21927538, 6.20186455, 6.26350828,
6.24124514, 6.22028969, 6.26251321, 6.2402584, 6.23404584, 6.26153227,
6.22171658, 5.94065657, 6.10363006, 6.11606487, 6.12850589, 6.14093826,
6.15337749, 6.16582359, 6.17826103, 6.19070472, 6.20313974, 6.20009703,
5.96044213, 5.96988333, 5.98023582, 5.98966667, 5.99910246, 6.00003829,
6.00947365, 6.01889843, 6.02832882, 6.01983402, 6.02925771, 6.038687,
6.0481219, 6.05754688, 6.03963788, 6.04906608, 6.05848435, 6.06792377,
6.07735326, 6.08677283, 6.05941948, 6.06885218, 6.07829049, 6.08771889,
6.09713671, 6.10657633, 6.11600538, 6.07922538, 6.08864707, 6.10756108,
6.12000483, 6.13243993, 6.12019786, 6.14488189, 6.15733073, 6.16977091,
6.16621949, 6.13805015, 6.13652024, 5.941545, 6.20491484, 6.18423897,
6.17806466, 6.16355552, 6.15738696, 6.14558294, 6.14286638, 6.13670293,
6.12217027, 6.11601258, 6.10148275, 6.09533146, 6.08080511, 6.07464337,
6.06011984, 6.03729438, 6.05394895, 6.02546329, 6.0136389, 6.03674112,
6.05743408, 6.07812006, 6.09879971, 6.11948795, 6.11063647, 6.08914275,
6.08440881, 6.0018212, 6.02491713, 5.98999461, 6.01308427, 5.97815849,
6.00125809, 5.96632973, 5.98943792, 5.9995124, 6.02119838, 6.04364466,
6.0223476, 6.04560587, 6.03821257, 6.06131821, 6.06046748, 5.97888909,
5.95766873, 6.24771247, 6.04931495, 6.25538943, 6.23227728, 6.25434093,
6.25329159, 6.25225759, 6.25120656, 6.25015469, 6.24911757, 6.06338238,
6.08539205, 6.10756976, 6.12975108, 6.15193667, 6.17411029, 6.19630377,
6.21848591, 6.22602495, 6.23123663, 6.20931486, 6.23019515, 6.20826628,
6.22915282, 6.20721685, 6.22810966, 6.21962063, 6.20209266, 6.20618216,
6.19702482, 6.1799057, 6.15772301, 6.13554395, 6.11336914, 6.09118237,
6.09738412, 6.11958004, 6.12698723, 6.14767387, 6.16835417, 6.18613747,
6.185096, 6.165456, 6.14476821, 6.15765091, 6.23561071, 6.08001353,
6.22353732, 6.2376767, 6.21143885, 6.19936347, 6.18727866, 6.17520066,
6.16311385, 6.15103386, 6.13894506, 6.12686243, 6.11478725, 6.10270261,
6.09818625, 6.12128852, 6.2468456, 6.22571713, 6.24558662, 6.22445138,
6.24434288, 6.22320086, 6.24308194, 6.22194875, 6.24182062, 6.22068065,
6.24057332, 6.21942655, 6.2113264, 6.22341814, 6.19699748, 6.18490568,
6.1988361, 6.17283631, 6.16074252, 6.14867115, 6.13657473, 6.13954049,
6.16263694, 6.18482009, 6.20327221, 6.20009595, 6.19278885, 6.17005571
), lat = c(54.67598304, 54.83924292, 54.83162024, 54.82483795,
54.82033259, 54.80904336, 54.79775292, 54.78646988, 54.77517665,
54.76389082, 54.75260377, 54.74131515, 54.73002531, 54.72096456,
54.71392047, 54.70687309, 54.69983176, 54.69278713, 54.68573957,
54.68934722, 54.7027117, 54.69910571, 54.71606682, 54.71246092,
54.70614626, 54.72943123, 54.72582507, 54.71951053, 54.71576339,
54.72280423, 54.72985112, 54.74274399, 54.75402944, 54.73569581,
54.72983408, 54.7653223, 54.77660496, 54.78789538, 54.79918423,
54.81047187, 54.80230996, 54.74279524, 54.73918917, 54.74155047,
54.75043676, 54.75615956, 54.75255324, 54.75849353, 54.76951451,
54.76590829, 54.77879358, 54.78287875, 54.84106585, 54.79004116,
54.73264696, 54.7439301, 54.755221, 54.76651031, 54.77779842,
54.78908531, 54.80037062, 54.81166369, 54.82295519, 54.83631649,
54.78306731, 54.79535153, 54.77609951, 54.7883729, 54.80065457,
54.76912877, 54.78140068, 54.7936805, 54.80595963, 54.7621547,
54.77443373, 54.78671208, 54.79898973, 54.81126633, 54.75518666,
54.76746422, 54.77974071, 54.7920169, 54.80429202, 54.81656608,
54.74821493, 54.76049101, 54.7727664, 54.78504073, 54.79732298,
54.80959594, 54.82187682, 54.74124062, 54.75351485, 54.76118719,
54.77247897, 54.78376916, 54.79513973, 54.79505815, 54.80634591,
54.8176321, 54.8309898, 54.82587825, 54.81251828, 54.80340625,
54.85043439, 54.85669012, 54.84379843, 54.8629602, 54.85006754,
54.83850747, 54.86921769, 54.85633303, 54.87548056, 54.86259492,
54.88174916, 54.86885358, 54.88800555, 54.8751176, 54.89427628,
54.89688611, 54.88137801, 54.88534048, 54.87379377, 54.87235508,
54.86608859, 54.85982748, 54.85356275, 54.84730376, 54.83491117,
54.82992904, 54.84309445, 54.86224596, 54.86080945, 54.85069668,
54.84926234, 54.8391549, 54.83771415, 54.82760306, 54.82617384,
54.81401612, 54.81866848, 54.82193287, 54.83203, 54.85454492,
54.8418856, 54.84463218, 54.83126946, 54.807705, 54.81314447,
54.95082492, 54.90870481, 54.85261135, 54.8544958, 54.86597391,
54.87933643, 54.89269028, 54.90605271, 54.91941509, 54.93277779,
54.91930405, 54.92337651, 54.92712528, 54.93087901, 54.93462874,
54.93838307, 54.94213376, 54.94588009, 54.93325056, 54.86785843,
54.86365241, 54.88122101, 54.87701472, 54.89458354, 54.890377,
54.90794604, 54.9204011, 54.92916856, 54.90373959, 54.91606989,
54.92541899, 54.92166542, 54.91791682, 54.91416421, 54.91041621,
54.89753741, 54.90128459, 54.88863077, 54.8823668, 54.87609923,
54.88468492, 54.89804726, 54.89094652, 54.89720452, 54.90830415,
55.08370977, 54.93641839, 55.07226944, 55.06170442, 55.06083624,
55.04939327, 55.03795778, 55.02652115, 55.01508302, 55.00364374,
54.99220296, 54.98077001, 54.96932695, 54.95789135, 54.94469353,
54.94333719, 54.96418243, 54.9585686, 54.97754901, 54.9719349,
54.99090692, 54.98529252, 55.00427341, 54.99865908, 55.01763087,
55.01201625, 55.03099761, 55.02538271, 55.03790915, 55.04934232,
55.02208092, 55.01064489, 54.99998971, 54.99920808, 54.98776941,
54.97632995, 54.9648976, 54.95153594, 54.95007267, 54.95382515,
54.96186591, 54.98662348, 54.97394968, 54.97118391)), class = "data.frame", row.names = c(NA,
-238L))
What I have done is as follow :
Add the point of interest to the beginning of df
df = rbind(userLocation,df)
Set the radius to 0.64 since according to here, every 0.1 is equivalent to 11.1 km !
radius <- 0.64
#Identifying neighbors
res <- nn2(df, k=nrow(df), searchtype="radius", radius = radius)
Since my point of interest is the first row in df I would expect all the non zero index in the first row are the points within my 70 km threshold
Ind <- res$nn.idx[1,][res$nn.idx[1,]>0]
My Ind object has just one value!
Ind
[1] 1
but if I plot the data, all of the points are within 70 km distance :
I would appreciate it if someone could help me here.

Error when using cluster package to compute euclidean distances

I have been working on a text mining project. I have performed some LDA topic modelling and now I have my topic probabilities. I would like to use the cluster package so that I can get the euclidean distances between documents so I can create a network graph, but I keep on getting an error. Any recommendation for good visualisation techniques would also be warmly welcomed :)
library(cluster)
FundDist <- as.matrix(daisy(EUTopicNetworks, metric = "euclidean", stand = TRUE))
Error in daisy(EUTopicNetworks, metric = "euclidean", stand = TRUE) : invalid type character for column numbers 1
In addition: Warning messages:
1: In data.matrix(x) : NAs introduced by coercion
2: In daisy(EUTopicNetworks, metric = "euclidean", stand = TRUE) :
with mixed variables, metric "gower" is used automatically
3: In min(x) : no non-missing arguments to min; returning Inf
4: In max(x) : no non-missing arguments to max; returning -Inf
I have never uploaded reproducible data on this website using the dput() function before. So I hope I have done this correct. I have copied and pasted the output below. Thank you for taking the time to read my problem.
EUTopicNetworks <- structure(list(Filename = c("AT_Burenland_2007.txt", "AT21_Kaernten_07.txt",
"AT12_LowerAustria_07_13.txt", "AT_Nat_2007.txt", "AT34_Salzburg_07.txt",
"AT22_Steiermark_07.txt", "AT36_Tirol_07.txt", "UpperAustria2007.txt",
"AT13_Vienna_07.txt", "vorarlberg2007.txt", "AT_Austria_1.txt",
"AT11_Burgenland_1", "lowe austria 2014.txt", "AT13_Vienna2_14.txt",
"AT21_Kaernten_14.txt", "AT22_Steiermark_14.txt", "AT31_UpperAustria_14.txt",
"AT35_Salzburg_14.txt", "AT36_Tirol_14.txt", "AT37_Vorarlberg_14.txt",
"abbruzzo2007-2013.txt", "calabria2007-2013.txt", "campania2007-2013.txt",
"emiliaromagna2007-2013.txt", "sicily2007.txtt", "friuli2007-2013.txt",
"lazio2007-2013.txt", "liguria2007.txt", "lombardy2007-2013.txt",
"piemonte2007-2013.txt", "puglia2007-2013.txt", "sardinia2007-2013.txt",
"Bolzano_07.txt", "umbria 2007-2013.txt", "valledaosta 2007-2013.txt",
"tuscany2007.txt", "VENETO2007-2013.txt", "abruzzo2014-2020.txt",
"basilicata2014-2020.txt", "calabria2014-2020.txt", "campania2014-2020.txt",
"emiliaromagna2014-2020.txt", "sicily2014.txt", "friuli2014-2020.txt",
"lazio2014.txt", "liguria2014.txt", "lombardia2014-2020.txt",
"piemonte2014-2020.txt", "puglia_14.txt", "sardinia2014.txt",
"Bolzano_14.txt", "umbria2014.txt", "valledaosta 2014-2020.txt",
"tuscany2014.txt", "molise_14.txt", "molise_07.txt", "trento2007.txt",
"trento2014.txt", "ITALIANSTRATEGICPLAN2007-2013.txt", "italyinnovationstrategy2014-2020.txt",
"veneto2014-2020.txt", "aquitanie2014-2020.txt", "aquitanie2007.txt",
"auvergne2014-2020.txt", "auvergne_07.txt", "bretagne2014-2020.txt",
"bretagne_07.txt", "centre2014-2020.txt", "centre2007.txt", "champagne-ardenne 2007.txt",
"champagne-ardenne 2014.txt", "PICARDIE2007.txt", "picardie2014.txt",
"bassenormandie 2007.txt", "bassenormandie 2014.txt", "bourgogne2014.txt",
"bourgogne_07.txt", "midi-pyrenees2007.txt", "midipyrennes14.txt",
"franche-comte2014-2020.txt", "franche-comte_2007.txt", "hautenormandie2007.txt",
"hautenormandie2014-2020.txt", "limousine2014-2020.txt", "limousine2007.txt",
"loire2007.txt", "loire2014-2020.txt", "lorraine2014-2020.txt",
"lorraine2007.txt", "nordpasdecalais2007.txt", "nordpasdecalais2014-2020.txt",
"rhonealpes2014-2020.txt", "rhone-alpes2007.txt", "poitou-charenter2007.txt",
"poituou-charentes2014.txt", "corse2007.txt", "corsica.txt",
"bretagne_07.txt", "bretagne2014-2020.txt", "Baden-Wu_07.txt",
"Baden-wu14.txt", "bavaria2007.txt", "BAVARIA_14.txt", "BERLIN2014-2020.txt",
"Berlin_07.txt", "bradenburgh2014.txt", "Bradenburgh2007.txt",
"bremen2007.txt", "bremen2014.txt", "hamburg_07.txt", "HAMBURGO2014-2020.txt",
"Hessen_07.txt", "Hessian1.txt", "LowerSaxony2_07.txt", "LOWERSAXONY2014-2020.txt",
"Mecklenburg_07.txt", "MECKPOMM2014-2020.txt", "rheinland2014-2020.txt",
"RhinelanPlatz_07.txt", "saarland2014-2020.txt", "saarland_07.txt",
"sachsen-anhalt2014-2020.txt", "sachsen-anhelt2007.txt", "saxony_07.txt",
"saxony_14.txt", "Schleswig-Holstein2020.txt", "Schleswig-Holstein_07.txt",
"thuringia2007.txt", "THURINGIA2014-2020.txt", "Andalucia_2007-2013.txt",
"Andalusia_14.txt", "Aragon_14.txt", "Aragon_2007.txt", "Asturias_2007.txt",
"ES12_Asturias.txt", "Baleares_2007.txt", "Balears_14.txt", "Canarias_07.txt",
"Canaries_14.txt", "Cantabria_2007.txt", "ES13_Cantabria_14.txt",
"Castillala_Mancha_2007.txt", "ES42_Castilla-la_mancha.txt",
"CastillayLeon_dic_2007.txt", "ES41_Castilla-Leon.txt", "ES51_Catalonia_14.txt",
"catalonia2007.txt", "Madrid_2007-13.txt", "Madrid_14.txt", "Murcia_14.txt",
"murcia2007.txt", "Valencia_14.txt", "Valenciana_2007.txt", "laRioja2007.txt",
"CombiEngland_07.txt", "EastWales_07.txt", "NorthernIreland_07.txt",
"Scotland_07.txt", "WestWales_07.txt", "EastWales_14.txt", "England_14.txt",
"Northern_Ireland14.txt", "Scotland14.txt", "Westwales_14.txt",
"malta2007-2013.2.txt", "malta2014-2020.txt2.txt"), Funds = c(0.028649302,
0.036198106, 0.041060412, 0.036543709, 0.047044295, 0.01659907,
0.019221094, 0.056763265, 0.052615278, 0.045216842, 0.048176521,
0.038976137, 0.027341846, 0.037721688, 0.049252945, 0.05918185,
0.05440539, 0.017412537, 0.029307636, 0.022385126, 0.019737738,
0.027626844, 0.0334503, 0.043976555, 0.042856083, 0.021046234,
0.018061427, 0.014983543, 0.067145641, 0.019741648, 0.019018285,
0.030614714, 0.019666862, 0.028158874, 0.026009936, 0.019330949,
0.023088856, 0.044273539, 0.021168401, 0.017627883, 0.030486684,
0.017509486, 0.034035728, 0.034106673, 0.043486846, 0.029087254,
0.050564915, 0.047219925, 0.051437475, 0.029694445, 0.008588781,
0.045469371, 0.060967658, 0.049260664, 0.015106536, 0.026186649,
0.023254401, 0.053579943, 0.031056644, 0.045125396, 0.057680642,
0.01125217, 0.042532521, 0.041545015, 0.047940862, 0.036641552,
0.072252939, 0.035679102, 0.067488953, 0.008492444, 0.021052205,
0.020152732, 0.040564092, 0.02921307, 0.018565646, 0.022775302,
0.011711217, 0.019967731, 0.00877454, 0.022250866, 0.003696986,
0.011277284, 0.007740289, 0.02790784, 0.008134596, 0.014931457,
0.03269353, 0.041386999, 0.066164327, 0.011440048, 0.006215758,
0.010688796, 0.003811851, 0.003303556, 0.023094521, 0.010550119,
0.018023822, 0.022757839, 0.017667203, 0.02073341, 0.013537221,
0.011950717, 0.009010298, 0.019796088, 0.011314152, 0.01098032,
0.008832217, 0.040330019, 0.005822583, 0.006599734, 0.016338338,
0.013906508, 0.010973094, 0.010448791, 0.003723683, 0.013769165,
0.007583811, 0.009724543, 0.00237987, 0.005005899, 0.005048481,
0.013000829, 0.012671508, 0.003054379, 0.03508621, 0.012981055,
0.021982606, 0.009448894, 0.014883524, 0.018772709, 0.006068872,
0.018122102, 0.020449118, 0.015102835, 0.005449833, 0.011014679,
0.016602374, 0.006482356, 0.009969209, 0.002646448, 0.01205523,
0.04659564, 0.010866707, 0.0144986, 0.046946229, 0.028629168,
0.034634807, 0.059078927, 0.002919951, 0.016168915, 0.024403654,
0.09171777, 0.009978063, 0.015196456, 0.015174811, 0.047399696,
0.015303701, 0.011753077, 0.014862118, 0.01487099, 0.011742448,
0.018346786, 0.010785336, 0.010421162, 0.013791872, 0.026389358
), Biotech = c(0.024814541, 0.005668351, 0.017716491, 0.00853945,
0.015916015, 0.03888657, 0.001333459, 0.017368849, 0.023781704,
0.051278428, 0.005484117, 0.021759003, 0.027973849, 0.002774256,
0.005744201, 0.004244159, 0.00468969, 0.000581776, 0.022734494,
0.03445351, 0.000800523, 0.000362683, 0.026945766, 0.006823146,
0.005847249, 0.000630851, 0.020794353, 0.035979974, 0.006165474,
0.027793267, 0.00504312, 0.018927097, 0.000760576, 0.012289583,
0.002109001, 0.000442817, 0.000594334, 0.00037428, 0.06596126,
0.027988907, 0.019067461, 0.024872467, 0.015379713, 0.015295277,
9.36e-05, 0.000117979, 4e-05, 0.031220784, 0.001357913, 0.040951957,
0.000438858, 0.038880733, 0.00115553, 0.041152387, 0.042576251,
0.002254845, 0.022345729, 0.002596388, 0.022562024, 0.000243528,
0.000885187, 0.013339204, 0.001418329, 0.028089687, 0.002057198,
0.000244579, 0.000140129, 0.051721762, 0.014989271, 0.001673642,
0.04500578, 0.001615416, 0.00010688, 8.18e-05, 0.000526549, 0.024849247,
0.032961749, 0.033875354, 0.032145136, 0.012619383, 0.003522134,
0.012225185, 0.043464039, 0.077400519, 0.056308327, 0.020638077,
0.049992043, 0.038864222, 0.039459316, 0.034937031, 0.037406742,
0.029987413, 0.002413193, 0.000584526, 0.004584848, 0.012491496,
0.031710331, 0.017858395, 0.030812232, 0.003435739, 0.02648106,
0.006927007, 0.030785802, 0.044329986, 0.009838859, 0.002951219,
0.030722621, 0.020511401, 0.013623405, 0.081263322, 0.029623712,
0.003790876, 0.00335598, 0.018842609, 0.008430911, 0.032611226,
0.057455638, 0.004304486, 0.015733474, 0.043981231, 7.95e-05,
0.004054158, 0.045173701, 0.016378658, 0.015906368, 2.92e-05,
0.00057313, 0.00079682, 0.013209159, 0.039911915, 0.000237856,
0.022373161, 0.015821272, 0.026750309, 0.048698356, 0.041430357,
0.00287091, 0.007965338, 0.034481633, 0.001543219, 0.022152119,
0.041801127, 0.017463336, 0.038010604, 0.050393079, 0.045031199,
0.043613378, 0.037411148, 0.00186188, 0.018962051, 0.043254408,
0.018666636, 0.027696462, 0.024293257, 0.062711642, 0.000519461,
0.001056595, 0.031300324, 0.024742217, 0.024718682, 0.000780182,
0.01862668, 0.000973041, 0.000542227, 0.001011475, 0.011077226
), Transfers = c(0.00473547, 0.00038783, 0.000424567, 0.000695775,
0.000135175, 0.010334213, 0.000106781, 0.003008423, 0.000608193,
0.010326284, 0.000934925, 0.031277279, 0.00572826, 0.000260722,
0.001021529, 0.000154104, 0.000220061, 4.32e-05, 0.018335222,
0.013011634, 2.49e-05, 4.83e-05, 0.021935677, 0.000390414, 0.000130749,
3.77e-05, 0.009460382, 0.146681735, 7.44e-05, 0.082389135, 0.000592343,
0.000562132, 1.53e-05, 0.020403948, 1.31e-05, 2.46e-05, 5.51e-05,
0.000321357, 0.037377138, 0.006516009, 0.022055996, 0.041838049,
0.002549792, 0.00271147, 8.55e-05, 0.001550897, 0.001094715,
0.002059784, 2.73e-05, 0.012813067, 9.84e-06, 0.009924993, 8.74e-05,
0.004619721, 0.013069859, 2.14e-05, 0.053722696, 5.79e-05, 0.006753522,
1.18e-05, 0.005116721, 0.000108002, 2.73e-05, 0.003596542, 2.79e-05,
0.00438903, 8.31e-05, 0.026310482, 0.001005592, 0.000428282,
0.049529581, 1.93e-05, 8.57e-05, 0.001610554, 9.92e-06, 0.094923027,
0.031919217, 0.13955002, 0.083229087, 0.000284159, 0.000267466,
0.000349366, 0.056697448, 0.049064161, 0.075636951, 0.004204928,
0.006115066, 0.007264789, 0.002044115, 0.043477142, 0.046506897,
0.082070827, 0.00035585, 0.010126049, 0.000178782, 0.000133394,
0.019258021, 9.19e-05, 0.069771158, 0.164961859, 0.030302868,
0.008376654, 0.095394069, 0.069931231, 0.000553351, 0.000544636,
0.095332857, 0.001748097, 0.000288915, 0.049584358, 0.095331287,
0.000598831, 0.001574565, 0.124263691, 3.34e-05, 0.107925558,
0.087354139, 0.000618826, 0.000110399, 0.035831715, 5.52e-06,
0.003000538, 0.076722556, 0.001625612, 0.00057855, 2.15e-05,
6.78e-05, 0.000268523, 0.000567245, 0.04113056, 1.71e-05, 0.03401376,
0.001848523, 0.029357767, 0.078771496, 0.05552954, 0.068487283,
0.001617493, 0.045003856, 0.000170027, 0.102169304, 0.033286348,
0.000645582, 0.123061518, 0.024437451, 0.002628661, 0.013120533,
0.002000205, 0.000545963, 0.103891281, 0.01547252, 0.004918401,
0.032767954, 0.084638687, 0.093356166, 0.000156201, 0.000752217,
0.109659324, 0.208642497, 0.208474925, 0.000404265, 0.078084401,
0.000538784, 0.012066067, 0.018067282, 0.000205862), Collab = c(0.030001488,
0.036707564, 0.01458121, 0.026231048, 0.018525526, 0.011553297,
0.058634057, 0.001686141, 0.001348074, 0.006757227, 0.013508918,
0.003715637, 0.002921306, 0.009278328, 0.004626478, 0.002879119,
0.055770088, 0.095661212, 0.017193222, 0.004260887, 0.0994825,
0.094794299, 0.00236101, 0.05708391, 0.070789976, 0.093534164,
0.001109712, 0.009766358, 0.033402635, 0.011669702, 0.06682796,
0.001608723, 0.076258585, 0.0177607, 0.081032098, 0.094412392,
0.105163053, 0.000130001, 0.000308904, 0.000673957, 0.000108183,
0.006185235, 0.001417778, 0.001392482, 0.001763266, 4.19e-05,
0.000316372, 0.000538187, 0.057255911, 0.000888558, 0.117687659,
0.002003037, 0.068194122, 0.000653657, 0.000152612, 0.089555908,
0.002829031, 0.032391752, 0.000114824, 0.001213285, 0.000386851,
0.015705495, 0.049863754, 0.000186015, 0.036288112, 0.000121075,
0.001514642, 0.00150885, 0.000594681, 0.139375952, 0.002323917,
0.075647519, 0.002870689, 3.77e-05, 0.077144908, 0.026437255,
0.000115174, 0.00227099, 0.004700389, 0.041492391, 0.122675327,
0.020817113, 6.89e-05, 0.000303617, 0.000137477, 0.001432608,
0.000184365, 0.001050974, 0.000709209, 0.000270104, 0.000303001,
0.018320147, 0.099247105, 0.082998488, 0.000888759, 0.016183068,
0.006294048, 0.002853816, 0.019514895, 0.038458183, 0.002923949,
0.106293548, 0.011739459, 0.000128574, 0.007004556, 0.114129525,
0.012154148, 0.00942754, 0.009594396, 1.79e-05, 0.003734627,
8.05e-06, 0.119908919, 0.018081544, 0.075305864, 0.008538072,
0.000172614, 0.011539718, 0.001156176, 2.3e-05, 0.06492041, 0.12754611,
0.00024379, 0.006267908, 0.00306844, 0.001193837, 0.013286424,
0.113241894, 0.00550093, 0.000513184, 0.164987722, 0.008430982,
0.01127053, 0.00073653, 0.000330426, 0.002238095, 0.104762755,
0.010050252, 0.000469937, 0.145991698, 0.016278919, 0.000640692,
0.005282822, 0.005445685, 0.00014593, 0.000589578, 0.003085291,
0.003763146, 0.118843056, 0.019891671, 0.007112815, 0.004553507,
0.014161345, 0.011043344, 1.65e-05, 0.05419503, 0.107074967,
0.01952576, 0.015831838, 0.015618949, 0.133629759, 0.016718132,
0.120940954, 0.072855599, 0.066799617, 0.006925232)), .Names = c("Filename",
"Funds", "Biotech", "Transfers", "Collab"), class = "data.frame", row.names = c(NA,
-166L))
As #Cath mentioned, your problem is with the column of text. Removing this works:
EUTopicNetworks2 <- EUTopicNetworks[,-1]
class(EUTopicNetworks2)
library(cluster)
FundDist <- as.matrix(daisy(EUTopicNetworks2, metric = "euclidean", stand = TRUE))
By running this code I was able to answer the question I posed in one of the comments
row.names(EUTopicNetworks) <- EUTopicNetworks[,1]
EUTopicNetworks <- EUTopicNetworks[,-1]
library(cluster)
FundDist <- as.matrix(daisy(EUTopicNetworks, metric = "euclidean", stand = TRUE))

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

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

How to plot multiple graphs in one figure in r

I have a problem when plotting two datasets in one figure. The second dataset (B(57,4)) were derived from the first one (2000+,10)(average, std). In the end, I want to get figure like this:
Now I use the code following to plot the second dateset:
my.data<-read.table(paste(i,"myTS.dat",sep = ""),header = TRUE)
x<-my.data$time
y<-my.data$wl
sd<-my.data$wlsd
tiff(paste(i,".tiff",sep = ""),height=3815,width=4305,unit='px',compression="lzw",res=360)
gg<-qplot(x,y,xlab = "time",ylab = "Elevation")
gg_type1<-geom_line(colour = "blue",size = 0.5)
gg_type2<-geom_point(size = 3,shape=21,fill="white")
gg_bar<-geom_errorbar(aes(x = x,ymin = y-sd,ymax=y+sd),colour = "red",width=0.05)
gg_theme<-theme_set(theme_bw())+ theme(panel.grid.major=element_line(colour=NA))
p<-gg+gg_type1+gg_type2+gg_bar+gg_theme
print(p)
dev.off()
And get figure like this:
How to add the first dataset to the figure just like the grey points in first picture? I tried this but it didn't work.
origin<-read.table(paste("origin_",i,".txt",sep = ""),header = TRUE)
xo<-(origin$time)
yo<-(origin$height)
p<-gg+gg_type1+gg_type2+gg_bar+gg_theme+geom_point(aes(xo,yo))
Any suggestions or help are greatly appreciated.Thanks.
Okay, I put the my.data here:
structure(list(time = c(2010.586, 2010.74, 2010.819, 2010.822,
2010.901, 2011.052, 2011.132, 2011.205, 2011.285, 2011.364, 2011.444,
2011.518, 2011.597, 2011.677, 2011.748, 2011.827, 2011.83, 2012.06,
2012.063, 2012.142, 2012.213, 2012.292, 2012.372, 2012.525, 2012.604,
2012.683, 2012.757, 2012.836, 2013.066, 2013.068, 2013.148, 2013.219,
2013.299, 2013.381, 2013.452, 2013.46, 2013.532, 2013.611, 2013.69,
2013.844, 2013.923, 2013.997, 2014.077, 2014.156, 2014.23, 2014.307,
2014.389, 2014.46, 2014.468, 2014.54, 2014.622, 2014.701, 2014.773,
2014.852, 2014.855, 2014.934, 2015.085), wl = c(4716.69614519141,
4717.18695721942, 4716.95137413031, 4716.95215915847, 4716.95617293713,
4716.73451112085, 4716.91538177926, 4717.00588936267, 4716.78311524661,
4716.88238213472, 4716.98192878285, 4716.97499735093, 4716.96400457306,
4717.15611670712, 4716.99386029174, 4717.05634753127, 4716.96808398258,
4717.3385179692, 4716.69473283737, 4717.0563764012, 4716.97307380063,
4717.54419855758, 4716.6528308359, 4716.79914374548, 4716.87207534116,
4716.70372924768, 4716.88957602414, 4716.77689686401, 4717.089005203,
4716.79885280683, 4717.32157811021, 4716.4542772104, 4716.57303829829,
4716.69165719355, 4716.75878030774, 4716.51425619761, 4716.69628661921,
4716.76718193149, 4716.83711216341, 4716.56437245363, 4716.80095589741,
4716.92953229352, 4716.54242002516, 4719.15933244319, 4716.60029813372,
4716.77020818021, 4716.46140477099, 4716.89015101807, 4717.00917071744,
4716.45796269575, 4716.71523494857, 4716.42773085329, 4716.16425299646,
4716.56107921007, 4716.89280970058, 4716.72261405892, 4716.88387012439
), wlsd = c(0.216549886343437, 0.0482189681060723, 0.0588960842643573,
0.175719434105253, 0.0512158233301561, 0.0392292465112816, 0.0595950831354654,
0.0607877904822251, 0.0370930552408838, 0.617268490833093, 0.0383914957042668,
0.605527813866314, 0.0543574451035527, 0.0545768826476366, 0.0507742835767385,
0.0583394912905697, 0.0563566145080252, 0.0912149956407483, 0.0448705108316624,
0.069484057343461, 0.0458673635595506, 0.0758663652549518, 0.0379866112968593,
0.706702525314332, 0.0424187676989381, 0.0371769559424733, 0.0593394645898105,
0.0502308178338169, 0.0539188048527388, 0.0557205808317756, 0.0960199790307439,
0.0377344405056613, 0.623137480604024, 0.0450269480801559, 0.0638249721374399,
0.0375489717974975, 0.0376544472258395, 0.622074959650495, 0.186283259878619,
0.0492906734226584, 0.0523743622696856, 0.0486222624919726, 0.115848182732971,
0.115018243869508, 0.0427547194026263, 0.0702039197853462, 0.0414918973327205,
0.0520070741917287, 0.0585758170986699, 0.0377079876736141, 0.0392247467180624,
0.616261504979872, 0.263302559470029, 0.0486800241034257, 0.0514939409350517,
0.0509628426691605, 0.0480276613429565)), .Names = c("time",
"wl", "wlsd"), class = "data.frame", row.names = c(NA, -57L))
The original data are quite long to post. Just similar to my.data, but contains more rows.

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)
}

Resources