【发布时间】:2020-04-09 19:46:06
【问题描述】:
我有一个包含多个数据列字段的数据框,其中一个是索引变量。它本质上是与特定唯一标识符(单独的索引向量)相关的多个时间序列的事务。如果满足以下条件,我想过滤此数据框:
对应索引的第一个条目(顶部是最近的日期)少于 90 天与交易类型为 P-Purchase(如果第一个条目是 S-Sale 或反之)之间经过的时间(以天为单位)反之亦然(如果先销售再购买)。
我不确定是否应该使用 If else 语句或 dplyr 的 case.when 方法,所以我正在努力解决这个问题。
这是我使用 if else 或 dplyr 的工作脚本示例(生成错误):
使用 for 循环和 dplyr
for (i in length(ciknumbers2)) {
data10 <- if(InsiderList3$`Insider CIK` == ciknumbers2[i])
filter(head(InsiderList3$`Transaction Date`,1)-InsiderList3$`Transaction Date`< 90 &
head(InsiderList3$`Transaction Type`,1) != InsiderList3$`Transaction Type`)
}
- 只是 dplyr
filt_data <- InsiderList3 %>%
filter(
if (`Insider CIK` == ciknumbers2) {
head(InsiderList3$`Transaction Date`,1)-InsiderList3$`Transaction Date`<90 & head(InsiderList3$`Transaction Type`,1) != InsiderList3$`Transaction Type`
} else {
}
) %>%
mutate(totalrows = nrow(.)) %>%
summarize()
InsiderList3 %>%
filter(case_when(`Insider CIK` == ciknumbers2,
head(InsiderList3$`Transaction Date`,1)-InsiderList3$`Transaction Date`< 90,
head(InsiderList3$`Transaction Type`,1) != InsiderList3$`Transaction Type`
)) %>%
tail(1)
索引列表为:
"0001337645" "0001749420" "0001658704" "0001642765" "000852412" "0001499263" "0001769077" "0001239635" "0001790576" "0001198046"
数据框如下所示:
我们将不胜感激帮助在任何一种方法下构建解决方案。
使用示例 dput 更新
dput(InsiderList5)
structure(list(`Insider CIK` = c("0001337645", "0001337645",
"0001337645", "0001337645", "0001337645", "0001337645", "0001337645",
"0001337645", "0001337645"), `Insider Full Name and CIK` = structure(c(1L,
1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L), .Label = c("Bachmann Lisa M (0001337645)",
"Robins Ronald A Jr (0001499263)", "Strub Robert (0001769077)",
"Mueller Andrej (0001790576)", "Schlonsky Michael Allen (0001557088)",
"SRS Investment Management, LLC (0001503174)", "JAMES MICHAEL C (0001365831)",
"THORN BRUCE K (0001215178)", "Ramsden Jonathan E (0001451778)",
"PATEL GOYAL KRUTI (0001770886)", "Asmar Christian (0001787532)",
"Bergman Artur (0001769490)", "Castillo Kirsten (0001808806)",
"Andres Juan (0001760670)", "Jolson Joseph A (0001398113)", "Wilson Jan C. (0001807821)",
"Beeler Brian K (0001641580)", "Magnuson Lee A (0001726150)",
"Fernandes Prabhavathi (0001540883)", "Osbourn William F Jr (0001421529)",
"Morno-Wade Suzan (0001761233)", "Mancini Joseph H. (0001573159)",
"Pasquale Maria E (0001736295)", "STERN ADAM K (0001403497)",
"Heiss Xavier (0001803559)", "Feldman Michael David (0001693649)",
"Dellovo Victor (0001484174)", "Dhanak Dashyant (0001760682)",
"Robinson Douglas (0001383267)", "Barry Corie S (0001676999)",
"KLAERNER GERRIT (0001743681)", "GAY JOHN M. (0001765684)", "Tiscornia Anthony D (0001707972)",
"Nefkens Michael G (0001566846)", "Shulkin David (0001808395)",
"STAFFORD JOHN S III (0001218981)", "Nelson Connia M (0001767555)",
"Boyd Steven (0001706140)", "ARMISTICE CAPITAL, LLC (0001601086)",
"LAROCHE RICHARD F JR (0001012859)", "Holloman James Phillip (0001424987)"
), class = "factor"), `Acquistion or Disposition` = structure(c(1L,
1L, 2L, 2L, 1L, 2L, 2L, 1L, 2L), .Label = c("A", "D", "-"), class = "factor"),
`Transaction Date` = structure(c(18358, 18353, 18353, 18333,
18332, 18332, 18330, 18290, 18155), class = "Date"), `Deemed Execution Date` = structure(c(1L,
1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L), .Label = c("Â", "2020-01-02"
), class = "factor"), Issuer = structure(c(1L, 1L, 1L, 1L,
1L, 1L, 1L, 2L, 1L), .Label = c("BIG LOTS INC", "GMS Inc.",
"ABERCROMBIE & FITCH CO /DE/", "GREEN DOT CORP", "AVIS BUDGET GROUP, INC.",
"GUIDED THERAPEUTICS INC", "Terra Tech Corp.", "MENS WEARHOUSE INC",
"PETSMART INC", "TAILORED BRANDS INC", "ETSY INC", "AVID TECHNOLOGY, INC.",
"Fastly, Inc.", "Ocugen, Inc.", "Avantor, Inc.", "Evelo Biosciences, Inc.",
"Moderna, Inc.", "Harvest Capital Credit Corp", "JMP GROUP LLC",
"Spartan Energy Acquisition Corp.", "Horizon Pharma plc",
"Horizon Therapeutics Public Ltd Co", "RAVEN INDUSTRIES INC",
"Cempra Holdings, LLC", "CEMPRA, INC.", "TIME WARNER CABLE INC.",
"XEROX CORP", "Xerox Holdings Corp", "INCYTE CORP", "DarioHealth Corp.",
"INVIVO THERAPEUTICS HOLDINGS CORP.", "LabStyle Innovations Corp.",
"Matinas BioPharma Holdings, Inc.", "Modigene Inc.", "ORGANOVO HOLDINGS, INC.",
"PROLOR Biotech, Inc.", "CSP INC /MA/", "VERINT SYSTEMS INC",
"BEST BUY CO INC", "DOMINOS PIZZA INC", "Tricida, Inc.",
"Novan, Inc.", "Coupa Software Inc", "DXC Technology Co",
"Hewlett Packard Enterprise Co", "RESIDEO TECHNOLOGIES, INC.",
"ORASURE TECHNOLOGIES INC", "AWARE INC /MA/", "Xencor Inc",
"Hudson Global, Inc.", "Cerecor Inc.", "AMAG PHARMACEUTICALS, INC.",
"AYTU BIOSCIENCE, INC", "EYEGATE PHARMACEUTICALS INC", "INNOVUS PHARMACEUTICALS, INC.",
"ReShape Lifesciences Inc.", "CROSS BORDER RESOURCES, INC.",
"NATIONAL HEALTHCARE CORP", "CINTAS CORP", "ROCKWELL AUTOMATION INC",
"ROCKWELL AUTOMATION, INC"), class = "factor"), Form = structure(c(1L,
1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L), .Label = c("4", "3", "5",
"4/A", "3/A"), class = "factor"), `Transaction Type` = structure(c(1L,
1L, 2L, 2L, 1L, 2L, 2L, 1L, 2L), .Label = c("A-Award", "F-InKind",
"M-Exempt", "S-Sale", "-", "G-Gift", "W-Will", "J-Other",
"P-Purchase", "X-InTheMoney", "D-Return", "C-Conversion",
"I-Discretionary"), class = "factor"), `Direct or Indirect Ownership` = structure(c(1L,
1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L), .Label = c("--D", "-ED",
"--I", "1-I", "---", "-EI"), class = "factor"), `Number of Securities Transacted` = structure(c(44L,
49L, 34L, 54L, 16L, 30L, 17L, 53L, 51L), .Label = c("10133.0000",
"10500.0000", "11165.0000", "11651.0000", "12559.0000", "12962.0000",
"14200.0000", "15452.0000", "16563.0000", "17386.0000", "17500.0000",
"17574.0000", "18349.0000", "18835.0000", "18917.0000", "19453.0000",
"1976.0000", "1988.0000", "20396.0000", "20614.0000", "2156.0000",
"2169.0000", "2231.0000", "22343.0000", "24000.0000", "24150.0000",
"24750.0000", "2750.0000", "2751.0000", "2912.0000", "29733.0000",
"2986.0000", "30643.0000", "3166.0000", "3228.0000", "3326.0000",
"3502.0000", "3610.0000", "36650.0000", "37831.0000", "4136.0000",
"4499.0000", "4536.0000", "46634.0000", "50000.0000", "5800.0000",
"6048.0000", "6479.0000", "6980.0000", "7517.0000", "8579.0000",
"9241.0000", "941.0000", "9488.0000", "9538.0000", "", "1000.0000",
"10000.0000", "1009.0000", "11714.0000", "1200.0000", "1398.0000",
"1405.0000", "1483.0000", "17482.0000", "194.0000", "198.0000",
"2000.0000", "2213.0000", "250.0000", "2885.0000", "2957.0000",
"29636.0000", "3662.0000", "395.0000", "400.0000", "4400.0000",
"4709.0000", "5000.0000", "5200.0000", "5474.0000", "566.0000",
"600.0000", "6000.0000", "603.0000", "650.0000", "6801.0000",
"6841.0000", "7000.0000", "784.0000", "9503.0000", "9740.0000",
"1457.0000", "20000.0000", "33208.0000", "40000.0000", "4603.0000",
"526.0000", "6348.0000", "8037.0000", "16753.0000", "26672.0000",
"100.0000", "1048.0000", "1073.0000", "1080.0000", "10962.0000",
"11349.0000", "1212.0000", "1249.0000", "12698.0000", "1314.0000",
"1354.0000", "1358.0000", "14900.0000", "15000.0000", "15765.0000",
"1607.0000", "1668.0000", "17103.0000", "1748.0000", "20003.0000",
"2067.0000", "2092.0000", "2158.0000", "2398.0000", "2496.0000",
"2602.0000", "3002.0000", "30442.0000", "3057.0000", "3183.0000",
"3750.0000", "4102.0000", "4200.0000", "4500.0000", "4556.0000",
"4785.0000", "4972.0000", "5238.0000", "6161.0000", "6600.0000",
"675.0000", "679.0000", "686.0000", "8201.0000", "8461.0000",
"9518.0000", "1.0000", "1070300.0000", "1122700.0000", "1376795.0000",
"1588800.0000", "1621445.0000", "213321.0000", "288439.0000",
"3500.0000", "3500000.0000", "400000.0000", "4189300.0000",
"500000.0000", "1100.0000", "11500.0000", "120000.0000",
"1200000.0000", "12500.0000", "125000.0000", "134.0000",
"1500.0000", "150000.0000", "1500000.0000", "151162.0000",
"160000.0000", "185724.0000", "190000.0000", "1935.0000",
"200000.0000", "2000000.0000", "215196.0000", "240.0000",
"244133.0000", "2500.0000", "250000.0000", "27320.0000",
"2900.0000", "3100.0000", "3300.0000", "35000.0000", "3900.0000",
"4000.0000", "450000.0000", "4600.0000", "490196.0000", "500.0000",
"51282.0000", "5300.0000", "5400.0000", "54429.0000", "54430.0000",
"5500.0000", "58168.0000", "600000.0000", "6100.0000", "64599.0000",
"6500.0000", "67680.0000", "7100.0000", "7560.0000", "7565.0000",
"76865.0000", "800000.0000", "900000.0000", "91465.0000",
"9700.0000", "10010.0000", "105135.0000", "1069.0000", "115911.0000",
"12.0000", "12213.0000", "1452.0000", "16812.0000", "17895.0000",
"1860.0000", "19050.0000", "1961.0000", "19653.0000", "21046.0000",
"2138.0000", "21600.0000", "21815.0000", "219.0000", "23235.0000",
"2351.0000", "2721.0000", "2777.0000", "2981.0000", "31026.0000",
"35211.0000", "3565.0000", "40585.0000", "4509.0000", "48351.0000",
"4938.0000", "49926.0000", "5352.0000", "5644.0000", "6354.0000",
"651.0000", "6732.0000", "68634.0000", "6874.0000", "709.0000",
"7236.0000", "724.0000", "73.0000", "78170.0000", "7844.0000",
"811.0000", "8500.0000", "8535.0000", "9505.0000", "9509.0000",
"9826.0000", "9827.0000", "1278.0000", "140000.0000", "1475.0000",
"1481.0000", "1838.0000", "1871.0000", "2002.0000", "20439.0000",
"2143.0000", "23202.0000", "2611.0000", "2775.0000", "3028.0000",
"3031.0000", "3032.0000", "320.0000", "3356.0000", "36000.0000",
"3656.0000", "3705.0000", "3748.0000", "40438.0000", "41491.0000",
"4250.0000", "5375.0000", "5681.0000", "5750.0000", "60000.0000",
"639.0000", "67500.0000", "67568.0000", "70000.0000", "7500.0000",
"8707.0000", "8709.0000", "92807.0000", "10417.0000", "1061.0000",
"1088.0000", "1198.0000", "1199.0000", "123.0000", "1433.0000",
"1590.0000", "1604.0000", "1641.0000", "1930.0000", "1931.0000",
"2022.0000", "2023.0000", "2055.0000", "2311.0000", "276.0000",
"2901.0000", "32412.0000", "3398.0000", "3399.0000", "3400.0000",
"3408.0000", "346.0000", "357.0000", "3653.0000", "4159.0000",
"4160.0000", "459.0000", "525.0000", "530.0000", "55316.0000",
"593.0000", "669.0000", "720.0000", "721.0000", "774.0000",
"999.0000", "106447.0000", "11874.0000", "13759.0000", "150.0000",
"153060.0000", "15888.0000", "1652.0000", "180.0000", "19477.0000",
"2216.0000", "231.0000", "28859.0000", "32309.0000", "35449.0000",
"6790.0000", "8960.0000", "9045.0000", "10524.0000", "109027.0000",
"11250.0000", "11900.0000", "11976.0000", "14500.0000", "17023.0000",
"1828.0000", "200.0000", "22500.0000", "25741.0000", "2626.0000",
"26759.0000", "3350.0000", "3550.0000", "36527.0000", "38473.0000",
"450.0000", "4874.0000", "50403.0000", "7246.0000", "7400.0000",
"7754.0000", "9422.0000", "54000.0000", "10006.0000", "104.0000",
"11319.0000", "13697.0000", "15281.0000", "161120.0000",
"16317.0000", "2046.0000", "2188.0000", "254396.0000", "28924.0000",
"300.0000", "3001.0000", "31380.0000", "3272.0000", "3632.0000",
"5581.0000", "7094.0000", "730.0000", "8006.0000", "8187.0000",
"1001.0000", "10611.0000", "10744.0000", "12695.0000", "1300.0000",
"13462.0000", "1400.0000", "1435.0000", "14964.0000", "16575.0000",
"1700.0000", "1713.0000", "1799.0000", "1901.0000", "1948.0000",
"2134.0000", "2294.0000", "2400.0000", "25359.0000", "3000.0000",
"312.0000", "3150.0000", "31513.0000", "34100.0000", "3510.0000",
"3600.0000", "3699.0000", "3710.0000", "3810.0000", "4038.0000",
"40969.0000", "4100.0000", "4477.0000", "4523.0000", "4524.0000",
"4597.0000", "4799.0000", "5129.0000", "5150.0000", "5324.0000",
"5379.0000", "5600.0000", "58355.0000", "5900.0000", "6078.0000",
"6388.0000", "6808.0000", "6966.0000", "700.0000", "703.0000",
"7272.0000", "7300.0000", "7506.0000", "7920.0000", "794.0000",
"8300.0000", "8900.0000", "9118.0000", "37500.0000", "10232.0000",
"11200.0000", "1204.0000", "12260.0000", "153000.0000", "17259.0000",
"17260.0000", "17931.0000", "1825.0000", "19014.0000", "20465.0000",
"21690.0000", "2173.0000", "2370.0000", "2784.0000", "29027.0000",
"29520.0000", "2955.0000", "297.0000", "3200.0000", "36782.0000",
"3700.0000", "3741.0000", "3871.0000", "4119.0000", "4209.0000",
"4534.0000", "48000.0000", "4903.0000", "4969.0000", "51779.0000",
"558000.0000", "6545.0000", "6716.0000", "7962.0000", "8000.0000",
"8240.0000", "8425.0000", "8775.0000", "8888.0000", "9500.0000",
"9810.0000", "1025.0000", "1140.0000", "2030.0000", "2281.0000",
"100000.0000", "12105.0000", "13123.0000", "133499.0000",
"15266.0000", "183570.0000", "9000.0000", "10089.0000", "10781.0000",
"11192.0000", "1162.0000", "11757.0000", "11800.0000", "1363.0000",
"15031.0000", "1576.0000", "163281.0000", "19579.0000", "1960.0000",
"20104.0000", "2024.0000", "2157.0000", "2330.0000", "2371.0000",
"2372.0000", "24299.0000", "25550.0000", "2607.0000", "2608.0000",
"2798.0000", "3474.0000", "3898.0000", "40359.0000", "40820.0000",
"4312.0000", "4469.0000", "4676.0000", "5026.0000", "61744.0000",
"6316.0000", "6391.0000", "785.0000", "8394.0000", "879.0000",
"887.0000", "1409.0000", "14350.0000", "17514.0000", "199.0000",
"2430.0000", "2529.0000", "2964.0000", "3587.0000", "583.0000",
"7153.0000", "7443.0000", "7657.0000", "8640.0000", "1005.0000",
"109.0000", "1122.0000", "11860.0000", "12349.0000", "1282.0000",
"131.0000", "13521.0000", "1366.0000", "13978.0000", "1430.0000",
"14312.0000", "1620.0000", "16359.0000", "1699.0522", "1817.0000",
"1954.0000", "2018.0000", "2102.0000", "21780.0000", "2182.0000",
"2374.0000", "24065.0000", "247.0000", "2470.0000", "2627.8701",
"2810.0000", "30297.0000", "315.0000", "3307.0000", "3462.0000",
"3578.0000", "358.0000", "3830.0000", "3916.0000", "4021.0000",
"4089.0000", "4391.0000", "4412.0000", "470.0000", "4742.0000",
"4776.0000", "4860.0000", "5045.0000", "5110.0000", "5465.0000",
"607.0000", "6418.0000", "659.0000", "672.0000", "740.0000",
"7417.0000", "750.0000", "7574.0000", "7818.0000", "7881.0000",
"8072.0000", "8731.0000", "9047.0000", "1223.0000", "127.0000",
"128.0000", "16428.0000", "1842.0000", "22772.0000", "41193.0000",
"517.0000", "5389.0000", "5928.0000", "6761.0000", "6881.0000",
"76.0000", "77.0000", "10400.0000", "107416.0000", "128299.0000",
"17000.0000", "275000.0000", "278407.0000", "31500.0000",
"416667.0000", "479271.0000", "493.0000", "577901.0000",
"627901.0000", "750000.0000", "80000.0000", "85.0000", "952676.0000",
"3727.0000", "554.0000", "12623.0000", "13135.0000", "14579.0000",
"16901.0000", "2049.0000", "21755.0000", "22338.0000", "2246.0000",
"2373.0000", "24538.0000", "28389.0000", "3265.0000", "3729.0000",
"39462.0000", "3954.0000", "50494.0000", "5584.0000", "5585.0000",
"6134.0000", "6718.0000", "68604.0000", "6991.0000", "7145.0000",
"758.0000", "8197.0000", "9089.0000", "9865.0000", "110.0000",
"1120.0000", "1165.0000", "12000.0000", "1586.0000", "2142.0000",
"2927.0000", "30000.0000", "952.0000", "3844.0000", "48403.0000",
"533.0000", "6878.0000", "101.0000", "10599.0000", "11000.0000",
"1125.0000", "1186.0000", "122.0000", "12200.0000", "12320.0000",
"1344.0000", "1373.0000", "1380.0000", "1432.0000", "14726.0000",
"1524.0000", "1529.0000", "15500.0000", "1555.0000", "1568.0000",
"15762.0000", "1780.0000", "1800.0000", "1841.0000", "1875.0000",
"1979.0000", "2084.0000", "2152.0000", "233.0000", "2409.0000",
"2443.0000", "2635.0000", "2835.0000", "2899.0000", "3070.0000",
"3080.0000", "3096.0000", "3136.0000", "3146.0000", "3296.0000",
"3405.0000", "3419.0000", "3751.0000", "3757.0000", "3849.0000",
"4106.0000", "4107.0000", "4292.0000", "4321.0000", "4645.0000",
"4901.0000", "4931.0000", "503.0000", "5060.0000", "5316.0000",
"5317.0000", "5412.0000", "5497.0000", "5557.0000", "5838.0000",
"5862.0000", "6083.0000", "6168.0000", "6323.0000", "802.0000",
"8487.0000", "9635.0000", "13378.0000", "14906.0000", "1537.0000",
"1643.0000", "21393.0000", "2191.0000", "23384.0000", "23670.0000",
"2451.0000", "25578.0000", "28974.0000", "2982.0000", "3123.0000",
"3134.0000", "31343.0000", "3246.0000", "334.0000", "3426.0000",
"3513.0000", "360.0000", "399.0000", "41123.0000", "4357.0000",
"436.0000", "4404.0000", "443.0000", "523.0000", "545.0000",
"5511.0000", "62829.0000", "6309.0000", "6783.0000", "7170.0000",
"787.0000", "793.0000", "87503.0000", "103.0000", "10854.0000",
"110000.0000", "11108.0000", "1273.0000", "1419.0000", "1503.0000",
"15790.0000", "1615.0000", "164.0000", "18440.0000", "1911.0000",
"1932.0000", "1942.0000", "2369.0000", "2497.0000", "26400.0000",
"2919.0000", "292000.0000", "2995.0000", "2996.0000", "31422.0000",
"3371.0000", "3503.0000", "3504.0000", "3643.0000", "3892.0000",
"3948.0000", "3987.0000", "4146.0000", "496.0000", "5203.0000",
"58.0000", "6685.0000", "68.0000", "727.0000", "9220.0000",
"34000.0000", "1325.0000", "140.0000", "2040.0000", "260.0000",
"261.0000", "268.0000", "285.0000", "306.0000", "407.0000",
"408.0000", "425.0000", "434.0000", "442.0000", "4759.0000",
"501.0000", "51.0000", "519.0000", "52.0000", "54.0000",
"55.0000", "763.0000", "764.0000", "828.0000", "95.0000",
"96.0000", "988.0000", "1011.0000", "102915.0000", "103367.0000",
"10460.0000", "10603.0000", "108193.0000", "1172.0000", "1175.0000",
"11823.0000", "14072.0000", "141881.0000", "143120.0000",
"14724.0000", "147607.0000", "154400.0000", "15745.0000",
"15831.0000", "16526.0000", "18100.0000", "19589.0000", "20700.0000",
"2100.0000", "211406.0000", "215868.0000", "24100.0000",
"25413.0000", "257965.0000", "34.0000", "35340.0000", "36700.0000",
"37845.0000", "39448.0000", "398.0000", "40205.0000", "4025.0000",
"449.0000", "4653.0000", "467.0000", "487.0000", "494.0000",
"4964.0000", "512076.0000", "58767.0000", "636.0000", "681.0000",
"691.0000", "70680.0000", "725.0000", "7843.0000", "834.0000",
"844.0000", "86.0000", "874.0000", "976.0000", "9927.0000",
"8965.0000", "10025.0000", "10150.0000", "103454.0000", "11516.0000",
"120324.0000", "12641.0000", "13000.0000", "13700.0000",
"14000.0000", "14611.0000", "19750.0000", "2225.0000", "24351.0000",
"24653.0000", "25.0000", "25000.0000", "252225.0000", "26888.0000",
"286671.0000", "29500.0000", "30007.0000", "305.0000", "30775.0000",
"30992.0000", "324.0000", "36500.0000", "36965.0000", "37951.0000",
"38099.0000", "38300.0000", "43500.0000", "43720.0000", "44771.0000",
"48312.0000", "5004.0000", "50293.0000", "5217240.0000",
"5308.0000", "5349.0000", "53767.0000", "58000.0000", "58862.0000",
"59863.0000", "6047.0000", "60876.0000", "6215.0000", "63061.0000",
"73423.0000", "75347.0000", "79035.0000", "91677.0000", "92779.0000",
"1041.0000", "1211.0000", "41401.0000", "4282.0000", "772.0000",
"0.0000", "108920.0000", "1374.0000", "1487639.0000", "1567.0000",
"1918587.0000", "1951219.0000", "19569979.0000", "200637.0000",
"2456822.0000", "26611.0000", "300000.0000", "335279.0000",
"3455129.0000", "3907165.0000", "4280.0000", "431489.0000",
"4403409.0000", "49303.0000", "5000000.0000", "76190.0000",
"8433.0000", "85191.0000", "9626.0000", "981282.0000", "1038.0000",
"12131.0000", "133334.0000", "1669.0000", "1921.0000", "1980.0000",
"2331.0000", "2600.0000", "2630.0000", "2959.0000", "378232.0000",
"40235.0000", "4138.0000", "4407.0000", "4473.0000", "4959.0000",
"49921.0000", "51688.0000", "5302.0000", "5726.0000", "7105.0000",
"8635.0000", "96534.0000", "1096.0000", "12386.0000", "12614.0000",
"13726.0000", "14640.0000", "14951.0000", "151.0000", "155.0000",
"159.0000", "162.0000", "166.0000", "181.0000", "182.0000",
"184.0000", "186.0000", "188.0000", "18902.0000", "19376.0000",
"205.0000", "207.0000", "20706.0000", "209.0000", "211.0000",
"213.0000", "220.0000", "235.0000", "2604.0000", "28186.0000",
"286.0000", "314.0000", "31436.0000", "34976.0000", "350.0000",
"3730.0000", "3731.0000", "3745.0000", "385.0000", "4019.0000",
"42282.0000", "432.0000", "448.0000", "5091.0000", "5373.0000",
"5650.0000", "581.0000", "6115.0000", "658.0000", "6981.0000",
"7462.0000", "7523.0000", "7761.0000", "8106.0000", "829.0000",
"84.0000", "875.0000", "8964.0000", "898.0000", "935.0000",
"9762.0000"), class = "factor")), row.names = c(NA, 9L), class = "data.frame")
【问题讨论】:
-
您能否使用
dput分享一些示例数据以及您希望最终结果的样子(图片不是很有帮助)。 -
感谢您的回复。我对 dput 不是很熟悉,当我对数据框进行调用时,我提到它的大量文本不适合此聊天。理想情况下,在过滤标准之后,如果有任何匹配项,我会留下该标识符列表。如果你能告诉如何最好地为你显示数据,我会把它放在聊天中。
-
假设您的
data.frame称为 InsiderList3,您可以使用dput(InsiderList3[1:50, ])共享前 50 行。 -
奇怪的是,即使我选择 10 行,输出也是 50k 个字符。我正在尝试将其添加到问题中。
-
在这种情况下,您应该将其限制为更少的列以创建最小的工作示例
标签: r for-loop if-statement dplyr