[R] debug only top level function

2019-06-06 Thread PIKAL Petr
Dear all I have a question about debug function. I did not use it for long time but my vague memory tell me, that when I used debug(myfunction) in past, only myfunction was debugged and browser ignored any embedded function. example (simple) fff <- function(x) mean(x, na.rm=T) when I issue >

Re: [R] debug only top level function

2019-06-06 Thread Duncan Murdoch
On 06/06/2019 4:55 a.m., PIKAL Petr wrote: Dear all I have a question about debug function. I did not use it for long time but my vague memory tell me, that when I used debug(myfunction) in past, only myfunction was debugged and browser ignored any embedded function. example (simple) fff <-

Re: [R] debug only top level function

2019-06-06 Thread PIKAL Petr
Thanks Duncan. I think you found it. I have an object called s within my function. I wanted to check it, so I hit "s". This did not bring the object but instead it change behaviour of debug function. I did not find this in help pages nor in R exts or R intro manual. Maybe it would be worth cons

Re: [R] Plotting more than one regression line in ggplot

2019-06-06 Thread Rui Barradas
Hello, You are confusing some of the values of L1 with L1 itself. If you just want two of those values in your plot, "onepctCO2MEDIAN" and "RCP8.5MEDIAN", you need to subset the data filtering out the rows with L1 == "RCP4.5MEDIAN". And please forget geom_jitter, it is completely inappropriat

Re: [R] Open a file which name contains a tilde

2019-06-06 Thread Ivan Krylov
On Wed, 5 Jun 2019 18:07:15 +0200 Frank Schwidom wrote: > +> path.expand("a ~ b") > [1] "a /home/user b" > How can I switch off any file crippling activity? It doesn't seem to be possible if readline is enabled and works correctly. Calls to path.expand [1] end up [2] in R_ExpandFileName [3],

Re: [R] Parallel processes collapse into one

2019-06-06 Thread Ivan Krylov
On Mon, 3 Jun 2019 06:37:46 +0200 Nicola Lunardon wrote: > R seems to be running, but simulations do not progress further. Have you tried message() (or REprintf() in C code) to narrow down the specific part of the code where simulations stop in their progress? It's less convenient than a good de

Re: [R] debug only top level function

2019-06-06 Thread Duncan Murdoch
On 06/06/2019 6:00 a.m., PIKAL Petr wrote: Thanks Duncan. I think you found it. I have an object called s within my function. I wanted to check it, so I hit "s". This did not bring the object but instead it change behaviour of debug function. I did not find this in help pages nor in R exts or

Re: [R] Plotting more than one regression line in ggplot

2019-06-06 Thread rain1290--- via R-help
Hi Rui (and everyone), Thank you for this! Yes, this did work fine, as I can see my scatter plots and regression lines on the same plot, along with the appropriate coloring scheme! :) Just one last question concerning this - I melted other dataframes into my new "NewestdataUltra". I now have 4 o

Re: [R] debug only top level function

2019-06-06 Thread Martin Maechler
> Duncan Murdoch > on Thu, 6 Jun 2019 07:38:40 -0400 writes: > On 06/06/2019 6:00 a.m., PIKAL Petr wrote: >> Thanks Duncan. >> >> I think you found it. I have an object called s within my function. I wanted to check it, so I hit "s". This did not bring the object but

Re: [R] Plotting more than one regression line in ggplot

2019-06-06 Thread PIKAL Petr
Hi Probably missing quotation marks in geom_smooth geom_smooth(method = "lm", se = FALSE) Cheers Petr > -Original Message- > From: R-help On Behalf Of rain1290--- via R- > help > Sent: Thursday, June 6, 2019 4:35 PM > To: ruipbarra...@sapo.pt; r-help@R-project.org > Subject: Re: [R] Pl

[R] Pasting R code lines into labels

2019-06-06 Thread Nick Wray via R-help
Is there any way of taking a line of r code (eg y<-x^2) and pasting that line of code, as is, into a label, so that for example I could then have a plot label "Plot of y<-x^2"? Thanks Nick Wray [[alternative HTML version deleted]] __ R-help@r

Re: [R] Plotting more than one regression line in ggplot

2019-06-06 Thread Rui Barradas
Hello, 1) In the text you say your dataset is named NewestdataUltra but in the ggplot instruction it's Newestdata. One of these is wrong. 2) Is it onepctCO2MEDIAN or RCPonepctCO2MEDIAN? 3) You are filtering out the value in point ) above. So you only plot 3 regression lines, you don't need 4

Re: [R] Pasting R code lines into labels

