更改每个要应用或映射

时间:2017-12-15 13:27:43

标签: r

我正在使用:

Apply

为了从订单列表中提取主要送货方式(> 650K行)。

如何更改此设置以使用MapFirst<-function(x) detect(OrdersWide2[x,2:ncol(OrdersWide2)], function(y) y != "", .right = F) 我尝试使用:

Type1Test<-apply(OrdersWide2[1:5,],1,FUN = First)

NULL

但继续获得!=""。或者,是否有更好的方法可以跨越每列的列获取OrdersWide2<-structure(list(Sales.Doc. = c("0001748328", "0001920412", "0020189342", "0020189350", "0020189353", "0020189354"), `47-Will Call` = c("47-Will Call", "47-Will Call", NA, NA, NA, NA), `48-LTL` = c(NA_character_, NA_character_, NA_character_, NA_character_, NA_character_, NA_character_ ), `49-FTL` = c(NA_character_, NA_character_, NA_character_, NA_character_, NA_character_, NA_character_), `50-Sea Freight` = c(NA_character_, NA_character_, NA_character_, NA_character_, NA_character_, NA_character_ ), `51-Air Freight` = c(NA_character_, NA_character_, NA_character_, NA_character_, NA_character_, NA_character_), `52-FedEx 1Day Freight` = c(NA_character_, NA_character_, NA_character_, NA_character_, NA_character_, NA_character_ ), `53-FedEx 2Day Freight` = c(NA_character_, NA_character_, NA_character_, NA_character_, NA_character_, NA_character_), `54-FedEx 3Day Freight` = c(NA_character_, NA_character_, NA_character_, NA_character_, NA_character_, NA_character_ ), `55-FedEx Intl. Priority` = c(NA_character_, NA_character_, NA_character_, NA_character_, NA_character_, NA_character_ ), `56-FedEx Intl. Economy` = c(NA_character_, NA_character_, NA_character_, NA_character_, NA_character_, NA_character_ ), `57-FedEx Intl. Pri. Frt` = c(NA_character_, NA_character_, NA_character_, NA_character_, NA_character_, NA_character_ ), `60-FedEx Ground Guarant` = c(NA_character_, NA_character_, NA_character_, NA_character_, NA_character_, NA_character_ ), `64-DHL Global Forward` = c(NA_character_, NA_character_, NA_character_, NA_character_, NA_character_, NA_character_ ), `65-Courier Services` = c(NA_character_, NA_character_, NA_character_, NA_character_, NA_character_, NA_character_ ), `70-Purolator Ground` = c(NA, NA, "70-Purolator Ground", "70-Purolator Ground", "70-Purolator Ground", "70-Purolator Ground" ), `71-QRC Logistics` = c(NA_character_, NA_character_, NA_character_, NA_character_, NA_character_, NA_character_), `72-Purolator Express` = c(NA_character_, NA_character_, NA_character_, NA_character_, NA_character_, NA_character_), `73-Purolator Exp 9:00AM` = c(NA_character_, NA_character_, NA_character_, NA_character_, NA_character_, NA_character_), `74-Purolator Exp10:30AM` = c(NA_character_, NA_character_, NA_character_, NA_character_, NA_character_, NA_character_), `90-BOMI` = c(NA_character_, NA_character_, NA_character_, NA_character_, NA_character_, NA_character_ )), .Names = c("Sales.Doc.", "47-Will Call", "48-LTL", "49-FTL", "50-Sea Freight", "51-Air Freight", "52-FedEx 1Day Freight", "53-FedEx 2Day Freight", "54-FedEx 3Day Freight", "55-FedEx Intl. Priority", "56-FedEx Intl. Economy", "57-FedEx Intl. Pri. Frt", "60-FedEx Ground Guarant", "64-DHL Global Forward", "65-Courier Services", "70-Purolator Ground", "71-QRC Logistics", "72-Purolator Express", "73-Purolator Exp 9:00AM", "74-Purolator Exp10:30AM", "90-BOMI"), row.names = c(NA, 6L), class = "data.frame") 的第一个实例?

示例数据:

{{1}}

0 个答案:

没有答案