[R] code to convert 3D geographical coordinates to Cartesian?

2012-12-30 Thread Tom Roche
s the mathematics convention that azimuth=Θ and polar angle=φ (vs the reverse physics convention). Net: the task seems straightforward enough, but there's certainly scope for error, so I'd prefer to use tested, well-used code if available. Am I missing something?

Re: [R] code to convert 3D geographical coordinates to Cartesian?

2012-12-30 Thread Tom Roche
27;t believe that functionality this fundamental is not API. But I have looked at several packages and am not seeing it. I suspect that either it's so low-level that it's just not exposed as API, or just that there is API but I'm not seeing it in the package docs ("hidden in

Re: [R] code to convert 3D geographical coordinates to Cartesian?

2012-12-31 Thread Tom Roche
the ability to transform those various formats. I consider geospatiality to be a core competency for R, and geographical <-> Cartesian transforms to be fundamental to that: YMMV. thanks again, Tom Roche --sample hack follows to end of post-- # Convert geogra

[R] [lattice] display a projected map on a layerplot

2013-02-13 Thread Tom Roche
wd=0.8, col='darkgray')) # still no map :-( dev.off() system(sprintf("xpdf %s", lcc.pdf)) # end example # The data looks right, in that it greatly resembles the original example (from which the above is adapted), which follows my .sig. However the original-ex

[R] [newbie] how to find and combine geographic maps with particular features?

2013-04-25 Thread Tom Roche
{ > stop(sprintf('plot.vis.layers: ERROR: cannot handle > (length(map.list)==%i', length(map.list))) > } > dev.off() > } # end plot.vis.layers This allows me to combine US state boundaries with national boundaries of Canada and Mexico (though only via the kludge abov

[R] [newbie] *apply to matching elements of n arrays?

2013-05-08 Thread Tom Roche
directly to me as well as the list (I'm on the digest, which gets huge). TIA, Tom Roche __ 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.h

Re: [R] [newbie] *apply to matching elements of n arrays?

2013-05-11 Thread Tom Roche
Tom Roche Wed, 08 May 2013 20:38:12 -0400 >> I have two spatial grids defined the same way (i.e., same number of >> rows and columns--and dimensions, both 2D). Wherever both >> * the value of an element i,j in the first grid is NA >> * the value of element i,j in the

[R] [newbie] return index(s) for value?

2013-05-11 Thread Tom Roche
an answer (probably because I'm not using the correct search terms). Feel free (in fact, be encouraged :-) to reply directly to me as well as to the list (I'm on the digest, which gets huge). TIA, Tom Roche __ R-help@r-project.org mailing li

Re: [R] [newbie] return index(s) for value?

2013-05-11 Thread Tom Roche
https://stat.ethz.ch/pipermail/r-help/2013-May/353343.html >> Is there a function 'foo' such that, given an array and a value, >> iff the value is present in the array, it returns the index(s) of >> the value? E.g., >> > matrix(1:9, nrow=3) -> grid >> > grid >> [,1] [,2] [,3] >> [1,]1

[R] R equivalent of python module structure and functionality?

2012-09-11 Thread Tom Roche
ript's functionality, e.g., >>> sys.path.append('/path/to') >>> from cmdline import * >>> process_command_line(...) How to do this in R? TIA, Tom Roche __ 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] R equivalent of python module structure and functionality?

2012-09-11 Thread Tom Roche
littler provides that Rscript doesn't-- both do hash-bang--but that's probably orthogonal to this question.) https://stat.ethz.ch/pipermail/r-help/2012-September/323554.html > I also wanted to point Tom to CRAN packages > getopt > optparse > written specifically to supp

Re: [R] R equivalent of python module structure and functionality?

2012-09-12 Thread Tom Roche
list( > make_option(c("-b", "--bar"), default="hello world") > ) > opt <- parse_args(OptionParser(option_list=option_list)) > foo(bar=opt$bar) > } > # end foo.R ## And I have modified my code @ https://github.com/TomRoche/GE

[R] [newbie] failure to plot a RasterLayer with raster::plot or fields::image.plot

2012-10-21 Thread Tom Roche
with spatial plotting would take a look at the output and the code, and diagnose the problem. Note that both output and code will remain public, hopefully to be useful to the next person attempting this sort of task. And of course I will be sure to annotate the code and pro