2019-06-06 Thread Marc Schwartz via R-help
> On Jun 6, 2019, at 11:19 AM, Nick Wray via R-help > wrote: > > Is there any way of taking a line of r code (eg y<-x^2) and pasting that line > of code, as is, into a label, so that for example I could then have a plot > label "Plot of y<-x^2"? > > Thanks Nick Wray Hi, See ?plotmath A

Re: [R] Plotting more than one regression line in ggplot

2019-06-06 Thread rain1290--- via R-help
Hi Rui, Yes, you are right. It should be this, but I tried with only 3 colors, as you suggested: ggplot(subset(NewestdataUltra, L1 != 'onepctCO2MEDIAN'), aes(x, value, colour = L1)) + geom_point() + scale_color_manual(values =c("green", "blue" "red")) + geom_smooth(method = lm, se=FALSE) I stil

Re: [R] Plotting more than one regression line in ggplot

2019-06-06 Thread Rui Barradas
Hello, It's impossible to say without seeing the data. What is the return value of df_tmp <- subset(NewestdataUltra, L1 != 'onepctCO2MEDIAN') unique(df_tmp$L1) The number of colors must be the same as length(unique(df_tmp$L1)) Hope this helps, Rui Barradas Às 16:49 de 06/06/19, rain1...@a

Re: [R] Pasting R code lines into labels

