Store the result in excel

hi Friends
I want to stored the result in excel but result will be stored in different variables
for example a1,a2,a3,a4,a5

my program

random_maker <- function()
{
  x <- as.integer(eval(parse(text=readline("Enter the Range: "))))
  y <- as.integer(readline("Number of input: "))
  g <- sample(x, y, replace=T)
 
  print(g)
}

a <-replicate(5, random_maker())

plz give your suggestion

Hi,

the easiest way is to combine your different variables to a data.frame or data.table using e.g. rbind() and then use the xlsx package to save it as Excel file.

Best regards
Sebastian

thanks for your answer.....

If your question's been answered, would you mind choosing a solution? (see FAQ below for how) It makes it a bit easier to visually navigate the site and see which questions still need help.

Thanks