[R] Regex Help

2016-12-12 Thread Bert Gunter
1. Once you have the character vector from the regex, see ?strsplit to get the strings on either side of the "->" . You may have to fiddle a bit if one or the other side is empty. You can then format the results as you like. 2. "Graphical representation similar to this" is too vague a specificati

Re: [R] how do I define a function which is equivalent to `deparse(substitute(x))`?

2016-12-12 Thread Bert Gunter
John: If you insist: > desub <- function(x) deparse(sys.call(-length(sys.parents())+1)[[2]]) > > f <- function(y)desub(y) > g <- function(y)message(desub(y)) > > f(log) [1] "log" > g(log) log However, I would agree that searching backward through the call stack can be tricky. For exampl

Re: [R] Merging two columns of unequal length

2016-12-12 Thread Jeff Newmiller
You can't do that. You can either make a different data frame, or you can stack the data in additional rows. If you make your example reproducible, we may be able to give more specific help. Also, post in plain text to avoid HTML code corruption. http://stackoverflow.com/questions/5963269/ho

Re: [R] Merging two columns of unequal length

2016-12-12 Thread Mark Sharp
I did not look at the code, but note the following. By definition, 1. You cannot highlight code in plan text, which is the format accepted by r-help. 2. You cannot have columns of different lengths in a dataframe. R. Mark Sharp, Ph.D. msh...@txbiomed.org > On Dec 12, 2016, at 5:41 PM, Bail

Re: [R] how do I define a function which is equivalent to `deparse(substitute(x))`?

2016-12-12 Thread frederik
Thank you, John and David. Yes someone already came up with that one on Stack Overflow. Although I don't quite understand how it works - it would be nice to see a step-by-step explanation of what is getting substituted and evaluated in which environment. I guess 'eval.parent' must do its own subs

Re: [R] output

2016-12-12 Thread Marc Schwartz
Hi, With the WriteXLS() function, from the package of the same name, if you specify '.xlsx' for the file name extension, the function will create an Excel 2007 compatible file, which can handle worksheets of up to 1,048,576 rows by 16,384 columns. Thus: WriteXLS(dat, "test4.xlsx", row.names

Re: [R] [RE: [Rd] why does parent.frame() cycle when called from inside capture.output()?]

2016-12-12 Thread Mark.Bravington
Hi Frederik Goodo, glad you found mvbutils::mvb.parent.frame useful. I had forgotten that it's in mvbutils rather than debug package. This all dates back about 15 years... To be fair, I don't think R's behaviour with duplicated-but-aliased frames in the call stack is a "bug"--- everything norm

Re: [R] Reshape to wide format

2016-12-12 Thread Subodh Adhikari
For long to wide, try *dcas*t function in reshape2 package. (*melt* is from wide to long). Subodh On Mon, Dec 12, 2016 at 10:10 AM, Miluji Sb wrote: > [image: Boxbe] Miluji Sb ( > miluj...@gmail.com) is not on your Guest List >

Re: [R] output

2016-12-12 Thread Jeff Newmiller
1) I recommend against using xls for very large data sets. (Not that xlsx is really that much better.) If you really think this is necessary you will probably need to split the data frame and write each element of the resulting list. See ?split. 2) Google tells me (as it could have told you) th

Re: [R] how do I define a function which is equivalent to `deparse(substitute(x))`?

2016-12-12 Thread Fox, John
Dear Bert, Your current version satisfies the original posting, but, though simpler than mine, is a bit fragile, in the following sense: > desub <- function(x) (all.vars(sys.call(-2))) > f <- function(x){ + message(desub(x)) + } > f(log) log > g <- function(x){ + desub(x) + } > g(log

[R] output

2016-12-12 Thread Val
Hi all, I have a data frame with more than 100,000 rows. datx <- function(n,mean,sd) { mean+sd*scale(rnorm(n)) } dat <- datx(11,10,2) 1) WriteXLS(dat, "test4.xls", row.names=FALSE) Error in WriteXLS(dat, "test4.xls", row.names = FALSE) : One or more of the data frames named in 'x' exceeds

Re: [R] how do I define a function which is equivalent to `deparse(substitute(x))`?

2016-12-12 Thread Bert Gunter
John. et. al: I assumed the message call was there to convert a quoted string to an unquoted name and simply did this with as.name() in desub(). The point of using sys.call() is that you can go up the call stack as far as you need, so if you want to leave in the message() call, just go one farther

Re: [R] how do I define a function which is equivalent to `deparse(substitute(x))`?

2016-12-12 Thread Fox, John
Dear Bert, It's nitpicking, I guess, but the call to message() is in the original posting. Your solution produces > desub <- function(x) as.name(all.vars(sys.call(-1))) > f <- function(x){ + message(desub(x)) + } > f(log) x Best, John > -Original Message- > From: Bert Gunter [ma

