-4

I have 3 dataframes FOOTWEAR,APPAREL,ACCESSORIES and each dataframe show the performance of 50 different suppliers showing their:

 sales,stock,markdown,purchases,changes in stock.

I want to create output that takes data of each supplier from the 3 dataframes, combine it to one dataframe and export as an Excel. So the output should be 50 Excel tables with information of each supplier and their performance in all departments.

zx8754
  • 52,746
  • 12
  • 114
  • 209
tee
  • 1
  • 3
    how to ask good questions in R https://stackoverflow.com/questions/5963269/how-to-make-a-great-r-reproducible-example and welcome to stackoverflow ;-) – Joyvalley Jul 23 '18 at 09:52
  • 2
    Welcome to SO! Please read [ask] and give a [mcve]! – jogo Jul 23 '18 at 10:05

1 Answers1

0

Let df1, df2, df3 be your 3 dataframes (FOOTWEAR, APPAREL, ACCESSORIES). I have made subset with 5 rows from mtcars data.

df1<-subset(mtcars[1:5,])
df2<-subset(mtcars[6:10,])
df3<-subset(mtcars[11:15,])

Then the following loop could be used:

for (i in 1:nrow(df1)){

   assign(paste('r', i, sep = ''), 
          cbind(assign(paste('s', i, sep = ''), 
                       cbind(df1,df2)[i,]),df3)[i,])
 }

r1 to r50 will be your desired dataframes.

rar
  • 894
  • 1
  • 9
  • 24