我有一个组合零件清单数据框,其中包含机械耗材和电源的零件清单信息。我想根据其中一个PL.Combined列中的某些描述符将机械耗材和电源分离到他们自己的数据框中。
例如我有:
PL.Combined
PART.NUMBER DESCRIPTION
1x NUT
2x WIRE
3x BOLT
4x CIRCUIT
5x BRACKET
6X CONTACT
我想从电气部件{WIRE,CIRCUIT,CONTACT}中提取机械部件{NUT,BOLT,BRACKET}。
有类似的东西:
>PL.Electrical
PART.NUMBER DESCRIPTION
2x WIRE
4x CIRCUIT
6X CONTACT
>PL.Mechanical
PART.NUMBER DESCRIPTION
1x NUT
3x BOLT
5x BRACKET
有关如何做到这一点的任何建议?
答案 0 :(得分:1)
如果您有指定的广告资源列表,则可以使用该列表将数据拆分为2 success: function(data) {
$('someElement').append(data); // append the partial view to the DOM
var message = $('#message').val(); // get the value of the message
toastr.success(message , 'Success'); // display it
}
。处理此问题的一种好方法可以按如下方式完成:
data.frames
如果您对inventory<-read.csv("stackoverflow.csv",stringsAsFactors = F)
inventory
PART.NUMBER DESCRIPTION
1 1x 1/2 inch NUT
2 2x 2mm WIRE
3 3x screw BOLT
4 4x closed & open CIRCUIT
5 5x joint BRACKET
6 6X adhesive CONTACT
inventory$New_desc<-do.call(rbind,lapply(strsplit(inventory[,2],split=" "), function(x) tail(x,1)))
inventory
PART.NUMBER DESCRIPTION New_desc
1 1x 1/2 inch NUT NUT
2 2x 2mm WIRE WIRE
3 3x screw BOLT BOLT
4 4x closed & open CIRCUIT CIRCUIT
5 5x joint BRACKET BRACKET
6 6X adhesive CONTACT CONTACT
Mech<-c("NUT", "BOLT", "BRACKET")
Elec<-c("WIRE", "CIRCUIT", "CONTACT")
Split_inventory<-list()
Split_inventory[['Mech']]<-inventory[which(inventory$New_desc %in% Mech),]
Split_inventory[['Elec']]<-inventory[which(inventory$New_desc %in% Elec),]
不太熟悉,请将它们分成lists
,遵循相同的逻辑:
data.frames