【问题标题】:Merge multiple sub-lists with the same elements using lapply functions in R使用 R 中的 lapply 函数合并具有相同元素的多个子列表
【发布时间】:2020-06-03 20:49:13
【问题描述】:

我知道这对你们中的大多数人来说可能是微不足道的,但是我没有使用过很多 apply 函数。另外,由于性能原因,我试图避免使用for loop,而是想使用lapply 函数。

我有一个 results 列表,其中包含 n 个具有相同子列表组件(“shipment”、“orders”、“boxes”、“prepacks”)的子列表。所以,我想做的是:将所有子列表合并到一个列表 results 与四个子列表(“shipment”,“orders”,“boxes”,“prepacks”强>)。

Here is the structure of the results list

dput(results[[1]])

列表(装运 = 结构(列表(TransactionTimeUtc = 结构(c(1582023318.99033, 1582023319.11、1582023319.30792、1582023319.44646、1582023319.95777、 1582023320.15857), class= c("POSIXct", "POSIXt"), tzone = "UTC"), 操作= c(“插入”,“插入”,“插入”,“插入”,“插入”, “插入”),集合 = c(“装运”,“装运”,“装运”, "装运", "装运", "装运"), AppId = c("logistics.bi.datapublisher", “logistics.bi.datapublisher”,“logistics.bi.datapublisher”, “logistics.bi.datapublisher”,“logistics.bi.datapublisher”, "logistics.bi.datapublisher"), Document.ShipmentId = c("11058187", “11058183”、“11058185”、“11058191”、“11058190”、“11058196” ), Document.IsFreightForwarded = c(FALSE, FALSE, FALSE, FALSE, 错误,错误),Document.CustomerId = c(38883L,24826L,81640L, 27319L, 16306L, 156776L), Document.DispatchDate = 结构(c(1582002000, 1582002000, 1582002000, 1582002000, 1582002000, 1582002000 ), class= c("POSIXct", "POSIXt"), tzone = "UTC"), Document.ReadyToShipDate = structure(c(1582014305.557, 1582012026.518、1582010013.899、1582014501.524、1582014852.788、 1582012136.384), class= c("POSIXct", "POSIXt"), tzone = "UTC"), Document.ShipDate = c("2020-02-18T05:00:00Z", "2020-02-18T05:00:00Z", “2020-02-18T05:00:00Z”、“2020-02-18T05:00:00Z”、“2020-02-18T05:00:00Z”、 "2020-02-18T05:00:00Z"), Document.CompletedByUserId = c(22241L, 22241L, 22241L, 22241L, 22241L, 22241L), Document.ShipAttention = c("BAOPING CAO", 不,《陈春青》《文竹武》《杉杉赋》《张新》 ), Document.ModelVersion = c(2L, 2L, 2L, 2L, 2L, 2L), Document.ShippedByUserId = c(438L, 438L, 438L, 438L, 438L, 438L), Document.TotalQtyShipped = c(1L, 3L, 2L, 1L, 1L, 1L), Document.Itn = c(NA, NA, NA, NA, NA, NA), Document.ShipmentReference = c("B11058187", "B11058183", "B11058185"、"B11058191"、"B11058190"、"B11058196")、Document.ConsolidationMethod = c("0", “0”,“0”,“0”,“0”,“0”),Document.ShipmentType = c(“RR”, "RR", "RR", "RR", "RR", "RR"), Document.RealShipDate = c("2020-02-18T05:00:00Z", “2020-02-18T05:00:00Z”、“2020-02-18T05:00:00Z”、“2020-02-18T05:00:00Z”、 "2020-02-18T05:00:00Z", "2020-02-18T05:00:00Z"), Document.PortOfLading = c("广州", “广州”、“广州”、“广州”、“广州”、“广州” ), Document.LeadTrackingNumber = c("295841879239", "295840702753", “295839545260”、“295841999709”、“295842158158”、“295840755210” ), Document.Billing.IsBilled = c(FALSE, FALSE, FALSE, FALSE, FALSE, FALSE), Document.Billing.CustomerBilling.IsoCurrencyCode = c("CNY", "CNY", "CNY", "CNY", "CNY", "CNY"), Document.Billing.CustomerBilling.CompanyId = c(10L, 10L, 10L, 10L, 10L, 10L), Document.Billing.CustomerBilling.IsSAB = c(FALSE, 假,假,假,假,假),Document.Billing.CustomerBilling.TermId = c(4L, 1L, 1L, 4L, 3L, 1L), Document.Billing.CustomerBilling.IsDistributor = c(FALSE, 假,假,假,假,假),Document.Billing.CustomerBilling.IsBillTax = c(假, 错误,错误,错误,错误,错误),Document.Billing.CustomerBilling.CustomerId = c(38883L, 24826L、81640L、27319L、16306L、156776L)、Document.Billing.CustomerBilling.BillingId = c(12920L, 6510L, 38838L, 7099L, 9036L, 997359L), Document.Billing.CustomerBilling.Address.Division = c("", "", "", "", "", ""), Document.Billing.CustomerBilling.Address.IsoCountryCode = c("CN", "CN", "CN", "CN", "CN", "CN"), Document.Billing.CustomerBilling.Address.AddressId = c(53750L, 34998L, 141602L, 268186L, 40823L, 288577L), Document.Billing.CustomerBilling.Address.City = c("江苏", "江苏", "北京", "安徽", "北京", "广东"), Document.Billing.CustomerBilling.Address.AddressLine2 = c("南京 经济技术开发区”, “工业开发区汉江路”、“凉水河路8号”、 “高新技术开发区”、“联东U顾开发区”、 "南山区南新路"), Document.Billing.CustomerBilling.Address.AddressLine3 = c("南京", “无锡”、“昌平区”、“葛江区芜湖”、“马驹桥镇通州区”、 "深圳"), Document.Billing.CustomerBilling.Address.AddressLine1 = c("横泾路11号", “51座-国家高新”、“301室”、“华夏科技园506”、 “京盛南街15号”、“苏豪大厦11A2室” ), Document.Billing.CustomerBilling.Address.PostalCode = c("210013", "214028", "102200", "241006", "101102", "518000"), Document.Billing.CustomerBilling.Address.AddressName = c("南京 康尼科技实业有限公司", “无锡普菲斯有限公司”、“北京百合通机电”、 “安徽华东职业技术学院”、“北京信邦电气有限公司”、 "深圳市宏泰瑞科技有限公司"), Document.Billing.CustomerBilling.Address.StateCode = c("", "", "", "", "", ""), Document.PrecisionConfig.Locale = c("TEAMRM", "TEAMRM", "TEAMRM", "TEAMRM", "TEAMRM", "TEAMRM"), Document.PrecisionConfig.Client = c("GZ", "GZ", "GZ", "GZ", "GZ", "GZ"), Document.PrecisionConfig.Language = c("STE", "STE", "STE", "STE", "STE", "STE"), Document.PrecisionConfig.PackingLocation = c("GZ", "GZ", "GZ", "GZ", "GZ", "GZ"), Document.Status.ChangedDate = c("2020-02-18T10:55:18.534Z", “2020-02-18T10:55:18.122Z”、“2020-02-18T10:55:18.329Z”、“2020-02-18T10:55:18.94Z”、 “2020-02-18T10:55:18.846Z”、“2020-02-18T10:55:19.471Z”)、 Document.Status.StatusId = c(4L, 4L, 4L, 4L, 4L, 4L), Document.Status.Description = c("已发货", "已发货", "已发货", "已发货", "已发货", "已发货"), Document.TranslationInfo.BillToAddress.City = c("", "", "", "", "", ""), Document.TranslationInfo.BillToAddress.Name = C(” ",

"<U+65E0><U+9521><U+5E02> <U+65E0><U+9521><U+666E><U+6D1B><U+83F2><U+65AF><U+7535><U+5B50><U+6709><U+9650><U+516C><U+53F8> ", 
"<U+5317><U+4EAC><U+67CF><U+548C><U+901A><U+673A><U+7535><U+8BBE><U+5907><U+6709><U+9650><U+516C><U+53F8>",

"<U+4E2D><U+822A><U+534E><U+4E1C><U+5149><U+7535><U+6709><U+9650><U+516C><U+53F8>",

"<U+5317><U+4EAC><U+4FE1><U+90A6><U+7535><U+5B50><U+6709><U+9650><U+516C><U+53F8>",

"<U+6DF1><U+5733><U+5E02><U+9E3F><U+6CF0><U+745E><U+79D1><U+6280><U+6709><U+9650><U+516C><U+53F8>"
), Document.TranslationInfo.BillToAddress.CountryIso = c("CN", 
"CN", "CN", "CN", "CN", "CN"), Document.TranslationInfo.BillToAddress.Line3 = c(NA, 
NA, NA, NA, NA, NA), Document.TranslationInfo.BillToAddress.Line2 = c(NA, 
NA, NA, NA, NA, NA), Document.TranslationInfo.BillToAddress.Line1 = c("<U+5357><U+4EAC><U+5E02><U+7ECF><U+6D4E><U+6280><U+672F><U+5F00><U+53D1><U+533A><U+6052><U+7ADE><U+8DEF>11<U+53F7>",

"<U+65E0><U+9521><U+56FD><U+5BB6><U+9AD8><U+65B0><U+6280><U+672F><U+4EA7><U+4E1A><U+5F00><U+53D1><U+533A>51-A<U+53F7><U+5730><U+5757>",

"<U+5317><U+4EAC><U+5E02><U+660C><U+5E73><U+533A><U+79D1><U+6280><U+56ED><U+533A><U+51C9><U+6C34><U+6CB3><U+8DEF>8<U+53F7>301<U+5BA4>",

"<U+829C><U+6E56><U+9AD8><U+65B0><U+5F00><U+53D1><U+533A><U+534E><U+590F><U+79D1><U+6280><U+56ED>506<U+4FE1><U+7BB1>", 
"<U+5317><U+4EAC><U+5E02><U+901A><U+5DDE><U+533A><U+9A6C><U+9A79><U+6865><U+9547><U+8054><U+4E1C>U<U+8C37><U+5F00><U+53D1><U+533A><U+897F><U+533A><U+666F><U+76DB><U+5357><U+56DB><U+8857>15<U+53F7>",

"<U+6DF1><U+5733><U+5E02><U+5357><U+5C71><U+533A><U+5357><U+65B0><U+8DEF><U+82CF><U+8C6A><U+540D><U+53A6>11A2<U+5BA4>"
), Document.TranslationInfo.BillToAddress.State = c("<U+6C5F><U+82CF>", 
"<U+6C5F><U+82CF>", "", "<U+5B89><U+5FBD>", "<U+5317><U+4EAC>", 
NA), Document.TranslationInfo.SoldToAddress.City = c("<U+5357><U+4EAC>", 
"<U+65E0><U+9521>", "<U+5317><U+4EAC>", "<U+829C><U+6E56>", 
"<U+5317><U+4EAC>", "<U+5E7F><U+4E1C>"), Document.TranslationInfo.SoldToAddress.Name =

c(" ",

"<U+65E0><U+9521><U+5E02> <U+65E0><U+9521><U+666E><U+6D1B><U+83F2><U+65AF><U+7535><U+5B50><U+6709><U+9650><U+516C><U+53F8> ", 
"<U+5317><U+4EAC><U+67CF><U+548C><U+901A><U+673A><U+7535><U+8BBE><U+5907><U+6709><U+9650><U+516C><U+53F8>",

"<U+4E2D><U+822A><U+534E><U+4E1C><U+5149><U+7535><U+6709><U+9650><U+516C><U+53F8>",

"<U+5317><U+4EAC><U+4FE1><U+90A6><U+7535><U+5B50><U+6709><U+9650><U+516C><U+53F8>",

"<U+6DF1><U+5733><U+5E02><U+9E3F><U+6CF0><U+745E><U+79D1><U+6280><U+6709><U+9650><U+516C><U+53F8>"
), Document.TranslationInfo.SoldToAddress.CountryIso = c("CN", 
"CN", "CN", "CN", "CN", "CN"), Document.TranslationInfo.SoldToAddress.Line3 = c(NA, 
NA, NA, NA, NA, NA), Document.TranslationInfo.SoldToAddress.Line2 = c(NA, 
NA, NA, NA, NA, NA), Document.TranslationInfo.SoldToAddress.Line1 = c("<U+5357><U+4EAC><U+5E02><U+7ECF><U+6D4E><U+6280><U+672F><U+5F00><U+53D1><U+533A><U+6052><U+7ADE><U+8DEF>11<U+53F7>",

"<U+65E0><U+9521><U+56FD><U+5BB6><U+9AD8><U+65B0><U+6280><U+672F><U+4EA7><U+4E1A><U+5F00><U+53D1><U+533A>51-A<U+53F7><U+5730><U+5757>",

"<U+5317><U+4EAC><U+5E02><U+660C><U+5E73><U+533A><U+79D1><U+6280><U+56ED><U+533A><U+51C9><U+6C34><U+6CB3><U+8DEF>8<U+53F7>301<U+5BA4>",

"<U+829C><U+6E56><U+9AD8><U+65B0><U+5F00><U+53D1><U+533A><U+534E><U+590F><U+79D1><U+6280><U+56ED>506<U+4FE1><U+7BB1>", 
"<U+5317><U+4EAC><U+5E02><U+901A><U+5DDE><U+533A><U+9A6C><U+9A79><U+6865><U+9547><U+8054><U+4E1C>U<U+8C37><U+5F00><U+53D1><U+533A><U+897F><U+533A><U+666F><U+76DB><U+5357><U+56DB><U+8857>15<U+53F7>",

"<U+6DF1><U+5733><U+5E02><U+5357><U+5C71><U+533A><U+5357><U+65B0><U+8DEF><U+82CF><U+8C6A><U+540D><U+53A6>11A2<U+5BA4>"
), Document.TranslationInfo.SoldToAddress.State = c("<U+6C5F><U+82CF>", 
"<U+6C5F><U+82CF>", "", "<U+5B89><U+5FBD>", "<U+5317><U+4EAC>", 
NA), Document.TranslationInfo.ShipToAddress.City = c("<U+5357><U+4EAC>", 
"<U+65E0><U+9521>", "<U+5317><U+4EAC>", "<U+829C><U+6E56>", 
"<U+5317><U+4EAC>", "<U+5E7F><U+4E1C>"), Document.TranslationInfo.ShipToAddress.Name =

c(" ",

"<U+65E0><U+9521><U+5E02> <U+65E0><U+9521><U+666E><U+6D1B><U+83F2><U+65AF><U+7535><U+5B50><U+6709><U+9650><U+516C><U+53F8> ", 
"<U+5317><U+4EAC><U+67CF><U+548C><U+901A><U+673A><U+7535><U+8BBE><U+5907><U+6709><U+9650><U+516C><U+53F8>",

"<U+4E2D><U+822A><U+534E><U+4E1C><U+5149><U+7535><U+6709><U+9650><U+516C><U+53F8>",

"<U+5317><U+4EAC><U+4FE1><U+90A6><U+7535><U+5B50><U+6709><U+9650><U+516C><U+53F8>",

"<U+6DF1><U+5733><U+5E02><U+9E3F><U+6CF0><U+745E><U+79D1><U+6280><U+6709><U+9650><U+516C><U+53F8>"
), Document.TranslationInfo.ShipToAddress.CountryIso = c("CN", 
"CN", "CN", "CN", "CN", "CN"), Document.TranslationInfo.ShipToAddress.Line3 = c(NA, 
NA, NA, NA, NA, NA), Document.TranslationInfo.ShipToAddress.Line2 = c(NA, 
NA, NA, NA, NA, NA), Document.TranslationInfo.ShipToAddress.Line1 = c("<U+5357><U+4EAC><U+5E02><U+7ECF><U+6D4E><U+6280><U+672F><U+5F00><U+53D1><U+533A><U+6052><U+7ADE><U+8DEF>11<U+53F7>",

"<U+9521><U+592A><U+516C><U+8DEF><U+5EF6><U+7965><U+8DEF><U+666E><U+6D1B><U+65AF><U+9E45><U+6E56><U+7269><U+6D41><U+56ED><U+533A>B3-1<U+5E93>

18888048952 /13771174954()",

"<U+5317><U+4EAC><U+5E02><U+660C><U+5E73><U+533A><U+79D1><U+6280><U+56ED><U+533A><U+51C9><U+6C34><U+6CB3><U+8DEF>8<U+53F7>301<U+5BA4>",

"<U+829C><U+6E56><U+9AD8><U+65B0><U+5F00><U+53D1><U+533A><U+534E><U+590F><U+79D1><U+6280><U+56ED>  (<U+8BF7><U+7528><U+987A><U+4E30><U+53D1>,<U+968F><U+8D27><U+9644><U+5408><U+683C><U+8BC1>)",

"<U+5317><U+4EAC><U+5E02><U+901A><U+5DDE><U+533A><U+9A6C><U+9A79><U+6865><U+9547><U+8054><U+4E1C>U<U+8C37><U+5F00><U+53D1><U+533A><U+897F><U+533A><U+666F><U+76DB><U+5357><U+56DB><U+8857>15<U+53F7>

", “11A2” ), Document.TranslationInfo.ShipToAddress.State = c("", “”、“”、“”、“”、 NA), Document.ShipFromFacility.Code = c("GZ", "GZ", "GZ", "GZ", "GZ", "GZ"), Document.ShipFromFacility.PackingLocation = c("GZ", "GZ", "GZ", "GZ", "GZ", "GZ"), Document.EndOfDayData.EodStartedDate = c("2020-02-18T10:55:16.039Z", “2020-02-18T10:55:16.039Z”、“2020-02-18T10:55:16.039Z”、“2020-02-18T10:55:16.039Z”、 “2020-02-18T10:55:16.039Z”、“2020-02-18T10:55:16.039Z”)、 Document.EndOfDayData.EndOfDayId = c("5e4bc2944ad0b20a788c9f58", “5e4bc2944ad0b20a788c9f58”、“5e4bc2944ad0b20a788c9f58”、“5e4bc2944ad0b20a788c9f58”、 “5e4bc2944ad0b20a788c9f58”,“5e4bc2944ad0b20a788c9f58”), Document.ShipTo.FacilityCode = c(NA, NA, NA, NA, NA, NA), Document.ShipTo.LocationId = c(46484L, 305058L, 109551L, 32449L, 36327L, 340964L), Document.ShipTo.Description = c("南京康尼科技实业有限公司", “无锡普菲斯有限公司”、“北京百合通机电”、 “安徽华东职业技术学院”、“北京信邦电子有限公司”、 "深圳市宏泰瑞科技有限公司"), Document.ShipTo.Address.CountryId = c(42L, 42L, 42L, 42L, 42L, 42L), Document.ShipTo.Address.Name = c("南京康尼科技实业有限公司", “无锡普菲斯有限公司”、“北京百合通机电”、 “安徽华东职业技术学院”、“北京信邦电子有限公司”、 "深圳市宏泰瑞科技有限公司"), Document.ShipTo.Address.CountryCode = c("CN", "CN", "CN", "CN", "CN", "CN"), Document.ShipTo.Address.Locality = c("JIANGSU", "无锡", "北京", "安徽", "北京", "广东"), Document.ShipTo.Address.Country = c("CHINA", "中国", "中国", "中国", "中国", "中国"), Document.ShipTo.Address.CompanyId = c(0L, 0L, 0L, 0L, 0L, 0L), Document.ShipTo.Address.AdministrativeArea = c(NA, NA, NA, NA, NA, NA), Document.ShipTo.Address.AddressLine2 = c("南京经济技术开发区", “西太路燕翔路”、“凉水河路8号”、“高新技术开发区”、 “联东U顾开发区”、“南山区南新路” ), Document.ShipTo.Address.AddressLine3 = c("南京", "", “昌平区”、“葛江区芜湖”、“马驹桥镇通州区”、 "深圳"), Document.ShipTo.Address.AddressLine1 = c("横泾路11号", “B3-1,普洛斯物流园”,“301室”,“华夏科技园506”, “京盛南四街15号2楼”、“苏豪大厦11A2室” ), Document.ShipTo.Address.PostalCode = c("210013", "214028", “102200”、“241006”、“101102”、“518000”),Document.ShipTo.Address.Organization = c(NA, 不适用,不适用,不适用,不适用,不适用),Document.ShipTo.Address.StateId = c(不适用, 不适用,不适用,不适用,不适用,不适用),Document.ShipTo.Address.Id = c(53751L, 241741L, 141603L, 36180L, 40824L, 288577L), Document.ShipTo.Address.StateCode = c(NA, NA, NA, NA, NA, NA), Document.Freight.ShipVia = c("SFEXPRESS", “SFEXPRESS”、“SFEXPRESS”、“SFEXPRESS”、“SFEXPRESS”、“SFEXPRESS” ), Document.Freight.FreightBill = c(NA, NA, NA, NA, NA, NA ), Document.Freight.TransportMode = c("40", "40", "40", "40", "40", "40"), Document.Freight.ServiceLevel = c("优先交付", “优先交付”、“优先交付”、“优先交付”、 "优先递送", "优先递送"), Document.Freight.Carrier = c("FedEx GZ", “FedEx GZ”、“FedEx GZ”、“FedEx GZ”、“FedEx GZ”、“FedEx GZ” ), Document.Freight.ServiceOption = c(NA, NA, NA, NA, NA, NA), Document.Freight.FreightCharge = c(0, 0, 0, 0, 0, 0)), class= "data.frame", row.names = c(NA, -6L)),订单=结构(列表(Document.ShipmentId = c(“11058187”,“11058183”,“11058183”,“11058183”,“11058185”,“11058185”, “11058191”,“11058190”,“11058196”),SourceType = c(“Samtec”, “Samtec”、“Samtec”、“Samtec”、“Samtec”、“Samtec”、“Samtec”、“Samtec”、 "Samtec"), ScheduleB = c("8536.69.4040", "8536.69.4040", "8536.69.4040", “8536.69.4040”、“8538.90.7040”、“8538.90.7080”、“8536.69.4040”、 "8538.90.7080", "8544.42.0000"), 订单号 = c(28937505L, 28966001L, 28966012L, 28966007L, 28990315L, 28990315L, 29038425L, 29031533L, 29026460L), OrderType = c("Sales", "Sales", "Sales", “销售”、“销售”、“销售”、“销售”、“销售”、“销售”), LineNumber = c(4L, 46L, 28L, 23L, 2L, 1L, 10L, 1L, 1L), 数量 = c(39L, 100L, 200L, 100L, 3000L, 1500L, 100L, 30L, 14L), UnitPrice.Ftp = c("Q", “Q”,“Q”,“Q”,“Q”,“Q”,“Q”,“Q”,“Q”),UnitPrice.Usd = c(TRUE, 对,对,对,对,对,对,对,对),UnitPrice.EffectiveDate = 结构(c(1582008968.592, 1582008947.42、1582008947.42、1582008947.451、1582008957.436、 1582008957.436、1582008988.735、1582008983.36、1582009014.657 ), class= c("POSIXct", "POSIXt"), tzone = "UTC"), UnitPrice.ConvertedAmount = c(3.142, 0.708, 0.044, 0.368, 0.174, 0.397, 1.17, 0.1831, 30.22), UnitPrice.ConversionRate = c(1, 1, 1, 1, 1, 1, 1, 1, 1), UnitPrice.Currency = c("USD", "USD", "USD", "USD", "USD", "USD", "USD", "USD", "USD"), UnitPrice.Amount = c(3.142, 0.708, 0.044, 0.368, 0.174, 0.397, 1.17, 0.1831, 30.22), UnitPrice.Fact = c(1, 1, 1, 1, 1, 1, 1, 1, 1)), class= "data.frame", row.names = c(NA, -9L)), box = structure(list(Document.ShipmentId = c("11058187", "11058183", "11058185", "11058185", "11058191", "11058190", "11058196" ), BoxId = c(52577769L, 52576903L, 52576098L, 52576104L, 52577814L, 52577959L, 52576965L), BoxNumber = c(1L, 1L, 1L, 2L, 1L, 1L, 1L), 重量 = c(0.4, 0.6, 0.95, 0.3, 0.4, 0.05, 0.9),皮重 = c(0.2, 0.05, 0.27, 0.27, 0.2, 0.05, 0.2), CartonType = c("GZ SPECIAL", "CARRIER PACK", "XS SMART BOX", "XS SMART BOX", "GZ SPECIAL", "CARRIER PACK", "03"), 体积 = c(0.3166, 0, 0.3463, 0.3463, 0.3166, 0, 0.2633), DimWeight = c(54, 1, 60, 60, 54, 1, 45), WeightUOM = c("KG", "KG", "KG", "KG", "KG", "KG", "KG"), TrackingNumber = c("295841879239", "295840702753", "295839545260", “051109917394”、“295841999709”、“295842158158”、“295840755210” ), VolumeUOM = c("FT3", "FT3", "FT3", "FT3", "FT3", "FT3", "FT3"), 尺寸 = c("70 x 16 x 8-CM", "0 x 0 x 0-CM", “35 x 35 x 8-CM”、“35 x 35 x 8-CM”、“70 x 16 x 8-CM”、“0 x 0 x 0-CM”、 "23 x 18 x 18-CM")), class= "data.frame", row.names = c(NA, -7L)), 预包装 = 结构(列表(BoxId = c(52577769L, 52576903L, 52576903L, 52576903L, 52576098L, 52576104L, 52577814L, 52577959L, 52576965L), 订单号 = c(28937505L, 28966012L, 28966007L, 28966001L, 28990315L, 28990315L, 29038425L, 29031533L, 29026460L), CustomerPartNumber = c("21010120001100", "LKE726C5311LF", "CI029275", "CI027108"、""、""、""、"A2042007400SD"、"")、SamtecPartNumber = c("ASP-175287-03", "DW-02-15-T-S-360", "ASP-65584-06", “ASP-21981-02”、“IPD1-02-D”、“CC79L-2024-01-L”、“MMS-106-01-L-SV”、 “IPD1-02-D-K”、“SFSD-30-28-G-20.00-DR-NDX”)、PONumber = c(“4100390391”,“4507354833”,“4507354833”,“4507354833”, “202001070005”、“202001070005”、“202001130017”、“AAAX010550”、 "HTR20200115025"), CountryOfOrigin = c("MY", "US", "MY", "MY", "US", "US", "CN", "US", "CN"), 发货数量 = c(39L, 200L, 100L, 100L, 1500L, 3000L, 100L, 30L, 14L), LineNumber = c(4L, 28L, 23L, 46L, 1L, 2L, 10L, 1L, 1L),CalculatedShipDate = c(NA, NA, NA, NA, NA, NA, NA, NA, NA), PrepackId = c(52394288L, 52233983L, 52433768L, 52444006L, 52402376L, 52255069L, 52447860L, 52405172L, 52266971L), 包装类型 = c(“预包装”,“预包装”,“预包装”,“预包装”,“预包装”,“预包装”, "预包装", "预包装", "预包装"), GroupId = c("P32302374", “P32273371”、“P32311011”、“P32312799”、“P32304228”、“P32277008”、 “P32313605”、“P32304830”、“P32279161”))、class= “data.frame”、 row.names = c(NA, -9L)))

【问题讨论】:

  • 欢迎来到 Stack Overflow!您能否阅读并合并来自How to make a great R reproducible example 的元素?尤其是使用dput() 作为输入的方面,然后是您预期数据集的明确示例?
  • 每当嵌套数据框出现在列表中时,可能是您处理了 JSON 文件。如果是这样,请在正文中发布此文件的示例(而不是image)。
  • 对此我深表歉意。由于文件的长度,我只包含了第一个子列表,其余的都是相同的结构。

标签: r list merge lapply


【解决方案1】:

实际上,我能够自己解决。这就是我所做的:

shipment <- lapply(results, "[[", 1) %>% bind_rows
orders <- lapply(results, "[[", 2) %>% bind_rows
boxes<- lapply(results, "[[", 3) %>% bind_rows
prepacks <- lapply(results, "[[", 4) %>% bind_rows

【讨论】:

    猜你喜欢
    • 2015-08-14
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多