Re: [R] [newbie] failure to plot a RasterLayer with raster::plot or fields::image.plot

2012-10-21 Thread Tom Roche
https://stat.ethz.ch/pipermail/r-help/2012-October/326837.html > summary: spatial data to be input to a regional-scale environmental > model must (1) be converted to netCDF and then (2) "regridded" > (cropped, projected, increased resolution). In a public git > repository > https://github.com/Tom

[R] decorating API in R

2012-11-09 Thread Tom Roche
put much scarce time into researching this, I thought I'd ask the community for suggestions, references, and especially examples for how to do this in R, especially how to extend one R package with another. TIA, Tom Roche __ R-help@r-project.or

[R] [newbie] convert 3D spatial array to dataframe

2012-11-17 Thread Tom Roche
383 1015 384 1115 385 How to do that? I'm guessing this involves function=reshape, but I can't see how to make `reshape` work for this usecase. TIA, Tom Roche __ R-help@r-project.org mailing list https://stat.ethz.ch/mail

Re: [R] [newbie] convert 3D spatial array to dataframe

2012-11-17 Thread Tom Roche
ot;) library(lattice) levelplot(conc ~ lon * lat | factor(lev), data = data.frame) works! thanks all, Tom Roche __ 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] [lattice] how to label panels with variable value (not name)?

2012-11-18 Thread Tom Roche
ta.frame) However I will need to before-and-after compare this to the results of a reboxing, or 3D regridding, of this data, so I would prefer instead to label each panel in the lattice with the _value_ of the level (an atmospheric pressure), rather than the name or index of the level. H

[R] [lattice] format and rotation of strip text

2012-11-18 Thread Tom Roche
like the x-axis label) + the layer value truncated or rounded to some significant digits, e.g., '1.1' I suspect this can be done with strip.custom, but am not seeing how; please enlighten! Your assistance is appreciated, Tom Roche __ R-help

Re: [R] [lattice] how to label panels with variable value (not name)?

2012-11-18 Thread Tom Roche
@ https://stat.ethz.ch/pipermail/r-help/2012-November/329479.html Thanks! Tom Roche __ 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] [lattice] format and rotation of strip text

2012-11-18 Thread Tom Roche
.levels=as.character(round(array.3d.df[['lev']], 3)), strip.levels=TRUE, horizontal=TRUE, strip.names=FALSE , par.strip.text=list(cex=0.5) ) ) Note that, - without the line above commented out, strip values are (correctly) all 1.123 + with the line above

[R] [solved!] Re: [lattice] format and rotation of strip text

2012-11-20 Thread Tom Roche
zation documentation, please lemme know. (For that matter, why is there not something like an r-sig-vis?) Your assistance is appreciated! Hoping this will be useful to others, Tom Roche __ 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] [lattice] how to overlay a geographical map on a levelplot?

2012-11-20 Thread Tom Roche
y small, quite self-contained example follows the quote above, in which I plot toy data in the sort of lattice layout I need ... except that each panel lacks a map appropriate to the spatial domain. If your competencies extend to that, your assistance would be appreciated.

Re: [R] [lattice] how to overlay a geographical map on a levelplot?

2012-11-20 Thread Tom Roche
https://stat.ethz.ch/pipermail/r-sig-geo/2012-November/016757.html >> summary: How to overlay a geographical map on each panel in a lattice >> (or Trellis), e.g., of levelplot's? https://stat.ethz.ch/pipermail/r-help/2012-November/329714.html > Does [this] match what you are looking for? Alas, n

[R] [solved!] [lattice] how to overlay a geographical map on a levelplot?

2012-11-20 Thread Tom Roche
https://stat.ethz.ch/pipermail/r-sig-geo/2012-November/016757.html >> summary: How to overlay a geographical map on each panel in a lattice >> (or Trellis), e.g., of levelplot's? https://stat.ethz.ch/pipermail/r-help/2012-November/329716.html > you need to launch the library 'latticeExtra' That'

[R] translating IDL to R

