【发布时间】:2020-10-11 10:04:38
【问题描述】:
我正在尝试对从 2014 年开始到 2019 年结束的整个研究期间出现的个人进行子集化。因此,输出将是数据帧中每一年都出现的姓名列表。
我试过以下代码:
big_data <- dplyr::bind_rows(df1, df2, df3, df4, df5, df6) # I've bound 6 different dataframes (each with data from one of the years) by row. These dfs have a different number of rows and columns. Some columns repeat in different years, while others don't.
Date <- as.POSIXlt.Date(big_data$Date)
Year <- separate(big_data, Date, into = c('Month', 'Day', 'Year') %>% select(Year)) # I've extracted the Year from the Date variable (DD/MM/YYYY)
Year <- big_data$Year # I've added it to the big_data
Interval <- Year %between% c("2014", "2019") # I've created a timeperiod with the start and end years of the study
big_data [, all.names(FocalID %in% Interval)] # I've tried to get the names of the individuals (in variable FocalID) that are present in the interval (but probably doesn't mean in every year)
显然这段代码不起作用。你能帮帮我吗?谢谢!
【问题讨论】: