1

I'm trying to write a function to print out a pdf of some graph. I would like my function to take 2 arguments (options): the dataset which I will draw my graphs from and a string variable which is used for the pdf file name. How do I pass the string to a command within the function? my code is :

 plot_all_layout <- function(network, filename){
    layouts <- grep("^layout_", ls("package:igraph"), value=TRUE)[-1] 
      # Remove layouts that do not apply to our graph.
      layouts <- layouts[!grepl("bipartite|merge|norm|sugiyama|tree", layouts)]

      par(mfrow=c(3,3), mar=c(1,1,1,1))
      pdf("filename.pdf") #here is where I would like to call the local var

      for (layout in layouts) {
        print(layout)
        l <- do.call(layout, list(network)) 
        plot(network, edge.arrow.mode=0, layout=l, main=layout) }
      dev.off()
      par(mfrow=c(1,1)
  }
1
  • Is "filename.pdf" the string for a variable in R or the name of a pdf-file in some directory? Commented Dec 14, 2017 at 7:32

1 Answer 1

1

I think you should use pdf(paste0(filename, ".pdf"))

Hope this helps.

Sign up to request clarification or add additional context in comments.

Comments

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.