Re: [R] how do I define a function which is equivalent to `deparse(substitute(x))`?

2016-12-12 Thread Bert Gunter
*If* I understand correctly -- and please let me know if I don't -- this seems somewhat more straightforward and less "hacky" : > desub <- function(x) as.name(all.vars(sys.call(-1))) Yielding in the OP's example: > g <- function(y)desub(y) > g(log) log Cheers, Bert Bert Gunter "The trouble wit

Re: [R] how do I define a function which is equivalent to `deparse(substitute(x))`?

2016-12-12 Thread David Winsemius
> On Dec 12, 2016, at 2:07 PM, Fox, John wrote: > > Dear Frederick, > > I found this a challenging puzzle, and it took me awhile to come up with an > alternative, and I think slightly simpler, solution: > >> desub <- function(y) { > + deparse(eval(substitute(substitute(y)), > +

Re: [R] Log plus one transformation in R

2016-12-12 Thread Faradj Koliev
Many thanks! logp1(x) worked just fine. Best, Faradj Skickat från min iPhone > 12 dec. 2016 kl. 22:54 skrev peter dalgaard : > > And, for crying out loud... just try it with x = 1.234e-16 or so. One would > think that the hint |x| << 1 was obvious enough. > > -pd > >> On 12 Dec 2016, at 18

Re: [R] how do I define a function which is equivalent to `deparse(substitute(x))`?

2016-12-12 Thread Fox, John
Dear Frederick, I found this a challenging puzzle, and it took me awhile to come up with an alternative, and I think slightly simpler, solution: > desub <- function(y) { + deparse(eval(substitute(substitute(y)), + env=parent.frame())) + } > f <- function(x){ + message

Re: [R] Log plus one transformation in R

2016-12-12 Thread peter dalgaard
And, for crying out loud... just try it with x = 1.234e-16 or so. One would think that the hint |x| << 1 was obvious enough. -pd > On 12 Dec 2016, at 18:26 , William Dunlap via R-help > wrote: > > Print more digits of the quotient or subtract one from it and you will see > the difference: >

Re: [R] Log plus one transformation in R

2016-12-12 Thread Jeff Newmiller
Numerical accuracy in floating point math is a much broader discussion than R, but [1] seems to summarize it reasonably well. There are whole courses on this topic at university. [1] http://www.johndcook.com/blog/2010/06/07/math-library-functions-that-seem-unnecessary/ -- Sent from my phone.

Re: [R] Log plus one transformation in R

2016-12-12 Thread David Winsemius
> On Dec 12, 2016, at 9:26 AM, John Sorkin wrote: > > David, > > I did read the help page. All it says is > log1p(x) computes log(1+x) accurately also for |x| << 1 (and less accurately > when x is approximately -1). Not true. You evidently did not run the examples. -- David. > > This give

Re: [R] Log plus one transformation in R

2016-12-12 Thread William Dunlap via R-help
The problem is that 1+x does not give accurate results for small x: > (1+1e-17) == 1 [1] TRUE Bill Dunlap TIBCO Software wdunlap tibco.com On Mon, Dec 12, 2016 at 9:26 AM, John Sorkin wrote: > David, > > I did read the help page. All it says is > > log1p(x) computes *log(1+x)* accuratel

Re: [R] Log plus one transformation in R

2016-12-12 Thread William Dunlap via R-help
Print more digits of the quotient or subtract one from it and you will see the difference: > log1p(0.01)/log(0.01+1) - 1 [1] 8.22666379463044e-11 Bill Dunlap TIBCO Software wdunlap tibco.com On Mon, Dec 12, 2016 at 8:53 AM, John Sorkin wrote: > At the risk of being flamed . . . > What

Re: [R] Log plus one transformation in R

2016-12-12 Thread John Sorkin
David, I did read the help page. All it says is log1p(x) computes log(1+x) accurately also for |x| << 1 (and less accurately when x is approximately -1). This gives me pause. Does it mean that log(x) does not give accurate results? If log1p gives more accurate values than log, why is the log fun

Re: [R] Log plus one transformation in R

2016-12-12 Thread David L Carlson
The difference increases as the value gets closer to 0: > dput(log1p(0.01)) 9.950333e-07 > dput(log(1+0.01)) 9.9499918067e-07 > dput(log1p(0.01)/log(0.01+1)) 1.008227 > dput(log1p(0.0001)/log(0.0001+1)) 1.607747 > dput(log1p(0.01)/log(0.

[R] Reshape to wide format

2016-12-12 Thread Miluji Sb
Dear all, I have the following monthly data by coordinates: I would like to reshape this data to wide format so that each column is a coordinate and each row is a month, coordinate1 coordinate2 coordinate3... Month 1 Month 2 Is the best option to concatenate the iso3, lon, and lat variables to

Re: [R] Log plus one transformation in R

2016-12-12 Thread David Winsemius
> On Dec 12, 2016, at 8:53 AM, John Sorkin wrote: > > At the risk of being flamed . . . > What is the difference between log1p(x) and log(x+1)? > The two methods appear to give the same results: >> log1p(0.01)/log(0.01+1) > [1] 1 > John Read the help page more carefully. -- David. >

Re: [R] Log plus one transformation in R

2016-12-12 Thread John Sorkin
At the risk of being flamed . . . What is the difference between log1p(x) and log(x+1)? The two methods appear to give the same results: > log1p(0.01)/log(0.01+1) [1] 1 John John David Sorkin M.D., Ph.D. Professor of Medicine Chief, Biostatistics and Informatics University of Maryland Sch

Re: [R] Log plus one transformation in R

2016-12-12 Thread Martin Maechler
> Faradj Koliev > on Mon, 12 Dec 2016 17:23:20 +0100 writes: > Hi all, How do I perform log(x+1) in R? > log1p_trans() from the package ”scales" doesn’t seem to > work for me. amazing that you did not find log1p() in base R. ___

Re: [R] Log plus one transformation in R

2016-12-12 Thread William Dunlap via R-help
log1p(x), in the base package computes log(1+x) accurately for small x (and large). E.g., > options(digits=16) > base::log1p(1e-14) [1] 9.95e-15 > base::log1p(1e-14) - base::log(1+1e-14) [1] 7.992778373591124e-18 > as.numeric(log(Rmpfr::mpfr(1,precBits=1000) + Rmpfr::mpfr(1e-14, precBi

Re: [R] Log plus one transformation in R

2016-12-12 Thread Spencer Graves
"?log" includes documentation for "log1p" in the base package Will that work? Spencer Graves On 12/12/2016 10:23 AM, Faradj Koliev wrote: Hi all, How do I perform log(x+1) in R? log1p_trans() from the package ”scales" doesn’t seem to work for me. Best, Faradj __

Re: [R] Log plus one transformation in R

2016-12-12 Thread John Sorkin
Faradj, I all you need to do is newvalue <- log(x+1) John David Sorkin M.D., Ph.D. Professor of Medicine Chief, Biostatistics and Informatics University of Maryland School of Medicine Division of Gerontology and Geriatric Medicine Baltimore VA Medical Center 10 North Greene Street GRECC (BT/1

[R] Log plus one transformation in R

2016-12-12 Thread Faradj Koliev
Hi all, How do I perform log(x+1) in R? log1p_trans() from the package ”scales" doesn’t seem to work for me. Best, Faradj __ R-help@r-project.org mailing list -- To UNSUBSCRIBE and more, see https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do re

Re: [R] [FORGED] help with gradient boxplot

2016-12-12 Thread Fix Ace via R-help
Hi, Paul, Thank you so much for this further clarification! Ace On Sunday, December 11, 2016 2:09 PM, Paul Murrell wrote: Hi Great to hear you have it working. Figuring out the names of grobs takes two things: 1. someone has to name the grobs 2. grid.ls() The reason why I did my exa

[R] [RE: [Rd] why does parent.frame() cycle when called from inside capture.output()?]

2016-12-12 Thread frederik
Thanks, Mark - I'm taking up your invitation to forward your message to the list just because it gives us some valuable data on (1) how long the behavior has been around, and (2) how many other people (don't) understand the behavior, and (3) how we might fix or work around it. I notice some other

[R] [R-pkgs] Announcing eulerr 1.0.0

2016-12-12 Thread Johan Larsson
Dear R users, I would like to announce version 1.0.0 of eulerr (https://cran.r-project.org/package=eulerr). eulerr produces venn and euler diagrams for any number of sets. The user inputs a string of set relationships, for instance eulerr(c("A" = 10, "B" = 5, "A&B" = 2)), and out pops a spec

[R] why does parent.frame() cycle when called from inside capture.output()?

2016-12-12 Thread frederik
Hello R devel/help, I ran into this strange behavior: # showstack is supposed to walk through the stack of parent # environments when it is called: showstack = function() { env = environment() for(i in 1:12) { env = do.call(parent.frame, list(), env=env) pr

Re: [R] how do I define a function which is equivalent to `deparse(substitute(x))`?

2016-12-12 Thread frederik
Thank you, that made me laugh :) On Sun, Dec 11, 2016 at 08:53:42PM -0800, David Winsemius wrote: > > > On Dec 11, 2016, at 5:35 PM, frede...@ofb.net wrote: > > > > Dear R-Help, > > > > I was going to ask Jeff to read the entire works of William > > Shakespeare to learn why his reply was not he