Create unequal row dataframe

Hi,

df <- data.frame("SN" = 1:4, "A" = c("Cl_A","Cl_B","Cl_C","Cl_D"), "B" = c("Apple","Banana","Apple","Banana"),"C"=c("Paper","Paper","Plastic","Plastic"),"D"=c("No issues","No issues","No issues","No issues"))

ab <- data.frame("U" = c("Apple","Strawberry"), "V" = c("Strawberry","Grapes","Watermelon"),"W"=c("Berries","Apples","Nuts"),
"X"=c("Peach","Banana","Strawberry","Grapes"),"Y"=c("Banana","Apple","Strawberry","Grapes"))

In given dataframe i need to do following manipulations.

1)Need to create unequal rows dataframe. (ab)
2)Need unique rows where "D" == "No issues" (df)
3)Need count of unique df$A for unique df$B(group by)
4)Find unique (df$B) i.e (Apple and Banana) in dataframe ab.
if distinct(df$B) (Apple & Banana) is found in any column of ab together ,take sum of count of apple and banana and mutate with count else "0".
if the sum of count(df$B) is >2 then mutate df$dim "on" else "off"(create 2 new columns)

output like

SN A B C D new dim
1 Cl_A Apple Paper No issues 1 on
2 Cl_B Banana Paper No issues 1 on
3 Cl_C Apple Paper No issues 1 on
4 Cl_D Banana Paper No issues 1 on

This topic was automatically closed 21 days after the last reply. New replies are no longer allowed.