【发布时间】:2020-12-18 21:22:27
【问题描述】:
我有两个数据集,分别命名为 E 和 eF。
E<- structure(list(Inception_Date = structure(c(962323200, 962323200,
810950400, 988675200, 1042502400, 1536624000), tzone = "UTC", class =
c("POSIXct","POSIXt")), Name = c("Calvert Social Index B", "Calvert US
Large Cap Core Rspnb Idx A", "Green Century Equity Individual
Investor", "Praxis Value Index A", "Vanguard FTSE Social Index I",
"Amundi IS Amundi MSCI USA SRI ETF DR")), row.names = c(NA, -6L),
class = c("tbl_df", "tbl", "data.frame"))
eF <- structure(list(Inception_Date = structure(c(760233600, 519868800,
1380067200, 1101772800, 1325203200, 628473600, 1325203200, 1123804800
), tzone = "UTC", class = c("POSIXct", "POSIXt")), Name = c("Amana
Growth Investor", "Amana Income Investor", "Amana Income
Institutional", "American Century Sustainable Equity A",
"Ariel Appreciation Institutional", "Ariel Appreciation Investor",
"Ariel Focus Institutional", "Baywood Socially Responsible Invs"
)), row.names = c(NA, -8L), class = c("tbl_df", "tbl", "data.frame"
))
我将以下代码应用于数据 E 和 eF。
for (k in 1:nrow(E)) {
F_temp <- eF;
G_temp <- F_temp %>% filter(abs(F_temp$Inception_Date-
E$Inception_Date[k]) <= 1500);
print(G_temp)}
由于“全球环境”下的“G_temp”显示为0 obs。仅包含 2 个变量(必须是循环列表中的最后一个组件),如何制作一个 .csv 文件,显示所有“G_temp”组件合并在一起删除重复项?
谢谢
【问题讨论】: