How can I display subsets of temporary data?

I have input and a subset to see only rows with position 4 or 5 in a column called CODE. Then I selected this data to be able to look at a specific view. Then I made sure that the entries in the DATE column were read as a date, and not as a factor (which was the default). Then I draw two columns against each other:

ph<-read.csv(url("http://luq.lternet.edu/data/lterdb88/data/Lfdp1-ElVerdePhenology.txt"))
ftsd<-subset(ph, ph$CODE %in% c("4","5"))
DACEXC<-subset(ftsd, ftsd$SPECIES %in% "DACEXC")
DACEXC$DATE<-as.Date(DACEXC$DATE, format="%m/%d/%y")
plot(DACEXC$DATE,DACEXC$NUMBER)

The data goes from 1992 to 2007, and I would like to build one year at a time. I will do this for many species, but I cannot figure out how to do this. I tried a number of things, including limiting the x axis or trying to make a subset of just one year, but didn't get it. I tried some of the following ideas:

plot(DACEXC$DATE,DACEXC$NUMBER, xlim=c(1992,1993))
plot(DACEXC$DATE,DACEXC$NUMBER, xlim=c(01/01/1992,12/31/1992))
plot(DACEXC$DATE,DACEXC$NUMBER, xlim=c(1992:1993))

DACEXC92<-subset(DACEXC92, DATE==1992)
DACEXC92
[1] DATE    BASKET  SPECIES CODE    NUMBER 
<0 rows> (or 0-length row.names)

, , .

DACEXC92<-subset(DACEXC92, DATE==04/01/92)
DACEXC92
[1] DATE    BASKET  SPECIES CODE    NUMBER 
<0 rows> (or 0-length row.names)

, , ?

+3
2

DateTimeClass (POSIXct Date), , .

 DACEXC$DATE <- as.POSIXct(strptime(DACEXC$DATE, "%Y-%m-%d"))

(as.Date(DACEXC$DATE) as.POSIXct(DACEXC$DATE), , , , , , ).

POSIXlt :

 with(DACEXC[as.POSIXlt(DACEXC$DATE)$year + 1900 == 1993, ], plot(DATE, NUMBER))

:

with(DACEXC[as.POSIXlt(DACEXC$DATE)$year + 1900 %in% 1993:1995, ], 
     plot(DATE, NUMBER))

, DateTime, format(DACEXC$DATE, "%Y") == "1993".

. ?strptime ?DateTimeClasses .

+4

, xlim :

with(DACEXC,
  plot(DATE,NUMBER, 
     xlim=as.Date(c("1992-01-01","1992-12-31"))
  )
)

:

enter image description here

, xlim, . , chron:

library(chron)
DACEXC92 <- DACEXC[years(DACEXC$DATE)==1992,]
with(DACEXC92,plot(DATE,NUMBER))

:

enter image description here

+3

Source: https://habr.com/ru/post/1795669/


All Articles