Re: [R] Turning a variable name into a function argument

2016-06-28 Thread David Winsemius
> On Jun 28, 2016, at 6:19 PM, KMNanus wrote: > > You’ve stated my intent perfectly. I tried depress(substitute(x)) within > ggplot and it didn’t work. > > However, the solution (which I discovered about 10 minutes ago), turned out > to remarkably easy - I just assigned

Re: [R] Turning a variable name into a function argument

2016-06-28 Thread KMNanus
You’ve stated my intent perfectly. I tried depress(substitute(x)) within ggplot and it didn’t work. However, the solution (which I discovered about 10 minutes ago), turned out to remarkably easy - I just assigned the new variable and it ran perfectly. It looks like this - myfun<-

Re: [R] Turning a variable name into a function argument

2016-06-28 Thread Jim Lemon
Hi Ken, As far as I can see, ggtitle accepts a single string. The help page is a bit obscure, implying that you can change the title with the "labs" function(?), but using the same explicit string in the "ggtitle" line, perhaps for didactic purposes. You seem to be asking to substitute your own

Re: [R] Turning a variable name into a function argument

2016-06-28 Thread Bert Gunter
I frankly don't know what the heck you are doing but, (inline below) Bert Gunter "The trouble with having an open mind is that people keep coming along and sticking things into it." -- Opus (aka Berkeley Breathed in his "Bloom County" comic strip ) On Tue, Jun 28, 2016 at 1:46 PM, KMNanus

Re: [R] Turning a variable name into a function argument

2016-06-28 Thread KMNanus
I’m trying to modify the function from outside, i.e., when I call the function. Ken kmna...@gmail.com 914-450-0816 (tel) 347-730-4813 (fax) > On Jun 28, 2016, at 5:07 PM, Greg Snow <538...@gmail.com> wrote: > > Can you edit the source of the function? or are you trying to modify an >

Re: [R] Turning a variable name into a function argument

2016-06-28 Thread KMNanus
Thanks for getting back to me. None of them work, because I’m trying to use the string in the function call - myfun(z, “string”) to replace the empty space in ggtitle. When I call myfun(z, gsub(“__”, “string (or any word)”, myfun), I get an error msg because gsub is looking for a data

Re: [R] Turning a variable name into a function argument

2016-06-28 Thread Greg Snow
There are several options. The option that is most like search and replace is to use the `sub` or `gsub` function (or similar functions in added packages). But you may be able to accomplish what you want even simpler by using the `paste`, `paste0`, or `sprintf` functions. On Tue, Jun 28, 2016

Re: [R] Turning a variable name into a function argument

2016-06-28 Thread KMNanus
Thanks for getting back to me, I’m sorry if I was unclear. What I’m trying to figure out is the equivalent of “find and replace” in Word. I have a function - myfun <- function(z){ ggplot(df, aes(x,y)+ geom_point() + ggtitle (“___ quick brown fox jumped over the lazy dog”)} Calling

Re: [R] Turning a variable name into a function argument

2016-06-28 Thread David Winsemius
> On Jun 27, 2016, at 6:12 PM, KMNanus wrote: > > I’m inexperience but am trying to get my head around using functions to make > a number of ggplots easier to do. > > I have a function that creates a ggplot taking one input variable as an > argument. The variable name is

[R] Turning a variable name into a function argument

2016-06-27 Thread KMNanus
I’m inexperience but am trying to get my head around using functions to make a number of ggplots easier to do. I have a function that creates a ggplot taking one input variable as an argument. The variable name is shorthand for the actual variable (variable name = tue, Actual name =