[R] variable values

2009-02-12 Thread Tim Smith
Hi all,

I was working with some probabilities and wanted to store some small values. 
For example:

> x = 2e-250
> x
[1] 2e-250
> y = 2e-300
> y
[1] 2e-300
> z = 2e-350
> z
[1] 0


Is there any way to store a small value (e.g. 2e-350) in R?

thanks!



  
[[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] variable values

2009-02-13 Thread David Winsemius


Step 1: Read the R-FAQ 7.31:

Step 2: Ask yourself whether it is likely that such a small value can  
be sensibly distinguished from zero using a program that stores values  
in double precision.


Step 3: Consider alternate methods, perhaps logarithms or programs  
that are equipped to deal with arbitrary precision. There have been  
threads on such strategies. I got on-topic results with an r-search  
on : "very small" log probabilit*


--
David Winsemius

On Feb 12, 2009, at 2:09 PM, Tim Smith wrote:


Hi all,

I was working with some probabilities and wanted to store some small  
values. For example:



x = 2e-250
x

[1] 2e-250

y = 2e-300
y

[1] 2e-300

z = 2e-350
z

[1] 0


Is there any way to store a small value (e.g. 2e-350) in R?

thanks!




[[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] variable values in plotmath expressions

2012-03-15 Thread Richard M. Heiberger
## I would like help in using variable values in plotmath expressions
## in lattice

x <- 1:10
y <- 1:10
pval <- .95

plot(y ~ x, ## works as I want in base graphics
 main=substitute(list(alpha * " = " * group("",list(p),"")),
list(p=pval)))

plot(y ~ x, ## doesn't work as intended: "pval" is displayed
 main=substitute(list(alpha * " = " * group("",list(pval),""

try( ## doesn't work: object 'alpha' not found
xyplot(y ~ x,
 main=substitute(list(alpha * " = " * group("",list(p),"")),
list(p=pval)))
)

xyplot(y ~ x, ## doesn't work as intended: "substitute" is displayed
 main=expression(substitute(list(alpha * " = " * group("",list(p),"")),
list(p=pval

xyplot(y ~ x, ## doesn't work as intended: "p" is displayed and "pval" is
displayed
 main=expression(list(alpha * " = " * group("",list(p),"")),
list(p=pval)))

xyplot(y ~ x, ## doesn't work as intended: "pval" is displayed
 main=expression(list(alpha * " = " * group("",list(pval),""


Thanks
Rich

[[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] variable values in plotmath expressions

2012-03-15 Thread Joshua Wiley
Hi Rich,

I'm not sure if you have a reason outside this toy example to want to
be using list() and group(), but if not I would go with this:

xyplot(y ~ x, main = substitute(expression(alpha == p), list(p = pval)))

Hope this helps,

Josh

On Thu, Mar 15, 2012 at 7:25 PM, Richard M. Heiberger  wrote:
> ## I would like help in using variable values in plotmath expressions
> ## in lattice
>
> x <- 1:10
> y <- 1:10
> pval <- .95
>
> plot(y ~ x, ## works as I want in base graphics
>     main=substitute(list(alpha * " = " * group("",list(p),"")),
> list(p=pval)))
>
> plot(y ~ x, ## doesn't work as intended: "pval" is displayed
>     main=substitute(list(alpha * " = " * group("",list(pval),""
>
> try( ## doesn't work: object 'alpha' not found
> xyplot(y ~ x,
>     main=substitute(list(alpha * " = " * group("",list(p),"")),
> list(p=pval)))
> )
>
> xyplot(y ~ x, ## doesn't work as intended: "substitute" is displayed
>     main=expression(substitute(list(alpha * " = " * group("",list(p),"")),
> list(p=pval
>
> xyplot(y ~ x, ## doesn't work as intended: "p" is displayed and "pval" is
> displayed
>     main=expression(list(alpha * " = " * group("",list(p),"")),
> list(p=pval)))
>
> xyplot(y ~ x, ## doesn't work as intended: "pval" is displayed
>     main=expression(list(alpha * " = " * group("",list(pval),""
>
>
> Thanks
> Rich
>
>        [[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.



-- 
Joshua Wiley
Ph.D. Student, Health Psychology
Programmer Analyst II, Statistical Consulting Group
University of California, Los Angeles
https://joshuawiley.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] variable values in plotmath expressions

2012-03-15 Thread Gabor Grothendieck
On Thu, Mar 15, 2012 at 10:25 PM, Richard M. Heiberger  wrote:
> ## I would like help in using variable values in plotmath expressions
> ## in lattice
>
> x <- 1:10
> y <- 1:10
> pval <- .95
>
> plot(y ~ x, ## works as I want in base graphics
>     main=substitute(list(alpha * " = " * group("",list(p),"")),
> list(p=pval)))
>
> plot(y ~ x, ## doesn't work as intended: "pval" is displayed
>     main=substitute(list(alpha * " = " * group("",list(pval),""
>
> try( ## doesn't work: object 'alpha' not found
> xyplot(y ~ x,
>     main=substitute(list(alpha * " = " * group("",list(p),"")),
> list(p=pval)))
> )
>
> xyplot(y ~ x, ## doesn't work as intended: "substitute" is displayed
>     main=expression(substitute(list(alpha * " = " * group("",list(p),"")),
> list(p=pval
>
> xyplot(y ~ x, ## doesn't work as intended: "p" is displayed and "pval" is
> displayed
>     main=expression(list(alpha * " = " * group("",list(p),"")),
> list(p=pval)))
>
> xyplot(y ~ x, ## doesn't work as intended: "pval" is displayed
>     main=expression(list(alpha * " = " * group("",list(pval),""

Try bquote with classic graphics or as.expression(bquote(...)) with lattice:

plot(y ~ x, main = bquote(alpha == .(pval)))

xyplot(y ~ x, main = as.expression(bquote(alpha  == group("", .(pval) ,""



-- 
Statistics & Software Consulting
GKX Group, GKX Associates Inc.
tel: 1-877-GKX-GROUP
email: ggrothendieck at 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.