2012-07-23 Thread Tom Roche
ate your assistance. TIA, Tom Roche ---2 IDL routines follow to EOF--- from ftp://gfed3:dailyandhou...@zea.ess.uci.edu/GFEDv3.1/Readme.pdf ; idl code to generate daily emissions + nlon=720 ; number of grid points by longitude nlat=360 ; number of grid points by latitude

[R] translating IDL to R

2012-07-23 Thread Tom Roche
ounted @ http://goo.gl/QBZ3y Your assistance is appreciated! Tom Roche __ 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 comme

Re: [R] translating IDL to R

2012-07-24 Thread Tom Roche
summary: I believe I have ported the GFED IDL example routines to R (following .sig to end of post). But there are some very "loose ends," notably 2 for-loops which need replaced by more R-ful code. details: Tom Roche Mon, 23 Jul 2012 21:59:54 -0400 > [The GFED] example IDL code

[R] [ncdf4] error converting GEIA data to netCDF

2012-08-27 Thread Tom Roche
I tried to find the GEIA data distributed in netCDF format, and asked around, but have gotten no responses. ) TIA, Tom Roche __ 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] [netcdfgroup] [ncdf4] error converting GEIA data to netCDF

2012-08-28 Thread Tom Roche
Tom Roche Mon, 27 Aug 2012 23:31:23 -0400 >> summary: I can successfully ncvar_put(...) data to a file, but when >> I try to ncvar_get(...) the same data in the one and only datavar >> I get >> > Error in if (nc$var[[li]]$hasAddOffset) addOffset = nc$var[[li]]$add

Re: [R] [netcdfgroup] [ncdf4] error converting GEIA data to netCDF

2012-08-28 Thread Tom Roche
Pascal Oettli: MERCI BEAUCOUP! (though I would have thanked you earlier if I hadn't had to dig through the r-help digest first :-) Tom Roche Mon, 27 Aug 2012 23:31:23 -0400 >> summary: I can successfully ncvar_put(...) data to a file, but when >> I try to ncvar_get(...) th

Re: [R] [netcdfgroup] [ncdf4] error converting GEIA data to netCDF

2012-08-28 Thread Tom Roche
to_netCDF/blob/c380c0a28dc8c71dbf0c2ba18130a2439a4fe089/GEIA.to.netCDF.r I've also attached that (quoted) following my .sig, with the top-most constant and function declarations removed for brevity. The dimension definitions are prefixed with '1', the variable definition is prefixed

Re: [R] [netcdfgroup] [ncdf4] error converting GEIA data to netCDF

2012-08-28 Thread Tom Roche
Tom Roche Tue, Aug 28, 2012 at 4:23 PM >> Can ncdf4 be made to fail more helpfully? E.g., to fail immediately >> on nc_open without assignment? David W. Pierce Tue, 28 Aug 2012 13:23:53 -0700 > I'll see if there exists some way to do a better check for this. TIA. > One o

[R] [newbie] scripting remote check for R package

2012-09-02 Thread Tom Roche
E='whatever' for S in 'foo' 'bar' 'baz' ; do ssh ${RSERVER} "${EXEC_NAME} --version" done periodically. I'm wondering, what incantation to utter (bash preferred) via ssh to query a given server's R for a given package? TIA, Tom Roche

Re: [R] [newbie] scripting remote check for R package

2012-09-03 Thread Tom Roche
natively, what should I tell my admin to do in order to make both Rscript and R available?) 3 Is there any reason to install R without Rscript? (Alternatively, when I ask my admin to install Rscript, is there any objection I should anticipate?) thanks again, Tom Roche __

Re: [R] [newbie] scripting remote check for R package

2012-09-03 Thread Tom Roche
ER} "${EXEC_PATH} CMD BATCH --slave --no-timing ${BATCH_INPUT_PATH} ${BATCH_OUTPUT_PATH}" ssh ${RSERVER} "ls -al ${BATCH_OUTPUT_PATH}" ssh ${RSERVER} "head -n 1 ${BATCH_OUTPUT_PATH}" echo # newline done Given the pain, I'd still like to know: > 2

Re: [R] [newbie] scripting remote check for R package

2012-09-04 Thread Tom Roche
ne done which works. I'd still like to know: > 2 What should my admin have done to install both Rscript and R? > (Alternatively, what should I tell my admin to do in order to make > both Rscript and R available?) > 3 Is there any reason to install R witho

