Hello dears,
I know that this is an old issue that already solved a lot with your codes , i searched a lot to find how to do it but couldn't find the appropriate code
i need to reshape a data frame transfering some columns into rows and adding a flag to then as follows in the following simple code
Product = c("abc","def","ghi","xyz","SHL","Hdy")
Orders_New_Customer = c(2,3,5,4,7,6)
Value_New_Customer = c(65,45,78,65,48,54)
Orders_Old_Customer = c(4,5,8,78,45,47)
Value_Old_Customer = c(85,98,47,92,48,66)
DF = data.frame(Product,Orders_New_Customer,Value_New_Customer,Orders_Old_Customer,Value_Old_Customer)
View(DF)
##Needed to be as follows
Product = c("abc","def","ghi","xyz","SHL","Hdy")
Orders = c(2,3,5,4,7,6)
Values = c(65,45,78,65,48,54)
Customer_Type = c("New","New","New","New","New","New")
DF_New = data.frame(Product,Orders,Values,Customer_Type)
Product = c("abc","def","ghi","xyz","SHL","Hdy")
Orders = c(4,5,8,78,45,47)
Values = c(85,98,47,92,48,66)
Customer_Type = c("Old","Old","Old","Old","Old","Old")
DF_Old = data.frame(Product,Orders,Values,Customer_Type)
Total_DF = rbind(DF_New,DF_Old)
View(Total_DF
How can i do that especially that the desired dataframe size is very big and there are many dimensions like customer type i will add them.
Thanks in advance