Re: [R] C stack error in as.vector() starting in R 3.3.0

2016-07-06 Thread Eric Archer - NOAA Federal
Luke,

Thanks for this point out. I started removing packages one-by-one in R
v.3.3.1. Oddly enough, it went away after I removed the Matrix package.
When I restarted R, the same version of Matrix (1.2-6) had been
"reinstalled" (?), but now no C stack error. Lets see if the others that
were having a similar problem have the same result.

Cheers,
Eric


----

*Eric Archer, Ph.D.*
Southwest Fisheries Science Center
NMFS, NOAA
8901 La Jolla Shores Drive
La Jolla, CA 92037 USA
858-546-7121 (work)
858-546-7003 (FAX)

Marine Mammal Genetics Group: swfsc.noaa.gov/mmtd-mmgenetics
ETP Cetacean Assessment Program: swfsc.noaa.gov/mmtd-etp
https://github/ericarcher

"


*The universe doesn't care what you believe. The wonderful thing about
science is that it   doesn't ask for your faith, it just asks   for your
eyes.*"  - Randall Munroe

"*Lighthouses are more helpful than churches.*"
   - Benjamin Franklin

   "*...but I'll take a GPS over either one.*"
   - John C. "Craig" George

On Wed, Jul 6, 2016 at 4:06 PM, <luke-tier...@uiowa.edu> wrote:

