Related
Each element of the pp list has five subelements, each containing a vector of values called expr. Also, list iid contains one element with the same number and length of sub-elements of each element in pp. In order to integrate two lists, I want for each element of pp, the characters in the iid become a column name and the corresponding values in the pp to become rows like a data frame. At the end, all the values should be comncatenated and divided in five as it is in the inputs.
## pp list
pp <- list(ENSG00000141956 = list(foldSet_1 = structure(list(expr = c(0.3803048,
-0.1005805, -0.1388998, -0.439475, 0.3326845, -0.6787136, -0.8862647,
0.5526945, 0.4432067, -0.4434515862, -0.3608854, 0.0120686657,
0.09344841, 0.400137, 0.7890199, -0.492058, 0.07042376, 0.3025703,
0.1189347, -0.795448, -0.102853, 0.677594, -0.4110812)), row.names = c(NA,
-23L), class = c("tbl_df", "tbl", "data.frame")), foldSet_2 = structure(list(
expr = c(0.3910626, 0.4011977, -0.5375317082, 1.118997, -0.714867812,
0.7692958314, -0.7411604, -0.105918, -0.06774316, 0.37792,
-1.50101, 0.4659521, 0.05462016, 0.8191656, 0.2534708, -0.7851615,
0.06491725, -0.1145606, 0.2031628, -0.3784291, 1.75129, -0.2781814
)), row.names = c(NA, -22L), class = c("tbl_df", "tbl", "data.frame"
)), foldSet_3 = structure(list(expr = c(0.1346737, -0.3018867,
2.008637597, 0.2174854, 0.1817713, 0.2068479, 0.4385861, -0.6867911553,
-0.04973609, 0.9683988, -0.004377791, 0.4063974, -0.08958473,
0.2791352, -0.6540139556, 0.2491497, -0.3315336, 0.5217149, -0.3263807,
-0.4260331, 0.2909981, 0.2420486, 0.03705211)), row.names = c(NA,
-23L), class = c("tbl_df", "tbl", "data.frame")), foldSet_4 = structure(list(
expr = c(0.01042395, -0.4773195, 0.08209318, -0.7586276,
0.1575954, -0.7206272, 0.2283236, -0.1310485, 0.422618, 0.0108831611,
0.5423006, -0.1537052, -0.206502, 0.196586, -0.8410328, 0.09204746,
-0.7454582, 0.1416914, -0.8276129, 0.8363268, -0.7257737,
0.3657267)), row.names = c(NA, -22L), class = c("tbl_df",
"tbl", "data.frame")), foldSet_5 = structure(list(expr = c(1.265001,
-0.8963425427, 0.2428121, 0.2942902, -0.01086715, 0.5085538,
0.6372121, 0.8329305, 0.1185538, -0.5767332, 0.3843823, 0.2350104,
-0.2325683, -0.1219577, 0.6623785, -0.5607696, -1.5371637259,
-1.657621852, -0.01256456, 0.4563003, -0.7890026, -1.197397,
0.3742298)), row.names = c(NA, -23L), class = c("tbl_df", "tbl",
"data.frame"))), ENSG00000141959 = list(foldSet_1 = structure(list(
expr = c(-0.3003046, 0.005579603, -0.2596373, -0.3522028,
0.1879026, 0.1967071, -0.4713157, -0.3310353, -0.1003091,
0.3832126993, -0.05301061, -0.3635412607, 0.4025212, 0.1362349,
-0.1587811, 0.3373843, 0.1998857, 0.4367898, -0.5611188,
0.02719134, -0.1471497, 0.12489, 0.6190356)), row.names = c(NA,
-23L), class = c("tbl_df", "tbl", "data.frame")), foldSet_2 = structure(list(
expr = c(0.0579663, 0.3904131, 0.2544079194, -0.1574236,
0.69677048, -0.0876293718, -0.5368353, 0.225058, -0.5255409,
-0.3314226, -1.622316, 0.1064199, 0.1061926, 0.3527317, -0.4675344,
0.1723076, -0.1159002, -0.006312083, -0.2083593, -0.00007146444,
0.1268512, -0.07700766)), row.names = c(NA, -22L), class = c("tbl_df",
"tbl", "data.frame")), foldSet_3 = structure(list(expr = c(0.1401876,
-0.3250818, 0.5946272517, -0.2694272, -0.2912538, -0.0780406,
0.3063621, 0.0676218118, -0.2015818, 0.1549354, 0.5281673, 1.037816,
-0.3362126, -0.4971578, -0.0889611491, -0.0641598, 0.7628252,
-0.2208091, -0.7417216, -0.3509665, 0.07412728, -0.4002744, -0.5406274
)), row.names = c(NA, -23L), class = c("tbl_df", "tbl", "data.frame"
)), foldSet_4 = structure(list(expr = c(-0.350688, 0.5425585,
0.2550953, 0.6242607, 0.6671248, -0.3640666, 0.3625934, -0.02385531,
0.2368257, -0.1671464501, 0.1443962, 0.2876699, 0.5233608, 0.411042,
-0.6771724, 0.04496645, -0.7915447, -0.4581436, -0.008061834,
0.156641, 0.5718667, -0.8583139)), row.names = c(NA, -22L), class = c("tbl_df",
"tbl", "data.frame")), foldSet_5 = structure(list(expr = c(0.5290703,
-0.1029373935, 0.1481799, -0.3074795, 0.825576, 0.3023727, 0.2402515,
0.09724703, 0.09133488, 0.5141968, 0.362571, -0.1941567, -0.09751567,
-0.9363854, -0.03207956, 0.6985924, -0.6445457624, -0.0887025618,
0.01355917, 0.002195536, -0.05979083, 0.1404834, -0.2035347)), row.names = c(NA,
-23L), class = c("tbl_df", "tbl", "data.frame"))))
## iid list
iid <- list(foldSet_1 = c("GTEX-11EQ9", "GTEX-12WSJ", "GTEX-1EKGG",
"GTEX-1EU9M", "GTEX-1EWIQ", "GTEX-1F5PK", "GTEX-1GMRU", "GTEX-1GTWX",
"GTEX-S95S", "GTEX-SN8G", "GTEX-T5JC", "GTEX-T6MO", "GTEX-TKQ2",
"GTEX-U3ZM", "GTEX-V1D1", "GTEX-WFG7", "GTEX-WFG8", "GTEX-WFJO",
"GTEX-WOFM", "GTEX-Y5V6", "GTEX-Y8LW", "GTEX-ZC5H", "GTEX-ZXES"
), foldSet_2 = c("GTEX-11EM3", "GTEX-11EMC", "GTEX-11ZTT", "GTEX-1212Z",
"GTEX-12696", "GTEX-1269C", "GTEX-1GF9U", "GTEX-1GMR8", "GTEX-1I4MK",
"GTEX-S4Q7", "GTEX-U3ZG", "GTEX-WWTW", "GTEX-WZTO", "GTEX-X4EO",
"GTEX-XPT6", "GTEX-Y5V5", "GTEX-YB5K", "GTEX-YEC4", "GTEX-ZF3C",
"GTEX-ZG7Y", "GTEX-ZP4G", "GTEX-ZT9W"), foldSet_3 = c("GTEX-11I78",
"GTEX-11VI4", "GTEX-12C56", "GTEX-13111", "GTEX-1399R", "GTEX-1FIGZ",
"GTEX-1GN2E", "GTEX-RUSQ", "GTEX-T5JW", "GTEX-UPJH", "GTEX-V955",
"GTEX-VUSG", "GTEX-W5WG", "GTEX-WRHK", "GTEX-XBED", "GTEX-XMK1",
"GTEX-XQ3S", "GTEX-XXEK", "GTEX-Y8DK", "GTEX-ZEX8", "GTEX-ZPCL",
"GTEX-ZQG8", "GTEX-ZTPG"), foldSet_4 = c("GTEX-1122O", "GTEX-1211K",
"GTEX-12WSL", "GTEX-T6MN", "GTEX-TMZS", "GTEX-UPK5", "GTEX-WFON",
"GTEX-WHSB", "GTEX-WHWD", "GTEX-WY7C", "GTEX-WYVS", "GTEX-X15G",
"GTEX-XGQ4", "GTEX-Y9LG", "GTEX-YEC3", "GTEX-ZDTS", "GTEX-ZDTT",
"GTEX-ZF2S", "GTEX-ZLV1", "GTEX-ZPIC", "GTEX-ZT9X", "GTEX-ZUA1"
), foldSet_5 = c("GTEX-12WSN", "GTEX-1F48J", "GTEX-1F52S", "GTEX-1GMR3",
"GTEX-SUCS", "GTEX-U3ZH", "GTEX-U3ZN", "GTEX-WEY5", "GTEX-WH7G",
"GTEX-X4EP", "GTEX-X4LF", "GTEX-X5EB", "GTEX-XBEW", "GTEX-XLM4",
"GTEX-Y5LM", "GTEX-Y8E4", "GTEX-YF7O", "GTEX-ZF29", "GTEX-ZTSS",
"GTEX-ZTTD", "GTEX-ZV6S", "GTEX-ZVT2", "GTEX-ZVZP"))
The desired output looks like this:
pp_out <- list(ENSG00000141956 = structure(list(`GTEX-11EQ9` = 0.00272564851305302,
`GTEX-12WSJ` = 0.00272564851305302, `GTEX-1EKGG` = 0.0202754075985887,
`GTEX-1EU9M` = 0.00676249893692591, `GTEX-1EWIQ` = 0.00336835547752925,
`GTEX-1F5PK` = 0.00336835547752925, `GTEX-1GMRU` = 0.0191065491234794,
`GTEX-1GTWX` = 0.00272564851305302, `GTEX-S95S` = 0.00503517684692274,
`GTEX-SN8G` = 0.0150945626471007, `GTEX-T5JC` = 0.00602406792927852,
`GTEX-T6MO` = 0.00272564851305302, `GTEX-TKQ2` = 0.00272564851305302,
`GTEX-U3ZM` = 0.00272564851305302, `GTEX-V1D1` = 0.00300074743348399,
`GTEX-WFG7` = 0.00300074743348399, `GTEX-WFG8` = 0.00327584635391496,
`GTEX-WFJO` = 0.00300074743348399, `GTEX-WOFM` = 0.00272564851305302,
`GTEX-Y5V6` = 0.00614716297153329, `GTEX-Y8LW` = 0.0208907435639813,
`GTEX-ZC5H` = 0.00879692835036466, `GTEX-ZXES` = 0.00574896900884754,
`GTEX-11EM3` = -0.0149845730327965, `GTEX-11EMC` = -0.013847280341284,
`GTEX-11ZTT` = -0.0275325515044248, `GTEX-1212Z` = -0.0141988014913753,
`GTEX-12696` = -0.0136176647967972, `GTEX-1269C` = -0.0275325515044248,
`GTEX-1GF9U` = -0.0153360941828878, `GTEX-1GMR8` = -0.0136116558238996,
`GTEX-1I4MK` = -0.0138532893141817, `GTEX-S4Q7` = -0.0151539874321891,
`GTEX-U3ZG` = -0.0138532893141817, `GTEX-WWTW` = -0.027416654871718,
`GTEX-WZTO` = -0.0215030592385638, `GTEX-X4EO` = -0.0205524436634252,
`GTEX-XPT6` = -0.0136116558238996, `GTEX-Y5V5` = -0.0174136560129391,
`GTEX-YB5K` = -0.0138532893141817, `GTEX-YEC4` = -0.0136176647967972,
`GTEX-ZF3C` = -0.0208273881822836, `GTEX-ZG7Y` = -0.0136176647967972,
`GTEX-ZP4G` = -0.0250634259373212, `GTEX-ZT9W` = -0.0136176647967972,
`GTEX-11I78` = -0.037929571081887, `GTEX-11VI4` = -0.0352737894666712,
`GTEX-12C56` = -0.0364115473528404, `GTEX-13111` = -0.0353679266239015,
`GTEX-1399R` = -0.0376033957001448, `GTEX-1FIGZ` = -0.0308210759870506,
`GTEX-1GN2E` = -0.0376033957001448, `GTEX-RUSQ` = -0.0376033957001448,
`GTEX-T5JW` = -0.0420643633134619, `GTEX-UPJH` = -0.0360853719710982,
`GTEX-V955` = -0.037929571081887, `GTEX-VUSG` = -0.0360853719710982,
`GTEX-W5WG` = -0.0330565450632938, `GTEX-WRHK` = -0.037929571081887,
`GTEX-XBED` = -0.037929571081887, `GTEX-XMK1` = -0.0352737894666712,
`GTEX-XQ3S` = -0.0350417512421593, `GTEX-XXEK` = -0.0376033957001448,
`GTEX-Y8DK` = -0.0376033957001448, `GTEX-ZEX8` = -0.0360853719710982,
`GTEX-ZPCL` = -0.0364115473528404, `GTEX-ZQG8` = -0.0381176463621845,
`GTEX-ZTPG` = -0.037929571081887, `GTEX-1122O` = 0.0311974749143465,
`GTEX-1211K` = 0.0302892560510041, `GTEX-12WSL` = 0.0310530889747851,
`GTEX-T6MN` = 0.0253053324056306, `GTEX-TMZS` = 0.0251609464660692,
`GTEX-UPK5` = 0.0250389673364521, `GTEX-WFON` = 0.0251609464660692,
`GTEX-WHSB` = 0.0310530889747851, `GTEX-WHWD` = 0.0253053324056306,
`GTEX-WY7C` = 0.0310530889747851, `GTEX-WYVS` = 0.0360370126201587,
`GTEX-X15G` = 0.0253053324056306, `GTEX-XGQ4` = 0.0254497183451919,
`GTEX-Y9LG` = 0.0236698466255728, `GTEX-YEC3` = 0.0250389673364521,
`GTEX-ZDTS` = 0.0302892560510041, `GTEX-ZDTT` = 0.02716525500288,
`GTEX-ZF2S` = 0.0302892560510041, `GTEX-ZLV1` = 0.0250389673364521,
`GTEX-ZPIC` = 0.0254497183451919, `GTEX-ZT9X` = 0.0302892560510041,
`GTEX-ZUA1` = 0.0311974749143465, `GTEX-12WSN` = 0.0196357496993677,
`GTEX-1F48J` = 0.0167271490318362, `GTEX-1F52S` = 0.0168263419569211,
`GTEX-1GMR3` = 0.0199993991223454, `GTEX-SUCS` = 0.0167271490318362,
`GTEX-U3ZH` = 0.0166279561067514, `GTEX-U3ZN` = 0.0168263419569211,
`GTEX-WEY5` = 0.0218122431555806, `GTEX-WH7G` = 0.0169603561059156,
`GTEX-X4EP` = 0.0167271490318362, `GTEX-X4LF` = 0.0168263419569211,
`GTEX-X5EB` = 0.0231724562877696, `GTEX-XBEW` = 0.0187383789152412,
`GTEX-XLM4` = 0.0167271490318362, `GTEX-Y5LM` = 0.0168263419569211,
`GTEX-Y8E4` = 0.0121019992430171, `GTEX-YF7O` = 0.0168263419569211,
`GTEX-ZF29` = 0.0168980287283542, `GTEX-ZTSS` = 0.0166279561067514,
`GTEX-ZTTD` = 0.0168263419569211, `GTEX-ZV6S` = 0.0199993991223454,
`GTEX-ZVT2` = 0.0195049035328895, `GTEX-ZVZP` = 0.0199993991223454), class = "data.frame", row.names = c(NA,
-1L)), ENSG00000141959 = structure(list(`GTEX-11EQ9` = 0.00386794757219419,
`GTEX-12WSJ` = 0.00331068544990299, `GTEX-1EKGG` = 0.00549727349038067,
`GTEX-1EU9M` = -0.00220598881051638, `GTEX-1EWIQ` = -0.00220598881051638,
`GTEX-1F5PK` = -0.00047576052598424, `GTEX-1GMRU` = -0.000019400770038708,
`GTEX-1GTWX` = -0.00265461664506892, `GTEX-S95S` = -0.000205735129200752,
`GTEX-SN8G` = -0.00148165048282797, `GTEX-T5JC` = -0.00164872668822519,
`GTEX-T6MO` = -0.0013787012914417, `GTEX-TKQ2` = -0.00265461664506892,
`GTEX-U3ZM` = -0.00164872668822519, `GTEX-V1D1` = -0.00220598881051638,
`GTEX-WFG7` = -0.00103302264827544, `GTEX-WFG8` = -0.000205735129200752,
`GTEX-WFJO` = 0.00659503688105354, `GTEX-WOFM` = 0.00169406666058391,
`GTEX-Y5V6` = 0.00659503688105354, `GTEX-Y8LW` = 0.00269498140995324,
`GTEX-ZC5H` = 0.00225132878287511, `GTEX-ZXES` = 0.00549727349038067,
`GTEX-11EM3` = 0.0210024880281395, `GTEX-11EMC` = 0.0171347306001959,
`GTEX-11ZTT` = 0.018137007193539, `GTEX-1212Z` = 0.0228033435746737,
`GTEX-12696` = 0.0205811017648125, `GTEX-1269C` = 0.0168279586537404,
`GTEX-1GF9U` = 0.0205811017648125, `GTEX-1GMR8` = 0.0175495081991909,
`GTEX-1I4MK` = 0.0183843909485424, `GTEX-S4Q7` = 0.0211578279565913,
`GTEX-U3ZG` = 0.0177114567919747, `GTEX-WWTW` = 0.0204149125032887,
`GTEX-WZTO` = 0.0164914915754566, `GTEX-X4EO` = 0.0178224278158885,
`GTEX-XPT6` = 0.0198274900394434, `GTEX-Y5V5` = 0.0177114567919747,
`GTEX-YB5K` = 0.0180479238702585, `GTEX-YEC4` = 0.0168279586537404,
`GTEX-ZF3C` = 0.0214942950348751, `GTEX-ZG7Y` = 0.0171347306001959,
`GTEX-ZP4G` = 0.0171347306001959, `GTEX-ZT9W` = 0.0246041991212079,
`GTEX-11I78` = 0.00746714052332263, `GTEX-11VI4` = 0.00818008340245513,
`GTEX-12C56` = 0.0123095880229919, `GTEX-13111` = 0.00943601338470202,
`GTEX-1399R` = 0.00897187247388116, `GTEX-1FIGZ` = 0.00795749001625596,
`GTEX-1GN2E` = 0.00943601338470202, `GTEX-RUSQ` = 0.00780432935650995,
`GTEX-T5JW` = 0.00563415692477041, `GTEX-UPJH` = 0.00671924314064018,
`GTEX-V955` = 0.00904257623212573, `GTEX-VUSG` = 0.00994736151433579,
`GTEX-W5WG` = 0.00971976985656361, `GTEX-WRHK` = 0.00671924314064018,
`GTEX-XBED` = 0.00941833027807091, `GTEX-XMK1` = 0.00780432935650995,
`GTEX-XQ3S` = 0.00977320221788934, `GTEX-XXEK` = 0.00671924314064018,
`GTEX-Y8DK` = 0.00818008340245513, `GTEX-ZEX8` = 0.00795749001625596,
`GTEX-ZPCL` = 0.0100569586897509, `GTEX-ZQG8` = 0.00746714052332263,
`GTEX-ZTPG` = 0.00904257623212573, `GTEX-1122O` = -0.0148396051801961,
`GTEX-1211K` = -0.0141597831410679, `GTEX-12WSL` = -0.0141750601473065,
`GTEX-T6MN` = -0.0141133976650269, `GTEX-TMZS` = -0.012512044067443,
`GTEX-UPK5` = -0.0141133976650269, `GTEX-WFON` = -0.0143460749121506,
`GTEX-WHSB` = -0.0139271058939441, `GTEX-WHWD` = -0.00993393444101102,
`GTEX-WY7C` = -0.00920772692584177, `GTEX-WYVS` = -0.0144923036878726,
`GTEX-X15G` = -0.00993393444101102, `GTEX-XGQ4` = -0.0135798044016206,
`GTEX-Y9LG` = -0.0148396051801961, `GTEX-YEC3` = -0.0150722824273198,
`GTEX-ZDTS` = -0.0144923036878726, `GTEX-ZDTT` = -0.0143060119167898,
`GTEX-ZF2S` = -0.00955502841816534, `GTEX-ZLV1` = -0.0141133976650269,
`GTEX-ZPIC` = -0.0135798044016206, `GTEX-ZT9X` = -0.00920772692584177,
`GTEX-ZUA1` = -0.0152185112030418, `GTEX-12WSN` = -0.0151287367580205,
`GTEX-1F48J` = -0.0164455761832253, `GTEX-1F52S` = -0.016964848400182,
`GTEX-1GMR3` = -0.0151522926443206, `GTEX-SUCS` = -0.0126712489200476,
`GTEX-U3ZH` = -0.0144246945509821, `GTEX-U3ZN` = -0.0151522926443206,
`GTEX-WEY5` = -0.0155466417925569, `GTEX-WH7G` = -0.0113544094948428,
`GTEX-X4EP` = -0.0151287367580205, `GTEX-X4LF` = -0.0142298023673521,
`GTEX-X5EB` = -0.0164220202969252, `GTEX-XBEW` = -0.0106503672878044,
`GTEX-XLM4` = -0.0156480089749772, `GTEX-Y5LM` = -0.0164220202969252,
`GTEX-Y8E4` = -0.0140893159157665, `GTEX-YF7O` = -0.0164220202969252,
`GTEX-ZF29` = -0.0156480089749772, `GTEX-ZTSS` = -0.0156715648612773,
`GTEX-ZTTD` = -0.0170940674370707, `GTEX-ZV6S` = -0.0142298023673521,
`GTEX-ZVT2` = -0.0170940674370707, `GTEX-ZVZP` = -0.01773885972213), class = "data.frame", row.names = c(NA,
-1L)))
I know the subject is widely covers but I didn't find the code working for my case... I have a dataframe of this type:
V1 V2 V3
1: label1 alias_fr alias_fr
2: label1 triplet triplet
3: label1 Q9327 Q3122270
4: label2 NULL NULL
5: label3 alias_fr NULL
6: label3 triplet NULL
7: label3 Q678 NULL
This dataframe is generated after mapping a json output to a query from a df input:
df <- Map(rbind, originalDF$input,out) #I first used Map(c,..) but it seems to be more difficult to reshape than rbind
df <- rbind.fill(lapply(df,function(y){as.data.frame(t(y),stringsAsFactors=FALSE)}))
class(df)
[1] "data.frame"
The example given is simplified though, as I have more than 3 columns, and some values are lists. Nevertheless when I have non-NULL values for a label I have always the same number of rows within a column (3 in my example: alias_fr, triplet, Qxx).
And I would like to have V2 and V3 values in row for each V1 value:
V1 var1 var2 var3
label1 alias_fr triplet Q9327
label1 alias_fr triplet Q3122270
label2 NULL NULL NULL
label3 alias_fr triplet Q678
I try to start melt: melt(df,id="V1"), but then I am stuck.
I also tried reshape, cast, dcast, without any success, and I am more and more confuse with all reshaping stuff... If a reshape master is around, I would be very gratefull ;)
[Edit]: real objects to clarify my issue
Ok so this is an extract of the real dataset I’m working with:
#original dataset (actually it’s one column of the dataset)
originalDF <- c("Guy de Maupassant", "J.-J. Goldman", "Poitou-Charentes")
#output of the API query from the text in the orginalDF
out <- list(structure(list(`_index` = c("alias_fr", "alias_fr"), `_type` = c("triplet",
"triplet"), `_id` = c("Q9327", "Q3122270"), `_score` = c(NA,
NA), sort = list(-4.95263021255079, -6.65910164747673), `_source.types` = list(
structure(list(id = c("Q5", "dbPedia.Person"), value = c("être humain",
"personne")), .Names = c("id", "value"), class = "data.frame", row.names = 1:2),
structure(list(id = c("Q11424", "dbPedia.Film"), value = c("film",
"film")), .Names = c("id", "value"), class = "data.frame", row.names = 1:2)),
`_source.pageRank` = c(-4.95263021255079, -6.65910164747673
), `_source.subTypes` = list(structure(list(id = c("Q1930187",
"Q36180", "Q15949613", "Q6625963", "Q214917"), value = c("journaliste",
"écrivain", "nouvelliste", "romancier", "dramaturge")), .Names = c("id",
"value"), class = "data.frame", row.names = c(NA, 5L)), NULL),
`_source.label` = c("Guy de Maupassant", "Guy de Maupassant"
), `_source.id` = c("Q9327", "Q3122270")), .Names = c("_index",
"_type", "_id", "_score", "sort", "_source.types", "_source.pageRank",
"_source.subTypes", "_source.label", "_source.id"), class = "data.frame", row.names = 1:2),
list(), structure(list(`_index` = "alias_fr", `_type` = "triplet",
`_id` = "Q17009", `_score` = NA, sort = list(-5.0448283638424),
`_source.types` = list(structure(list(id = "Q22670030",
value = "ancienne région française"), .Names = c("id",
"value"), class = "data.frame", row.names = 1L)), `_source.pageRank` = -5.0448283638424,
`_source.label` = "Poitou-Charentes", `_source.id` = "Q17009"), .Names = c("_index",
"_type", "_id", "_score", "sort", "_source.types", "_source.pageRank",
"_source.label", "_source.id"), class = "data.frame", row.names = 1L))
#df object (generated from Map, then rbind.fill)
df <- structure(list(V1 = list("Guy de Maupassant", "Guy de Maupassant",
"Guy de Maupassant", "Guy de Maupassant", "Guy de Maupassant",
"Guy de Maupassant", "Guy de Maupassant", "Guy de Maupassant",
"Guy de Maupassant", "Guy de Maupassant", "J.-J. Goldman",
"Poitou-Charentes", "Poitou-Charentes", "Poitou-Charentes",
"Poitou-Charentes", "Poitou-Charentes", "Poitou-Charentes",
"Poitou-Charentes", "Poitou-Charentes", "Poitou-Charentes"),
V2 = list("alias_fr", "triplet", "Q9327", NA_character_,
-4.95263021255079, structure(list(id = c("Q5", "dbPedia.Person"
), value = c("être humain", "personne")), .Names = c("id",
"value"), class = "data.frame", row.names = 1:2), "-4.95263021255079",
structure(list(id = c("Q1930187", "Q36180", "Q15949613",
"Q6625963", "Q214917"), value = c("journaliste", "écrivain",
"nouvelliste", "romancier", "dramaturge")), .Names = c("id",
"value"), class = "data.frame", row.names = c(NA, 5L)),
"Guy de Maupassant", "Q9327", NULL, "alias_fr", "triplet",
"Q17009", NA_character_, -5.0448283638424, structure(list(
id = "Q22670030", value = "ancienne région française"), .Names = c("id",
"value"), class = "data.frame", row.names = 1L), "-5.0448283638424",
"Poitou-Charentes", "Q17009"), V3 = list("alias_fr",
"triplet", "Q3122270", NA_character_, -6.65910164747673,
structure(list(id = c("Q11424", "dbPedia.Film"), value = c("film",
"film")), .Names = c("id", "value"), class = "data.frame", row.names = 1:2),
"-6.65910164747673", NULL, "Guy de Maupassant", "Q3122270",
NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL,
NULL), V4 = list(NULL, NULL, NULL, NULL, NULL, NULL,
NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL,
NULL, NULL, NULL, NULL, NULL)), .Names = c("V1", "V2",
"V3", "V4"), row.names = c(NA, 20L), class = "data.frame")
For your particular example (each label has a maximum of three rows), one approach would be
require(dplyr)
df <- data.frame(label = c(rep('a',3),'b', rep('c',3)), id1 = c(1,2,3,NA, 1,2,4), id2 = c(1,2,5,NA,NA,NA,NA))
#I used different names than you, because I have the impression that each column belongs to another measurement or so
df1 <- select(df, label, id1)#subsets your df into two data frames
df2 <- select(df, label, id2)
df1a <- df1 %>% group_by(label) %>% summarise (var1 = id1[1], var2 = id1[2], var3 = id1[3])
df2b <- df2 %>% group_by(label) %>% summarise (var1 = id2[1], var2 = id2[2], var3 = id2[3])
#this groups the columns after your label and then you can force the creation of NA values for the observations that do not have a row in your df
df_final <- rbind(df1a,df2b)
> df_final
# A tibble: 6 x 4
label var1 var2 var3
<fctr> <dbl> <dbl> <dbl>
1 a 1 2 3
2 b NA NA NA
3 c 1 2 4
4 a 1 2 5
5 b NA NA NA
6 c NA NA NA
I know that this is not elegant, and not generalisable, because you manually assign a new column for each row that you have/ do not have in your df, but it should work with your example.
i have data frame called df,how to create new column from existing list column data frame.
my data frame.
Policy Item
Checked list(Processed = "Valid", Gmail = "yy#gmail", Information = list(list(Descrption = "T1, R1", VID = "YUY")))
Sample list(Processed = "Valid", Gmail = "tt#gmail", Information = list(list(Descrption = "D3, Y3", VID = "RT")))
Processed list(Processed = "Valid", Gmail = "pp#gmail", Information = list(list(Descrption = "Y2, LE", VID = "UIU")))
my expected data frame.
Policy Processed Gmail Descrption VID
Checked Valid yy#gmail "T1,R1" "YUY"
Sample Valid tt#gmail "D3,Y3" "RT"
Processed Valid pp#gmail "Y2,LE" "UIU"
i'm using below code to get my expected dataframe .
na_if_null <- function(x) if (is.null(x)) NA else x
new_cols <- lapply(
Filter(is.list, df),
function(list_col) {
names_ <- setNames(nm = unique(do.call(c, lapply(list_col, names))))
lapply(names_, function(name) sapply(list_col, function(x)
trimws(na_if_null(as.list(x)[[name]]))))
}
)
res <- do.call(
data.frame,
c(
list(df, check.names = FALSE, stringsAsFactors = FALSE),
do.call(c, new_cols)
)
)
But i'm getting below Data frame.please help me to done my post.
Policy Item Item.Processed Item.Gmail Item.Information
Checked list(Processed = "Valid", Gmail = "yy#gmail", Information = list(list(Descrption = "T1, R1", VID = "YUY"))) Processed yy#gmail list(Descrption = "T1, R1", VID = "YUY")
Sample list(Processed = "Valid", Gmail = "tt#gmail", Information = list(list(Descrption = "D3, Y3", VID = "RT"))) Processed tt#gmail list(Descrption = "D3, Y3", VID = "RT")
Processed list(Processed = "Valid", Gmail = "pp#gmail", Information = list(list(Descrption = "Y2, LE", VID = "UIU"))) Processed pp#gmail list(Descrption = "Y2, LE", VID = "UIU")
dput
structure(list(Policy = c("Checked", "Sample", "Processed"), Item = list(
structure(list(Processed = "Valid", Gmail = "yy#gmail", Information = list(
structure(list(Descrption = "T1, R1", VID = "YUY"), .Names = c("Descrption",
"VID"), class = "data.frame", row.names = 1L))), .Names = c("Processed",
"Gmail", "Information"), class = "data.frame", row.names = 1L),
structure(list(Processed = "Valid", Gmail = "tt#gmail", Information = list(
structure(list(Descrption = "D3, Y3", VID = "RT"), .Names = c("Descrption",
"VID"), class = "data.frame", row.names = 1L))), .Names = c("Processed",
"Gmail", "Information"), class = "data.frame", row.names = 1L),
structure(list(Processed = "Valid", Gmail = "pp#gmail", Information = list(
structure(list(Descrption = "Y2, LE", VID = "UIU"), .Names = c("Descrption",
"VID"), class = "data.frame", row.names = 1L))), .Names = c("Processed",
"Gmail", "Information"), class = "data.frame", row.names = 1L))), row.names = c(NA,
3L), class = "data.frame", .Names = c("Policy", "Item"))
Sample data frame
Policy colval Item
Checked list(PID="4",Bdetail ="ui,89") list(Processed = "Valid", Gmail = "yy#gmail", Information = list(list(Descrption = "T1, R1", VID = "YUY")))
Sample list(PID="7",Bdetail ="ju,78") list(Processed = "Valid", Gmail = "tt#gmail", Information = list(list(Descrption = "D3, Y3", VID = "RT")))
Processed list(PID ="8",Bdetail ="nj,45") list(Processed = "Valid", Gmail = "pp#gmail", Information = list(list(Descrption = "Y2, LE", VID = "UIU")))
Here a solution in base R:
dd <-
cbind(
dx$Policy,
do.call(rbind,
lapply(seq_len(nrow(dx)), function(i)unlist(dx$Item[i]))
)
)
colnames(dd) <- c("Policy","Processed","Gmail","Descrption","VID")
dd
# Policy Processed Gmail Descrption VID
# [1,] "Checked" "Valid" "yy#gmail" "T1, R1" "YUY"
# [2,] "Sample" "Valid" "tt#gmail" "D3, Y3" "RT"
# [3,] "Processed" "Valid" "pp#gmail" "Y2, LE" "UIU"
Basically I am using unlist for each item. and Then joining them using the classic d.call(rbind,llist).
edit
in case you want tu use the same names as the original sub lists you can do something like :
colnames(dd) <- c("Policy",gsub(".*[.]","",colnames(dd)[-1]))
data.table solution
library(data.table)
setDT(dx)
dx[, rbindlist(lapply(.SD,function(x)data.table(t(unlist(x))))),Policy]
Easily done with unnest from tidyr:
library(dplyr)
library(tidyr)
df %>%
unnest() %>%
unnest()
Result:
Policy Processed Gmail Descrption VID
1 Checked Valid yy#gmail T1, R1 YUY
2 Sample Valid tt#gmail D3, Y3 RT
3 Processed Valid pp#gmail Y2, LE UIU
Data:
df = structure(list(Policy = c("Checked", "Sample", "Processed"), Item = list(
structure(list(Processed = "Valid", Gmail = "yy#gmail", Information = list(
structure(list(Descrption = "T1, R1", VID = "YUY"), .Names = c("Descrption",
"VID"), class = "data.frame", row.names = 1L))), .Names = c("Processed",
"Gmail", "Information"), class = "data.frame", row.names = 1L),
structure(list(Processed = "Valid", Gmail = "tt#gmail", Information = list(
structure(list(Descrption = "D3, Y3", VID = "RT"), .Names = c("Descrption",
"VID"), class = "data.frame", row.names = 1L))), .Names = c("Processed",
"Gmail", "Information"), class = "data.frame", row.names = 1L),
structure(list(Processed = "Valid", Gmail = "pp#gmail", Information = list(
structure(list(Descrption = "Y2, LE", VID = "UIU"), .Names = c("Descrption",
"VID"), class = "data.frame", row.names = 1L))), .Names = c("Processed",
"Gmail", "Information"), class = "data.frame", row.names = 1L))), row.names = c(NA,
3L), class = "data.frame", .Names = c("Policy", "Item"))
Note:
Notice I used two passes of unnest because there are two levels of lists in your original dataframe. unnest automatically flattens all lists in the dataframe and reuses the names, but it does not do it recursively, so you will have to have as many unnest as there are list levels.
I have a vector of lists in it. Every list contain field category
I need delete all lists with fields category == resource.
I tried
for(i in 1:length(myList)){
if(myList[[as.numeric(i)]]$data$category == "resource"){
myList[[as.numeric(i)]]<-NULL
}
}
Is it correct?
> dput(myList[1:2])
list(structure(list(data = structure(list(device = "iPad2,4",
os_version = "ios 7.1.2", connection_type = "wifi", category = "user",
platform = "ios", session_num = 2, ios_idfv = "E12AA218-4061-4BA1-AFA3-47FEE1511C2E",
client_ts = 1454926346, sdk_version = "unity 2.4.3", limited_ad_tracking = TRUE,
user_id = "436E8588-B2FA-411A-896C-5757E7A2A377", manufacturer = "apple",
jailbroken = TRUE, ios_idfa = "436E8588-B2FA-411A-896C-5757E7A2A377",
build = "1.0", session_id = "558910f2-7c2c-4280-84fc-2fef1a50d291",
v = 2, engine_version = "unity 4.6.9"), .Names = c("device",
"os_version", "connection_type", "category", "platform", "session_num",
"ios_idfv", "client_ts", "sdk_version", "limited_ad_tracking",
"user_id", "manufacturer", "jailbroken", "ios_idfa", "build",
"session_id", "v", "engine_version")), first_in_batch = TRUE,
country_code = "RO", arrival_ts = 1454926344, game_id = 24540,
ip = "93.168.249.0"), .Names = c("data", "first_in_batch",
"country_code", "arrival_ts", "game_id", "ip")), structure(list(
data = structure(list(os_version = "ios 9.2.1", engine_version = "unity 4.6.9",
category = "user", v = 2, ios_idfa = "F06962FE-FCE5-475F-8CC2-83FF1F89E573",
sdk_version = "unity 2.4.3", user_id = "F06962FE-FCE5-475F-8CC2-83FF1F89E573",
session_num = 2, platform = "ios", connection_type = "wifi",
manufacturer = "apple", client_ts = 1454925528, limited_ad_tracking = TRUE,
session_id = "3ab1fbbb-5103-4ad8-bf56-94f70fea94a7",
device = "iPad4,1", ios_idfv = "2C940E82-B074-4A15-B9A7-A5983759042F",
build = "1.0"), .Names = c("os_version", "engine_version",
"category", "v", "ios_idfa", "sdk_version", "user_id", "session_num",
"platform", "connection_type", "manufacturer", "client_ts",
"limited_ad_tracking", "session_id", "device", "ios_idfv",
"build")), first_in_batch = TRUE, country_code = "AU", arrival_ts = 1454925528,
game_id = 24540, ip = "110.175.52.0"), .Names = c("data",
"first_in_batch", "country_code", "arrival_ts", "game_id", "ip"
)))
You could use rlist package :
library(rlist)
filtered_list <- list.exclude(myList, data$category == "ressource")
We could use Filter from base R
Filter(function(x) x$data$category!="resource", myList)
Below is a subsample of my data set (only 2 rows by 215 columns). I am trying to view them on RStudio but it gives me the following error:
Error in View : undefined columns selected
Do not really know what is going on. The whole set is 7786 rows by 215 columns. Viewing it works fine, however, when doing any kind of subsetting or removing one row it is no longer want to view.
structure(list(`NA` = structure(c(16343, 16344), class = "Date"),
AVON = c("615.5", "621.5"), BA. = c("471.5", "463.2"), CMRG = c("224.5",
"224.5"), COB = c("291.10000000000002", "283.5"), MGGT = c("451.2",
"444.7"), QQ. = c("224.5", "223.5"), RR. = c("953.65", "933.38"
), SNR = c("268.2", "264.7"), ULE = c("1771", "1746"), GKN = c("319.2",
"311.5"), BRAG = c("617", "603"), BVIC = c("668", "661"),
CCH = c("1333", "1327"), DGE = c("1785", "1760.5"), SAB = c("3428",
"3383"), STCK = c("291.60000000000002", "294"), ALNT = c("328",
"321"), CAR = c("125", "124.5"), CRDA = c("2053", "1990"),
ELM = c("255.5", "254.5"), JMAT = c("2919", "2825"), SYNT = c("212",
"210.8"), VCTA = c("1606", "1605"), DIA = c("901", "924"),
DNO = c("611", "611"), E2V = c("161", "160.5"), HLMA = c("612",
"598.5"), HTY = c("309.8", "308"), MGAM = c("296.8", "289.40000000000003"
), OXFD = c("1020", "1035"), RSHW = c("1630", "1625"), SXS = c("1808",
"1778"), TTG = c("166.75", "167.5"), XAR = c("376", "367"
), X = c("1527", "1520"), ABF = c("2679", "2654"), AE = c("633.5",
"640"), CARM = c("1647", "1637"), CWK = c("1328", "1320"),
DCG = c("383.75", "369"), DVO = c("237.75", "231"), GNCL = c("234",
"229.6"), HFG = c("416", "411"), FD = c("36.5", "34.75"),
TATE = c("591.5", "585"), MNDI = c("1011", "1012"), BI = c("616",
"620"), REX = c("491.8", "483.5"), RC = c("559", "540"),
SMDS = c("266.3", "257"), SMIN = c("1264", "1250"), VSVS = c("451.8",
"438.40000000000003"), AGA = c("163.25", "160.25"), BDEV = c("396.1",
"389.3"), BKG = c("2250", "2224"), BLWY = c("1567", "1558"
), BVS = c("779", "771"), CRST = c("325", "314.60000000000002"
), GLSN = c("393.5", "388.5"), MCB = c("83.53", "83.29"),
SN = c("1334", "1309"), RB. = c("5350", "5305"), RDW = c("280.7",
"273.8"), TW. = c("112.8", "111.8"), BODY = c("668.5", "647"
), FENR = c("317.60000000000002", "313.10000000000002"),
GDWN = c("3500", "3500"), HILS = c("561", "561.5"), IMI = c("1230",
"1206"), MRO = c("247.70000000000002", "246"), VAR = c("304",
"300.75"), RNO = c("56", "54.5"), RTRK = c("2765", "2736"
), SFR = c("63.5", "64"), SRX = c("2826", "2812"), TRI = c("105.75",
"105"), VTC = c("613.5", "612"), WEIR = c("2502", "2430"),
EVR = c("130", "123.60000000000001"), FXO = c("112.3", "105.10000000000001"
), BBA = c("325", "326"), BMS = c("494.38", "492"), CKN = c("2350",
"2341"), FSHR = c("1326", "1294"), RMG = c("392.2", "399.7"
), STOB = c("111", "109"), UKM = c("473.88", "467"), WIN = c("136.25",
"137.5"), GAW = c("597.5", "585"), HTM = c("131.5", "129.25"
), `NA` = c(NA_character_, NA_character_), AAL = c("1384",
"1363.5"), ABG = c("218.8", "209.1"), ANTO = c("721", "702"
), AF = c("131.5", "130.25"), AQ = c("18.5", "18.75"), ARMS = c("69",
"62.25"), BLT = c("1715", "1690.5"), CEY = c("61.15", "61"
), FRES = c("760", "747"), GEMD = c("192", "191.75"), GLEN = c("343.2",
"336.45"), HOC = c("135.30000000000001", "130.19999999999999"
), KAZ = c("263.39999999999998", "260.10000000000002"), KMRL = c("9.5",
"9.3000000000000007"), LMI = c("185.8", "176.8"), NWR = c("1.97",
"1.82"), `NA` = c(NA_character_, NA_character_), DL = c("190.20000000000002",
"190"), OG = c("22", "24"), OLY = c("516", "496.6"), RIO = c("3031.5",
"3020"), RRS = c("4209", "4154"), VED = c("998.5", "974.5"
), AFR = c("103.5", "109.4"), BG. = c("1140", "1093"), B. = c("453.45",
"452.75"), CNE = c("176.5", "171.6"), ENQ = c("109.60000000000001",
"107.8"), EXI = c("157", "150"), HDY = c("102", "99.75"),
JKX = c("48.25", "47"), OHR = c("229.3", "220.9"), MO = c("333",
"324.7"), RDSA = c("2358.5", "2331"), RDSB = c("2437", "2418.5"
), SIA = c("381", "377.90000000000003"), SMDR = c("100",
"98.5"), TLW = c("644.5", "631"), AMEC = c("1104", "1077"
), CIU = c("283.5", "275.75"), GMS = c("157", "157"), HTG = c("892.5",
"876"), LAM = c("163.25", "160"), FC = c("1037", "1011"),
WG. = c("759.5", "743"), BRBY = c("1511", "1476"), ZC = c("365.7",
"366"), SG = c("1133", "1126"), TED = c("1863", "1862"),
ULVR = c("2585", "2547"), AZN = c("4441.5", "4360.5"), BTG = c("700",
"697.5"), CIR = c("304", "300"), DH = c("758", "753"), GNS = c("1130",
"1130"), GSK = c("1413", "1414"), HIK = c("1733", "1715"),
SH = c("5340", "5310"), SK = c("329.25", "319"), VEC = c("132",
"132"), AGK = c("1548", "1528"), AHT = c("1043", "1024"),
ATK = c("1317", "1323"), BAB = c("1092", "1085"), BNZL = c("1610",
"1597"), BRAM = c("376", "374"), BRSN = c("980", "979"),
CLLN = c("304.60000000000002", "304.3"), CMS = c("59.75",
"59.5"), CNCT = c("149.25", "151"), CI = c("1164", "1165"
), CTR = c("259.5", "255"), DCC = c("3422", "3405"), DLAR = c("477",
"478"), DLM = c("689.5", "685"), ECOM = c("223", "219.8"),
ESNT = c("797.5", "792.5"), EXO = c("176.5", "180"), EXN = c("983.5",
"968"), GFS = c("250.70000000000002", "251.6"), GFTU = c("626",
"616"), HAS = c("116.3", "115.7"), HRG = c("45.75", "45.75"
), HSV = c("319.7", "319"), HWDN = c("339.1", "335"), HYC = c("749",
"748"), IRV = c("599.5", "592.5"), ITRK = c("2621", "2631"
), LVD = c("201.75", "201.5"), MER = c("435", "436.75"),
MMC = c("25.25", "25"), MNZS = c("569", "575.5"), MI = c("418.6",
"421"), MTO = c("287.90000000000003", "286.60000000000002"
), NTG = c("483.8", "481.3"), AY = c("983.5", "989"), FL = c("182",
"180.1"), RCDO = c("671", "667.5"), RENT = c("117.8", "116"
), RGU = c("169.70000000000002", "169.9"), RS = c("261",
"251.6"), RWA = c("302.5", "302.5"), SDY = c("70.5", "69.75"
), SERC = c("286.10000000000002", "279.8"), SHI = c("166.6",
"161.1"), SIV = c("199.75", "200"), SKS = c("90", "92"),
STHR = c("350.25", "358.5"), TK = c("1664", "1635"), TRB = c("170.5",
"172"), V. = c("609.5", "600"), WOS = c("3242", "3243"),
XCH = c("188", "184.75"), ARM = c("906", "887.5"), BVC = c("16.38",
"16.25"), CSR = c("758", "756"), IMG = c("188.5", "184.75"
), LRD = c("309.7", "306.7"), IC = c("298.10000000000002",
"299"), SEU = c("141", "141"), ST = c("104.60000000000001",
"99.9"), BATS = c("3482", "3480"), IMT = c("2664", "2679"
)), .Names = c("NA", "AVON", "BA.", "CMRG", "COB", "MGGT",
"QQ.", "RR.", "SNR", "ULE", "GKN", "BRAG", "BVIC", "CCH", "DGE",
"SAB", "STCK", "ALNT", "CAR", "CRDA", "ELM", "JMAT", "SYNT",
"VCTA", "DIA", "DNO", "E2V", "HLMA", "HTY", "MGAM", "OXFD", "RSHW",
"SXS", "TTG", "XAR", "X", "ABF", "AE", "CARM", "CWK", "DCG",
"DVO", "GNCL", "HFG", "FD", "TATE", "MNDI", "BI", "REX", "RC",
"SMDS", "SMIN", "VSVS", "AGA", "BDEV", "BKG", "BLWY", "BVS",
"CRST", "GLSN", "MCB", "SN", "RB.", "RDW", "TW.", "BODY", "FENR",
"GDWN", "HILS", "IMI", "MRO", "VAR", "RNO", "RTRK", "SFR", "SRX",
"TRI", "VTC", "WEIR", "EVR", "FXO", "BBA", "BMS", "CKN", "FSHR",
"RMG", "STOB", "UKM", "WIN", "GAW", "HTM", NA, "AAL", "ABG",
"ANTO", "AF", "AQ", "ARMS", "BLT", "CEY", "FRES", "GEMD", "GLEN",
"HOC", "KAZ", "KMRL", "LMI", "NWR", NA, "DL", "OG", "OLY", "RIO",
"RRS", "VED", "AFR", "BG.", "B.", "CNE", "ENQ", "EXI", "HDY",
"JKX", "OHR", "MO", "RDSA", "RDSB", "SIA", "SMDR", "TLW", "AMEC",
"CIU", "GMS", "HTG", "LAM", "FC", "WG.", "BRBY", "ZC", "SG",
"TED", "ULVR", "AZN", "BTG", "CIR", "DH", "GNS", "GSK", "HIK",
"SH", "SK", "VEC", "AGK", "AHT", "ATK", "BAB", "BNZL", "BRAM",
"BRSN", "CLLN", "CMS", "CNCT", "CI", "CTR", "DCC", "DLAR", "DLM",
"ECOM", "ESNT", "EXO", "EXN", "GFS", "GFTU", "HAS", "HRG", "HSV",
"HWDN", "HYC", "IRV", "ITRK", "LVD", "MER", "MMC", "MNZS", "MI",
"MTO", "NTG", "AY", "FL", "RCDO", "RENT", "RGU", "RS", "RWA",
"SDY", "SERC", "SHI", "SIV", "SKS", "STHR", "TK", "TRB", "V.",
"WOS", "XCH", "ARM", "BVC", "CSR", "IMG", "LRD", "IC", "SEU",
"ST", "BATS", "IMT"), row.names = 7785:7786, class = "data.frame")
I am on Mac OS 10.10, R 3.1.1 and RStudio 0.98.1060.
One of your column names is NA. If d is your data defined above, then try names(d)[92]. Try replacing with a non-missing column name.
As allready mentioned by DMC, but with a short version of your example code.
a <- structure(list(`NA` = structure(c(16343, 16344), class = "Date"),
AVON = c("615.5", "621.5"),
BA. = c("471.5", "463.2"),
`NA` = c(NA_character_, NA_character_), AAL = c("1384", "1363.5")),
.Names = c(NA, "AVON", "BA.", "NA", "AAL"), row.names = 7785:7786, class = "data.frame")
View(a)
Error in View : undefined columns selected
names(a)
[1] NA "AVON" "BA." "NA" "AAL"
a <- structure(list(`NA` = structure(c(16343, 16344), class = "Date"),
AVON = c("615.5", "621.5"),
BA. = c("471.5", "463.2"),
`NA` = c(NA_character_, NA_character_), AAL = c("1384", "1363.5")),
.Names = c("NA", "AVON", "BA.", "NA", "AAL"), row.names = 7785:7786, class = "data.frame")
View(a)
names(a)
[1] "NA" "AVON" "BA." "NA" "AAL"
You need to have proper names in the data frame to View it.