#r #dataframe #nested
Вопрос:
У меня есть следующий фрейм данных, в котором я хотел бы объединить все значения в data
столбце (таблица в этом вложенном фрейме данных), а затем mutate
6 соответствующих переменных в df.test
, чтобы сохранить эти значения.
structure(list(Unipro.ID = c("Q13177", "Q8TD19"), Gene.name = c("PAK2",
"NEK9"), Mod.site = c("Q13177_278", "Q8TD19_81"), Mod.site2 = c("PAK2_278",
"NEK9_81"), `mod.or.not(Y/N)` = c("Y", "Y"), `kinase.or.not(Y/N)` = c("Y",
"Y"), data = list(structure(list(`First Scan` = c(18638, 18640,
18699, 18889, 18890, 19117, 19277, 19387, 19395, 19495, 19502,
19576, 19650, 19726, 19802, 19879, 19956, 20034, 20111, 20189,
20266, 20342, 20420, 20497, 20574, 20670, 20727, 20803, 20918,
20956, 21033, 21147, 21185, 21263, 21377, 21416, 21492, 21607,
21646, 21762, 21840, 21879, 21994, 22072, 22113, 22240, 22298,
22356, 22473, 22530, 22703, 22760, 22820, 22936, 23012, 23165,
23243, 23281, 23396, 23472, 23572, 23590, 23665, 23741, 23760,
23894, 23970, 23990, 24122, 24200, 24372, 24428, 24568, 24605,
24661, 24702, 24860, 25051, 25116, 25457, 25459, 25470, 25522,
25806, 26042, 26288, 26516, 27123, 27344, 27573, 27867, 28024,
28224, 29830, 30443, 32854), TMT126 = c(0, 0, 0, 0, 0, 0, 0,
0, 0, 0, 683.603289421257, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
0, 0, 0, 0, 0, 0, 0, 1058.63721546934, 5105.06075558397, 0, 0,
0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 786.877999584963, 0, 0, 0, 0, 0,
0, 0, 0, 0, 0, 0, 0, 1158.61443528477, 0, 0, 0, 0, 0, 790.552967308115,
1769.24251582031, 0, 0, 4230.5333458008, 0, 754.027149866911,
0, 0, 937.667214973757, 0, 0, 16065.4787548108, 0, 1033.79325384522,
0, 1545.17012178734, 22490.6473715619, 0, 12391.863457809, 1694.80635977683,
1669.92554702357, 2915.19207246094, 1305.76068893333, 1218.70367092158,
1724.48555844726, 1220.71902820389, 1142.29342043404, 15089.1510828024,
786.642299340822, 0, 0, 803.014098225646), TMT127N = c(0, 0,
0, 0, 0, 0, 0, 865.592199462889, 0, 0, 959.490090490725, 0, 0,
0, 3632.481907304, 0, 0, 0, 0, 0, 2281.36683418381, 0, 0, 1148.88409380685,
2282.96815473633, 0, 737.964767776176, 0, 0, 714.336386722035,
1336.78857436523, 0, 992.266982382272, 0, 8167.51299697265, 1481.83583737793,
0, 0, 0, 0, 0, 994.583403515622, 0, 3822.09582135578, 730.363546764861,
0, 0, 1601.84151123047, 0, 0, 0, 0, 1248.0926793457, 0, 2349.57136347657,
0, 925.784469760195, 0, 0, 0, 0, 0, 0, 0, 2869.82125708008, 779.87640303955,
0, 4092.33059296876, 0, 0, 0, 1133.40195924235, 0, 0, 0, 15684.5063332031,
0, 0, 0, 2583.52765913085, 24540.0170683595, 1238.62926386719,
11428.895775, 1483.56418256835, 1332.67443391114, 1825.25018671875,
1123.61925747071, 1030.31205838623, 1533.51140185547, 2153.17955595703,
1008.89100509033, 12831.9995203125, 1684.62781442872, 0, 1136.51165412598,
0), TMT128C = c(1611.91088437501, 1786.68805515069, 0, 1823.53765170799,
874.032758349609, 0, 0, 1177.50190689896, 646.466474431654, 1499.41582602539,
1255.4240426748, 1783.93500465848, 5996.15327152243, 8208.12153691405,
21348.7184882813, 33456.1981237878, 46046.4520991817, 5945.01241588586,
6798.69927773436, 18048.0166453125, 3490.51877753905, 7744.45986702618,
11529.8069519532, 3396.17701757812, 4651.27894687501, 14325.2306858641,
1561.40410561524, 0, 9592.47815625001, 2089.33504892578, 3367.76334082031,
10669.6799841273, 1439.18170268554, 0, 9310.75753007808, 1700.90959455201,
0, 6206.48464218753, 3397.72012818408, 0, 7079.64974935495, 1845.17109756826,
1177.34360229492, 6097.26335625001, 1754.74566738282, 1392.17984296875,
7026.71143068691, 2193.1615467585, 2836.98221749547, 6301.54294276034,
0, 3623.93436796874, 1312.70517940113, 0, 4724.16524276671, 0,
3946.52595689374, 2970.83282951206, 865.842519287108, 3283.01703994418,
0, 0, 1262.2417984723, 3482.3909258789, 4262.98461721732, 725.868942626953,
3139.75638657914, 6559.00482506506, 719.443235961914, 1980.26911301631,
735.412520327744, 2538.58699423828, 0, 0, 3345.73545624628, 17476.7195602775,
0, 3061.52193035407, 0, 3370.09478829905, 23476.7103351433, 1087.0128899699,
11912.6099077086, 1957.73038989257, 3158.21345361328, 3399.21823401529,
2593.01804501953, 934.40066220703, 2667.04373535038, 2390.35165488282,
1286.71902949219, 13590.0106023424, 1817.04336728435, 720.287557226125,
916.984646430313, 0), TMT129N = c(5236.22537109374, 5253.53062265625,
2574.52071173515, 6331.35667763673, 2909.4254578125, 2260.77584003907,
2299.19597588428, 2146.42980395508, 1524.82949099121, 4594.55742216798,
2945.06894956055, 3353.94465205077, 17265.8083640626, 58543.518953906,
42651.7719375001, 85288.5246984373, 147283.5420375, 16268.584838086,
31273.8547945313, 64984.9260843748, 15376.6111124999, 18807.9172359374,
41234.0440359375, 7038.37527421877, 14994.4310613281, 35007.7380726561,
5527.67209306639, 8827.66559818178, 32485.2518203124, 6771.8957270508,
10744.4285308594, 21706.4754328126, 7351.69939775389, 7286.74206159669,
31413.8810906249, 5402.31355253905, 7530.87224590352, 22346.2738640626,
7845.50157832029, 8598.84479102795, 13646.5870857421, 3948.41240126953,
4709.55193242188, 14502.506803125, 5527.37162548826, 4609.58657929687,
17346.4145701172, 3806.28572124023, 6695.23604707033, 10312.3288382812,
5030.34046109047, 12238.5130183594, 4008.11956391603, 3366.81581267473,
10163.4030287109, 5657.196356792, 9102.44150449222, 3997.46163222657,
3410.17096083986, 7459.02988359372, 2817.01574699993, 3228.9395395409,
1668.4944914795, 8344.1621935547, 6186.76663623048, 4037.21344028321,
4953.59359042969, 6163.53660527345, 2403.32564355468, 7143.26629951174,
1674.84291965332, 6149.94359912111, 2371.20030146484, 2708.46439392749,
8739.23083300782, 17708.4475347656, 2940.52380873895, 6755.28018515623,
2318.903026372, 5194.7135689453, 37003.6496414061, 1967.3172459961,
11835.060703125, 6357.79309687501, 6929.07336386721, 4922.18842499999,
5119.39548720702, 5098.90275791014, 5251.26713525389, 3925.45210825196,
3679.82248959962, 14610.4555587891, 3124.13869614258, 1892.91264873047,
2424.18607792969, 1217.02803508301), TMT130C = c(8534.51942065459,
7915.5220132809, 5427.32003829632, 6570.76122664215, 4059.66840776324,
6061.80182135341, 4680.93892861494, 3924.40329255471, 1651.02954082353,
9963.97493859979, 2095.70639501953, 6791.52962729408, 29089.1005494669,
84188.5986999335, 79102.1477485965, 111076.559352845, 228355.265937366,
31033.9549731673, 34443.9266034838, 100401.13011289, 20754.0266423186,
29334.7579023722, 70572.5366141732, 12419.2333360566, 17842.2049581652,
61518.6150214895, 10110.7438562966, 17502.4708992952, 61357.4708251869,
9995.86560411634, 17530.0854369149, 53203.79872126, 11560.0754183956,
13608.3534926174, 46828.7269257867, 11019.0036476036, 12751.4728461078,
26876.5493340097, 15817.3356058367, 13322.0303678209, 28346.2564980389,
6207.28749858749, 9509.23448457102, 36589.1961503305, 10263.6194964664,
7564.4130620443, 29223.5021208951, 7015.27604618795, 8985.64276558643,
18886.2813530505, 7104.5605795249, 17804.4468985063, 6812.45760606556,
6606.50436956103, 18488.5028791766, 5863.36827860186, 13255.0296116594,
6453.52502342659, 5515.76995189115, 13991.8058338637, 3809.92839574631,
5061.53991882257, 5991.94758913396, 11334.5748098943, 6206.71330898436,
5219.26272399663, 10963.7722168793, 7489.68230742191, 3361.11015884112,
9301.91002246388, 2802.03791217282, 10320.7319848397, 2509.93049810913,
3062.67670544402, 12115.818468418, 22596.7672476562, 5210.67744771832,
12678.5528095273, 3674.33047767757, 10158.3722420368, 38620.8279703125,
4299.66130273203, 16002.3112734375, 9597.19786319193, 10816.7672483378,
10449.5441895035, 8882.17509875803, 5726.84640941102, 8043.21098886215,
7002.83669129089, 4997.59224291582, 17214.8268832032, 4203.51644882184,
2044.40880964859, 2570.59274774035, 1621.14734118819), TMT131 = c(9418.17036445313,
8878.68274218749, 8378.77222617187, 5645.64330000002, 4753.99889121092,
4420.32600410157, 5180.99550117188, 4787.09710488281, 4537.51669335937,
11573.2264957031, 3011.21359365234, 6855.67281093751, 33135.919678125,
78639.2005781249, 89222.1922968751, 117395.8545375, 221719.7701125,
31420.3548656251, 46548.5491968752, 99822.2995687501, 21221.19759375,
31903.8316523437, 65884.2084140624, 12792.6073300781, 32494.3474710937,
55493.9358187499, 10832.2051148437, 16887.821878125, 56011.2740859373,
11016.5575394531, 15928.4518980469, 45726.2466890625, 10025.5855992188,
21737.7840796876, 59706.8427656249, 9716.2620714844, 18071.6204882813,
35495.48536875, 19939.4042976562, 13032.988340625, 32501.3787140625,
7199.69156542971, 10150.1181632812, 40466.1293437499, 10645.1514984375,
11109.5601890625, 28522.8374835938, 5834.91936972658, 6796.13434628906,
23190.480225, 9266.24059453124, 29075.5950890626, 7621.3969927734,
9322.90506210938, 22800.4644656249, 7069.82396484372, 15978.9590683593,
6530.85736874999, 6011.4814611328, 17323.3141382813, 4554.70168183593,
5415.33720234375, 6123.79340332032, 14385.484575, 10146.5210988281,
3506.75934082032, 13551.8667152343, 9222.76466718747, 5501.55972480469,
13922.8457027344, 4250.15196503907, 9017.17755468752, 3575.14872451172,
5562.49420546876, 17743.048228125, 24449.2857210939, 5704.12143984373,
15124.9334800781, 5079.61518925782, 10921.1189097656, 35210.8651640626,
4445.87090449217, 15901.6300136718, 11364.1122761719, 9222.57776601566,
8388.0708205078, 9823.76574609376, 6197.90128417968, 8764.95285703127,
9621.21499453124, 6218.11219218749, 15561.3999234375, 4677.02849882812,
3778.64337919922, 2264.6449546875, 2498.85718242187)), class = c("tbl_df",
"tbl", "data.frame"), row.names = c(NA, -96L)), structure(list(
`First Scan` = c(16668, 16732, 16751, 16894, 16948, 16970,
17120, 17177, 17210, 17367, 17403, 17406, 17633, 17638, 17833,
17917, 18052, 18090, 18149, 18285, 18338, 18376, 18397, 18504,
18561, 18605, 18642, 18662, 18702, 18753, 18755, 18792, 18932,
18983, 19022, 19210, 19238, 19249, 19438, 19586, 19669, 19707,
19742, 19898, 19937, 20040, 20131, 20172, 20302, 20361, 20405,
20613, 20633, 20790, 20962, 21004, 21148, 21187, 21382, 21454,
21455, 21585, 21726, 21729, 21966, 22000, 22197, 22267, 22585,
22789, 23382, 23725), TMT126 = c(1882.9047259105, 3449.99254746093,
1024.2977771073, 5158.15467082831, 15759.4817531249, 5163.23808916981,
23084.5250109376, 11158.1465572494, 2542.16341682018, 6236.75949960936,
2540.56668486328, 4643.57579941405, 3676.30715654298, 2933.73809824218,
0, 3710.6456292118, 4085.0294783203, 675.688557714844, 1950.23111088867,
2205.57922470703, 8296.83276855471, 2672.59435136718, 3034.29849873047,
45624.8063390625, 22890.978928125, 3676.17324550782, 804.357999226392,
2339.07756328126, 2307.76013144531, 21624.511528125, 1518.1371897772,
10635.9306925781, 2680.27191738282, 11041.5375597656, 7065.95542382811,
8761.31611523439, 1801.56362783203, 7668.99884179686, 7505.24644894218,
1129.2046734375, 5552.81345566407, 6607.18650630685, 2071.91356259765,
5463.23402109373, 5149.03205670459, 1219.86494693985, 4910.47049139314,
3155.11395608923, 1398.27528804432, 6326.38970151936, 3541.72186757812,
4198.17516679688, 1440.07868518477, 0, 3465.05218769531,
961.89374368008, 2280.46133583984, 2356.01639560548, 0, 2526.26822314453,
1853.50988980811, 1310.57137792969, 1419.80935503652, 1688.71382270508,
1531.11097573243, 1821.7144977539, 1352.28257709961, 2137.31568546879,
1951.55034804646, 1311.16770682422, 0, 1720.31448781044),
TMT127N = c(2771.68523671875, 5795.16860742187, 1532.51465844727,
4997.19921035158, 25241.5731433593, 7411.63585078126, 35598.7388882813,
11632.0612353516, 3981.85727929688, 8431.46010673831, 4482.49877431641,
6676.69583173827, 4001.42575561522, 3282.20197690431, 1573.56998100586,
3935.30607905274, 7116.32664960937, 2307.64589311523, 4102.16486528321,
4772.48413124998, 14428.697888086, 3332.28787353515, 5485.6754455078,
91312.7273437499, 37781.7556101563, 4225.51941313476, 1839.82785454101,
4019.30935473634, 3973.05389443358, 32996.0530066406, 2037.37071027832,
20023.8569953125, 3530.19987890626, 16245.3700406251, 11744.1997277344,
14524.1289123047, 2272.03076718749, 7951.62546621093, 11169.627975,
2088.36168669433, 8426.40678837892, 5546.88783515623, 825.817551295166,
11964.5538246094, 5850.03650859376, 1951.7206411377, 6372.5401716797,
2720.9217121582, 2928.83477036133, 7842.02046181641, 4470.19431181639,
5518.54197597655, 4886.56620761718, 2598.45832382813, 5150.38777236328,
1764.69598916016, 4431.15874072266, 5851.29773701172, 3535.65924873047,
4506.44162783202, 3948.30497885742, 3474.47286108398, 4899.0403397461,
3668.68391484374, 1715.68195283204, 1517.17190141602, 2988.61810048828,
3049.25398110351, 3346.69140673828, 1629.18274760742, 1652.68488032226,
3111.11825932616), TMT128C = c(3546.93682792969, 5443.04733562549,
2406.94690743869, 7409.37070198117, 24566.1728096405, 7605.80923058386,
37319.8058793624, 13554.5726592211, 4322.44607961136, 10647.2819212435,
5886.92810075651, 8753.17848761496, 6553.53110235196, 4646.29586668501,
1968.9492260545, 4154.15849160926, 7670.78133562564, 2768.92031395084,
3603.54312466775, 4079.51357784559, 16511.9767178725, 3885.32503013637,
4789.39730709742, 75477.2031668271, 39696.3689381062, 6235.92097131154,
2324.05125227432, 4163.9149784173, 5315.6094992347, 31155.5901563382,
1816.81292346028, 16308.3860112984, 4287.50902664535, 15935.5273428347,
12014.8172808907, 13939.1329255981, 3921.1247165634, 11449.7683673977,
13003.5107817882, 2150.04455439802, 10889.4027696227, 6249.74721525204,
3815.90910915446, 9774.84044695728, 5968.13675351661, 3450.75965045113,
6496.88961226217, 4185.18567482653, 3493.2378779832, 6249.25306422371,
4966.6136218745, 7318.69851904571, 4807.8110810617, 1540.76095735796,
6832.23484476677, 2965.60747444571, 4139.87531020355, 4987.87787026309,
3610.04293593895, 5899.23647575952, 5796.31857744029, 3008.6643611543,
5433.73871616973, 2796.2558469155, 2533.88330506493, 3404.51135442734,
1989.89578135028, 3963.71640004554, 1855.68417729492, 1858.78970920819,
1801.24628626465, 1521.81316450196), TMT129N = c(5603.3715375,
7466.48746787111, 5737.87805507811, 10125.7479275391, 27223.0979882812,
11989.9738019531, 44015.6930296875, 17091.8407880859, 7938.03088417966,
12459.8042378906, 7051.86322177736, 10014.4530556641, 7992.80055556639,
5937.58603710939, 3499.28743828124, 8939.26554726561, 11082.9714445312,
3852.90205781249, 4749.96272050781, 6339.30068320313, 18824.0227183594,
5960.32649501952, 4809.15115634765, 84223.8693140624, 36909.3952734375,
7050.83312226562, 2210.35349326172, 5805.73487548829, 6812.68262490236,
29434.3397519532, 2379.38804296874, 20404.2909726562, 5217.36262587891,
19563.0384855469, 13420.0282283203, 12340.821178125, 3700.34673647461,
10695.0951164062, 15392.6850773437, 2774.59824887696, 12177.5412128907,
7713.37043554689, 3815.38668457032, 11456.5398427734, 11993.45544375,
3913.54135283203, 9596.82833613281, 5349.46382695312, 3289.20360688477,
8314.06658349611, 5784.25196894531, 7882.8373013672, 5610.97252675783,
3071.51274536133, 7498.057575293, 3661.76029086913, 6717.39973330079,
6506.75830341797, 4466.70268945312, 5969.45083388673, 7538.86863662107,
3945.00036079102, 7081.96355947265, 3515.28444770509, 4725.6043602539,
4937.22756269533, 3392.35801362304, 5545.30827919922, 4755.80240244142,
3465.95602353517, 2446.60899624023, 3763.70442260743), TMT130C = c(10983.9436123188,
9211.23508829853, 10557.3906937124, 10405.446046875, 28290.6707273437,
16687.4414721715, 47013.3588375, 24663.9287051498, 10819.8059091653,
12112.6441605469, 12221.0968142757, 14143.6632554762, 8870.24921835937,
10222.1638647599, 4387.39878905819, 7903.13580132335, 12659.3879214159,
4977.95176757538, 6713.09197134976, 8619.08616316083, 25601.7183693629,
9371.93738344518, 8431.95007587771, 96391.5124218752, 44929.6342171874,
7378.82902968752, 3945.11645284669, 8071.18750848737, 7751.84701707912,
38104.5129609375, 3638.03642401144, 20403.32641875, 7808.49545553976,
23539.4361984374, 18752.01165285, 20811.394168736, 5824.4538993184,
18893.4697542139, 12674.1161636719, 2807.67847851562, 12264.333778125,
11014.4240599255, 6251.73090996096, 13488.8996818318, 15964.1844357857,
5828.08199702709, 11239.0816570313, 8253.48396721728, 4132.48828007812,
13706.3856985815, 7642.39674902346, 8508.96873105467, 8428.07027860162,
5015.03055391062, 9927.36947998573, 4157.77188427735, 6591.46973203123,
10252.0377530773, 5571.05266915471, 8466.28209717723, 9830.67984953953,
6387.25448143305, 8227.90628531475, 6429.95347392001, 5927.99930589914,
6179.43049557376, 4779.11406556715, 5853.8402419922, 5984.37583438957,
2653.83845332031, 4653.86852737383, 4421.67880346553), TMT131 = c(13383.1659585937,
10027.0432195313, 16206.8438039063, 16355.4699128906, 29514.0965624999,
32393.8092585938, 53039.4243328127, 23782.9527632812, 21228.6799054688,
15934.2437460937, 11102.0789214844, 15037.0606933593, 13194.4500703125,
9207.67683515628, 6735.74908359374, 12899.2203527343, 13469.5999195312,
6745.45593691405, 7115.74944609379, 11411.3147414063, 27412.2978679687,
11739.3367394532, 8886.12224414064, 96689.4600375001, 45453.11203125,
7980.59650781252, 6961.24482539061, 10250.2241015625, 13306.6513335937,
39924.4417171876, 6483.56406328127, 22704.3346148437, 9771.777984375,
24691.8792656249, 18723.0097054687, 16477.3002410156, 7680.46611621096,
17120.4574535157, 18478.2819375, 4914.95838925784, 14805.4535964844,
11972.9694691407, 6757.70631679689, 12590.9775105469, 19122.4749375,
7233.17976562498, 14106.4787144532, 11431.40191875, 7873.65249257815,
16542.6268992187, 8767.54336992188, 11536.5155554687, 10534.8182027344,
6824.66757714841, 13787.927071875, 7553.96639121096, 7917.68129238283,
12813.6645140625, 7735.42080351564, 7866.51996796874, 12833.8237371094,
7160.45798144533, 11867.8380820313, 7840.4843214844, 6481.4439357422,
8916.9703347656, 7413.33213457034, 12091.0962304687, 10392.2846542969,
5704.91811914064, 5982.57808242186, 6364.45633183592)), class = c("tbl_df",
"tbl", "data.frame"), row.names = c(NA, -72L))), `# of PSMs` = c(96,
72)), row.names = c(NA, -2L), groups = structure(list(Unipro.ID = c("Q13177",
"Q8TD19"), Gene.name = c("PAK2", "NEK9"), Mod.site = c("Q13177_278",
"Q8TD19_81"), Mod.site2 = c("PAK2_278", "NEK9_81"), `mod.or.not(Y/N)` = c("Y",
"Y"), `kinase.or.not(Y/N)` = c("Y", "Y"), .rows = structure(list(
1L, 2L), ptype = integer(0), class = c("vctrs_list_of", "vctrs_vctr",
"list"))), row.names = c(NA, -2L), class = c("tbl_df", "tbl",
"data.frame"), .drop = TRUE), class = c("grouped_df", "tbl_df",
"tbl", "data.frame"))
Вот окончательный фрейм данных, который я хочу (конечно, NA
он будет заменен значениями суммы).
Кроме того, как вызвать pivot_longer
6 столбцов TMT во всех вложенных таблицах?
Кто-нибудь знает, как это сделать? Спасибо за любую помощь!
Ответ №1:
df %>%
mutate(data = map(data, ~summarise(.x, across(where(is.numeric), sum)))) %>%
unnest_wider(data) %>%
select(-`First Scan`) %>%
ungroup()
# A tibble: 2 x 13
Unipro.ID Gene.name Mod.site Mod.site2 `mod.or.not(Y/N)` `kinase.or.not(Y/N)` TMT126
<chr> <chr> <chr> <chr> <chr> <chr> <dbl>
1 Q13177 PAK2 Q13177_278 PAK2_278 Y Y 1.00e5
2 Q8TD19 NEK9 Q8TD19_81 NEK9_81 Y Y 3.56e5
# ... with 6 more variables: TMT127N <dbl>, TMT128C <dbl>, TMT129N <dbl>,
# TMT130C <dbl>, TMT131 <dbl>, # of PSMs <dbl>
Ответ №2:
Вы можете сделать summarise(across(starts_with("TMT"), sum))
это после звонка unnest(data)
:
df <- structure(list(Unipro.ID = c("Q13177", "Q8TD19"), Gene.name = c(
"PAK2",
"NEK9"
), Mod.site = c("Q13177_278", "Q8TD19_81"), Mod.site2 = c(
"PAK2_278",
"NEK9_81"
), `mod.or.not(Y/N)` = c("Y", "Y"), `kinase.or.not(Y/N)` = c(
"Y",
"Y"
), data = list(structure(list(`First Scan` = c(
18638, 18640,
18699, 18889, 18890, 19117, 19277, 19387, 19395, 19495, 19502,
19576, 19650, 19726, 19802, 19879, 19956, 20034, 20111, 20189,
20266, 20342, 20420, 20497, 20574, 20670, 20727, 20803, 20918,
20956, 21033, 21147, 21185, 21263, 21377, 21416, 21492, 21607,
21646, 21762, 21840, 21879, 21994, 22072, 22113, 22240, 22298,
22356, 22473, 22530, 22703, 22760, 22820, 22936, 23012, 23165,
23243, 23281, 23396, 23472, 23572, 23590, 23665, 23741, 23760,
23894, 23970, 23990, 24122, 24200, 24372, 24428, 24568, 24605,
24661, 24702, 24860, 25051, 25116, 25457, 25459, 25470, 25522,
25806, 26042, 26288, 26516, 27123, 27344, 27573, 27867, 28024,
28224, 29830, 30443, 32854
), TMT126 = c(
0, 0, 0, 0, 0, 0, 0,
0, 0, 0, 683.603289421257, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
0, 0, 0, 0, 0, 0, 0, 1058.63721546934, 5105.06075558397, 0, 0,
0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 786.877999584963, 0, 0, 0, 0, 0,
0, 0, 0, 0, 0, 0, 0, 1158.61443528477, 0, 0, 0, 0, 0, 790.552967308115,
1769.24251582031, 0, 0, 4230.5333458008, 0, 754.027149866911,
0, 0, 937.667214973757, 0, 0, 16065.4787548108, 0, 1033.79325384522,
0, 1545.17012178734, 22490.6473715619, 0, 12391.863457809, 1694.80635977683,
1669.92554702357, 2915.19207246094, 1305.76068893333, 1218.70367092158,
1724.48555844726, 1220.71902820389, 1142.29342043404, 15089.1510828024,
786.642299340822, 0, 0, 803.014098225646
), TMT127N = c(
0, 0,
0, 0, 0, 0, 0, 865.592199462889, 0, 0, 959.490090490725, 0, 0,
0, 3632.481907304, 0, 0, 0, 0, 0, 2281.36683418381, 0, 0, 1148.88409380685,
2282.96815473633, 0, 737.964767776176, 0, 0, 714.336386722035,
1336.78857436523, 0, 992.266982382272, 0, 8167.51299697265, 1481.83583737793,
0, 0, 0, 0, 0, 994.583403515622, 0, 3822.09582135578, 730.363546764861,
0, 0, 1601.84151123047, 0, 0, 0, 0, 1248.0926793457, 0, 2349.57136347657,
0, 925.784469760195, 0, 0, 0, 0, 0, 0, 0, 2869.82125708008, 779.87640303955,
0, 4092.33059296876, 0, 0, 0, 1133.40195924235, 0, 0, 0, 15684.5063332031,
0, 0, 0, 2583.52765913085, 24540.0170683595, 1238.62926386719,
11428.895775, 1483.56418256835, 1332.67443391114, 1825.25018671875,
1123.61925747071, 1030.31205838623, 1533.51140185547, 2153.17955595703,
1008.89100509033, 12831.9995203125, 1684.62781442872, 0, 1136.51165412598,
0
), TMT128C = c(
1611.91088437501, 1786.68805515069, 0, 1823.53765170799,
874.032758349609, 0, 0, 1177.50190689896, 646.466474431654, 1499.41582602539,
1255.4240426748, 1783.93500465848, 5996.15327152243, 8208.12153691405,
21348.7184882813, 33456.1981237878, 46046.4520991817, 5945.01241588586,
6798.69927773436, 18048.0166453125, 3490.51877753905, 7744.45986702618,
11529.8069519532, 3396.17701757812, 4651.27894687501, 14325.2306858641,
1561.40410561524, 0, 9592.47815625001, 2089.33504892578, 3367.76334082031,
10669.6799841273, 1439.18170268554, 0, 9310.75753007808, 1700.90959455201,
0, 6206.48464218753, 3397.72012818408, 0, 7079.64974935495, 1845.17109756826,
1177.34360229492, 6097.26335625001, 1754.74566738282, 1392.17984296875,
7026.71143068691, 2193.1615467585, 2836.98221749547, 6301.54294276034,
0, 3623.93436796874, 1312.70517940113, 0, 4724.16524276671, 0,
3946.52595689374, 2970.83282951206, 865.842519287108, 3283.01703994418,
0, 0, 1262.2417984723, 3482.3909258789, 4262.98461721732, 725.868942626953,
3139.75638657914, 6559.00482506506, 719.443235961914, 1980.26911301631,
735.412520327744, 2538.58699423828, 0, 0, 3345.73545624628, 17476.7195602775,
0, 3061.52193035407, 0, 3370.09478829905, 23476.7103351433, 1087.0128899699,
11912.6099077086, 1957.73038989257, 3158.21345361328, 3399.21823401529,
2593.01804501953, 934.40066220703, 2667.04373535038, 2390.35165488282,
1286.71902949219, 13590.0106023424, 1817.04336728435, 720.287557226125,
916.984646430313, 0
), TMT129N = c(
5236.22537109374, 5253.53062265625,
2574.52071173515, 6331.35667763673, 2909.4254578125, 2260.77584003907,
2299.19597588428, 2146.42980395508, 1524.82949099121, 4594.55742216798,
2945.06894956055, 3353.94465205077, 17265.8083640626, 58543.518953906,
42651.7719375001, 85288.5246984373, 147283.5420375, 16268.584838086,
31273.8547945313, 64984.9260843748, 15376.6111124999, 18807.9172359374,
41234.0440359375, 7038.37527421877, 14994.4310613281, 35007.7380726561,
5527.67209306639, 8827.66559818178, 32485.2518203124, 6771.8957270508,
10744.4285308594, 21706.4754328126, 7351.69939775389, 7286.74206159669,
31413.8810906249, 5402.31355253905, 7530.87224590352, 22346.2738640626,
7845.50157832029, 8598.84479102795, 13646.5870857421, 3948.41240126953,
4709.55193242188, 14502.506803125, 5527.37162548826, 4609.58657929687,
17346.4145701172, 3806.28572124023, 6695.23604707033, 10312.3288382812,
5030.34046109047, 12238.5130183594, 4008.11956391603, 3366.81581267473,
10163.4030287109, 5657.196356792, 9102.44150449222, 3997.46163222657,
3410.17096083986, 7459.02988359372, 2817.01574699993, 3228.9395395409,
1668.4944914795, 8344.1621935547, 6186.76663623048, 4037.21344028321,
4953.59359042969, 6163.53660527345, 2403.32564355468, 7143.26629951174,
1674.84291965332, 6149.94359912111, 2371.20030146484, 2708.46439392749,
8739.23083300782, 17708.4475347656, 2940.52380873895, 6755.28018515623,
2318.903026372, 5194.7135689453, 37003.6496414061, 1967.3172459961,
11835.060703125, 6357.79309687501, 6929.07336386721, 4922.18842499999,
5119.39548720702, 5098.90275791014, 5251.26713525389, 3925.45210825196,
3679.82248959962, 14610.4555587891, 3124.13869614258, 1892.91264873047,
2424.18607792969, 1217.02803508301
), TMT130C = c(
8534.51942065459,
7915.5220132809, 5427.32003829632, 6570.76122664215, 4059.66840776324,
6061.80182135341, 4680.93892861494, 3924.40329255471, 1651.02954082353,
9963.97493859979, 2095.70639501953, 6791.52962729408, 29089.1005494669,
84188.5986999335, 79102.1477485965, 111076.559352845, 228355.265937366,
31033.9549731673, 34443.9266034838, 100401.13011289, 20754.0266423186,
29334.7579023722, 70572.5366141732, 12419.2333360566, 17842.2049581652,
61518.6150214895, 10110.7438562966, 17502.4708992952, 61357.4708251869,
9995.86560411634, 17530.0854369149, 53203.79872126, 11560.0754183956,
13608.3534926174, 46828.7269257867, 11019.0036476036, 12751.4728461078,
26876.5493340097, 15817.3356058367, 13322.0303678209, 28346.2564980389,
6207.28749858749, 9509.23448457102, 36589.1961503305, 10263.6194964664,
7564.4130620443, 29223.5021208951, 7015.27604618795, 8985.64276558643,
18886.2813530505, 7104.5605795249, 17804.4468985063, 6812.45760606556,
6606.50436956103, 18488.5028791766, 5863.36827860186, 13255.0296116594,
6453.52502342659, 5515.76995189115, 13991.8058338637, 3809.92839574631,
5061.53991882257, 5991.94758913396, 11334.5748098943, 6206.71330898436,
5219.26272399663, 10963.7722168793, 7489.68230742191, 3361.11015884112,
9301.91002246388, 2802.03791217282, 10320.7319848397, 2509.93049810913,
3062.67670544402, 12115.818468418, 22596.7672476562, 5210.67744771832,
12678.5528095273, 3674.33047767757, 10158.3722420368, 38620.8279703125,
4299.66130273203, 16002.3112734375, 9597.19786319193, 10816.7672483378,
10449.5441895035, 8882.17509875803, 5726.84640941102, 8043.21098886215,
7002.83669129089, 4997.59224291582, 17214.8268832032, 4203.51644882184,
2044.40880964859, 2570.59274774035, 1621.14734118819
), TMT131 = c(
9418.17036445313,
8878.68274218749, 8378.77222617187, 5645.64330000002, 4753.99889121092,
4420.32600410157, 5180.99550117188, 4787.09710488281, 4537.51669335937,
11573.2264957031, 3011.21359365234, 6855.67281093751, 33135.919678125,
78639.2005781249, 89222.1922968751, 117395.8545375, 221719.7701125,
31420.3548656251, 46548.5491968752, 99822.2995687501, 21221.19759375,
31903.8316523437, 65884.2084140624, 12792.6073300781, 32494.3474710937,
55493.9358187499, 10832.2051148437, 16887.821878125, 56011.2740859373,
11016.5575394531, 15928.4518980469, 45726.2466890625, 10025.5855992188,
21737.7840796876, 59706.8427656249, 9716.2620714844, 18071.6204882813,
35495.48536875, 19939.4042976562, 13032.988340625, 32501.3787140625,
7199.69156542971, 10150.1181632812, 40466.1293437499, 10645.1514984375,
11109.5601890625, 28522.8374835938, 5834.91936972658, 6796.13434628906,
23190.480225, 9266.24059453124, 29075.5950890626, 7621.3969927734,
9322.90506210938, 22800.4644656249, 7069.82396484372, 15978.9590683593,
6530.85736874999, 6011.4814611328, 17323.3141382813, 4554.70168183593,
5415.33720234375, 6123.79340332032, 14385.484575, 10146.5210988281,
3506.75934082032, 13551.8667152343, 9222.76466718747, 5501.55972480469,
13922.8457027344, 4250.15196503907, 9017.17755468752, 3575.14872451172,
5562.49420546876, 17743.048228125, 24449.2857210939, 5704.12143984373,
15124.9334800781, 5079.61518925782, 10921.1189097656, 35210.8651640626,
4445.87090449217, 15901.6300136718, 11364.1122761719, 9222.57776601566,
8388.0708205078, 9823.76574609376, 6197.90128417968, 8764.95285703127,
9621.21499453124, 6218.11219218749, 15561.3999234375, 4677.02849882812,
3778.64337919922, 2264.6449546875, 2498.85718242187
)), class = c(
"tbl_df",
"tbl", "data.frame"
), row.names = c(NA, -96L)), structure(list(
`First Scan` = c(
16668, 16732, 16751, 16894, 16948, 16970,
17120, 17177, 17210, 17367, 17403, 17406, 17633, 17638, 17833,
17917, 18052, 18090, 18149, 18285, 18338, 18376, 18397, 18504,
18561, 18605, 18642, 18662, 18702, 18753, 18755, 18792, 18932,
18983, 19022, 19210, 19238, 19249, 19438, 19586, 19669, 19707,
19742, 19898, 19937, 20040, 20131, 20172, 20302, 20361, 20405,
20613, 20633, 20790, 20962, 21004, 21148, 21187, 21382, 21454,
21455, 21585, 21726, 21729, 21966, 22000, 22197, 22267, 22585,
22789, 23382, 23725
), TMT126 = c(
1882.9047259105, 3449.99254746093,
1024.2977771073, 5158.15467082831, 15759.4817531249, 5163.23808916981,
23084.5250109376, 11158.1465572494, 2542.16341682018, 6236.75949960936,
2540.56668486328, 4643.57579941405, 3676.30715654298, 2933.73809824218,
0, 3710.6456292118, 4085.0294783203, 675.688557714844, 1950.23111088867,
2205.57922470703, 8296.83276855471, 2672.59435136718, 3034.29849873047,
45624.8063390625, 22890.978928125, 3676.17324550782, 804.357999226392,
2339.07756328126, 2307.76013144531, 21624.511528125, 1518.1371897772,
10635.9306925781, 2680.27191738282, 11041.5375597656, 7065.95542382811,
8761.31611523439, 1801.56362783203, 7668.99884179686, 7505.24644894218,
1129.2046734375, 5552.81345566407, 6607.18650630685, 2071.91356259765,
5463.23402109373, 5149.03205670459, 1219.86494693985, 4910.47049139314,
3155.11395608923, 1398.27528804432, 6326.38970151936, 3541.72186757812,
4198.17516679688, 1440.07868518477, 0, 3465.05218769531,
961.89374368008, 2280.46133583984, 2356.01639560548, 0, 2526.26822314453,
1853.50988980811, 1310.57137792969, 1419.80935503652, 1688.71382270508,
1531.11097573243, 1821.7144977539, 1352.28257709961, 2137.31568546879,
1951.55034804646, 1311.16770682422, 0, 1720.31448781044
),
TMT127N = c(
2771.68523671875, 5795.16860742187, 1532.51465844727,
4997.19921035158, 25241.5731433593, 7411.63585078126, 35598.7388882813,
11632.0612353516, 3981.85727929688, 8431.46010673831, 4482.49877431641,
6676.69583173827, 4001.42575561522, 3282.20197690431, 1573.56998100586,
3935.30607905274, 7116.32664960937, 2307.64589311523, 4102.16486528321,
4772.48413124998, 14428.697888086, 3332.28787353515, 5485.6754455078,
91312.7273437499, 37781.7556101563, 4225.51941313476, 1839.82785454101,
4019.30935473634, 3973.05389443358, 32996.0530066406, 2037.37071027832,
20023.8569953125, 3530.19987890626, 16245.3700406251, 11744.1997277344,
14524.1289123047, 2272.03076718749, 7951.62546621093, 11169.627975,
2088.36168669433, 8426.40678837892, 5546.88783515623, 825.817551295166,
11964.5538246094, 5850.03650859376, 1951.7206411377, 6372.5401716797,
2720.9217121582, 2928.83477036133, 7842.02046181641, 4470.19431181639,
5518.54197597655, 4886.56620761718, 2598.45832382813, 5150.38777236328,
1764.69598916016, 4431.15874072266, 5851.29773701172, 3535.65924873047,
4506.44162783202, 3948.30497885742, 3474.47286108398, 4899.0403397461,
3668.68391484374, 1715.68195283204, 1517.17190141602, 2988.61810048828,
3049.25398110351, 3346.69140673828, 1629.18274760742, 1652.68488032226,
3111.11825932616
), TMT128C = c(
3546.93682792969, 5443.04733562549,
2406.94690743869, 7409.37070198117, 24566.1728096405, 7605.80923058386,
37319.8058793624, 13554.5726592211, 4322.44607961136, 10647.2819212435,
5886.92810075651, 8753.17848761496, 6553.53110235196, 4646.29586668501,
1968.9492260545, 4154.15849160926, 7670.78133562564, 2768.92031395084,
3603.54312466775, 4079.51357784559, 16511.9767178725, 3885.32503013637,
4789.39730709742, 75477.2031668271, 39696.3689381062, 6235.92097131154,
2324.05125227432, 4163.9149784173, 5315.6094992347, 31155.5901563382,
1816.81292346028, 16308.3860112984, 4287.50902664535, 15935.5273428347,
12014.8172808907, 13939.1329255981, 3921.1247165634, 11449.7683673977,
13003.5107817882, 2150.04455439802, 10889.4027696227, 6249.74721525204,
3815.90910915446, 9774.84044695728, 5968.13675351661, 3450.75965045113,
6496.88961226217, 4185.18567482653, 3493.2378779832, 6249.25306422371,
4966.6136218745, 7318.69851904571, 4807.8110810617, 1540.76095735796,
6832.23484476677, 2965.60747444571, 4139.87531020355, 4987.87787026309,
3610.04293593895, 5899.23647575952, 5796.31857744029, 3008.6643611543,
5433.73871616973, 2796.2558469155, 2533.88330506493, 3404.51135442734,
1989.89578135028, 3963.71640004554, 1855.68417729492, 1858.78970920819,
1801.24628626465, 1521.81316450196
), TMT129N = c(
5603.3715375,
7466.48746787111, 5737.87805507811, 10125.7479275391, 27223.0979882812,
11989.9738019531, 44015.6930296875, 17091.8407880859, 7938.03088417966,
12459.8042378906, 7051.86322177736, 10014.4530556641, 7992.80055556639,
5937.58603710939, 3499.28743828124, 8939.26554726561, 11082.9714445312,
3852.90205781249, 4749.96272050781, 6339.30068320313, 18824.0227183594,
5960.32649501952, 4809.15115634765, 84223.8693140624, 36909.3952734375,
7050.83312226562, 2210.35349326172, 5805.73487548829, 6812.68262490236,
29434.3397519532, 2379.38804296874, 20404.2909726562, 5217.36262587891,
19563.0384855469, 13420.0282283203, 12340.821178125, 3700.34673647461,
10695.0951164062, 15392.6850773437, 2774.59824887696, 12177.5412128907,
7713.37043554689, 3815.38668457032, 11456.5398427734, 11993.45544375,
3913.54135283203, 9596.82833613281, 5349.46382695312, 3289.20360688477,
8314.06658349611, 5784.25196894531, 7882.8373013672, 5610.97252675783,
3071.51274536133, 7498.057575293, 3661.76029086913, 6717.39973330079,
6506.75830341797, 4466.70268945312, 5969.45083388673, 7538.86863662107,
3945.00036079102, 7081.96355947265, 3515.28444770509, 4725.6043602539,
4937.22756269533, 3392.35801362304, 5545.30827919922, 4755.80240244142,
3465.95602353517, 2446.60899624023, 3763.70442260743
), TMT130C = c(
10983.9436123188,
9211.23508829853, 10557.3906937124, 10405.446046875, 28290.6707273437,
16687.4414721715, 47013.3588375, 24663.9287051498, 10819.8059091653,
12112.6441605469, 12221.0968142757, 14143.6632554762, 8870.24921835937,
10222.1638647599, 4387.39878905819, 7903.13580132335, 12659.3879214159,
4977.95176757538, 6713.09197134976, 8619.08616316083, 25601.7183693629,
9371.93738344518, 8431.95007587771, 96391.5124218752, 44929.6342171874,
7378.82902968752, 3945.11645284669, 8071.18750848737, 7751.84701707912,
38104.5129609375, 3638.03642401144, 20403.32641875, 7808.49545553976,
23539.4361984374, 18752.01165285, 20811.394168736, 5824.4538993184,
18893.4697542139, 12674.1161636719, 2807.67847851562, 12264.333778125,
11014.4240599255, 6251.73090996096, 13488.8996818318, 15964.1844357857,
5828.08199702709, 11239.0816570313, 8253.48396721728, 4132.48828007812,
13706.3856985815, 7642.39674902346, 8508.96873105467, 8428.07027860162,
5015.03055391062, 9927.36947998573, 4157.77188427735, 6591.46973203123,
10252.0377530773, 5571.05266915471, 8466.28209717723, 9830.67984953953,
6387.25448143305, 8227.90628531475, 6429.95347392001, 5927.99930589914,
6179.43049557376, 4779.11406556715, 5853.8402419922, 5984.37583438957,
2653.83845332031, 4653.86852737383, 4421.67880346553
), TMT131 = c(
13383.1659585937,
10027.0432195313, 16206.8438039063, 16355.4699128906, 29514.0965624999,
32393.8092585938, 53039.4243328127, 23782.9527632812, 21228.6799054688,
15934.2437460937, 11102.0789214844, 15037.0606933593, 13194.4500703125,
9207.67683515628, 6735.74908359374, 12899.2203527343, 13469.5999195312,
6745.45593691405, 7115.74944609379, 11411.3147414063, 27412.2978679687,
11739.3367394532, 8886.12224414064, 96689.4600375001, 45453.11203125,
7980.59650781252, 6961.24482539061, 10250.2241015625, 13306.6513335937,
39924.4417171876, 6483.56406328127, 22704.3346148437, 9771.777984375,
24691.8792656249, 18723.0097054687, 16477.3002410156, 7680.46611621096,
17120.4574535157, 18478.2819375, 4914.95838925784, 14805.4535964844,
11972.9694691407, 6757.70631679689, 12590.9775105469, 19122.4749375,
7233.17976562498, 14106.4787144532, 11431.40191875, 7873.65249257815,
16542.6268992187, 8767.54336992188, 11536.5155554687, 10534.8182027344,
6824.66757714841, 13787.927071875, 7553.96639121096, 7917.68129238283,
12813.6645140625, 7735.42080351564, 7866.51996796874, 12833.8237371094,
7160.45798144533, 11867.8380820313, 7840.4843214844, 6481.4439357422,
8916.9703347656, 7413.33213457034, 12091.0962304687, 10392.2846542969,
5704.91811914064, 5982.57808242186, 6364.45633183592
)
), class = c(
"tbl_df",
"tbl", "data.frame"
), row.names = c(NA, -72L))), `# of PSMs` = c(
96,
72
)), row.names = c(NA, -2L), groups = structure(list(Unipro.ID = c(
"Q13177",
"Q8TD19"
), Gene.name = c("PAK2", "NEK9"), Mod.site = c(
"Q13177_278",
"Q8TD19_81"
), Mod.site2 = c("PAK2_278", "NEK9_81"), `mod.or.not(Y/N)` = c(
"Y",
"Y"
), `kinase.or.not(Y/N)` = c("Y", "Y"), .rows = structure(list(
1L, 2L
), ptype = integer(0), class = c(
"vctrs_list_of", "vctrs_vctr",
"list"
))), row.names = c(NA, -2L), class = c(
"tbl_df", "tbl",
"data.frame"
), .drop = TRUE), class = c(
"grouped_df", "tbl_df",
"tbl", "data.frame"
))
library(tidyverse)
df %>%
unnest(data) %>%
summarise(across(starts_with("TMT"), sum)) %>%
pivot_longer(starts_with("TMT")) %>%
# select only a few columns for optimized printing
select(Unipro.ID, Gene.name, Mod.site, Mod.site2, name, value)
#> `summarise()` has grouped output by 'Unipro.ID', 'Gene.name', 'Mod.site', 'Mod.site2', 'mod.or.not(Y/N)'. You can override using the `.groups` argument.
#> Adding missing grouping variables: `mod.or.not(Y/N)`
#> # A tibble: 12 × 7
#> # Groups: Unipro.ID, Gene.name, Mod.site, Mod.site2, mod.or.not(Y/N) [2]
#> `mod.or.not(Y/N)` Unipro.ID Gene.name Mod.site Mod.site2 name value
#> <chr> <chr> <chr> <chr> <chr> <chr> <dbl>
#> 1 Y Q13177 PAK2 Q13177_278 PAK2_278 TMT126 100372.
#> 2 Y Q13177 PAK2 Q13177_278 PAK2_278 TMT127N 127769.
#> 3 Y Q13177 PAK2 Q13177_278 PAK2_278 TMT128C 435779.
#> 4 Y Q13177 PAK2 Q13177_278 PAK2_278 TMT129N 1189693.
#> 5 Y Q13177 PAK2 Q13177_278 PAK2_278 TMT130C 1869744.
#> 6 Y Q13177 PAK2 Q13177_278 PAK2_278 TMT131 2008380.
#> 7 Y Q8TD19 NEK9 Q8TD19_81 NEK9_81 TMT126 355683.
#> 8 Y Q8TD19 NEK9 Q8TD19_81 NEK9_81 TMT127N 572770.
#> 9 Y Q8TD19 NEK9 Q8TD19_81 NEK9_81 TMT128C 594897.
#> 10 Y Q8TD19 NEK9 Q8TD19_81 NEK9_81 TMT129N 716943.
#> 11 Y Q8TD19 NEK9 Q8TD19_81 NEK9_81 TMT130C 904627.
#> 12 Y Q8TD19 NEK9 Q8TD19_81 NEK9_81 TMT131 1075259.
Создано 2021-09-19 пакетом reprex (v2.0.1)
Комментарии:
1. Классно! Большое спасибо! Можно ли сохранить вложенную
data
таблицу в окончательном выводе?2. Да, например, создав его копию:
iris %>% nest(-Species) %>% mutate(data2 = data) %>% unnest(data)
3. Спасибо! Но когда я побежал
df.test3 <- df.test %>% mutate(data2 = data) %>% unnest(data) %>% summarise(across(starts_with("TMT"), sum))
, скопированныйdata2
столбец исчезнет после вызоваsummarise
.4.
group_by
конечная сила, сохраняющая свой столбец индекса:iris %>% nest(-Species) %>% mutate(data2 = data) %>% unnest(data) %>% group_by(data2) %>% summarise(across(starts_with("Sepal."), sum))