1

I was trying to get a plot from a r function, so I wrote

fn=function (inputdata) {......;output=...;return(hist(output))}

I want to get a histogram with a title of the input data, for example, if my inputdata is "abc", then I want the histogram to have a title of "abc". I've tried to wrote

return(hist(output,main="inputdata"))

or

return(hist(output,main=inputdata))

but they are both wrong. How can I do it?

Natalia
  • 369
  • 3
  • 15

1 Answers1

2

As pointed out by Alex Reynolds, it is partly a duplicate of a previous post. Based on the anwer found on this post:

set.seed(42)     
eytwaryt <- rnorm(1000)

foo <- function(x){ hist(x, main=deparse(substitute(x))) }
foo(eytwaryt)