[R] how to get Rscript, and is there any reason not to?

2012-09-04 Thread Tom Roche
both Rscript and R available? (FWIW I believe the boxes are running CentOS, though possibly RHEL 5 or 6.) 2 Is there any reason to install R without Rscript? Alternatively, when I ask my admin to install Rscript, is there any objection I should anticipate? TIA, Tom

[R] [Rscript] difficulty passing named arguments from commandline

2012-09-06 Thread Tom Roche
N2O_oceanic.nc var.name=emi_n2o > Error in eval(expr, envir, enclos) : object '.' not found > Calls: eval -> eval > Execution halted Must the quoting be so strict/brittle, or am I missing something? Also, It Would Be Nice if there was more in the `help(Rscript)` examples about a

Re: [R] [Rscript] difficulty passing named arguments from commandline

2012-09-09 Thread Tom Roche
gt; with them. (This is somewhat safer than using eval(parse(text=)) > because it can do less.) Assigning arguments via strsplit() does seem to be more of a PITA, but it works now @ https://github.com/TomRoche/GEIA_to_netCDF/blob/master/netCDF.stats.to.stdout.r your assistance is appreciat

[R] [newbie] read row from file into vector

2011-12-29 Thread Tom Roche
summary: how to read a row (not column) from a file into a vector (not a data frame)? details: I'm using $ lsb_release -ds Linux Mint Debian Edition $ uname -rv 3.0.0-1-amd64 #1 SMP Sun Jul 24 02:24:44 UTC 2011 $ R --version R version 2.14.1 (2011-12-22) I'm new to R (having previously used i

Re: [R] [newbie] read row from file into vector

2011-12-29 Thread Tom Roche
Tom Roche 11-12-29 3:51 PM >>> E.g., for a file such that >>> $ head -n 2 ~/data/foo.csv | tail -n 1 >>> 5718,0.3,0.47,0,0,0,0,0,0,0,0,0.08,0.37,0,0,0.83,1.55,0,0,0,0,0,0,0,0,0,0.00,2.48,2.33,0.17,0,0,0,0,0,0,0.00,10.69,0.18,0,0,0,0 >>> I'd like to be a

[R] where to ask questions regarding package=ncdf?

2012-01-02 Thread Tom Roche
Should one ask questions relating to the R package 'ncdf' here? or look for a more netCDF-oriented (but probably less R-oriented) list? Why I ask: I'm relatively new to R, which I've only used in the past for graphics. I'm trying to learn R as an alternative to manipulating netCDF files with NCO

[R] [newbie] pager for large matrix?

2012-01-02 Thread Tom Roche
16] [,17] [,18] [,19] [,20] [,21] [,22] [2,] ... ... [,291] [,292] [,293] [,294] [,295] [,296] [,297] [,298] [,299] [2,] ... But that's gravy: all I really want is a pager, and preferably one that will allow me to output row-wise. Is there such a tool for R? or ESS? TIA, Tom Roc

[R] [newbie] stack operations, or functions with side effects (or both)

2012-01-04 Thread Tom Roche
> pop2(s) [1] 1 > print(s) [1] 1 2 3 4 5 ditto :-( What am I missing? * Is there already a stack API for R (which I would expect)? If so, where? * How to cause the desired side effect to the argument in the code above? TIA, Tom Roche __ R-help@r-

Re: [R] [newbie] stack operations, or functions with side effects (or both)

2012-01-05 Thread Tom Roche
k = NULL, > push = function(., el) { .$stack <- c(list(el), .$stack) }, > pop = function(.) { stopifnot(length(.$stack) > 0) > out <- .$stack[[1]] > .$stack[[1]] <- NULL > out > })) > mystack <- Stack$new() > mystack$push( 1 ) >

[R] [ncdf] programmatically copying a netCDF file

2012-01-05 Thread Tom Roche
iple, or are there steps that must (at least currently) necessarily be hand-coded? TIA, Tom Roche __ 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-gui

Re: [R] [ncdf] programmatically copying a netCDF file

2012-01-09 Thread Tom Roche
summary: Programmatically copying NetCDF mostly works: thanks for your assistance! However, 4 followup questions/responses (and motivation provided) below regarding problems encountered. details: Tom Roche Thu, 05 Jan 2012 18:29:35 -0500 >> I need to "do surgery" on a l

