0

我一直在摆弄一个 R 项目并遇到了障碍。生病解释目标是什么,它是制作一组图,显示根据测量时间(water_level_date)在地图上绘制的点,并在预选的时间段内相应地绘制。

我遇到的障碍是循环创建其他图但不应用日期限制。所以它产生相同的情节 12 次。我目前使用的循环是

for (i in c(1:length(date)))
filename=paste(sprintf('%05d', i), ".png", sep="")

我只是对循环使用什么感到有点困惑,因为我使用for()作为日期,我认为这是错误的,我想我必须使用seq_along但我不确定如何让它循环一个序列说01/01/198501/01/1986

日期是从数据框中检索的,但问题是它完全忽略了日期。任何帮助将不胜感激。是的,我知道我没有可重复的示例,只是想知道如何正确使用 seq_along 来获取在开始日期和结束日期之间循环的日期列表。

数据

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

代码如下

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

总体目标是让它例如绘制 1985-1986 年记录的所有点并排除所有其他点,而且还显示每个月,并且这些点是在特定月份绘制的。这些将被制作成 12 张图像。还要注意循环被窃听并不断打印更多相同的地图,所以不要忘记停止它。

4

1 回答 1

0

一个可重复的例子会有所帮助。目前尚不清楚问题是什么。这似乎有效:

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)
}
于 2013-11-14T02:58:25.800 回答