> I cannot reproduce this.  My best guess is that there is a problem,
> maybe a version incompatibility, with one of the packages loaded when
> load("problem.method.rdata"). This includes
>
> adegenet
> apex
> copula
> Rcpp
> DBI
> sp
> colorspace
>
> and any dependencies these are bringing in.
>
> Best,
>
> luke
>
> On Fri, 1 Jul 2016, Eric Archer - NOAA Federal wrote:
>
> Apologies for the long post. This is an issue I have been struggling with
>> and I have tried to be as complete, to the point, and reproducible as
>> possible.
>>
>> In documenting a package with roxygen2, I have come across an error that
>> does not occur in R 3.2.4 revised, but does occur in R 3.3.0 and 3.3.1.
>> Using traceback() and debug(), I've traced the error to a call made to
>> as.vector(x, "character") that seems to get stuck in a loop which
>> culminates in this error:
>>
>> Error: C stack usage  7970892 is too close to the limit
>>
>> The object that causes this error is of a signature type for a method.
>> With
>> some playing around, I've been able to work out that the error is actually
>> associated with the method that roxygen2 creates when doing its magic.
>> Something happens when this method definition with its associated
>> environment is in the workspace that causes the error.
>>
>> At this point, I should stress again that the error does NOT occur in R
>> 3.2.4 revised or earlier, but does occur in R 3.3.0 and 3.3.1. I have also
>> tested this with several versions of roxygen2 and that does not make a
>> difference. Thus, my ultimate question is what has changed in R 3.3.0 that
>> would lead to this so that the roxygen2 maintainers can correct it?
>>
>> As a test, I created a signature identical to the one that causes the
>> error
>> and tried the as.vector() command that would generate the loop. I don't
>> get
>> the error in my command line generated object, nor with the object that is
>> extracted from the method definition. However, when I load the method
>> definition into the workspace, the error will happen on either my command
>> line generated object, or the one extracted from the method definition and
>> will not stop happening until I restart R.
>>
>> I have reported this error as an issue on the roxygen2 GitHub repository
>> and it has been crossposted by another user who had a similar experience
>> with a different package on the devtools repository. Those posts, which
>> contain more information are here:
>>
>> https://github.com/klutometis/roxygen/issues/475
>> https://github.com/hadley/devtools/issues/1234
>>
>> Below is the result of sessionInfo() and the output of a session
>> demonstrating the effect. The files used are in a zip file here:
>>
>> https://github.com/klutometis/roxygen/files/335417/error.test.rdata.files.zip
>>
>> > sessionInfo()
>> R version 3.3.0 (2016-05-03)
>> Platform: x86_64-apple-darwin13.4.0 (64-bit)
>> Running under: OS X 10.11.5 (El Capitan)
>>
>> locale:
>> [1] en_US.UTF-8/en_US.UTF-8/en_US.UTF-8/C/en_US.UTF-8/en_US.UTF-8
>>
>> attached base packages:
>> [1] stats graphics  grDevices utils datasets  methods   base
>>
>> loaded via a namespace (and not attached):
>> [1] tools_3.3.0
>>
>> rm(list = ls())
>>>
>>> # Create test class and method
>>> setClass(Class = "gtypes", slots = c(loci = "data.frame", ploidy =
>>>
>> "numeric"), package = &quo

[R] C stack error in as.vector() starting in R 3.3.0

2016-07-01 Thread Eric Archer - NOAA Federal
Apologies for the long post. This is an issue I have been struggling with
and I have tried to be as complete, to the point, and reproducible as
possible.

In documenting a package with roxygen2, I have come across an error that
does not occur in R 3.2.4 revised, but does occur in R 3.3.0 and 3.3.1.
Using traceback() and debug(), I've traced the error to a call made to
as.vector(x, "character") that seems to get stuck in a loop which
culminates in this error:

Error: C stack usage  7970892 is too close to the limit

The object that causes this error is of a signature type for a method. With
some playing around, I've been able to work out that the error is actually
associated with the method that roxygen2 creates when doing its magic.
Something happens when this method definition with its associated
environment is in the workspace that causes the error.

At this point, I should stress again that the error does NOT occur in R
3.2.4 revised or earlier, but does occur in R 3.3.0 and 3.3.1. I have also
tested this with several versions of roxygen2 and that does not make a
difference. Thus, my ultimate question is what has changed in R 3.3.0 that
would lead to this so that the roxygen2 maintainers can correct it?

As a test, I created a signature identical to the one that causes the error
and tried the as.vector() command that would generate the loop. I don't get
the error in my command line generated object, nor with the object that is
extracted from the method definition. However, when I load the method
definition into the workspace, the error will happen on either my command
line generated object, or the one extracted from the method definition and
will not stop happening until I restart R.

I have reported this error as an issue on the roxygen2 GitHub repository
and it has been crossposted by another user who had a similar experience
with a different package on the devtools repository. Those posts, which
contain more information are here:

https://github.com/klutometis/roxygen/issues/475
https://github.com/hadley/devtools/issues/1234

Below is the result of sessionInfo() and the output of a session
demonstrating the effect. The files used are in a zip file here:
https://github.com/klutometis/roxygen/files/335417/error.test.rdata.files.zip

 > sessionInfo()
R version 3.3.0 (2016-05-03)
Platform: x86_64-apple-darwin13.4.0 (64-bit)
Running under: OS X 10.11.5 (El Capitan)

locale:
[1] en_US.UTF-8/en_US.UTF-8/en_US.UTF-8/C/en_US.UTF-8/en_US.UTF-8

attached base packages:
[1] stats graphics  grDevices utils datasets  methods   base

loaded via a namespace (and not attached):
[1] tools_3.3.0

> rm(list = ls())
>
> # Create test class and method
> setClass(Class = "gtypes", slots = c(loci = "data.frame", ploidy =
"numeric"), package = "roxygen_devtest")
> setGeneric("nInd", function(x, ...) standardGeneric("nInd"), package =
"adegenet")
[1] "nInd"
> setMethod("nInd", "gtypes", function(x, ...) nrow(x@loci) / x@ploidy)
[1] "nInd"
>
> test.method <- getMethod("nInd", "gtypes")
> str(test.method)
Formal class 'MethodDefinition' [package "methods"] with 4 slots
  ..@ .Data  :function (x, ...)
  ..@ target :Formal class 'signature' [package "methods"] with 3 slots
  .. .. ..@ .Data  : chr "gtypes"
  .. .. ..@ names  : chr "x"
  .. .. ..@ package: chr "roxygen_devtest"
  ..@ defined:Formal class 'signature' [package "methods"] with 3 slots
  .. .. ..@ .Data  : chr "gtypes"
  .. .. ..@ names  : chr "x"
  .. .. ..@ package: chr "roxygen_devtest"
  ..@ generic: atomic [1:1] nInd
  .. ..- attr(*, "package")= chr "adegenet"
>
> # No error:
> as.vector(test.method@defined, "character")
[1] "gtypes"
>
> # This is the method that generates the error
> load("problem.method.rdata")
>
> # Notice the difference in the environments of the two functions:
> test.method@.Data
function (x, ...)
nrow(x@loci)/x@ploidy
> problem.method@.Data
function (x, ...)
nrow(x@loci)/x@ploidy

>
> # Swap the problem function for the one I created:
> problem.method@.Data <- test.method@.Data
> save(problem.method, file = "fixed.method.rdata")
>
> # Here's the error (both with my method and the original):
> as.vector(test.method@defined, "character")
Error: C stack usage  7970892 is too close to the limit
> as.vector(problem.method@defined, "character")
Error: C stack usage  7970892 is too close to the limit

Restarting R session...

> # *** Restart R for this to work ***
> rm(list = ls())
>
> load("fixed.method.rdata")
> as.vector(problem.method@defined, "character")
[1] "gtypes"



*Eric Arc

[R] command not found from system() call in GUI with proper PATH

2014-10-24 Thread Eric Archer - NOAA Federal
Apologies for the cross-posting, but I couldn't tell if this was a general
R issue, or Mac-specific

When running a system file from within R, I have just started to get a
command not found error although my PATH seems to be properly set and I
can run the same system file from the terminal. The program I am trying to
run is 'fastsimcoal' and is in /usr/local/bin. I confirm this in the
terminal with

SWC-EARCHER-ML-3:~ eric.archer$ which fastsimcoal
/usr/local/bin/fastsimcoal

In the examples below, Sys.getenv(PATH) shows that /usr/local/bin is in
the PATH. I get the same error for any program in /usr/local/bin. However,
programs in other folders in the path seem to run through system()
properly.

Also, note that the return from Sys.getenv(PATH) is the same for running
in R-Studio vs. R in the terminal, but is truncated in the R GUI. As far as
I can tell I do not have a .Rprofile file in my default working directory,
R_HOME, or R_HOME/etc.

A final piece of information: I have just upgraded to OSX Yosemite v10.10.
This was not happening at some point prior to the upgrade, but it has been
a while since I tried this particular command, so I do not know if it was
working immediately prior to the OS upgrade.

Any help or insight is greatly appreciated.

Cheers,
eric

The examples:

From within R-Studio v0.98.1079:

 sessionInfo()
R version 3.1.1 (2014-07-10)
Platform: x86_64-apple-darwin13.1.0 (64-bit)

locale:
[1] en_US.UTF-8/en_US.UTF-8/en_US.UTF-8/C/en_US.UTF-8/en_US.UTF-8

attached base packages:
[1] stats graphics  grDevices utils datasets  methods   base

loaded via a namespace (and not attached):
[1] tools_3.1.1
 getwd()
[1] /Users/eric.archer
 Sys.getenv(PATH)
[1]
/usr/bin:/bin:/usr/sbin:/sbin:/usr/local/bin:/opt/X11/bin:/usr/local/git/bin:/usr/texbin
 system(fastsimcoal)
sh: fastsimcoal: command not found


The same script in the R console through the GUI gives:

 sessionInfo()
R version 3.1.1 (2014-07-10)
Platform: x86_64-apple-darwin13.1.0 (64-bit)

locale:
[1] en_US.UTF-8/en_US.UTF-8/en_US.UTF-8/C/en_US.UTF-8/en_US.UTF-8

attached base packages:
[1] stats graphics  grDevices utils datasets  methods   base
 getwd()
[1] /Users/eric.archer
 Sys.getenv(PATH)
[1] /usr/bin:/bin:/usr/sbin:/sbin:/usr/local/bin
 system(fastsimcoal)

/bin/sh: fastsimcoal: command not found


Running it through R in a  terminal window, it runs (output of
'fastsimcoal' truncated):

 sessionInfo()
R version 3.1.1 (2014-07-10)
Platform: x86_64-apple-darwin13.1.0 (64-bit)

locale:
[1] en_US.UTF-8/en_US.UTF-8/en_US.UTF-8/C/en_US.UTF-8/en_US.UTF-8

attached base packages:
[1] stats graphics  grDevices utils datasets  methods   base
 getwd()
[1] /Users/eric.archer
 Sys.getenv(PATH)
[1]
/usr/local/bin:/usr/bin:/bin:/usr/sbin:/sbin:/opt/X11/bin:/usr/local/git/bin:/usr/texbin
 system(fastsimcoal)


fastSimcoal2 (ver 2.1 December 2013)

Usage:

 -h  --help  : prints this help
 -i  --ifile test.par: name of parameter file
...



*Eric Archer, Ph.D.*
Southwest Fisheries Science Center
NMFS, NOAA
8901 La Jolla Shores Drive
La Jolla, CA 92037 USA
858-546-7121 (work)
858-546-7003 (FAX)

Marine Mammal Genetics Group: swfsc.noaa.gov/mmtd-mmgenetics
ETP Cetacean Assessment Program: swfsc.noaa.gov/mmtd-etp




*The universe doesn't care what you believe. The wonderful thing about
science is that it   doesn't ask for your faith, it just asks   for your
eyes.*  - Randall Munroe

*Lighthouses are more helpful than churches.*
   - Benjamin Franklin

   *...but I'll take a GPS over either one.*
   - John C. Craig George

[[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] Transferring commas in character vector to expression

2013-07-15 Thread Eric Archer - NOAA Federal
Bill,

Thanks so much for the tips. For the project that I'm doing now, I don't
need to worry about bullet-proofing it too much, but this is definitely
educational and will help tons when the next one comes around.

Cheers,
eric


On Sun, Jul 7, 2013 at 10:22 AM, William Dunlap wdun...@tibco.com wrote:

  x.lab - gsub(,,*symbol(\54\)*, x.lab)

 Wouldn't using just
*\,\*
 instead of
*symbol(\54\)*
 as the replacement do the same thing?
 To me it is simpler to understand.

 Note that this fails if the comma is the first or last
 character in the input because '*something*' is
 not a valid expression.  Another problem is that '**'
 is parsed the same as ^, so a**d is displayed as
 a Delta superscript Delta d.  One way to deal with that
 problem is to strip possible '*'s from the ends of
 x.lab and convert '**'s to '*'s before giving it to the parser.
x.lab - gsub(^\\*|\\*$, , x.lab)
x.lab - gsub(\\*\\*, *, x.lab)
 as in
 f1 - function (x.lab)
 {
 x.lab - gsub(\\*, *Delta*, x.lab)
 x.lab - gsub(,, *\,\*, x.lab)
 x.lab - gsub(^\\*|\\*$, , x.lab)
 x.lab - gsub(\\*\\*, *, x.lab)
 parse(text = x.lab, keep.source = FALSE)
 }
 where the code in your mail corresponds to the function f0:
 f0 - function (x.lab)
 {
 x.lab - gsub(\\*, *Delta*, x.lab)
 x.lab - gsub(,, *symbol(\54\)*, x.lab)
 parse(text = x.lab, keep.source = FALSE)
 }

 Another approach is not to turn the commas into strings, but
 turn anything that is not a '*' into a string.  Then you don't have
 to change your code when you discover that the inputs might
 contain semicolons or something else.
 f2 - function (x.lab)
 {
 x.lab - gsub(([^*]+),  \\\1\ , x.lab)
 # I put spaces around things to make it a little more readable;
 # they may not be very readable in some fonts.
 x.lab - gsub(\\*,  * Delta * , x.lab)
 x.lab - gsub(^ \\*|\\* $, , x.lab)
 x.lab - gsub(\\*  \\*, *, x.lab)
 parse(text = x.lab, keep.source = FALSE)
 }

 Use it as in
dotchart(1:4, labels=f2(c(***d, ,,c*, a,*d, )))
 This code gets ugly pretty quickly so you should bury it in a function.

 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 Eric Archer - NOAA Federal
  Sent: Saturday, July 06, 2013 10:55 PM
  To: Duncan Mackay; r-help-r-project.org
  Subject: Re: [R] Transferring commas in character vector to expression
 
  Duncan,
 
  Thanks! That was the tip I needed. With that, I was able to get this to
  work perfectly:
 
  x.lab - c(a*a, bbb, c,cc*c, d,dd)
  x.lab - gsub(\\*, *Delta*, x.lab)
  x.lab - gsub(,, *symbol(\54\)*, x.lab)
  dotchart(1:length(x.lab), labels = parse(text = x.lab))
 
 
 
  On Sat, Jul 6, 2013 at 9:38 PM, Duncan Mackay mac...@northnet.com.au
 wrote:
 
Eric
  
   How does this look - (you might have to add a few symbol(\54)  where
   needed for me this give a comma on windows7  ver 3.1
  
xyplot(1:4 ~ 1:4, scales = list(x=list(at = 1:4, labels =
  
 
 c(expression(a*a),expression(bbb),expression(c*Delta*cc*c),expression(d*Delta*symbol(
  \54)*dd)
   ) ) ) )
  
   I mostly use lattice and have forgotten how to do labels in basic plot
 so
   have used lattice. should be similar and you can modify to suit.
  
   It was trial and error in going up through the numbers  from about 38
  
  
   Duncan
  
   At 11:57 7/07/2013, you wrote:
  
   Duncan,
  
   Thanks for the suggestion, but that won't work for my situation. I'm
   trying to use a character vector to label some axis ticks. There are
 some
   elements in the vector that have either a comma, or both Greek symbols
 and
   a comma, like the the third and fourth elements in x.lab below:
  
x - 1:4
x.lab - c(a*a, bbb, c,cc*c, d,dd)
x.lab - gsub(\\*, *Delta*, x.lab)
x.lab - parse(text = x.lab)
   Error in parse(text = x.lab) : text:3:2: unexpected ','
   2: bbb
   3: c,
  ^
dotchart(x, labels = x.lab)
  
   The root problem that I'm stumped on is how to either:
   1) insert a comma into an expression and have it be read as a valid
   character, or
   2) replace the comma in the character string with 'list(a, b, c)' as in
   the help for plotmath and have it interpreted correctly.
  
   Cheers,
   eric
  
  
   On Sat, Jul 6, 2013 at 3:33 PM, Duncan Mackay mac...@northnet.com.au
   wrote:
Hi Eric
  
   I have not been following the thread but following on what David has
 said
   on previous occasions
  
   try for example
  
   plot(1,1, ylab =  expression(aa aaa,aa bb*Delta*b *Delta*cc,
 c) )
  
   Below is from a partly saved previous post of David's several months
 ago
   which may give you some ideas
  
   DATA_names-c(
   A mg kg,
   B mg kg,
   C mg kg,
   D mg kg,
   E mg kg,
   F mg kg,
   G mg kg,
   H mg kg)
  
   pos - barplot(1:length(DATA_names))
   text(x=pos,y=-1, xpd=TRUE, srt=45,
   labels= sapply( gsub(mg kg, (mg

Re: [R] Transferring commas in character vector to expression

2013-07-06 Thread Eric Archer - NOAA Federal
Duncan,

Thanks for the suggestion, but that won't work for my situation. I'm trying
to use a character vector to label some axis ticks. There are some elements
in the vector that have either a comma, or both Greek symbols and a comma,
like the the third and fourth elements in x.lab below:

 x - 1:4
 x.lab - c(a*a, bbb, c,cc*c, d,dd)
 x.lab - gsub(\\*, *Delta*, x.lab)
 x.lab - parse(text = x.lab)
Error in parse(text = x.lab) : text:3:2: unexpected ','
2: bbb
3: c,
   ^
 dotchart(x, labels = x.lab)

The root problem that I'm stumped on is how to either:
1) insert a comma into an expression and have it be read as a valid
character, or
2) replace the comma in the character string with 'list(a, b, c)' as in the
help for plotmath and have it interpreted correctly.

Cheers,
eric


On Sat, Jul 6, 2013 at 3:33 PM, Duncan Mackay mac...@northnet.com.auwrote:

 Hi Eric

 I have not been following the thread but following on what David has said
 on previous occasions

 try for example

 plot(1,1, ylab =  expression(aa aaa,aa bb*Delta*b *Delta*cc, c) )

 Below is from a partly saved previous post of David's several months ago
 which may give you some ideas

 DATA_names-c(
 A mg kg,
 B mg kg,
 C mg kg,
 D mg kg,
 E mg kg,
 F mg kg,
 G mg kg,
 H mg kg)

 pos - barplot(1:length(DATA_names))
 text(x=pos,y=-1, xpd=TRUE, srt=45,
labels= sapply( gsub(mg kg, (mg kg)^-1, DATA_names),
as.expression))

 HTH

 Duncan


 Duncan Mackay
 Department of Agronomy and Soil Science
 University of New England
 Armidale NSW 2351
 Email: home: mac...@northnet.com.au




 At 07:47 6/07/2013, you wrote:

 I'm trying to format a given character vector as an expression with Greek
 symbols to be used in labeling axis ticks. Thanks to some help from David
 Winsemius, I've learned how to make the substitution and place the Greek
 symbols in, however I've run into another problem: Some of my labels have
 commas in them, so when the parse command is executed, there is an
 unexpected symbol error. For example:

  x - c(aa, aaa,aa, bb*Delta*b, *Delta*cc,c)
  parse(text = x)
 Error in parse(text = x) : text:2:4: unexpected ','
 1: aa
 2: aaa,
  ^

 I've tried various iterations of wrapping the commas in interior quotes
 (aaa\,\aa), but then the error shifts to the quote. I see in plotmath
 that 'list(a,b,c)' gives me comma separated values, but I haven't been
 able
 to work out how to get this construction for elements that have a comma.

 Is this possible?

 --

 Eric Archer, Ph.D.
 Southwest Fisheries Science Center
 NMFS, NOAA
 8901 La Jolla Shores Drive
 La Jolla, CA 92037 USA
 858-546-7121 (work)
 858-546-7003 (FAX)

 Marine Mammal Genetics Group: swfsc.noaa.gov/prd-mmgenetics
 ETP Cetacean Assessment Program: swfsc.noaa.gov/prd-etp

 The universe doesn't care what you believe.
  The wonderful thing about science is that it
doesn't ask for your faith, it just asks
for your eyes.  - Randall Munroe

 Lighthouses are more helpful than churches.
- Benjamin Franklin

...but I'll take a GPS over either one.
- John C. Craig George

 [[alternative HTML version deleted]]

 __**
 R-help@r-project.org mailing list
 https://stat.ethz.ch/mailman/**listinfo/r-helphttps://stat.ethz.ch/mailman/listinfo/r-help
 PLEASE do read the posting guide http://www.R-project.org/**
 posting-guide.html http://www.R-project.org/posting-guide.html
 and provide commented, minimal, self-contained, reproducible code.






-- 

Eric Archer, Ph.D.
Southwest Fisheries Science Center
NMFS, NOAA
8901 La Jolla Shores Drive
La Jolla, CA 92037 USA
858-546-7121 (work)
858-546-7003 (FAX)

Marine Mammal Genetics Group: swfsc.noaa.gov/prd-mmgenetics
ETP Cetacean Assessment Program: swfsc.noaa.gov/prd-etp

The universe doesn't care what you believe.
 The wonderful thing about science is that it
   doesn't ask for your faith, it just asks
   for your eyes.  - Randall Munroe

Lighthouses are more helpful than churches.
   - Benjamin Franklin

   ...but I'll take a GPS over either one.
   - John C. Craig George

[[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] Transferring commas in character vector to expression

2013-07-06 Thread Eric Archer - NOAA Federal
Duncan,

Thanks! That was the tip I needed. With that, I was able to get this to
work perfectly:

x.lab - c(a*a, bbb, c,cc*c, d,dd)
x.lab - gsub(\\*, *Delta*, x.lab)
x.lab - gsub(,, *symbol(\54\)*, x.lab)
dotchart(1:length(x.lab), labels = parse(text = x.lab))



On Sat, Jul 6, 2013 at 9:38 PM, Duncan Mackay mac...@northnet.com.auwrote:

  Eric

 How does this look - (you might have to add a few symbol(\54)  where
 needed for me this give a comma on windows7  ver 3.1

  xyplot(1:4 ~ 1:4, scales = list(x=list(at = 1:4, labels =
 c(expression(a*a),expression(bbb),expression(c*Delta*cc*c),expression(d*Delta*symbol(\54)*dd)
 ) ) ) )

 I mostly use lattice and have forgotten how to do labels in basic plot so
 have used lattice. should be similar and you can modify to suit.

 It was trial and error in going up through the numbers  from about 38


 Duncan

 At 11:57 7/07/2013, you wrote:

 Duncan,

 Thanks for the suggestion, but that won't work for my situation. I'm
 trying to use a character vector to label some axis ticks. There are some
 elements in the vector that have either a comma, or both Greek symbols and
 a comma, like the the third and fourth elements in x.lab below:

  x - 1:4
  x.lab - c(a*a, bbb, c,cc*c, d,dd)
  x.lab - gsub(\\*, *Delta*, x.lab)
  x.lab - parse(text = x.lab)
 Error in parse(text = x.lab) : text:3:2: unexpected ','
 2: bbb
 3: c,
^
  dotchart(x, labels = x.lab)

 The root problem that I'm stumped on is how to either:
 1) insert a comma into an expression and have it be read as a valid
 character, or
 2) replace the comma in the character string with 'list(a, b, c)' as in
 the help for plotmath and have it interpreted correctly.

 Cheers,
 eric


 On Sat, Jul 6, 2013 at 3:33 PM, Duncan Mackay mac...@northnet.com.au 
 wrote:
  Hi Eric

 I have not been following the thread but following on what David has said
 on previous occasions

 try for example

 plot(1,1, ylab =  expression(aa aaa,aa bb*Delta*b *Delta*cc, c) )

 Below is from a partly saved previous post of David's several months ago
 which may give you some ideas

 DATA_names-c(
 A mg kg,
 B mg kg,
 C mg kg,
 D mg kg,
 E mg kg,
 F mg kg,
 G mg kg,
 H mg kg)

 pos - barplot(1:length(DATA_names))
 text(x=pos,y=-1, xpd=TRUE, srt=45,
 labels= sapply( gsub(mg kg, (mg kg)^-1,
 DATA_names),
 as.expression))

 HTH

 Duncan


 Duncan Mackay
 Department of Agronomy and Soil Science
 University of New England
 Armidale NSW 2351
 Email: home: mac...@northnet.com.au




 At 07:47 6/07/2013, you wrote:
  I'm trying to format a given character vector as an expression with Greek
 symbols to be used in labeling axis ticks. Thanks to some help from David
 Winsemius, I've learned how to make the substitution and place the Greek
 symbols in, however I've run into another problem: Some of my labels have
 commas in them, so when the parse command is executed, there is an
 unexpected symbol error. For example:

  x - c(aa, aaa,aa, bb*Delta*b, *Delta*cc,c)
  parse(text = x)
 Error in parse(text = x) : text:2:4: unexpected ','
 1: aa
 2: aaa,
  ^

 I've tried various iterations of wrapping the commas in interior quotes
 (aaa\,\aa), but then the error shifts to the quote. I see in plotmath
 that 'list(a,b,c)' gives me comma separated values, but I haven't been able
 to work out how to get this construction for elements that have a comma.

 Is this possible?

 --

 Eric Archer, Ph.D.
 Southwest Fisheries Science Center
 NMFS, NOAA
 8901 La Jolla Shores Drive
 La Jolla, CA 92037 USA
 858-546-7121 (work)
 858-546-7003 (FAX)

 Marine Mammal Genetics Group: swfsc.noaa.gov/prd-mmgenetics
 ETP Cetacean Assessment Program: swfsc.noaa.gov/prd-etp

 The universe doesn't care what you believe.
  The wonderful thing about science is that it
doesn't ask for your faith, it just asks
for your eyes.  - Randall Munroe

 Lighthouses are more helpful than churches.
- Benjamin Franklin

...but I'll take a GPS over either one.
- John C. Craig George

 [[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.






 --

 Eric Archer, Ph.D.
 Southwest Fisheries Science Center
 NMFS, NOAA
 8901 La Jolla Shores Drive
 La Jolla, CA 92037 USA
 858-546-7121 (work)
 858-546-7003 (FAX)

 Marine Mammal Genetics Group: swfsc.noaa.gov/prd-mmgenetics
 ETP Cetacean Assessment Program: swfsc.noaa.gov/prd-etp

 The universe doesn't care what you believe.
  The wonderful thing about science is that it
doesn't ask for your faith, it just asks
for your eyes.  - Randall Munroe

 Lighthouses are more helpful than churches.
- Benjamin Franklin

...but I'll take a GPS over either one.
- John C. Craig George

Re: [R] Substituting Greek symbols in some tick labels

2013-07-05 Thread Eric Archer - NOAA Federal
David, thanks for the reply.

No, I don't want to do it by hand because the actual data that I need to
label is much larger and variable. The deltas occur in the label character
vector for some labels and not others and are in different positions in the
character strings.

In the example I gave, the 'y' is the argument in the function to the
lapply where I was trying to iterate over the results from 'strsplit' to
insert the 'Delta' - the results showed me it wasn't the way to go, but I
was giving an example of what I'd tried.

Cheers,
eric


On Thu, Jul 4, 2013 at 11:31 PM, David Winsemius dwinsem...@comcast.netwrote:


 On Jul 4, 2013, at 8:14 PM, Eric Archer - NOAA Federal wrote:

  I have a character vector that I'm using to label ticks in a dotchart.
 Some
 of the elements in the vector have an asterisk (*) where a Greek Delta
 needs to be placed when the plot is generated. Here's a simple example:

 x - 1:4
 x.lab - c(a*a, bbb, c*c, ddd)
 dotchart(x, labels = x.lab)

 The first and third labels should be 'aDeltaa' and 'cDeltac'. I've
 tried things like,

 x.lab - strsplit(x.lab, [*])
 x.lab - lapply(x.lab, function(y) expression(paste(y, sep = Delta)))


 The plotmath function paste has no sep argument.

 Do you want to do this by hand? (Since you have not offered values of
 'y'.)

 x.lab - expression( a*Delta*a, bbb, c*Delta*c, ddd)

 #   Note use of * and no quotes in an expression vector.

  x - 1:4
 dotchart(x, labels = x.lab)

 --
 David.


 but because 'y' is unevaluated, the resulting list elements won't work as
 tick labels. I've tried to modify it by using bquote and substitute, but
 couldn't get anything closer. Any suggestions? Thanks!

 Cheers,
 eric

 --

 Eric Archer, Ph.D.
 Southwest Fisheries Science Center
 NMFS, NOAA
 8901 La Jolla Shores Drive
 La Jolla, CA 92037 USA
 858-546-7121 (work)
 858-546-7003 (FAX)

 Marine Mammal Genetics Group: swfsc.noaa.gov/prd-mmgenetics
 ETP Cetacean Assessment Program: swfsc.noaa.gov/prd-etp

 The universe doesn't care what you believe.
 The wonderful thing about science is that it
   doesn't ask for your faith, it just asks
   for your eyes.  - Randall Munroe

 Lighthouses are more helpful than churches.
   - Benjamin Franklin

   ...but I'll take a GPS over either one.
   - John C. Craig George

 [[alternative HTML version deleted]]

 __**
 R-help@r-project.org mailing list
 https://stat.ethz.ch/mailman/**listinfo/r-helphttps://stat.ethz.ch/mailman/listinfo/r-help
 PLEASE do read the posting guide http://www.R-project.org/**
 posting-guide.html http://www.R-project.org/posting-guide.html
 and provide commented, minimal, self-contained, reproducible code.


 David Winsemius, MD
 Alameda, CA, USA




-- 

Eric Archer, Ph.D.
Southwest Fisheries Science Center
NMFS, NOAA
8901 La Jolla Shores Drive
La Jolla, CA 92037 USA
858-546-7121 (work)
858-546-7003 (FAX)

Marine Mammal Genetics Group: swfsc.noaa.gov/prd-mmgenetics
ETP Cetacean Assessment Program: swfsc.noaa.gov/prd-etp

The universe doesn't care what you believe.
 The wonderful thing about science is that it
   doesn't ask for your faith, it just asks
   for your eyes.  - Randall Munroe

Lighthouses are more helpful than churches.
   - Benjamin Franklin

   ...but I'll take a GPS over either one.
   - John C. Craig George

[[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] Substituting Greek symbols in some tick labels

2013-07-05 Thread Eric Archer - NOAA Federal
David,

That's perfect! I just didn't think to use 'parse'. Thanks!

Cheers,
eric


On Fri, Jul 5, 2013 at 8:20 AM, David Winsemius dwinsem...@comcast.netwrote:


 On Jul 4, 2013, at 8:14 PM, Eric Archer - NOAA Federal wrote:

  I have a character vector that I'm using to label ticks in a dotchart.
 Some
  of the elements in the vector have an asterisk (*) where a Greek Delta
  needs to be placed when the plot is generated. Here's a simple example:
 
  x - 1:4
  x.lab - c(a*a, bbb, c*c, ddd)
  dotchart(x, labels = x.lab)
 
  The first and third labels should be 'aDeltaa' and 'cDeltac'. I've
  tried things like,
 
  x.lab - strsplit(x.lab, [*])
  x.lab - lapply(x.lab, function(y) expression(paste(y, sep = Delta)))
 
  but because 'y' is unevaluated, the resulting list elements won't work as
  tick labels. I've tried to modify it by using bquote and substitute, but
  couldn't get anything closer. Any suggestions? Thanks!

 Right. I would not throw away the * but rather change it to an inline
 Delta:

 x.lab - gsub(\\*, *Delta*, x.lab)

 # parse(text=x.lab)
 # returns: expression(a*Delta*a, bbb, c*Delta*c, ddd)#

 Then parse it:

 dotchart(x, labels = parse(text=x.lab) )


 
  Cheers,
  eric
 
  --
 
  Eric Archer, Ph.D.
  Southwest Fisheries Science Center
  NMFS, NOAA
  8901 La Jolla Shores Drive
  La Jolla, CA 92037 USA
  858-546-7121 (work)
  858-546-7003 (FAX)
 
  Marine Mammal Genetics Group: swfsc.noaa.gov/prd-mmgenetics
  ETP Cetacean Assessment Program: swfsc.noaa.gov/prd-etp
 
  The universe doesn't care what you believe.
  The wonderful thing about science is that it
doesn't ask for your faith, it just asks
for your eyes.  - Randall Munroe
 
  Lighthouses are more helpful than churches.
- Benjamin Franklin
 
...but I'll take a GPS over either one.
- John C. Craig George
 
[[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.

 David Winsemius
 Alameda, CA, USA




-- 

Eric Archer, Ph.D.
Southwest Fisheries Science Center
NMFS, NOAA
8901 La Jolla Shores Drive
La Jolla, CA 92037 USA
858-546-7121 (work)
858-546-7003 (FAX)

Marine Mammal Genetics Group: swfsc.noaa.gov/prd-mmgenetics
ETP Cetacean Assessment Program: swfsc.noaa.gov/prd-etp

The universe doesn't care what you believe.
 The wonderful thing about science is that it
   doesn't ask for your faith, it just asks
   for your eyes.  - Randall Munroe

Lighthouses are more helpful than churches.
   - Benjamin Franklin

   ...but I'll take a GPS over either one.
   - John C. Craig George

[[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] Transferring commas in character vector to expression

2013-07-05 Thread Eric Archer - NOAA Federal
I'm trying to format a given character vector as an expression with Greek
symbols to be used in labeling axis ticks. Thanks to some help from David
Winsemius, I've learned how to make the substitution and place the Greek
symbols in, however I've run into another problem: Some of my labels have
commas in them, so when the parse command is executed, there is an
unexpected symbol error. For example:

 x - c(aa, aaa,aa, bb*Delta*b, *Delta*cc,c)
 parse(text = x)
Error in parse(text = x) : text:2:4: unexpected ','
1: aa
2: aaa,
 ^

I've tried various iterations of wrapping the commas in interior quotes
(aaa\,\aa), but then the error shifts to the quote. I see in plotmath
that 'list(a,b,c)' gives me comma separated values, but I haven't been able
to work out how to get this construction for elements that have a comma.

Is this possible?

-- 

Eric Archer, Ph.D.
Southwest Fisheries Science Center
NMFS, NOAA
8901 La Jolla Shores Drive
La Jolla, CA 92037 USA
858-546-7121 (work)
858-546-7003 (FAX)

Marine Mammal Genetics Group: swfsc.noaa.gov/prd-mmgenetics
ETP Cetacean Assessment Program: swfsc.noaa.gov/prd-etp

The universe doesn't care what you believe.
 The wonderful thing about science is that it
   doesn't ask for your faith, it just asks
   for your eyes.  - Randall Munroe

Lighthouses are more helpful than churches.
   - Benjamin Franklin

   ...but I'll take a GPS over either one.
   - John C. Craig George

[[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] Substituting Greek symbols in some tick labels

2013-07-04 Thread Eric Archer - NOAA Federal
I have a character vector that I'm using to label ticks in a dotchart. Some
of the elements in the vector have an asterisk (*) where a Greek Delta
needs to be placed when the plot is generated. Here's a simple example:

x - 1:4
x.lab - c(a*a, bbb, c*c, ddd)
dotchart(x, labels = x.lab)

The first and third labels should be 'aDeltaa' and 'cDeltac'. I've
tried things like,

x.lab - strsplit(x.lab, [*])
x.lab - lapply(x.lab, function(y) expression(paste(y, sep = Delta)))

but because 'y' is unevaluated, the resulting list elements won't work as
tick labels. I've tried to modify it by using bquote and substitute, but
couldn't get anything closer. Any suggestions? Thanks!

Cheers,
eric

-- 

Eric Archer, Ph.D.
Southwest Fisheries Science Center
NMFS, NOAA
8901 La Jolla Shores Drive
La Jolla, CA 92037 USA
858-546-7121 (work)
858-546-7003 (FAX)

Marine Mammal Genetics Group: swfsc.noaa.gov/prd-mmgenetics
ETP Cetacean Assessment Program: swfsc.noaa.gov/prd-etp

The universe doesn't care what you believe.
 The wonderful thing about science is that it
   doesn't ask for your faith, it just asks
   for your eyes.  - Randall Munroe

Lighthouses are more helpful than churches.
   - Benjamin Franklin

   ...but I'll take a GPS over either one.
   - John C. Craig George

[[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] regex - negate a word

2009-01-18 Thread Eric Archer

Roland,

I think you were almost there with your first example.  Howabout using:

 x - c(abcdef, defabc, qwerty)
 y - grep(pattern=abc, x=x)
 z.char - x[-y]
 z.index - (1:length(x))[-y]

 z.char
[1] qwerty
 z.index
[1] 3

Cheers,
eric

Rau, Roland wrote:

Dear all,

let's assume I have a vector of character strings:

x - c(abcdef, defabc, qwerty)

What I would like to find is the following: all elements where the word
'abc' does not appear (i.e. 3 in this case of 'x').

Since I am not really experienced with regular expressions, I started
slowly and thought I find all word were 'abc' actually does appear:


grep(pattern=abc, x=x)

[1] 1 2

So far, so good. Now I read that ^ is the negation operator. But it can
also denote the beginning of a string as in:


grep(pattern=^abc, x=x)

[1] 1

Of course, we need to put it inside square brackets to negate the
expression [1]

grep(pattern=[^abc], x=x)

[1] 1 2 3

But this is not what I want either.

I'd appreciate any help. I assume this is rather easy and
straightforward.

Thanks,
Roland


[1] http://www.zytrax.com/tech/web/regex.htm: The ^ (circumflex or
caret) inside square brackets negates the expression

--
This mail has been sent through the MPI for Demographic Research.  Should you 
receive a mail that is apparently from a MPI user without this text displayed, 
then the address has most likely been faked. If you are uncertain about the 
validity of this message, please check the mail header or ask your system 
administrator for assistance.

__
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.


--

Eric Archer, Ph.D.
Southwest Fisheries Science Center
8604 La Jolla Shores Dr.
La Jolla, CA 92037
858-546-7121 (work)
858-546-7003 (FAX)

ETP Cetacean Assessment Program: http://swfsc.noaa.gov/prd-etp.aspx
Population ID Program: http://swfsc.noaa.gov/prd-popid.aspx



Innocence about Science is the worst crime today.
   - Sir Charles Percy Snow

Lighthouses are more helpful than churches.
   - Benjamin Franklin

   ...but I'll take a GPS over either one.
   - John C. Craig George

__
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] Update R, keep packages

2008-12-01 Thread Eric Archer

Will,

Below are the contents of my Rprofile.site file.  It makes sure that I 
have all of the packages I use regularly always up to date every time I 
start R.
I don't know if it is the smart way, but it works for me.  I'd be more 
than happy to get suggestions on improvements from the expeRts.


Cheers,
eric


local({
 repos - getOption(repos)
 repos[CRAN] - http://cran.stat.ucla.edu;
 options(digits = 3, stringsAsFactors = FALSE, repos = repos)
 library(grDevices)
 windows.options(record = TRUE)
 library(utils)
 update.packages(ask = FALSE)
 my.packages - c(adapt, ade4, ape, BRugs, cluster, coda, 
fields, gpclib,
   Geneland, genetics, gpclib, Hmisc, lattice, mapproj, 
maps, maptools, MASS,
   R.oo, R.utils, randomForest, rmetasim, rpart, sgeostat, 
shapefiles,

   sm, sp, spatial, spatstat, splancs)
 to.download - which(!my.packages %in% rownames(installed.packages()))
 if(length(to.download)  0) install.packages(my.packages[to.download], 
clean = TRUE)

})



Will wrote:

Hi,

when updating R I continuously face the problem that I have to 
reinstall packages or copy them into the new R library path.


Is there a smart way of configuring R (.Rprofile) so the packages 
installed under older R versions (different lib paths) are 
included/found by newer R versions (e.g. R site archive).

What problems due to version conflicts/out-of-date packages can arise?

I am working with R on a Linux server.

Thanks in advance,

Will

__
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.


--

Eric Archer, Ph.D.
Southwest Fisheries Science Center
National Marine Fisheries Service
 North Torrey Pines Court
La Jolla, CA 92037-1022
858-546-7121 (work)
858-546-7003 (FAX)

ETP Cetacean Assessment Program: http://swfsc.noaa.gov/prd-etp.aspx
Population ID Program: http://swfsc.noaa.gov/prd-popid.aspx 



Innocence about Science is the worst crime today.
  - Sir Charles Percy Snow

Lighthouses are more helpful than churches.
  - Benjamin Franklin

  ...but I'll take a GPS over either one.
  - John C. Craig George 



__
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] meaning of lenwrk value in adapt function

2007-10-29 Thread Eric Archer
R-listers,

In using the adapt function, I am getting the following warning:

Ifail=2, lenwrk was too small. -- fix adapt() !
 Check the returned relerr! in: adapt(ndim = 2, lower = lower.limit, 
upper = upper.limit, functn = pr.set, 

Would someone explain what the 'lenwrk' value indicates in order to help 
diagnose this issue.
Also, what are the possible codes for Ifail, so I can set some traps in 
my code to handle them correctly.

I apologize for not including a reproducible example in this query, but 
the function that is being called in adapt is a rather complex 
temporal-spatial density function and would require many lines of code 
along with the necessary data, and would not be useful at this stage in 
debugging.

Thanks in advance.

Cheers,


Eric Archer, Ph.D.
NOAA-SWFSC
8604 La Jolla Shores Dr.
La Jolla, CA 92037
858-546-7121,7003(FAX)
[EMAIL PROTECTED]

http://swfsc.nmfs.noaa.gov/prd/PROGRAMS/ETPCetacean/default.htm

__
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] Area of overlap between polygon and circle

2007-09-26 Thread Eric Archer

R-listers,

Given a polygon and a circle defined by its center coordinates and a 
radius, I would like to calculate the area of overlap.  I know that I 
can create a polygon from the circle and then use available packages to 
get the area of the intersection.  However, because the polygon is of a 
fixed size and I will be doing this for circles of varying sizes, I'm 
concerned about maintaining the appropriate amount of resolution with 
larger circles.   If there was already a package that did the above 
calculation without the creation of a circle polygon and would thus give 
an exact area, that would be preferred.  I have searched the archives 
and have not found a solution to this particular problem.  Thanks!


Cheers,
eric

--

Eric Archer, Ph.D.
NOAA-SWFSC
8604 La Jolla Shores Dr.
La Jolla, CA 92037
858-546-7121,7003(FAX)
[EMAIL PROTECTED]
http://swfsc.noaa.gov/prd-etp.aspx

Innocence about Science is the worst crime today.
  - Sir Charles Percy Snow


Lighthouses are more helpful than churches.
  - Benjamin Franklin

  ...but I'll take a GPS over either one.
  - John C. Craig George 



__
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.