Re: [R] remoting ESS/R with tramp

2012-01-12 Thread Tom Roche
Tom Roche Thu, 12 Jan 2012 11:56:25 -0500 >>> * I have access to the cluster [where I want to run R] configured >>> [in .ssh/config] such that I can `ssh t` from commandline. >>> 1 I can open an R file on the cluster with >>> `C-x C-f /t:/home/me/onlyOrigD

Re: [R] remoting ESS/R with tramp

2012-01-12 Thread Tom Roche
Tom Roche Thu, 12 Jan 2012 11:56:25 -0500 >>> * I have access to the cluster [where I want to run R] configured >>> [in my linux laptop's .ssh/config] such that I can `ssh t` from >>> commandline. Note also that I'm using keychain http://www.cybercit

Re: [R] [ncdf] programmatically copying a netCDF file

2012-01-13 Thread Tom Roche
Tom Roche Mon, Jan 9, 2012 at 3:54 PM, >> I need to copy most of a source file, modifying only part, and to >> write a target file. David William Pierce Thu, 12 Jan 2012 09:13:53 -0800 > I'd advise against doing this. I think it's the wrong approach. > Better to us

[R] [fields] image.plot abends with NAs in image.plot.info

2012-02-03 Thread Tom Roche
in. image.plot.info(...) tried/failed several ways to set values, before exiting with > Browse[2]> info > $xlim > [1] NA > $ylim > [1] NA > $zlim > [1] NA > $poly.grid > [1] FALSE which then causes the exception above. How to proceed? If there's a better way t

[R] [newbie] storage/use of user's own functions?

2012-02-05 Thread Tom Roche
o, the personal-functions folder? Apologies if this is a FAQ, but I didn't see anything about it @ http://cran.r-project.org/doc/FAQ/R-FAQ.html http://cran.r-project.org/doc/manuals/R-admin.html or in casual rseek-ing. TIA, Tom Roche __ R-help@r-

[R] [newbie] modules.sourceforge.net and system(...) calls

2012-02-08 Thread Tom Roche
something completely different? 2 How to catch failure of system(...) calls, so as to fail fast? (E.g., in case I try to run the R script without setting up the modules first.) TIA, Tom Roche __ R-help@r-project.org mailing list https://stat.ethz.c

Re: [R] Version control (git, mercurial) for R packages

2012-02-08 Thread Tom Roche
(though keep in mind that I'm new to R, so I Could Be Wrong): R-forge https://r-forge.r-project.org/ seems to be the "canonical" place to put R packages, and it's svn. That can be finessed, e.g., http://cameron.bracken.bz/git-with-r-forge FWIW, Tom Roche __

Re: [R] [fields] image.plot abends with NAs in image.plot.info

2012-02-15 Thread Tom Roche
Tom Roche Fri, Feb 3, 2012 at 11:16 AM >> summary: image.plot-ing two sets of netCDF data, with the second >> derived from the first. Should have noted that the data (atmospheric emissions) in * the second dataset is heavily positively-skewed. (This leads to a problem with the

[R] [newbie] separating plot output from debug output

2012-02-15 Thread Tom Roche
# does dev.off() Again, feasible but kludgey. 4 No status and debug messages. I hope to be that good someday :-) Am I missing something? Are there clean solutions to this problem? TIA, Tom Roche __ R-help@r-project.org mailing list https://stat.e

Re: [R] [newbie] separating plot output from debug output

2012-02-15 Thread Tom Roche
Tom Roche Wed, 15 Feb 2012 17:43:05 -0500 >> 1 I'm plotting to PDF, so everytime I dev.off() creates a new file, >> and I want everything in one file (as does my boss :-) >> 2 I'm doing the work on a cluster, where I very much do not have >> root, and

[R] [fields:image.plot] subtitle under title (not image)?

2012-05-01 Thread Tom Roche
ed), main=title, sub=subtitle) lines(map) } else { plot(0, type="n", axes=F, xlab="", ylab="", xlim=range(x.centers), ylim=range(y.centers), main=title, sub=subtitle) lines(map) } # end testing data TIA, Tom Roche _