2019-06-06 Thread Bert Gunter
The well known deparse(substitute(...)) construction. plot(1:9, main = paste("plot of",deparse(substitute(y <- x^2 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

Re: [R] Pasting R code lines into labels

2019-06-06 Thread Nick Wray via R-help
Thanks but that's not quite what I meant I am trying out different functions and they don't necessarily vary in a regular way (like say all being powers of x where it'd be simple to just have a vector for the powers you want) So I might have y<-x^2 y<-cos(x) y<-exp(x+1) What I am after is a way o

Re: [R] Pasting R code lines into labels

2019-06-06 Thread Bert Gunter
... and if you wanted too streamline the process, something like the following could be encapsulated in a function: fun <- quote(exp(x)) z <- 1:9 y <- eval(fun,list(x = z) ) plot(x, y, main = paste("Plot of y =", deparse(fun))) Further details can be found in the "Computing on the Language" secti

Re: [R] Pasting R code lines into labels

2019-06-06 Thread Nick Wray via R-help
Thanks Bert, that is exactly what I wanted. I think that you meant plot(z,y... in the last line? Nick > On 06 June 2019 at 17:13 Bert Gunter wrote: > > ... and if you wanted too streamline the process, something like the > following could be encapsulated in a function: > > fun <- qu

Re: [R] Open a file which name contains a tilde

2019-06-06 Thread Berry, Charles
> On Jun 6, 2019, at 3:59 AM, Ivan Krylov wrote: > > On Wed, 5 Jun 2019 18:07:15 +0200 > Frank Schwidom wrote: > >> +> path.expand("a ~ b") >> [1] "a /home/user b" > >> How can I switch off any file crippling activity? > > It doesn't seem to be possible if readline is enabled and works >

Re: [R] Plotting more than one regression line in ggplot

2019-06-06 Thread rain1290--- via R-help
Hi Rui, NewestdataUltra looks like this (Note that "HistoricalMEDIAN" is hidden, but it follows "RCP8.5MEDIAN" listing the same way): x variable value L1 1 0.0y 0. onepctCO2MEDIAN 2 0.006794447y 4.90024902 onepctCO2MEDIAN 3

Re: [R] Pasting R code lines into labels

2019-06-06 Thread Bert Gunter
Yes, plot(z,y,..) Bert On Thu, Jun 6, 2019 at 9:21 AM Nick Wray wrote: > Thanks Bert, that is exactly what I wanted. I think that you meant > plot(z,y... in the last line? > > Nick > > On 06 June 2019 at 17:13 Bert Gunter wrote: > > ... and if you wanted too streamline the process, something

Re: [R] Pass an equation as an argument of a sub-function

2019-06-06 Thread Bert Gunter
See here for almost the same issue: http://r.789695.n4.nabble.com/Pasting-R-code-lines-into-labels-td4757446.html Same answer: pass the unevaluated formula (i.e. an R expression) using substitute/quote. Then evaluate it appropriately using eval. Same references. Bert Gunter "The trouble with ha

Re: [R] Pass an equation as an argument of a sub-function

2019-06-06 Thread Bert Gunter
It is perhaps worth saying that my prior suggestion may not be the best strategy for doing what you want. The previous poster needed the actual expression to deparse as a label. If you only need the expression as a function to be evaluated, it may be better to pass the argument as a function -- a f

Re: [R] Pasting R code lines into labels

2019-06-06 Thread Marc Schwartz via R-help
Hi, Sorry for the misfire on the first attempt. After seeing the clarifications, I thought about a possible way to do this, perhaps a little more simply, while encapsulating the plotting in a function: plotFx <- function(x, fun) { plot(x, fun(x), main = paste0("Plot of y = ", deparse(fun)[2])

Re: [R] Plotting more than one regression line in ggplot

2019-06-06 Thread Rui Barradas
Hello, Try this. values_to_plot <- c("onepctCO2MEDIAN", "RCP4.5MEDIAN", "RCP8.5MEDIAN") sub_df <- subset(NewestdataUltra, L1 %in% values_to_plot) ggplot(sub_df, aes(x, value, colour = L1)) + geom_point() + scale_color_manual(values = c("green", "red", "blue")) + geom_smooth(method = lm)

Re: [R] Including a large number of variables in a formula.

2019-06-06 Thread Rolando I. Valdez via R-help
The first idea works perfect. Thank you!. El mié., 5 jun. 2019 a las 1:07, peter dalgaard () escribió: > Two ideas: > > nn <- names(wageszm14) > lvadd <- nn[grep("^lvacb", nn)] > > or > > lvadd <- paste0("lvacb", 23:81) > lvadd <- lvadd[lvadd %in% names(wageszm14)] > > > On 5 Jun 2019, at 06:46

Re: [R] max size of a file that R can open to work

2019-06-06 Thread Jeff Newmiller
Technically "opening" a file does not involve reading it into memory at all, so any limits would arise from the OS. As for "reading" the file, the amount of virtual memory [1] is the key factor, but different file formats can require more or less overhead memory to parse the data. Also, differe

Re: [R] Plotting more than one regression line in ggplot

2019-06-06 Thread rain1290--- via R-help
Hi Rui, Yes! This worked just fine! Thank you so, so much for your time and patience!  -Original Message- From: Rui Barradas To: rain1290 ; r-help Sent: Thu, Jun 6, 2019 3:25 pm Subject: Re: [R] Plotting more than one regression line in ggplot Hello, Try this. values_to_plot <- c("o

Re: [R] Pasting R code lines into labels

2019-06-06 Thread Bert Gunter
Well, if you want to do it this way, note that as written, the y axis default label isn't "nice," and you should anyway allow for additional graphical arguments (either way). Also, slightly better I think is to use the built-in access function, body(): plotFx <- function(x, fun, ...) { plot(x,

Re: [R] Open a file which name contains a tilde

2019-06-06 Thread Richard O'Keefe
How can expanding tildes anywhere but the beginning of a file name NOT be considered a bug? On Thu, 6 Jun 2019 at 23:04, Ivan Krylov wrote: > On Wed, 5 Jun 2019 18:07:15 +0200 > Frank Schwidom wrote: > > > +> path.expand("a ~ b") > > [1] "a /home/user b" > > > How can I switch off any file cri

Re: [R] Open a file which name contains a tilde

2019-06-06 Thread Duncan Murdoch
On 06/06/2019 5:04 p.m., Richard O'Keefe wrote: How can expanding tildes anywhere but the beginning of a file name NOT be considered a bug? It looks like a bug in R, but not necessarily a bug in libreadline: we may just be using tilde_expand improperly. Duncan Murdoch On Thu, 6 Jun 2019

Re: [R] Pasting R code lines into labels

2019-06-06 Thread Duncan Murdoch
These look like very fragile suggestions. Allow x^2 to be an argument (named expr, for example) to plotFx, don't force a user to write a function in a very particular way. Then use deparse(substitute(expr)) in the title. Duncan Murdoch On 06/06/2019 4:33 p.m., Bert Gunter wrote: Well, if y

[R] Automatically simulates random numbers (not general) in R?

2019-06-06 Thread Thevaraja, Mayooran
Hello Guys! I am wondering about below function which automatically simulates random numbers - given below that manual calculation too. Anyone help me to fix that error. I got that error "object of type 'closure' is not subsettable" So Do you have any ideas? Regards Mayooran ###

Re: [R] Automatically simulates random numbers (not general) in R?

2019-06-06 Thread Thevaraja, Mayooran
Yes, Now fixed it. Thanks for your help. So my function is given by start<-function(n){ #startn <- vector("list", n) indx <- 1:N start <-sort(sample(indx,1)) for (i in 1:n) { if (i<2) { start[i] <- sort(sample(indx,1)) } else { start[i] <- sort(sample(start[i-1]+1,1))