statistics - Keep completeness of record when subsetting time series datasets in R -
i'll explain problem better. have downloaded databasee 300,000 observations time span of 16 years. want subset database taking in account completeness.
- i want keep observations complete in terms of year.
example: assuming 3 different items (a,b , c) , time frame of 5 years.
for item have observation years 1 5; item b have observations years 1,2,4,5; item c have year 3.
i want subset dataset new dataset contain item a.
how can translate in code?
in simple way, having not seen data,
name <- c('a', 'a', 'a', 'a', 'a', 'b', 'b', 'b', 'b', 'c') year <- c(1, 2, 3, 4, 5, 1, 2, 4, 5, 3) data <- data.frame(name, year) tmp <- aggregate(year ~ name, data, length) tmp1 <- subset(tmp, year >=5)
Comments
Post a Comment