Re: [R] as.character(quote(x$y) ) = $ x y not x$y?
On Fri, May 9, 2014 at 10:42 PM, Hadley Wickham h.wick...@gmail.com wrote: Beware of the is.* functions: * is.object() does not test the usual definition of objects * is.vector() does not test the usual definition of vectors * is.numeric() does not work the same way as is.character() or is.integer() * is.Date() doesn't exist * is.nan() doesn't return TRUE for some NaNs Can we have an is.is function that tells us these things? is.is(is.object) [1] FALSE Warning: is.object() does not test the usual definition of objects is.is(is.is) [1] TRUE For further exploration, demo(is.things) creates a handy is.ALL function that outputs the result of running a lot of is.X functions on its argument. Barry __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.
Re: [R] as.character(quote(x$y) ) = $ x y not x$y?
On 10/05/2014, 6:46 AM, Barry Rowlingson wrote: On Fri, May 9, 2014 at 10:42 PM, Hadley Wickham h.wick...@gmail.com wrote: Beware of the is.* functions: * is.object() does not test the usual definition of objects * is.vector() does not test the usual definition of vectors * is.numeric() does not work the same way as is.character() or is.integer() * is.Date() doesn't exist * is.nan() doesn't return TRUE for some NaNs Can we have an is.is function that tells us these things? is.is(is.object) [1] FALSE Warning: is.object() does not test the usual definition of objects is.is(is.is) [1] TRUE For further exploration, demo(is.things) creates a handy is.ALL function that outputs the result of running a lot of is.X functions on its argument. I tried to write it, but the trouble is, is.is(is.is) is FALSE. Duncan __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.
Re: [R] as.character(quote(x$y) ) = $ x y not x$y?
On 10 May 2014, at 12:54 , Duncan Murdoch murdoch.dun...@gmail.com wrote: On 10/05/2014, 6:46 AM, Barry Rowlingson wrote: On Fri, May 9, 2014 at 10:42 PM, Hadley Wickham h.wick...@gmail.com wrote: Beware of the is.* functions: * is.object() does not test the usual definition of objects * is.vector() does not test the usual definition of vectors * is.numeric() does not work the same way as is.character() or is.integer() * is.Date() doesn't exist * is.nan() doesn't return TRUE for some NaNs Can we have an is.is function that tells us these things? is.is(is.object) [1] FALSE Warning: is.object() does not test the usual definition of objects is.is(is.is) [1] TRUE For further exploration, demo(is.things) creates a handy is.ALL function that outputs the result of running a lot of is.X functions on its argument. I tried to write it, but the trouble is, is.is(is.is) is FALSE. Duncan Worse, is.is(mybaby) | is.aint(mybaby) comes out TRUE whatever the value of mybaby. -- Peter Dalgaard, Professor, Center for Statistics, Copenhagen Business School Solbjerg Plads 3, 2000 Frederiksberg, Denmark Phone: (+45)38153501 Email: pd@cbs.dk Priv: pda...@gmail.com __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.
Re: [R] as.character(quote(x$y) ) = $ x y not x$y?
On May 10, 2014, at 3:54 AM, Duncan Murdoch wrote: On 10/05/2014, 6:46 AM, Barry Rowlingson wrote: On Fri, May 9, 2014 at 10:42 PM, Hadley Wickham h.wick...@gmail.com wrote: Beware of the is.* functions: * is.object() does not test the usual definition of objects * is.vector() does not test the usual definition of vectors * is.numeric() does not work the same way as is.character() or is.integer() * is.Date() doesn't exist * is.nan() doesn't return TRUE for some NaNs Can we have an is.is function that tells us these things? is.is(is.object) [1] FALSE Warning: is.object() does not test the usual definition of objects is.is(is.is) [1] TRUE For further exploration, demo(is.things) creates a handy is.ALL function that outputs the result of running a lot of is.X functions on its argument. I tried to write it, but the trouble is, is.is(is.is) is FALSE. Perhaps the R engine will surmount the Singularity when `is.think` returns `is.is`. Duncan David Winsemius Alameda, CA, USA __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.
Re: [R] as.character(quote(x$y) ) = $ x y not x$y?
Spencer: Hmmm Well, I don't get what's going on here -- as.character.default is internal -- but could you method-ize a simple synonym: asChar- function(e,...)UseMethod(asChar) asChar.call - function(e,...)deparse(e,...) asChar.default - function(e,...)as.character(e,...) asChar(xDy) [1] x$y asChar(1:5) [1] 1 2 3 4 5 Cheers, Bert Bert Gunter Genentech Nonclinical Biostatistics (650) 467-7374 Data is not information. Information is not knowledge. And knowledge is certainly not wisdom. H. Gilbert Welch On Thu, May 8, 2014 at 8:56 PM, Spencer Graves spencer.gra...@structuremonitoring.com wrote: On 5/8/2014 8:05 PM, Bert Gunter wrote: [1] x$y Spencer: Does deparse(substitute(x$y)) [1] x$y do what you want? No: The problem is methods dispatch. class(quote(x$y)) = 'call', but as.character(quote(x$y)) does NOT go to as.character.call. deparse(quote(x$y)) returns the answer I want, as Greg Snow noted earlier. However, it would be easier to remember if I could write as.character(quote(x$y)) and get the same thing. With as.character.call - function(x, ...)deparse(x, ...), as.character.call(quote(x$y)) returns x$y, as desired. However, the methods dispatch one might naively expect fails, as noted above. Thanks, Spencer Cheers, Bert -- Bert Bert Gunter Genentech Nonclinical Biostatistics (650) 467-7374 Data is not information. Information is not knowledge. And knowledge is certainly not wisdom. H. Gilbert Welch On Thu, May 8, 2014 at 5:56 PM, Spencer Graves spencer.gra...@structuremonitoring.com wrote: as.character.call seems not to work as an alias for deparse. Consider the following: xDy - quote(x$y) class(xDy) call as.character.call - function(x, ...)deparse(x, ...) as.character(xDy) [1] $ x y # fails str(xDy) # language x$y as.character.language - function(x, ...)language as.character(xDy) [1] $ x y Is it feasible to construct a method for as.character that works for objects of class call? Thanks, Spencer # Thanks for the quick replies from Richard Heiberger, Greg Show Bert Gunter. Might it make sense to create as.character.call as an alias for deparse? A few years ago, I wrote several functions like predict.fd as aliases for functions with less memorable names like eval.fd. Doing that made the fda package easier to use, at least for me ;-) Thanks again, Spencer On 5/7/2014 2:39 PM, Bert Gunter wrote: ... and str(quote(x$y)) language x$y as.list(quote(x$y)) [[1]] `$` [[2]] x [[3]] y ## may be instructive. Cheers, Bert Bert Gunter Genentech Nonclinical Biostatistics (650) 467-7374 Data is not information. Information is not knowledge. And knowledge is certainly not wisdom. H. Gilbert Welch On Wed, May 7, 2014 at 2:30 PM, Greg Snow 538...@gmail.com wrote: deparse(quote(x$y)) [1] x$y It looks like deparse does what you want here. On Wed, May 7, 2014 at 3:23 PM, Spencer Graves spencer.gra...@structuremonitoring.com wrote: Hello, All: Is there a simple utility someplace to convert quote(x$y) to x$y? I ask, because as.character(quote(x$y)) is a character vector of length 3 = $ x y. I want to convert this to x$y for a diagnostic message. class(quote(x$y)) = call, which suggests I could write as.character.call to perform this function. However, before I do, I felt a need to ask for other thoughts on this. Thanks, Spencer -- Gregory (Greg) L. Snow Ph.D. 538...@gmail.com __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code. -- Spencer Graves, PE, PhD President and Chief Technology Officer Structure Inspection and Monitoring, Inc. 751 Emerson Ct. San José, CA 95126 ph: 408-655-4567 web: www.structuremonitoring.com __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.
Re: [R] as.character(quote(x$y) ) = $ x y not x$y?
On 09/05/2014, 2:41 AM, Bert Gunter wrote: Spencer: Hmmm Well, I don't get what's going on here -- as.character.default is internal -- but could you method-ize a simple synonym: See ?InternalMethods: For efficiency, internal dispatch only occurs on objects, that is those for which is.object returns true. Duncan Murdoch asChar- function(e,...)UseMethod(asChar) asChar.call - function(e,...)deparse(e,...) asChar.default - function(e,...)as.character(e,...) asChar(xDy) [1] x$y asChar(1:5) [1] 1 2 3 4 5 Cheers, Bert Bert Gunter Genentech Nonclinical Biostatistics (650) 467-7374 Data is not information. Information is not knowledge. And knowledge is certainly not wisdom. H. Gilbert Welch On Thu, May 8, 2014 at 8:56 PM, Spencer Graves spencer.gra...@structuremonitoring.com wrote: On 5/8/2014 8:05 PM, Bert Gunter wrote: [1] x$y Spencer: Does deparse(substitute(x$y)) [1] x$y do what you want? No: The problem is methods dispatch. class(quote(x$y)) = 'call', but as.character(quote(x$y)) does NOT go to as.character.call. deparse(quote(x$y)) returns the answer I want, as Greg Snow noted earlier. However, it would be easier to remember if I could write as.character(quote(x$y)) and get the same thing. With as.character.call - function(x, ...)deparse(x, ...), as.character.call(quote(x$y)) returns x$y, as desired. However, the methods dispatch one might naively expect fails, as noted above. Thanks, Spencer Cheers, Bert -- Bert Bert Gunter Genentech Nonclinical Biostatistics (650) 467-7374 Data is not information. Information is not knowledge. And knowledge is certainly not wisdom. H. Gilbert Welch On Thu, May 8, 2014 at 5:56 PM, Spencer Graves spencer.gra...@structuremonitoring.com wrote: as.character.call seems not to work as an alias for deparse. Consider the following: xDy - quote(x$y) class(xDy) call as.character.call - function(x, ...)deparse(x, ...) as.character(xDy) [1] $ x y # fails str(xDy) # language x$y as.character.language - function(x, ...)language as.character(xDy) [1] $ x y Is it feasible to construct a method for as.character that works for objects of class call? Thanks, Spencer # Thanks for the quick replies from Richard Heiberger, Greg Show Bert Gunter. Might it make sense to create as.character.call as an alias for deparse? A few years ago, I wrote several functions like predict.fd as aliases for functions with less memorable names like eval.fd. Doing that made the fda package easier to use, at least for me ;-) Thanks again, Spencer On 5/7/2014 2:39 PM, Bert Gunter wrote: ... and str(quote(x$y)) language x$y as.list(quote(x$y)) [[1]] `$` [[2]] x [[3]] y ## may be instructive. Cheers, Bert Bert Gunter Genentech Nonclinical Biostatistics (650) 467-7374 Data is not information. Information is not knowledge. And knowledge is certainly not wisdom. H. Gilbert Welch On Wed, May 7, 2014 at 2:30 PM, Greg Snow 538...@gmail.com wrote: deparse(quote(x$y)) [1] x$y It looks like deparse does what you want here. On Wed, May 7, 2014 at 3:23 PM, Spencer Graves spencer.gra...@structuremonitoring.com wrote: Hello, All: Is there a simple utility someplace to convert quote(x$y) to x$y? I ask, because as.character(quote(x$y)) is a character vector of length 3 = $ x y. I want to convert this to x$y for a diagnostic message. class(quote(x$y)) = call, which suggests I could write as.character.call to perform this function. However, before I do, I felt a need to ask for other thoughts on this. Thanks, Spencer -- Gregory (Greg) L. Snow Ph.D. 538...@gmail.com __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code. -- Spencer Graves, PE, PhD President and Chief Technology Officer Structure Inspection and Monitoring, Inc. 751 Emerson Ct. San José, CA 95126 ph: 408-655-4567 web: www.structuremonitoring.com __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code. __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.
Re: [R] as.character(quote(x$y) ) = $ x y not x$y?
Ahhh. Thanks Duncan. -- Bert Bert Gunter Genentech Nonclinical Biostatistics (650) 467-7374 Data is not information. Information is not knowledge. And knowledge is certainly not wisdom. H. Gilbert Welch On Fri, May 9, 2014 at 2:41 AM, Duncan Murdoch murdoch.dun...@gmail.com wrote: On 09/05/2014, 2:41 AM, Bert Gunter wrote: Spencer: Hmmm Well, I don't get what's going on here -- as.character.default is internal -- but could you method-ize a simple synonym: See ?InternalMethods: For efficiency, internal dispatch only occurs on objects, that is those for which is.object returns true. Duncan Murdoch asChar- function(e,...)UseMethod(asChar) asChar.call - function(e,...)deparse(e,...) asChar.default - function(e,...)as.character(e,...) asChar(xDy) [1] x$y asChar(1:5) [1] 1 2 3 4 5 Cheers, Bert Bert Gunter Genentech Nonclinical Biostatistics (650) 467-7374 Data is not information. Information is not knowledge. And knowledge is certainly not wisdom. H. Gilbert Welch On Thu, May 8, 2014 at 8:56 PM, Spencer Graves spencer.gra...@structuremonitoring.com wrote: On 5/8/2014 8:05 PM, Bert Gunter wrote: [1] x$y Spencer: Does deparse(substitute(x$y)) [1] x$y do what you want? No: The problem is methods dispatch. class(quote(x$y)) = 'call', but as.character(quote(x$y)) does NOT go to as.character.call. deparse(quote(x$y)) returns the answer I want, as Greg Snow noted earlier. However, it would be easier to remember if I could write as.character(quote(x$y)) and get the same thing. With as.character.call - function(x, ...)deparse(x, ...), as.character.call(quote(x$y)) returns x$y, as desired. However, the methods dispatch one might naively expect fails, as noted above. Thanks, Spencer Cheers, Bert -- Bert Bert Gunter Genentech Nonclinical Biostatistics (650) 467-7374 Data is not information. Information is not knowledge. And knowledge is certainly not wisdom. H. Gilbert Welch On Thu, May 8, 2014 at 5:56 PM, Spencer Graves spencer.gra...@structuremonitoring.com wrote: as.character.call seems not to work as an alias for deparse. Consider the following: xDy - quote(x$y) class(xDy) call as.character.call - function(x, ...)deparse(x, ...) as.character(xDy) [1] $ x y # fails str(xDy) # language x$y as.character.language - function(x, ...)language as.character(xDy) [1] $ x y Is it feasible to construct a method for as.character that works for objects of class call? Thanks, Spencer # Thanks for the quick replies from Richard Heiberger, Greg Show Bert Gunter. Might it make sense to create as.character.call as an alias for deparse? A few years ago, I wrote several functions like predict.fd as aliases for functions with less memorable names like eval.fd. Doing that made the fda package easier to use, at least for me ;-) Thanks again, Spencer On 5/7/2014 2:39 PM, Bert Gunter wrote: ... and str(quote(x$y)) language x$y as.list(quote(x$y)) [[1]] `$` [[2]] x [[3]] y ## may be instructive. Cheers, Bert Bert Gunter Genentech Nonclinical Biostatistics (650) 467-7374 Data is not information. Information is not knowledge. And knowledge is certainly not wisdom. H. Gilbert Welch On Wed, May 7, 2014 at 2:30 PM, Greg Snow 538...@gmail.com wrote: deparse(quote(x$y)) [1] x$y It looks like deparse does what you want here. On Wed, May 7, 2014 at 3:23 PM, Spencer Graves spencer.gra...@structuremonitoring.com wrote: Hello, All: Is there a simple utility someplace to convert quote(x$y) to x$y? I ask, because as.character(quote(x$y)) is a character vector of length 3 = $ x y. I want to convert this to x$y for a diagnostic message. class(quote(x$y)) = call, which suggests I could write as.character.call to perform this function. However, before I do, I felt a need to ask for other thoughts on this. Thanks, Spencer -- Gregory (Greg) L. Snow Ph.D. 538...@gmail.com __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code. -- Spencer Graves, PE, PhD President and Chief Technology Officer Structure Inspection and Monitoring, Inc. 751 Emerson Ct. San José, CA 95126 ph: 408-655-4567 web: www.structuremonitoring.com __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible
Re: [R] as.character(quote(x$y) ) = $ x y not x$y?
Hi, Duncan: Thanks very much. I used to think that everything in R was a object. Now I know that is.object(quote(x)) is FALSE. (A decade ago, S-Plus asked me if I wanted to save changes to history. I thought, Wow! Do I get to change history? Hadley's Advanced R book mentions Reference classes in his OO field guide. It includes an example where changing a changes a copy previously made: b - a b$balance # [1] 200 a$balance - 0 b$balance # [1] 0 This bothers me far more than an object in R that's not an object ;-) Best Wishes, Spencer On 5/9/2014 6:48 AM, Bert Gunter wrote: Ahhh. Thanks Duncan. -- Bert Bert Gunter Genentech Nonclinical Biostatistics (650) 467-7374 Data is not information. Information is not knowledge. And knowledge is certainly not wisdom. H. Gilbert Welch On Fri, May 9, 2014 at 2:41 AM, Duncan Murdoch murdoch.dun...@gmail.com wrote: On 09/05/2014, 2:41 AM, Bert Gunter wrote: Spencer: Hmmm Well, I don't get what's going on here -- as.character.default is internal -- but could you method-ize a simple synonym: See ?InternalMethods: For efficiency, internal dispatch only occurs on objects, that is those for which is.object returns true. Duncan Murdoch asChar- function(e,...)UseMethod(asChar) asChar.call - function(e,...)deparse(e,...) asChar.default - function(e,...)as.character(e,...) asChar(xDy) [1] x$y asChar(1:5) [1] 1 2 3 4 5 Cheers, Bert Bert Gunter Genentech Nonclinical Biostatistics (650) 467-7374 Data is not information. Information is not knowledge. And knowledge is certainly not wisdom. H. Gilbert Welch On Thu, May 8, 2014 at 8:56 PM, Spencer Graves spencer.gra...@structuremonitoring.com wrote: On 5/8/2014 8:05 PM, Bert Gunter wrote: [1] x$y Spencer: Does deparse(substitute(x$y)) [1] x$y do what you want? No: The problem is methods dispatch. class(quote(x$y)) = 'call', but as.character(quote(x$y)) does NOT go to as.character.call. deparse(quote(x$y)) returns the answer I want, as Greg Snow noted earlier. However, it would be easier to remember if I could write as.character(quote(x$y)) and get the same thing. With as.character.call - function(x, ...)deparse(x, ...), as.character.call(quote(x$y)) returns x$y, as desired. However, the methods dispatch one might naively expect fails, as noted above. Thanks, Spencer Cheers, Bert -- Bert Bert Gunter Genentech Nonclinical Biostatistics (650) 467-7374 Data is not information. Information is not knowledge. And knowledge is certainly not wisdom. H. Gilbert Welch On Thu, May 8, 2014 at 5:56 PM, Spencer Graves spencer.gra...@structuremonitoring.com wrote: as.character.call seems not to work as an alias for deparse. Consider the following: xDy - quote(x$y) class(xDy) call as.character.call - function(x, ...)deparse(x, ...) as.character(xDy) [1] $ x y # fails str(xDy) # language x$y as.character.language - function(x, ...)language as.character(xDy) [1] $ x y Is it feasible to construct a method for as.character that works for objects of class call? Thanks, Spencer # Thanks for the quick replies from Richard Heiberger, Greg Show Bert Gunter. Might it make sense to create as.character.call as an alias for deparse? A few years ago, I wrote several functions like predict.fd as aliases for functions with less memorable names like eval.fd. Doing that made the fda package easier to use, at least for me ;-) Thanks again, Spencer On 5/7/2014 2:39 PM, Bert Gunter wrote: ... and str(quote(x$y)) language x$y as.list(quote(x$y)) [[1]] `$` [[2]] x [[3]] y ## may be instructive. Cheers, Bert Bert Gunter Genentech Nonclinical Biostatistics (650) 467-7374 Data is not information. Information is not knowledge. And knowledge is certainly not wisdom. H. Gilbert Welch On Wed, May 7, 2014 at 2:30 PM, Greg Snow 538...@gmail.com wrote: deparse(quote(x$y)) [1] x$y It looks like deparse does what you want here. On Wed, May 7, 2014 at 3:23 PM, Spencer Graves spencer.gra...@structuremonitoring.com wrote: Hello, All: Is there a simple utility someplace to convert quote(x$y) to x$y? I ask, because as.character(quote(x$y)) is a character vector of length 3 = $ x y. I want to convert this to x$y for a diagnostic message. class(quote(x$y)) = call, which suggests I could write as.character.call to perform this function. However, before I do, I felt a need to ask for other thoughts on this. Thanks, Spencer -- Gregory (Greg) L. Snow Ph.D. 538...@gmail.com __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented,
Re: [R] as.character(quote(x$y) ) = $ x y not x$y?
Beware of the is.* functions: * is.object() does not test the usual definition of objects * is.vector() does not test the usual definition of vectors * is.numeric() does not work the same way as is.character() or is.integer() * is.Date() doesn't exist * is.nan() doesn't return TRUE for some NaNs Hadley On Fri, May 9, 2014 at 4:32 PM, Spencer Graves spencer.gra...@structuremonitoring.com wrote: Hi, Duncan: Thanks very much. I used to think that everything in R was a object. Now I know that is.object(quote(x)) is FALSE. (A decade ago, S-Plus asked me if I wanted to save changes to history. I thought, Wow! Do I get to change history? Hadley's Advanced R book mentions Reference classes in his OO field guide. It includes an example where changing a changes a copy previously made: b - a b$balance # [1] 200 a$balance - 0 b$balance # [1] 0 This bothers me far more than an object in R that's not an object ;-) Best Wishes, Spencer On 5/9/2014 6:48 AM, Bert Gunter wrote: Ahhh. Thanks Duncan. -- Bert Bert Gunter Genentech Nonclinical Biostatistics (650) 467-7374 Data is not information. Information is not knowledge. And knowledge is certainly not wisdom. H. Gilbert Welch On Fri, May 9, 2014 at 2:41 AM, Duncan Murdoch murdoch.dun...@gmail.com wrote: On 09/05/2014, 2:41 AM, Bert Gunter wrote: Spencer: Hmmm Well, I don't get what's going on here -- as.character.default is internal -- but could you method-ize a simple synonym: See ?InternalMethods: For efficiency, internal dispatch only occurs on objects, that is those for which is.object returns true. Duncan Murdoch asChar- function(e,...)UseMethod(asChar) asChar.call - function(e,...)deparse(e,...) asChar.default - function(e,...)as.character(e,...) asChar(xDy) [1] x$y asChar(1:5) [1] 1 2 3 4 5 Cheers, Bert Bert Gunter Genentech Nonclinical Biostatistics (650) 467-7374 Data is not information. Information is not knowledge. And knowledge is certainly not wisdom. H. Gilbert Welch On Thu, May 8, 2014 at 8:56 PM, Spencer Graves spencer.gra...@structuremonitoring.com wrote: On 5/8/2014 8:05 PM, Bert Gunter wrote: [1] x$y Spencer: Does deparse(substitute(x$y)) [1] x$y do what you want? No: The problem is methods dispatch. class(quote(x$y)) = 'call', but as.character(quote(x$y)) does NOT go to as.character.call. deparse(quote(x$y)) returns the answer I want, as Greg Snow noted earlier. However, it would be easier to remember if I could write as.character(quote(x$y)) and get the same thing. With as.character.call - function(x, ...)deparse(x, ...), as.character.call(quote(x$y)) returns x$y, as desired. However, the methods dispatch one might naively expect fails, as noted above. Thanks, Spencer Cheers, Bert -- Bert Bert Gunter Genentech Nonclinical Biostatistics (650) 467-7374 Data is not information. Information is not knowledge. And knowledge is certainly not wisdom. H. Gilbert Welch On Thu, May 8, 2014 at 5:56 PM, Spencer Graves spencer.gra...@structuremonitoring.com wrote: as.character.call seems not to work as an alias for deparse. Consider the following: xDy - quote(x$y) class(xDy) call as.character.call - function(x, ...)deparse(x, ...) as.character(xDy) [1] $ x y # fails str(xDy) # language x$y as.character.language - function(x, ...)language as.character(xDy) [1] $ x y Is it feasible to construct a method for as.character that works for objects of class call? Thanks, Spencer # Thanks for the quick replies from Richard Heiberger, Greg Show Bert Gunter. Might it make sense to create as.character.call as an alias for deparse? A few years ago, I wrote several functions like predict.fd as aliases for functions with less memorable names like eval.fd. Doing that made the fda package easier to use, at least for me ;-) Thanks again, Spencer On 5/7/2014 2:39 PM, Bert Gunter wrote: ... and str(quote(x$y)) language x$y as.list(quote(x$y)) [[1]] `$` [[2]] x [[3]] y ## may be instructive. Cheers, Bert Bert Gunter Genentech Nonclinical Biostatistics (650) 467-7374 Data is not information. Information is not knowledge. And knowledge is certainly not wisdom. H. Gilbert Welch On Wed, May 7, 2014 at 2:30 PM, Greg Snow 538...@gmail.com wrote: deparse(quote(x$y)) [1] x$y It looks like deparse does what you want here. On Wed, May 7, 2014 at 3:23 PM, Spencer Graves spencer.gra...@structuremonitoring.com wrote: Hello, All: Is there a simple utility someplace to convert quote(x$y) to x$y? I ask, because as.character(quote(x$y)) is a character vector of length 3 = $ x y. I want to convert
Re: [R] as.character(quote(x$y) ) = $ x y not x$y?
Dear Hadley: Thanks for that. Digits are not numbers. Numbers are not data. Data is not information. Information is not intelligence. Intelligence is not knowledge. Knowledge is not wisdom. And your is. warnings are more useful than my trivia here. Spencer On 5/9/2014 2:42 PM, Hadley Wickham wrote: Beware of the is.* functions: * is.object() does not test the usual definition of objects * is.vector() does not test the usual definition of vectors * is.numeric() does not work the same way as is.character() or is.integer() * is.Date() doesn't exist * is.nan() doesn't return TRUE for some NaNs Hadley On Fri, May 9, 2014 at 4:32 PM, Spencer Graves spencer.gra...@structuremonitoring.com wrote: Hi, Duncan: Thanks very much. I used to think that everything in R was a object. Now I know that is.object(quote(x)) is FALSE. (A decade ago, S-Plus asked me if I wanted to save changes to history. I thought, Wow! Do I get to change history? Hadley's Advanced R book mentions Reference classes in his OO field guide. It includes an example where changing a changes a copy previously made: b - a b$balance # [1] 200 a$balance - 0 b$balance # [1] 0 This bothers me far more than an object in R that's not an object ;-) Best Wishes, Spencer On 5/9/2014 6:48 AM, Bert Gunter wrote: Ahhh. Thanks Duncan. -- Bert Bert Gunter Genentech Nonclinical Biostatistics (650) 467-7374 Data is not information. Information is not knowledge. And knowledge is certainly not wisdom. H. Gilbert Welch On Fri, May 9, 2014 at 2:41 AM, Duncan Murdoch murdoch.dun...@gmail.com wrote: On 09/05/2014, 2:41 AM, Bert Gunter wrote: Spencer: Hmmm Well, I don't get what's going on here -- as.character.default is internal -- but could you method-ize a simple synonym: See ?InternalMethods: For efficiency, internal dispatch only occurs on objects, that is those for which is.object returns true. Duncan Murdoch asChar- function(e,...)UseMethod(asChar) asChar.call - function(e,...)deparse(e,...) asChar.default - function(e,...)as.character(e,...) asChar(xDy) [1] x$y asChar(1:5) [1] 1 2 3 4 5 Cheers, Bert Bert Gunter Genentech Nonclinical Biostatistics (650) 467-7374 Data is not information. Information is not knowledge. And knowledge is certainly not wisdom. H. Gilbert Welch On Thu, May 8, 2014 at 8:56 PM, Spencer Graves spencer.gra...@structuremonitoring.com wrote: On 5/8/2014 8:05 PM, Bert Gunter wrote: [1] x$y Spencer: Does deparse(substitute(x$y)) [1] x$y do what you want? No: The problem is methods dispatch. class(quote(x$y)) = 'call', but as.character(quote(x$y)) does NOT go to as.character.call. deparse(quote(x$y)) returns the answer I want, as Greg Snow noted earlier. However, it would be easier to remember if I could write as.character(quote(x$y)) and get the same thing. With as.character.call - function(x, ...)deparse(x, ...), as.character.call(quote(x$y)) returns x$y, as desired. However, the methods dispatch one might naively expect fails, as noted above. Thanks, Spencer Cheers, Bert -- Bert Bert Gunter Genentech Nonclinical Biostatistics (650) 467-7374 Data is not information. Information is not knowledge. And knowledge is certainly not wisdom. H. Gilbert Welch On Thu, May 8, 2014 at 5:56 PM, Spencer Graves spencer.gra...@structuremonitoring.com wrote: as.character.call seems not to work as an alias for deparse. Consider the following: xDy - quote(x$y) class(xDy) call as.character.call - function(x, ...)deparse(x, ...) as.character(xDy) [1] $ x y # fails str(xDy) # language x$y as.character.language - function(x, ...)language as.character(xDy) [1] $ x y Is it feasible to construct a method for as.character that works for objects of class call? Thanks, Spencer # Thanks for the quick replies from Richard Heiberger, Greg Show Bert Gunter. Might it make sense to create as.character.call as an alias for deparse? A few years ago, I wrote several functions like predict.fd as aliases for functions with less memorable names like eval.fd. Doing that made the fda package easier to use, at least for me ;-) Thanks again, Spencer On 5/7/2014 2:39 PM, Bert Gunter wrote: ... and str(quote(x$y)) language x$y as.list(quote(x$y)) [[1]] `$` [[2]] x [[3]] y ## may be instructive. Cheers, Bert Bert Gunter Genentech Nonclinical Biostatistics (650) 467-7374 Data is not information. Information is not knowledge. And knowledge is certainly not wisdom. H. Gilbert Welch On Wed, May 7, 2014 at 2:30 PM, Greg Snow 538...@gmail.com wrote: deparse(quote(x$y)) [1] x$y It looks like deparse does what you want here. On Wed, May 7, 2014 at 3:23 PM, Spencer Graves spencer.gra...@structuremonitoring.com wrote: Hello,
Re: [R] as.character(quote(x$y) ) = $ x y not x$y?
as.character.call seems not to work as an alias for deparse. Consider the following: xDy - quote(x$y) class(xDy) call as.character.call - function(x, ...)deparse(x, ...) as.character(xDy) [1] $ x y # fails str(xDy) # language x$y as.character.language - function(x, ...)language as.character(xDy) [1] $ x y Is it feasible to construct a method for as.character that works for objects of class call? Thanks, Spencer # Thanks for the quick replies from Richard Heiberger, Greg Show Bert Gunter. Might it make sense to create as.character.call as an alias for deparse? A few years ago, I wrote several functions like predict.fd as aliases for functions with less memorable names like eval.fd. Doing that made the fda package easier to use, at least for me ;-) Thanks again, Spencer On 5/7/2014 2:39 PM, Bert Gunter wrote: ... and str(quote(x$y)) language x$y as.list(quote(x$y)) [[1]] `$` [[2]] x [[3]] y ## may be instructive. Cheers, Bert Bert Gunter Genentech Nonclinical Biostatistics (650) 467-7374 Data is not information. Information is not knowledge. And knowledge is certainly not wisdom. H. Gilbert Welch On Wed, May 7, 2014 at 2:30 PM, Greg Snow 538...@gmail.com wrote: deparse(quote(x$y)) [1] x$y It looks like deparse does what you want here. On Wed, May 7, 2014 at 3:23 PM, Spencer Graves spencer.gra...@structuremonitoring.com wrote: Hello, All: Is there a simple utility someplace to convert quote(x$y) to x$y? I ask, because as.character(quote(x$y)) is a character vector of length 3 = $ x y. I want to convert this to x$y for a diagnostic message. class(quote(x$y)) = call, which suggests I could write as.character.call to perform this function. However, before I do, I felt a need to ask for other thoughts on this. Thanks, Spencer -- Gregory (Greg) L. Snow Ph.D. 538...@gmail.com __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code. __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.
Re: [R] as.character(quote(x$y) ) = $ x y not x$y?
[1] x$y Spencer: Does deparse(substitute(x$y)) [1] x$y do what you want? Cheers, Bert -- Bert Bert Gunter Genentech Nonclinical Biostatistics (650) 467-7374 Data is not information. Information is not knowledge. And knowledge is certainly not wisdom. H. Gilbert Welch On Thu, May 8, 2014 at 5:56 PM, Spencer Graves spencer.gra...@structuremonitoring.com wrote: as.character.call seems not to work as an alias for deparse. Consider the following: xDy - quote(x$y) class(xDy) call as.character.call - function(x, ...)deparse(x, ...) as.character(xDy) [1] $ x y # fails str(xDy) # language x$y as.character.language - function(x, ...)language as.character(xDy) [1] $ x y Is it feasible to construct a method for as.character that works for objects of class call? Thanks, Spencer # Thanks for the quick replies from Richard Heiberger, Greg Show Bert Gunter. Might it make sense to create as.character.call as an alias for deparse? A few years ago, I wrote several functions like predict.fd as aliases for functions with less memorable names like eval.fd. Doing that made the fda package easier to use, at least for me ;-) Thanks again, Spencer On 5/7/2014 2:39 PM, Bert Gunter wrote: ... and str(quote(x$y)) language x$y as.list(quote(x$y)) [[1]] `$` [[2]] x [[3]] y ## may be instructive. Cheers, Bert Bert Gunter Genentech Nonclinical Biostatistics (650) 467-7374 Data is not information. Information is not knowledge. And knowledge is certainly not wisdom. H. Gilbert Welch On Wed, May 7, 2014 at 2:30 PM, Greg Snow 538...@gmail.com wrote: deparse(quote(x$y)) [1] x$y It looks like deparse does what you want here. On Wed, May 7, 2014 at 3:23 PM, Spencer Graves spencer.gra...@structuremonitoring.com wrote: Hello, All: Is there a simple utility someplace to convert quote(x$y) to x$y? I ask, because as.character(quote(x$y)) is a character vector of length 3 = $ x y. I want to convert this to x$y for a diagnostic message. class(quote(x$y)) = call, which suggests I could write as.character.call to perform this function. However, before I do, I felt a need to ask for other thoughts on this. Thanks, Spencer -- Gregory (Greg) L. Snow Ph.D. 538...@gmail.com __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code. __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.
Re: [R] as.character(quote(x$y) ) = $ x y not x$y?
On 5/8/2014 8:05 PM, Bert Gunter wrote: [1] x$y Spencer: Does deparse(substitute(x$y)) [1] x$y do what you want? No: The problem is methods dispatch. class(quote(x$y)) = 'call', but as.character(quote(x$y)) does NOT go to as.character.call. deparse(quote(x$y)) returns the answer I want, as Greg Snow noted earlier. However, it would be easier to remember if I could write as.character(quote(x$y)) and get the same thing. With as.character.call - function(x, ...)deparse(x, ...), as.character.call(quote(x$y)) returns x$y, as desired. However, the methods dispatch one might naively expect fails, as noted above. Thanks, Spencer Cheers, Bert -- Bert Bert Gunter Genentech Nonclinical Biostatistics (650) 467-7374 Data is not information. Information is not knowledge. And knowledge is certainly not wisdom. H. Gilbert Welch On Thu, May 8, 2014 at 5:56 PM, Spencer Graves spencer.gra...@structuremonitoring.com wrote: as.character.call seems not to work as an alias for deparse. Consider the following: xDy - quote(x$y) class(xDy) call as.character.call - function(x, ...)deparse(x, ...) as.character(xDy) [1] $ x y # fails str(xDy) # language x$y as.character.language - function(x, ...)language as.character(xDy) [1] $ x y Is it feasible to construct a method for as.character that works for objects of class call? Thanks, Spencer # Thanks for the quick replies from Richard Heiberger, Greg Show Bert Gunter. Might it make sense to create as.character.call as an alias for deparse? A few years ago, I wrote several functions like predict.fd as aliases for functions with less memorable names like eval.fd. Doing that made the fda package easier to use, at least for me ;-) Thanks again, Spencer On 5/7/2014 2:39 PM, Bert Gunter wrote: ... and str(quote(x$y)) language x$y as.list(quote(x$y)) [[1]] `$` [[2]] x [[3]] y ## may be instructive. Cheers, Bert Bert Gunter Genentech Nonclinical Biostatistics (650) 467-7374 Data is not information. Information is not knowledge. And knowledge is certainly not wisdom. H. Gilbert Welch On Wed, May 7, 2014 at 2:30 PM, Greg Snow 538...@gmail.com wrote: deparse(quote(x$y)) [1] x$y It looks like deparse does what you want here. On Wed, May 7, 2014 at 3:23 PM, Spencer Graves spencer.gra...@structuremonitoring.com wrote: Hello, All: Is there a simple utility someplace to convert quote(x$y) to x$y? I ask, because as.character(quote(x$y)) is a character vector of length 3 = $ x y. I want to convert this to x$y for a diagnostic message. class(quote(x$y)) = call, which suggests I could write as.character.call to perform this function. However, before I do, I felt a need to ask for other thoughts on this. Thanks, Spencer -- Gregory (Greg) L. Snow Ph.D. 538...@gmail.com __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code. -- Spencer Graves, PE, PhD President and Chief Technology Officer Structure Inspection and Monitoring, Inc. 751 Emerson Ct. San José, CA 95126 ph: 408-655-4567 web: www.structuremonitoring.com __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.
[R] as.character(quote(x$y) ) = $ x y not x$y?
Hello, All: Is there a simple utility someplace to convert quote(x$y) to x$y? I ask, because as.character(quote(x$y)) is a character vector of length 3 = $ x y. I want to convert this to x$y for a diagnostic message. class(quote(x$y)) = call, which suggests I could write as.character.call to perform this function. However, before I do, I felt a need to ask for other thoughts on this. Thanks, Spencer __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.
Re: [R] as.character(quote(x$y) ) = $ x y not x$y?
deparse(quote(x$y)) [1] x$y On Wed, May 7, 2014 at 5:23 PM, Spencer Graves spencer.gra...@structuremonitoring.com wrote: Hello, All: Is there a simple utility someplace to convert quote(x$y) to x$y? I ask, because as.character(quote(x$y)) is a character vector of length 3 = $ x y. I want to convert this to x$y for a diagnostic message. class(quote(x$y)) = call, which suggests I could write as.character.call to perform this function. However, before I do, I felt a need to ask for other thoughts on this. Thanks, Spencer __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code. __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.
Re: [R] as.character(quote(x$y) ) = $ x y not x$y?
deparse(quote(x$y)) [1] x$y It looks like deparse does what you want here. On Wed, May 7, 2014 at 3:23 PM, Spencer Graves spencer.gra...@structuremonitoring.com wrote: Hello, All: Is there a simple utility someplace to convert quote(x$y) to x$y? I ask, because as.character(quote(x$y)) is a character vector of length 3 = $ x y. I want to convert this to x$y for a diagnostic message. class(quote(x$y)) = call, which suggests I could write as.character.call to perform this function. However, before I do, I felt a need to ask for other thoughts on this. Thanks, Spencer __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code. -- Gregory (Greg) L. Snow Ph.D. 538...@gmail.com __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.
Re: [R] as.character(quote(x$y) ) = $ x y not x$y?
... and str(quote(x$y)) language x$y as.list(quote(x$y)) [[1]] `$` [[2]] x [[3]] y ## may be instructive. Cheers, Bert Bert Gunter Genentech Nonclinical Biostatistics (650) 467-7374 Data is not information. Information is not knowledge. And knowledge is certainly not wisdom. H. Gilbert Welch On Wed, May 7, 2014 at 2:30 PM, Greg Snow 538...@gmail.com wrote: deparse(quote(x$y)) [1] x$y It looks like deparse does what you want here. On Wed, May 7, 2014 at 3:23 PM, Spencer Graves spencer.gra...@structuremonitoring.com wrote: Hello, All: Is there a simple utility someplace to convert quote(x$y) to x$y? I ask, because as.character(quote(x$y)) is a character vector of length 3 = $ x y. I want to convert this to x$y for a diagnostic message. class(quote(x$y)) = call, which suggests I could write as.character.call to perform this function. However, before I do, I felt a need to ask for other thoughts on this. Thanks, Spencer __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code. -- Gregory (Greg) L. Snow Ph.D. 538...@gmail.com __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code. __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.
Re: [R] as.character(quote(x$y) ) = $ x y not x$y?
Thanks for the quick replies from Richard Heiberger, Greg Show Bert Gunter. Might it make sense to create as.character.call as an alias for deparse? A few years ago, I wrote several functions like predict.fd as aliases for functions with less memorable names like eval.fd. Doing that made the fda package easier to use, at least for me ;-) Thanks again, Spencer On 5/7/2014 2:39 PM, Bert Gunter wrote: ... and str(quote(x$y)) language x$y as.list(quote(x$y)) [[1]] `$` [[2]] x [[3]] y ## may be instructive. Cheers, Bert Bert Gunter Genentech Nonclinical Biostatistics (650) 467-7374 Data is not information. Information is not knowledge. And knowledge is certainly not wisdom. H. Gilbert Welch On Wed, May 7, 2014 at 2:30 PM, Greg Snow 538...@gmail.com wrote: deparse(quote(x$y)) [1] x$y It looks like deparse does what you want here. On Wed, May 7, 2014 at 3:23 PM, Spencer Graves spencer.gra...@structuremonitoring.com wrote: Hello, All: Is there a simple utility someplace to convert quote(x$y) to x$y? I ask, because as.character(quote(x$y)) is a character vector of length 3 = $ x y. I want to convert this to x$y for a diagnostic message. class(quote(x$y)) = call, which suggests I could write as.character.call to perform this function. However, before I do, I felt a need to ask for other thoughts on this. Thanks, Spencer -- Gregory (Greg) L. Snow Ph.D. 538...@gmail.com __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code. __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.
[R] as.character limits length of result for formula
If you want a character representation of a long formula (or a formula with long names), you can use: as.character(my.formula) However restriction on length of an as.character result returns only the beginning of a long formula, and without comment. In most cases, the following expression provides the complete result: paste(my.formula[[2]], ~ , paste(attr(terms(my.formula), term.labels),collapse= + ),sep=) It would be better to make as.character handle any size formula. [[alternative HTML version deleted]] __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.
Re: [R] as.character limits length of result for formula
as.character() doesn't give a faithful character representation of its input for lots of language- related inputs. E.g., f - reformulate(paste(sep=,X,1:500), quote(log(Y))) cat(strwrap(as.character(f), 60), sep=\n) ~ log(Y) X1 + X2 + X3 + X4 + X5 + X6 + X7 + X8 + X9 + X10 + X11 + X12 + X13 + X14 + X15 + X16 + X17 + X18 + X19 + X20 + X21 + X22 + X23 + X24 + X25 + X26 + X27 + X28 + X29 + X30 + X31 + X32 + X33 + X34 + X35 + X36 + X37 + X38 + X39 + X40 + X41 + X42 + X43 + X44 + X45 + X46 + X47 + X48 + X49 + X50 + X51 + X52 + X53 + X54 + X55 + X56 + X57 + X58 + X59 + X60 + X61 + X62 + X63 + X64 + X65 + X66 + X67 + X68 + X69 + X70 + X71 + X72 + X73 + X74 + X75 + X76 + X77 + X78 + X79 + X80 + X81 + X82 + X83 + X84 + X85 + (Yes, there is nothing after the X85 +.) deparse() works better for such objects. You may want to use paste(collapse=\n) on its output to make a single string. deparse(f) [1] log(Y) ~ X1 + X2 + X3 + X4 + X5 + X6 + X7 + X8 + X9 + X10 + X11 + [2] X12 + X13 + X14 + X15 + X16 + X17 + X18 + X19 + X20 + X21 + ... lots of text omitted ... [53] X480 + X481 + X482 + X483 + X484 + X485 + X486 + X487 + X488 + [54] X489 + X490 + X491 + X492 + X493 + X494 + X495 + X496 + X497 + [55] X498 + X499 + X500 Bill Dunlap Spotfire, TIBCO Software wdunlap tibco.com -Original Message- From: r-help-boun...@r-project.org [mailto:r-help-boun...@r-project.org] On Behalf Of Terrence Ireland Sent: Wednesday, June 01, 2011 12:19 PM To: r-help@r-project.org Subject: [R] as.character limits length of result for formula If you want a character representation of a long formula (or a formula with long names), you can use: as.character(my.formula) However restriction on length of an as.character result returns only the beginning of a long formula, and without comment. In most cases, the following expression provides the complete result: paste(my.formula[[2]], ~ , paste(attr(terms(my.formula), term.labels),collapse= + ),sep=) It would be better to make as.character handle any size formula. [[alternative HTML version deleted]] __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code. __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.
[R] as.character ()
Hello, I'm trying to tranform a numeric vector into a character vector. x=c(2.00,1.20,5.00,6.56) y= as.character(x) y [1] 21.2 56.56 What I want is : [1] 2.001.20 5.006.56 Does someone know how to do this please ? Benoit Bruneau __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.
Re: [R] as.character ()
Is this what you want: x=c(2.00,1.20,5.00,6.56) sprintf(%.2f, x) [1] 2.00 1.20 5.00 6.56 On Mon, Mar 31, 2008 at 4:45 PM, benlafleche [EMAIL PROTECTED] wrote: Hello, I'm trying to tranform a numeric vector into a character vector. x=c(2.00,1.20,5.00,6.56) y= as.character(x) y [1] 21.2 56.56 What I want is : [1] 2.001.20 5.006.56 Does someone know how to do this please ? Benoit Bruneau __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code. -- Jim Holtman Cincinnati, OH +1 513 646 9390 What is the problem you are trying to solve? __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.
Re: [R] as.character ()
An older alternative uses format() x - c(2.00, 1.20, 5.00, 6.56) format(x) [1] 2.00 1.20 5.00 6.56 -Original Message- From: [EMAIL PROTECTED] [mailto:[EMAIL PROTECTED] On Behalf Of jim holtman Sent: Tuesday, 1 April 2008 7:48 AM To: benlafleche Cc: R-help@r-project.org Subject: Re: [R] as.character () Is this what you want: x=c(2.00,1.20,5.00,6.56) sprintf(%.2f, x) [1] 2.00 1.20 5.00 6.56 On Mon, Mar 31, 2008 at 4:45 PM, benlafleche [EMAIL PROTECTED] wrote: Hello, I'm trying to tranform a numeric vector into a character vector. x=c(2.00,1.20,5.00,6.56) y= as.character(x) y [1] 21.2 56.56 What I want is : [1] 2.001.20 5.006.56 Does someone know how to do this please ? Benoit Bruneau __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code. -- Jim Holtman Cincinnati, OH +1 513 646 9390 What is the problem you are trying to solve? __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code. __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.
Re: [R] as.character(seq(-.35,.95,.1))
Hi [EMAIL PROTECTED] napsal dne 20.11.2007 17:07:42: On 11/20/2007 10:50 AM, Ken Fullish wrote: as.character(seq(-.25,.95,.1)) [1] -0.25 -0.15 -0.05 0.05 0.15 0.25 0.35 0.45 0.55 0.65 0.75 0.85 0.95 as.character(seq(-.35,.95,.1)) [1] -0.35 -0.25 -0.15 -0.0499 0.05 [6] 0.150.25 0.350.450.55 [11] 0.650.75 0.850.95 Not a big deal, just curiosity: Why do I obtain this ugly -0.0499 instead of the expected -0.05 ? Because as.character() tries to do an accurate conversion, and the number in your vector is closer to -0.0499 than to -0.05. You could get the -0.05 by something like round( seq(...), 2). The reason seq() doesn't give you exactly -0.05 is that the starting values and step size you've chosen are not exactly representable in R's floating point format. It can only store fractions exactly when the denominator is a power of 2. And it is not related exclusively to R but to floating point arithmetic in computer binary language. Regards Petr Duncan Murdoch __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code. __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.
Re: [R] as.character(seq(-.35,.95,.1))
see FAQ 7.31 On Nov 20, 2007 10:50 AM, Ken Fullish [EMAIL PROTECTED] wrote: as.character(seq(-.25,.95,.1)) [1] -0.25 -0.15 -0.05 0.05 0.15 0.25 0.35 0.45 0.55 0.65 0.75 0.85 0.95 as.character(seq(-.35,.95,.1)) [1] -0.35 -0.25 -0.15 -0.0499 0.05 [6] 0.150.25 0.350.450.55 [11] 0.650.75 0.850.95 Not a big deal, just curiosity: Why do I obtain this ugly -0.0499 instead of the expected -0.05 ? Regards K. __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code. -- Jim Holtman Cincinnati, OH +1 513 646 9390 What is the problem you are trying to solve? __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.
Re: [R] as.character(seq(-.35,.95,.1))
On 11/20/2007 10:50 AM, Ken Fullish wrote: as.character(seq(-.25,.95,.1)) [1] -0.25 -0.15 -0.05 0.05 0.15 0.25 0.35 0.45 0.55 0.65 0.75 0.85 0.95 as.character(seq(-.35,.95,.1)) [1] -0.35 -0.25 -0.15 -0.0499 0.05 [6] 0.150.25 0.350.450.55 [11] 0.650.75 0.850.95 Not a big deal, just curiosity: Why do I obtain this ugly -0.0499 instead of the expected -0.05 ? Because as.character() tries to do an accurate conversion, and the number in your vector is closer to -0.0499 than to -0.05. You could get the -0.05 by something like round( seq(...), 2). The reason seq() doesn't give you exactly -0.05 is that the starting values and step size you've chosen are not exactly representable in R's floating point format. It can only store fractions exactly when the denominator is a power of 2. Duncan Murdoch __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.
[R] as.character(seq(-.35,.95,.1))
as.character(seq(-.25,.95,.1)) [1] -0.25 -0.15 -0.05 0.05 0.15 0.25 0.35 0.45 0.55 0.65 0.75 0.85 0.95 as.character(seq(-.35,.95,.1)) [1] -0.35 -0.25 -0.15 -0.0499 0.05 [6] 0.150.25 0.350.450.55 [11] 0.650.75 0.850.95 Not a big deal, just curiosity: Why do I obtain this ugly -0.0499 instead of the expected -0.05 ? Regards K. __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.
Re: [R] as.character(seq(-.35,.95,.1))
On Tue, 2007-11-20 at 11:07 -0500, Duncan Murdoch wrote: On 11/20/2007 10:50 AM, Ken Fullish wrote: as.character(seq(-.25,.95,.1)) [1] -0.25 -0.15 -0.05 0.05 0.15 0.25 0.35 0.45 0.55 0.65 0.75 0.85 0.95 as.character(seq(-.35,.95,.1)) [1] -0.35 -0.25 -0.15 -0.0499 0.05 [6] 0.150.25 0.350.450.55 [11] 0.650.75 0.850.95 Not a big deal, just curiosity: Why do I obtain this ugly -0.0499 instead of the expected -0.05 ? Because as.character() tries to do an accurate conversion, and the number in your vector is closer to -0.0499 than to -0.05. You could get the -0.05 by something like round( seq(...), 2). The reason seq() doesn't give you exactly -0.05 is that the starting values and step size you've chosen are not exactly representable in R's floating point format. It can only store fractions exactly when the denominator is a power of 2. In addition, if you want to take numeric values and format them for output with a known number of fixed decimal places, use either ?formatC or ?sprintf, the latter being generally preferred: sprintf(%.2f, seq(-.25,.95,.1)) [1] -0.25 -0.15 -0.05 0.05 0.15 0.25 0.35 0.45 [9] 0.55 0.65 0.75 0.85 0.95 sprintf(%.2f, seq(-.35,.95,.1)) [1] -0.35 -0.25 -0.15 -0.05 0.05 0.15 0.25 0.35 [9] 0.45 0.55 0.65 0.75 0.85 0.95 HTH, Marc Schwartz __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.