[R] Best settings for RStudio video recording?

2020-08-13 Thread Jonathan Greenberg
Folks:

I was wondering if you all would suggest some helpful RStudio
configurations that make recording a session via e.g. zoom the most useful
for students doing remote learning.  Thoughts?

--j

-- 
Jonathan A. Greenberg, PhD
Randall Endowed Professor and Associate Professor of Remote Sensing
Global Environmental Analysis and Remote Sensing (GEARS) Laboratory
Natural Resources & Environmental Science
University of Nevada, Reno
1664 N Virginia St MS/0186
Reno, NV 89557
Phone: 415-763-5476
https://www.gearslab.org/

[[alternative HTML version deleted]]

__
R-help@r-project.org mailing list -- To UNSUBSCRIBE and more, see
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] Checking for a proper "stop" statement...

2018-02-21 Thread Jonathan Greenberg
Folks:

Consider the following two use cases:

goodfunction <- function()
{
stop("Something went wrong..."
}

# vs.

badfunction <- function()
{
notgood()
}

Is there a way for me to test if the functions make use of a stop()
statement WITHOUT modifying the stop() output (assume I can't mod the
function containing the stop() statement itself)?  For "goodfunction" the
answer is TRUE, for "badfunction" the answer is FALSE.  Both return an
error, but only one does it "safely".

I thought the answer might lie in a tryCatch statement but I'm having a
hard time figuring out how to do this test.

--j
-- 
-- 
Jonathan A. Greenberg, PhD
Randall Endowed Professor and Associate Professor of Remote Sensing
Global Environmental Analysis and Remote Sensing (GEARS) Laboratory
Natural Resources & Environmental Science
University of Nevada, Reno
1664 N Virginia St MS/0186
Reno, NV 89557
Phone: 415-763-5476
http://www.unr.edu/nres
Gchat: jgrn...@gmail.com, Skype: jgrn3007

[[alternative HTML version deleted]]

__
R-help@r-project.org mailing list -- To UNSUBSCRIBE and more, see
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] R command to open a file browser on Windows and Mac?

2015-08-03 Thread Jonathan Greenberg
Folks:

Is there an easy function to open a finder window (on mac) or windows
explorer window (on windows) given an input folder?  A lot of times I want
to be able to see via a file browser my working directory.  Is there a good
R hack to do this?

--j

[[alternative HTML version deleted]]

__
R-help@r-project.org mailing list -- To UNSUBSCRIBE and more, see
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] table over a matrix dimension...

2014-07-10 Thread Jonathan Greenberg
R-helpers:

I'm trying to determine the frequency of characters for a matrix
applied to a single dimension, and generate a matrix as an output.
I've come up with a solution, but it appears inelegant -- I was
wondering if there is an easier way to accomplish this task:

# Create a matrix of factors (characters):
random_characters=matrix(sample(letters[1:4],1000,replace=TRUE),100,10)

# Applying with the table() function doesn't work properly, because not all rows
# have ALL of the factors, so I get a list output:
apply(random_characters,1,table)

# Hacked solution:
unique_values = letters[1:4]

countsmatrix - t(apply(random_characters,1,function(x,unique_values)
{
counts=vector(length=length(unique_values))
for(i in seq(unique_values))
{
counts[i] = sum(x==unique_values[i])
}
return(counts)
},
unique_values=unique_values
))

# Gets me the output I want but requires two nested loops (apply and
for() ), so
# not efficient for very large datasets.

###

Is there a more elegant solution to this?

--j

-- 
Jonathan A. Greenberg, PhD
Assistant Professor
Global Environmental Analysis and Remote Sensing (GEARS) Laboratory
Department of Geography and Geographic Information Science
University of Illinois at Urbana-Champaign
259 Computing Applications Building, MC-150
605 East Springfield Avenue
Champaign, IL  61820-6371
Phone: 217-300-1924
http://www.geog.illinois.edu/~jgrn/
AIM: jgrn307, MSN: jgrn...@hotmail.com, Gchat: jgrn307, Skype: jgrn3007

__
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] StatET and R 3.1.0

2014-04-11 Thread Jonathan Greenberg
R-helpers:

I posted a message to the statet listserv, but I thought I'd ask here
as well since it is one of the major R developer environments-- has
anyone gotten the StatET plugin for Eclipse working with R 3.1.0 yet?
Any tricks?  I did manage to get rj updated to 2.0 via:

install.packages(c(rj, rj.gd),
repos=http://download.walware.de/rj-2.0,type=source;)

But the plugin is throwing an error (using the last maintenance update
at http://download.walware.de/eclipse-4.3/testing):

Launching the R Console was cancelled, because it seems starting the R
engine failed.  Please make sure that R package 'rj' (1.1 or
compatible) is installed
and that the R library paths are set correctly for the R environment
configuration 'R'.

--j

-- 
Jonathan A. Greenberg, PhD
Assistant Professor
Global Environmental Analysis and Remote Sensing (GEARS) Laboratory
Department of Geography and Geographic Information Science
University of Illinois at Urbana-Champaign
259 Computing Applications Building, MC-150
605 East Springfield Avenue
Champaign, IL  61820-6371
Phone: 217-300-1924
http://www.geog.illinois.edu/~jgrn/
AIM: jgrn307, MSN: jgrn...@hotmail.com, Gchat: jgrn307, Skype: jgrn3007

__
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] Ignore escape characters in a string...

2014-04-09 Thread Jonathan Greenberg
Thanks all, I'll try some of these suggestions out but it seems like a
raw string ability could come in helpful -- there aren't any packages
out there that have this capability?

--j

On Tue, Apr 8, 2014 at 1:23 PM, Jeff Newmiller jdnew...@dcn.davis.ca.us wrote:
 What is wrong with

 winpath - readLines(clipboard )

 ?

 If you want to show that as a literal in your code, then don't bother 
 assigning it to a variable, but let it echo to output and copy THAT and put 
 it in your source code.

 There is also file.choose()...

 ---
 Jeff NewmillerThe .   .  Go Live...
 DCN:jdnew...@dcn.davis.ca.usBasics: ##.#.   ##.#.  Live Go...
   Live:   OO#.. Dead: OO#..  Playing
 Research Engineer (Solar/BatteriesO.O#.   #.O#.  with
 /Software/Embedded Controllers)   .OO#.   .OO#.  rocks...1k
 ---
 Sent from my phone. Please excuse my brevity.

 On April 8, 2014 8:00:03 AM PDT, Jonathan Greenberg j...@illinois.edu wrote:
R-helpers:

One of the minor irritations I have is copying paths from Windows
explorer, which look like:

C:\Program Files\R\R-3.0.3

and using them in a setwd() statement, since the \ is, of course,
interpreted as an escape character.  I have to, at present, manually
add in the double slashes or reverse them.

So, I'd like to write a quick function that takes this path:

winpath - C:\Program Files\R\R-3.0.3

and converts it to a ready-to-go R path -- is there a way to have R
IGNORE escape characters in a character vector?

Alternatively, is there some trick to using a copy/paste from Windows
explorer I'm not aware of?

--j




-- 
Jonathan A. Greenberg, PhD
Assistant Professor
Global Environmental Analysis and Remote Sensing (GEARS) Laboratory
Department of Geography and Geographic Information Science
University of Illinois at Urbana-Champaign
259 Computing Applications Building, MC-150
605 East Springfield Avenue
Champaign, IL  61820-6371
Phone: 217-300-1924
http://www.geog.illinois.edu/~jgrn/
AIM: jgrn307, MSN: jgrn...@hotmail.com, Gchat: jgrn307, Skype: jgrn3007

__
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] Ignore escape characters in a string...

2014-04-08 Thread Jonathan Greenberg
R-helpers:

One of the minor irritations I have is copying paths from Windows
explorer, which look like:

C:\Program Files\R\R-3.0.3

and using them in a setwd() statement, since the \ is, of course,
interpreted as an escape character.  I have to, at present, manually
add in the double slashes or reverse them.

So, I'd like to write a quick function that takes this path:

winpath - C:\Program Files\R\R-3.0.3

and converts it to a ready-to-go R path -- is there a way to have R
IGNORE escape characters in a character vector?

Alternatively, is there some trick to using a copy/paste from Windows
explorer I'm not aware of?

--j



-- 
Jonathan A. Greenberg, PhD
Assistant Professor
Global Environmental Analysis and Remote Sensing (GEARS) Laboratory
Department of Geography and Geographic Information Science
University of Illinois at Urbana-Champaign
259 Computing Applications Building, MC-150
605 East Springfield Avenue
Champaign, IL  61820-6371
Phone: 217-300-1924
http://www.geog.illinois.edu/~jgrn/
AIM: jgrn307, MSN: jgrn...@hotmail.com, Gchat: jgrn307, Skype: jgrn3007

__
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] numeric to factor via lookup table

2014-03-28 Thread Jonathan Greenberg
R-helpers:

Hopefully this is an easy one.  Given a lookup table:

mylevels - data.frame(ID=1:10,code=letters[1:10])

And a set of values (note these do not completely cover the mylevels range):

values - c(1,2,5,5,10)

How do I convert values to a factor object, using the mylevels to
define the correct levels (ID matches the values), and code is the
label?

--j

-- 
Jonathan A. Greenberg, PhD
Assistant Professor
Global Environmental Analysis and Remote Sensing (GEARS) Laboratory
Department of Geography and Geographic Information Science
University of Illinois at Urbana-Champaign
259 Computing Applications Building, MC-150
605 East Springfield Avenue
Champaign, IL  61820-6371
Phone: 217-300-1924
http://www.geog.illinois.edu/~jgrn/
AIM: jgrn307, MSN: jgrn...@hotmail.com, Gchat: jgrn307, Skype: jgrn3007

__
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] Overriding predict based on newdata...

2014-03-18 Thread Jonathan Greenberg
David:

Thanks!  Is it generally frowned upon (if I'm Incorporating this into
a package) to override a generic function like predict, even if I
plan on making it a pass-through function (same parameters, and if the
data type doesn't match my weird data type, it will simply pass the
parameters through to the generic S3 predict)?

--j

On Mon, Mar 17, 2014 at 4:08 AM, David Winsemius dwinsem...@comcast.net wrote:
 S3 classes only dispatch on the basis of the first parameter class. That was 
 one of the reasons for the development of S4-classed objects. You say you 
 have the expectation that the object is of a class that has an ordinary 
 `predict` method presumably S3 in character,  so you probably need to write a 
 function that will mask the existing method. You would rewrite the existing 
 test for the existence of 'newdata' and the the definition of the new 
 function would persist through the rest of the session and could be 
 source()-ed in further sessions.

 --
 David.


 On Mar 16, 2014, at 2:09 PM, Jonathan Greenberg wrote:

 R-helpers:

 I'm having some trouble with this one -- I figure because I'm a bit of
 a noob with S3 classes...  Here's my challenge: I want to write a
 custom predict statement that is triggered based on the presence and
 class of a *newdata* parameter (not the object parameter).  The
 reason is I am trying to write a custom function based on an oddly
 formatted dataset that has been assigned an R class.  If the predict
 function detects it (class(newdata) == myweirdformat) it does a
 conversion of the newdata to what most predict statements expect (e.g.
 a dataframe) and then passes the converted dataset along to the
 generic predict statement.  If newdata is missing or is not of the odd
 class it should just pass everything along to the generic predict as
 usual.

 What would be the best way to approach this problem?  Since (my
 understanding) is that predict is dispatched based on the object
 parameter, this is causing me confusion -- my object should still
 remain the model, I'm just allowing a new data type to be fed into the
 predict model(s).

 Cheers!

 --j

 --
 Jonathan A. Greenberg, PhD
 Assistant Professor
 Global Environmental Analysis and Remote Sensing (GEARS) Laboratory
 Department of Geography and Geographic Information Science
 University of Illinois at Urbana-Champaign
 259 Computing Applications Building, MC-150
 605 East Springfield Avenue
 Champaign, IL  61820-6371
 Phone: 217-300-1924
 http://www.geog.illinois.edu/~jgrn/
 AIM: jgrn307, MSN: jgrn...@hotmail.com, Gchat: jgrn307, Skype: jgrn3007

 __
 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




-- 
Jonathan A. Greenberg, PhD
Assistant Professor
Global Environmental Analysis and Remote Sensing (GEARS) Laboratory
Department of Geography and Geographic Information Science
University of Illinois at Urbana-Champaign
259 Computing Applications Building, MC-150
605 East Springfield Avenue
Champaign, IL  61820-6371
Phone: 217-300-1924
http://www.geog.illinois.edu/~jgrn/
AIM: jgrn307, MSN: jgrn...@hotmail.com, Gchat: jgrn307, Skype: jgrn3007

__
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] Overriding predict based on newdata...

2014-03-16 Thread Jonathan Greenberg
R-helpers:

I'm having some trouble with this one -- I figure because I'm a bit of
a noob with S3 classes...  Here's my challenge: I want to write a
custom predict statement that is triggered based on the presence and
class of a *newdata* parameter (not the object parameter).  The
reason is I am trying to write a custom function based on an oddly
formatted dataset that has been assigned an R class.  If the predict
function detects it (class(newdata) == myweirdformat) it does a
conversion of the newdata to what most predict statements expect (e.g.
a dataframe) and then passes the converted dataset along to the
generic predict statement.  If newdata is missing or is not of the odd
class it should just pass everything along to the generic predict as
usual.

What would be the best way to approach this problem?  Since (my
understanding) is that predict is dispatched based on the object
parameter, this is causing me confusion -- my object should still
remain the model, I'm just allowing a new data type to be fed into the
predict model(s).

Cheers!

--j

-- 
Jonathan A. Greenberg, PhD
Assistant Professor
Global Environmental Analysis and Remote Sensing (GEARS) Laboratory
Department of Geography and Geographic Information Science
University of Illinois at Urbana-Champaign
259 Computing Applications Building, MC-150
605 East Springfield Avenue
Champaign, IL  61820-6371
Phone: 217-300-1924
http://www.geog.illinois.edu/~jgrn/
AIM: jgrn307, MSN: jgrn...@hotmail.com, Gchat: jgrn307, Skype: jgrn3007

__
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] install packages from R-forge SVN

2014-02-26 Thread Jonathan Greenberg
R-helpers:

I was curious if anyone developed a package/approach to installing
packages directly from the R-forge SVN subsystem (rather than waiting
for it to build)?  I can, of course, SVN it command line but I was
hoping for an install.packages(svn://) sort of approach.  Cheers!

--j

-- 
Jonathan A. Greenberg, PhD
Assistant Professor
Global Environmental Analysis and Remote Sensing (GEARS) Laboratory
Department of Geography and Geographic Information Science
University of Illinois at Urbana-Champaign
259 Computing Applications Building, MC-150
605 East Springfield Avenue
Champaign, IL  61820-6371
Phone: 217-300-1924
http://www.geog.illinois.edu/~jgrn/
AIM: jgrn307, MSN: jgrn...@hotmail.com, Gchat: jgrn307, Skype: jgrn3007

__
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] Checking for and adding ... arguments to a function...

2014-02-17 Thread Jonathan Greenberg
R-helpers:

I'm guessing this is an easy one for some of you, but I'm a bit
stumped.  Given some arbitrary function (doesn't matter what it does):

myfunction - function(a,b,c)
{
return(a+b+c)
}

I want to test this function for the presence of the ellipses (...)
and, if they are missing, create a new function that has them:

myfunction - function(a,b,c,...)
{
return(a+b+c)
}

So, 1) how do I test for whether a function has an ellipses argument
and, 2) how do I append the ellipses to the argument list if they do
exist?

Note that the test/modification should be done without invoking the
function, e.g. I'm not asking how to test for this WITHIN the
function, I'm asking how to test myfunction directly as an R object.

Thanks!

--j


-- 
Jonathan A. Greenberg, PhD
Assistant Professor
Global Environmental Analysis and Remote Sensing (GEARS) Laboratory
Department of Geography and Geographic Information Science
University of Illinois at Urbana-Champaign
259 Computing Applications Building, MC-150
605 East Springfield Avenue
Champaign, IL  61820-6371
Phone: 217-300-1924
http://www.geog.illinois.edu/~jgrn/
AIM: jgrn307, MSN: jgrn...@hotmail.com, Gchat: jgrn307, Skype: jgrn3007

__
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] Official way to set/retrieve options in packages?

2013-10-18 Thread Jonathan Greenberg
Wanted to re-start this thread a bit, since I'm still not exactly sure
the best approach to my problem -- basically, the parameters I'm try
to make persistent are installation locations of a particular command
line program that is not installed along with an R package I'm working
on (GDAL, for those of you who are interested in the specifics).  The
function tries to dummy-proof this process by doing a (mostly)
brute-force search of the user's drive for the program location the
first time it executes, and then stores this information (the path to
a given executable) in an option for use with other functions.   This
search process can take some time, so I'd prefer to have this option
set in a semi-permanent way (so it persists between sessions).

Now, Brian Ripley suggested modifying the .Rprofile, but Bert Guntner
suggested this might not be a welcome behavior.  Given that, on an
operating system level, there are often per-program directories for
preferences, would it follow that it might make sense to store
package-options in some standardized location?  If so, where might
this be?  Would it make sense to drop then in the package directory?

Is this a discussion that should move over to r-developers?

--j

On Sat, Jun 1, 2013 at 4:57 PM, Prof Brian Ripley rip...@stats.ox.ac.uk wrote:
 On 01/06/2013 22:44, Anthony Damico wrote:
 hope this helps..  :)

  # define an object `x`
  x - list( any value here , 10 )

  # set `myoption` to that object
  options( myoption = x )

  # retrieve it later (perhaps within a function elsewhere in the package)
  ( y - getOption( myoption ) )


 it's nice to name your options `mypackage.myoption` so users know what
 package the option is associated with in case they type `options()`


 here's the `.onLoad` function in the R survey package.  notice how the
 options are only set *if* they don't already exist--

 But a nicer convention is that used by most packages in R itself: if the
 option is not set, the function using it assumes a suitable default.
 That would make sense for all the FALSE defaults below.

 Note though that this is not 'persistent': users have to set options in
 their startup files (see ?Startup).   There is no official location to
 store package configurations.  Users generally dislike software saving
 settings in their own file space so it seems very much preferable to use
 the standard R mechanisms (.Rprofile etc).


 survey:::.onLoad

 function (...)
 {
  if (is.null(getOption(survey.lonely.psu)))
 options(survey.lonely.psu = fail)
  if (is.null(getOption(survey.ultimate.cluster)))
 options(survey.ultimate.cluster = FALSE)
  if (is.null(getOption(survey.want.obsolete)))
 options(survey.want.obsolete = FALSE)
  if (is.null(getOption(survey.adjust.domain.lonely)))
 options(survey.adjust.domain.lonely = FALSE)
  if (is.null(getOption(survey.drop.replicates)))
 options(survey.drop.replicates = TRUE)
  if (is.null(getOption(survey.multicore)))
 options(survey.multicore = FALSE)
  if (is.null(getOption(survey.replicates.mse)))
 options(survey.replicates.mse = FALSE)
 }
 environment: namespace:survey




 On Sat, Jun 1, 2013 at 4:01 PM, Jonathan Greenberg j...@illinois.eduwrote:

 R-helpers:

 Say I'm developing a package that has a set of user-definable options that
 I would like to be persistent across R-invocations (they are saved
 someplace).  Of course, I can create a little text file to be written/read,
 but I was wondering if there is an officially sanctioned way to do this?
   I see there is an options() and getOptions() function, but I'm unclear how
 I would use this in my own package to create/save new options for my
 particular package.  Cheers!

 --j

 --
 Jonathan A. Greenberg, PhD
 Assistant Professor
 Global Environmental Analysis and Remote Sensing (GEARS) Laboratory
 Department of Geography and Geographic Information Science
 University of Illinois at Urbana-Champaign
 607 South Mathews Avenue, MC 150
 Urbana, IL 61801
 Phone: 217-300-1924
 http://www.geog.illinois.edu/~jgrn/
 AIM: jgrn307, MSN: jgrn...@hotmail.com, Gchat: jgrn307, Skype: jgrn3007

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


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



 --
 Brian D. Ripley,  rip...@stats.ox.ac.uk
 Professor of Applied Statistics,  http://www.stats.ox.ac.uk/~ripley/
 University of Oxford, Tel:  +44 1865 272861 (self)
 1 South Parks

Re: [R] Error: C stack usage is too close to the limit when using list.files()

2013-09-28 Thread Jonathan Greenberg
Thanks all -- ok, so the symbolic link issue is a distinct
possibility, but fundamentally doesn't solve the issue since most
users will have symbolic links on their machines SOMEPLACE, so a full
drive scan will run into these issues --  is list.files calling find,
or is it using a different algorithm?  This seems like a shortcoming
in the list.files algorithm -- is there a better solution (short of a
System call, which I'm still not sure will work on Macs without Xcode
-- a colleague of mine did NOT have Xcode, and reported not being able
to run find from the command line) -- perhaps a different package?

--j

On Fri, Sep 27, 2013 at 3:08 PM, William Dunlap wdun...@tibco.com wrote:
 Toss a couple of extra files in there and you will see the output grow 
 exponentially.

 % touch dir/IMPORTANT_1 dir/subdir/IMPORTANT_2

 and in R those two new files cause 82 more strings to appear in list.file's 
 output:

 nchar(list.files(dir, recursive=TRUE))
  [1]  11  18  33  40  55  62  77  84  99 106 121 128 143 150 165 172 187 194 
 209
 [20] 216 231 238 253 260 275 282 297 304 319 326 341 348 363 370 385 392 407 
 414
 [39] 429 436 451 458 473 480 495 502 517 524 539 546 561 568 583 590 605 612 
 627
 [58] 634 649 656 671 678 693 700 715 722 737 744 759 766 781 788 803 810 825 
 832
 [77] 847 854 869 876 891 898 901

 'find', by default, does not following symbolic links.

 % find dir
 dir
 dir/subdir
 dir/subdir/IMPORTANT_2
 dir/subdir/linkToUpperDir
 dir/IMPORTANT_1

 The -L option makes it follow them, but it won't follow loops:

 % find -L dir
 dir
 dir/subdir
 dir/subdir/IMPORTANT_2
 find: File system loop detected; `dir/subdir/linkToUpperDir' is part of the 
 same file system loop as `dir'.
 dir/IMPORTANT_1

 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 William Dunlap
 Sent: Friday, September 27, 2013 12:56 PM
 To: Jonathan Greenberg; r-help
 Subject: Re: [R] Error: C stack usage is too close to the limit when using 
 list.files()

 Do you have some symbolic links that make loops in your file system?
 list.files() has problems with such loops and find does not.  E.g.,  on a 
 Linux box:

 % cd /tmp
 % mkdir dir dir/subdir
 % cd dir/subdir
 % ln -s ../../dir linkToUpperDir
 % cd /tmp
 % R --quiet
  list.files(dir, recursive=TRUE, full=TRUE)
 [1]
 dir/subdir/linkToUpperDir/subdir/linkToUpperDir/subdir/linkToUpperDir/subdir/linkToU
 pperDir/subdir/linkToUpperDir/subdir/linkToUpperDir/subdir/linkToUpperDir/subdir/linkT
 oUpperDir/subdir/linkToUpperDir/subdir/linkToUpperDir/subdir/linkToUpperDir/subdir/li
 nkToUpperDir/subdir/linkToUpperDir/subdir/linkToUpperDir/subdir/linkToUpperDir/subdi
 r/linkToUpperDir/subdir/linkToUpperDir/subdir/linkToUpperDir/subdir/linkToUpperDir/su
 bdir/linkToUpperDir/subdir/linkToUpperDir/subdir/linkToUpperDir/subdir/linkToUpperDir
 /subdir/linkToUpperDir/subdir/linkToUpperDir/subdir/linkToUpperDir/subdir/linkToUpper
 Dir/subdir/linkToUpperDir/subdir/linkToUpperDir/subdir/linkToUpperDir/subdir/linkToUp
 perDir/subdir/linkToUpperDir/subdir/linkToUpperDir/subdir/linkToUpperDir/subdir/linkTo
 UpperDir/subdir/linkToUpperDir/subdir/linkToUpperDir/subdir/linkToUpperDir/subdir/lin
 kToUpperDir/subdir/linkToUpperDir/subdir/linkToUpperDir
  system(find dir)
 dir
 dir/subdir
 dir/subdir/linkToUpperDir

 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 Jonathan Greenberg
  Sent: Friday, September 27, 2013 12:13 PM
  To: r-help
  Subject: [R] Error: C stack usage is too close to the limit when using 
  list.files()
 
  R-helpers:
 
  I'm running a file search on my entire drive (Mac OS X) using:
 
  files_found - 
  list.files(dir=/,pattern=somepattern,recursive=TRUE,full.names=TRUE)
  where somepattern is a search pattern (which I have confirmed via a
  unix find / -name somepattern only returns ~ 3 results).
 
  I keep getting an error:
 
  Error: C stack usage is too close to the limit
 
  when running this command.  Any ideas on 1) how to fix this or 2) if
  there is an alternative to using list.files() to accomplish this
  search without resorting to an external package?
 
  Cheers!
 
  --jonathan
 
 
  --
  Jonathan A. Greenberg, PhD
  Assistant Professor
  Global Environmental Analysis and Remote Sensing (GEARS) Laboratory
  Department of Geography and Geographic Information Science
  University of Illinois at Urbana-Champaign
  259 Computing Applications Building, MC-150
  605 East Springfield Avenue
  Champaign, IL  61820-6371
  Phone: 217-300-1924
  http://www.geog.illinois.edu/~jgrn/
  AIM: jgrn307, MSN: jgrn...@hotmail.com, Gchat: jgrn307, Skype: jgrn3007
 
  __
  R-help@r-project.org mailing list
  https://stat.ethz.ch/mailman/listinfo/r-help
  PLEASE do read the posting guide

[R] Error: C stack usage is too close to the limit when using list.files()

2013-09-27 Thread Jonathan Greenberg
R-helpers:

I'm running a file search on my entire drive (Mac OS X) using:

files_found - 
list.files(dir=/,pattern=somepattern,recursive=TRUE,full.names=TRUE)
where somepattern is a search pattern (which I have confirmed via a
unix find / -name somepattern only returns ~ 3 results).

I keep getting an error:

Error: C stack usage is too close to the limit

when running this command.  Any ideas on 1) how to fix this or 2) if
there is an alternative to using list.files() to accomplish this
search without resorting to an external package?

Cheers!

--jonathan


-- 
Jonathan A. Greenberg, PhD
Assistant Professor
Global Environmental Analysis and Remote Sensing (GEARS) Laboratory
Department of Geography and Geographic Information Science
University of Illinois at Urbana-Champaign
259 Computing Applications Building, MC-150
605 East Springfield Avenue
Champaign, IL  61820-6371
Phone: 217-300-1924
http://www.geog.illinois.edu/~jgrn/
AIM: jgrn307, MSN: jgrn...@hotmail.com, Gchat: jgrn307, Skype: jgrn3007

__
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] Error: C stack usage is too close to the limit when using list.files()

2013-09-27 Thread Jonathan Greenberg
Ben:

I'd like to avoid using that (previous version of my code solved it in
that way) -- I would like cross-platform compatibility and I am pretty
sure, along with Windows, vanilla Macs don't come with find either
unless XCode has been installed.

Is the list.files() code itself recursive when using recursive=TRUE
(so it has one recursion per bottom-folder)?

--j

P.S. I recognized that in my initial post I indicated using dir as
the parameter -- it should have been path (the error occurred
through the correct usage of list.files(path=/,...)   That'll teach
me not to copy/paste from my code...

On Fri, Sep 27, 2013 at 2:36 PM, Ben Bolker bbol...@gmail.com wrote:
 Jonathan Greenberg jgrn at illinois.edu writes:


 R-helpers:

 I'm running a file search on my entire drive (Mac OS X) using:

 files_found -
 list.files(dir=/,pattern=somepattern,recursive=TRUE,full.names=TRUE)
 where somepattern is a search pattern (which I have confirmed via a
 unix find / -name somepattern only returns ~ 3 results).

 I keep getting an error:

 Error: C stack usage is too close to the limit

 when running this command.  Any ideas on 1) how to fix this or 2) if
 there is an alternative to using list.files() to accomplish this
 search without resorting to an external package?

   I assuming that using

 system(find / -name somepattern)

 (possibly with intern=TRUE) isn't allowed?  (I don't know what you're
 trying to do, but if you don't need it to work on Windows-without-cygwin,
 this should work across most Unix variants (although a -print might
 be required)

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



-- 
Jonathan A. Greenberg, PhD
Assistant Professor
Global Environmental Analysis and Remote Sensing (GEARS) Laboratory
Department of Geography and Geographic Information Science
University of Illinois at Urbana-Champaign
259 Computing Applications Building, MC-150
605 East Springfield Avenue
Champaign, IL  61820-6371
Phone: 217-300-1924
http://www.geog.illinois.edu/~jgrn/
AIM: jgrn307, MSN: jgrn...@hotmail.com, Gchat: jgrn307, Skype: jgrn3007

__
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] library() and install.packages() no longer working (Access is denied error)

2013-09-13 Thread Jonathan Greenberg
In the last week, SOMETHING on my system must have changed because
when trying to library() or install.packages() on R 3.0.1 x64 on a
Windows 2008 R2 server:

 library(raster)
Error in normalizePath(path.expand(path), winslash, mustWork) :
  path[1]=D:/Users/[UID]/Documents/R/win-library/3.0: Access is denied

 install.packages(raster)
Installing package into ‘D:/Users/[UID]/Documents/R/win-library/3.0’
(as ‘lib’ is unspecified)
trying URL 
'http://ftp.osuosl.org/pub/cran/bin/windows/contrib/3.0/raster_2.1-49.zip'
Content type 'application/zip' length 2363295 bytes (2.3 Mb)
opened URL
downloaded 2.3 Mb

Error in normalizePath(path.expand(path), winslash, mustWork) :
  path[1]=D:\Users\[UID]\Documents\R\win-library\3.0: Access is denied
In addition: Warning message:
In normalizePath(path.expand(path), winslash, mustWork) :
  path[1]=D:/Users/[UID]/Documents/R/win-library/3.0: Access is denied

The permissions on that directory APPEAR to be correct (I can add
files/folders, rename them, delete them), but alas R continues to give
me these errors.  Both the users and the sysadmin claim nothing was
changed, but clearly something did.

As a heads up, I did try removing PATHTO/win-library/3.0, and re-ran
the install.packages(raster), at which point R asked me Would you
like to use a personal directory instead?.  I clicked yes.  It then
asks me Would you like to create a personal library
'D:/Users/[UID]/Documents/R/win-library/3.0' to install packages into?
 I clicked yes.  The Mirror browser shows up, I select a mirror.  A
3.0 directory is created, but I got the same error, and when examining
the (new) 3.0 directory, nothing is created inside of it.

Any ideas what this could be caused by?

--j

-- 
Jonathan A. Greenberg, PhD
Assistant Professor
Global Environmental Analysis and Remote Sensing (GEARS) Laboratory
Department of Geography and Geographic Information Science
University of Illinois at Urbana-Champaign
607 South Mathews Avenue, MC 150
Urbana, IL 61801
Phone: 217-300-1924
http://www.geog.illinois.edu/~jgrn/
AIM: jgrn307, MSN: jgrn...@hotmail.com, Gchat: jgrn307, Skype: jgrn3007

__
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] ifelse question (I'm not sure why this is working)...

2013-09-10 Thread Jonathan Greenberg
R-helpers:

One of my intrepid students came up with a solution to a problem where
they need to write a function that takes a vector x and a scalar d,
and return the indices of the vector x where x %% d is equal to 0 (x
is evenly divisible by d).  I thought I had a good handle on the
potential solutions, but one of my students sent me a function that
WORKS, but for the life of me I can't figure out WHY.  Here is the
solution:

remainderFunction-function(x,d)
{
   ifelse(x%%d==0,yes=return(which(x%%d==0)),no=return(NULL))
}
remainderFunction(x=c(23:47),d=3)

I've never seen an ifelse statement used that way, and I was fully
expecting that to NOT work, or to place the output of which(x%%d==0)
in each location where the statement x%%d==0 was true.

Any ideas on deconstructing this?

--j

-- 
Jonathan A. Greenberg, PhD
Assistant Professor
Global Environmental Analysis and Remote Sensing (GEARS) Laboratory
Department of Geography and Geographic Information Science
University of Illinois at Urbana-Champaign
607 South Mathews Avenue, MC 150
Urbana, IL 61801
Phone: 217-300-1924
http://www.geog.illinois.edu/~jgrn/
AIM: jgrn307, MSN: jgrn...@hotmail.com, Gchat: jgrn307, Skype: jgrn3007

__
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] Vectorized version of colMeans/rowMeans for higher dimension arrays?

2013-08-29 Thread Jonathan Greenberg
For matrices, colMeans/rowMeans are quick, vectorized functions.  But
say I have a higher dimensional array:

moo - array(runif(400*9*3),dim=c(400,9,3))

And I want to get the mean along the 2nd dimension.  I can, of course,
use apply:

moo1 - apply(moo,c(1,3),mean)

But this is not a vectorized operation (so it doesn't execute as
quickly).  How would one vectorize this operation (if possible)?  Is
there an array equivalent of colMeans/rowMeans?

--j

-- 
Jonathan A. Greenberg, PhD
Assistant Professor
Global Environmental Analysis and Remote Sensing (GEARS) Laboratory
Department of Geography and Geographic Information Science
University of Illinois at Urbana-Champaign
607 South Mathews Avenue, MC 150
Urbana, IL 61801
Phone: 217-300-1924
http://www.geog.illinois.edu/~jgrn/
AIM: jgrn307, MSN: jgrn...@hotmail.com, Gchat: jgrn307, Skype: jgrn3007

__
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] Determining the maximum memory usage of a function

2013-06-20 Thread Jonathan Greenberg
Folks:

I apologize for the cross-posting between r-help and r-sig-hpc, but I
figured this question was relevant to both lists.  I'm writing a
function to be applied to an input dataset that will be broken up into
chunks for memory management reasons and for parallel execution.  I am
trying to determine, for a given function, what the *maximum* memory
usage during its execution is (which may not be the beginning or the
end of the function, but somewhere in the middle), so I can plan for
the chunk size (e.g. have a table of chunk size vs. max memory usage).

Is there a trick for determining this?

--j

--
Jonathan A. Greenberg, PhD
Assistant Professor
Global Environmental Analysis and Remote Sensing (GEARS) Laboratory
Department of Geography and Geographic Information Science
University of Illinois at Urbana-Champaign
607 South Mathews Avenue, MC 150
Urbana, IL 61801
Phone: 217-300-1924
http://www.geog.illinois.edu/~jgrn/
AIM: jgrn307, MSN: jgrn...@hotmail.com, Gchat: jgrn307, Skype: jgrn3007

__
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] Determining the maximum memory usage of a function

2013-06-20 Thread Jonathan Greenberg
Jim:

Thanks, but I'm looking for something that can be used somewhat
automatically -- the function in question would be user-provided and
passed to my chunking algorithm, so in this case it would be the
end-user (not me) who would have to embed these -- would
Rprof(memory.profiling=TRUE)
# my function
Rprof(NULL)
... and then taking the max of the tseries output be a reasonable
approach?  If so, which of the three outputs (vsize.small vsize.large
  nodes) would be best compared against the available memory?

Cheers!

--j

On Thu, Jun 20, 2013 at 10:07 AM, jim holtman jholt...@gmail.com wrote:
 What I would do is to use memory.size() to get the amount of memory being
 used.  Do a call at the beginning of the function to determine the base, and
 then at other points in the code to see what the difference from the base is
 and keep track of the maximum difference.  I am not sure if just getting the
 memory usage at the end would be sufficient since there may be some garbage
 collection in between, or you might be creating some large objects and then
 deleting/reusing them.  So keep track after large chunks of code to see what
 is happening.


 On Thu, Jun 20, 2013 at 10:45 AM, Jonathan Greenberg j...@illinois.edu
 wrote:

 Folks:

 I apologize for the cross-posting between r-help and r-sig-hpc, but I
 figured this question was relevant to both lists.  I'm writing a
 function to be applied to an input dataset that will be broken up into
 chunks for memory management reasons and for parallel execution.  I am
 trying to determine, for a given function, what the *maximum* memory
 usage during its execution is (which may not be the beginning or the
 end of the function, but somewhere in the middle), so I can plan for
 the chunk size (e.g. have a table of chunk size vs. max memory usage).

 Is there a trick for determining this?

 --j

 --
 Jonathan A. Greenberg, PhD
 Assistant Professor
 Global Environmental Analysis and Remote Sensing (GEARS) Laboratory
 Department of Geography and Geographic Information Science
 University of Illinois at Urbana-Champaign
 607 South Mathews Avenue, MC 150
 Urbana, IL 61801
 Phone: 217-300-1924
 http://www.geog.illinois.edu/~jgrn/
 AIM: jgrn307, MSN: jgrn...@hotmail.com, Gchat: jgrn307, Skype: jgrn3007

 __
 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
 Data Munger Guru

 What is the problem that you are trying to solve?
 Tell me what you want to do, not how you want to do it.



-- 
Jonathan A. Greenberg, PhD
Assistant Professor
Global Environmental Analysis and Remote Sensing (GEARS) Laboratory
Department of Geography and Geographic Information Science
University of Illinois at Urbana-Champaign
607 South Mathews Avenue, MC 150
Urbana, IL 61801
Phone: 217-300-1924
http://www.geog.illinois.edu/~jgrn/
AIM: jgrn307, MSN: jgrn...@hotmail.com, Gchat: jgrn307, Skype: jgrn3007

__
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] Official way to set/retrieve options in packages?

2013-06-02 Thread Jonathan Greenberg
What would be an example of setting, saving, and re-loading an option to a
user's .Rprofile -- and would this be a no-no in a CRAN package?

--j


On Sat, Jun 1, 2013 at 4:57 PM, Prof Brian Ripley rip...@stats.ox.ac.ukwrote:

 On 01/06/2013 22:44, Anthony Damico wrote:
  hope this helps..  :)
 
   # define an object `x`
   x - list( any value here , 10 )
 
   # set `myoption` to that object
   options( myoption = x )
 
   # retrieve it later (perhaps within a function elsewhere in the
 package)
   ( y - getOption( myoption ) )
 
 
  it's nice to name your options `mypackage.myoption` so users know what
  package the option is associated with in case they type `options()`
 
 
  here's the `.onLoad` function in the R survey package.  notice how the
  options are only set *if* they don't already exist--

 But a nicer convention is that used by most packages in R itself: if the
 option is not set, the function using it assumes a suitable default.
 That would make sense for all the FALSE defaults below.

 Note though that this is not 'persistent': users have to set options in
 their startup files (see ?Startup).   There is no official location to
 store package configurations.  Users generally dislike software saving
 settings in their own file space so it seems very much preferable to use
 the standard R mechanisms (.Rprofile etc).

 
  survey:::.onLoad
 
  function (...)
  {
   if (is.null(getOption(survey.lonely.psu)))
  options(survey.lonely.psu = fail)
   if (is.null(getOption(survey.ultimate.cluster)))
  options(survey.ultimate.cluster = FALSE)
   if (is.null(getOption(survey.want.obsolete)))
  options(survey.want.obsolete = FALSE)
   if (is.null(getOption(survey.adjust.domain.lonely)))
  options(survey.adjust.domain.lonely = FALSE)
   if (is.null(getOption(survey.drop.replicates)))
  options(survey.drop.replicates = TRUE)
   if (is.null(getOption(survey.multicore)))
  options(survey.multicore = FALSE)
   if (is.null(getOption(survey.replicates.mse)))
  options(survey.replicates.mse = FALSE)
  }
  environment: namespace:survey
 
 
 
 
  On Sat, Jun 1, 2013 at 4:01 PM, Jonathan Greenberg j...@illinois.edu
 wrote:
 
  R-helpers:
 
  Say I'm developing a package that has a set of user-definable options
 that
  I would like to be persistent across R-invocations (they are saved
  someplace).  Of course, I can create a little text file to be
 written/read,
  but I was wondering if there is an officially sanctioned way to do
 this?
I see there is an options() and getOptions() function, but I'm
 unclear how
  I would use this in my own package to create/save new options for my
  particular package.  Cheers!
 
  --j
 
  --
  Jonathan A. Greenberg, PhD
  Assistant Professor
  Global Environmental Analysis and Remote Sensing (GEARS) Laboratory
  Department of Geography and Geographic Information Science
  University of Illinois at Urbana-Champaign
  607 South Mathews Avenue, MC 150
  Urbana, IL 61801
  Phone: 217-300-1924
  http://www.geog.illinois.edu/~jgrn/
  AIM: jgrn307, MSN: jgrn...@hotmail.com, Gchat: jgrn307, Skype: jgrn3007
 
   [[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.
 
 
[[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.
 


 --
 Brian D. Ripley,  rip...@stats.ox.ac.uk
 Professor of Applied Statistics,  http://www.stats.ox.ac.uk/~ripley/
 University of Oxford, Tel:  +44 1865 272861 (self)
 1 South Parks Road, +44 1865 272866 (PA)
 Oxford OX1 3TG, UKFax:  +44 1865 272595




-- 
Jonathan A. Greenberg, PhD
Assistant Professor
Global Environmental Analysis and Remote Sensing (GEARS) Laboratory
Department of Geography and Geographic Information Science
University of Illinois at Urbana-Champaign
607 South Mathews Avenue, MC 150
Urbana, IL 61801
Phone: 217-300-1924
http://www.geog.illinois.edu/~jgrn/
AIM: jgrn307, MSN: jgrn...@hotmail.com, Gchat: jgrn307, Skype: jgrn3007

[[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] Official way to set/retrieve options in packages?

2013-06-01 Thread Jonathan Greenberg
R-helpers:

Say I'm developing a package that has a set of user-definable options that
I would like to be persistent across R-invocations (they are saved
someplace).  Of course, I can create a little text file to be written/read,
but I was wondering if there is an officially sanctioned way to do this?
 I see there is an options() and getOptions() function, but I'm unclear how
I would use this in my own package to create/save new options for my
particular package.  Cheers!

--j

-- 
Jonathan A. Greenberg, PhD
Assistant Professor
Global Environmental Analysis and Remote Sensing (GEARS) Laboratory
Department of Geography and Geographic Information Science
University of Illinois at Urbana-Champaign
607 South Mathews Avenue, MC 150
Urbana, IL 61801
Phone: 217-300-1924
http://www.geog.illinois.edu/~jgrn/
AIM: jgrn307, MSN: jgrn...@hotmail.com, Gchat: jgrn307, Skype: jgrn3007

[[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] RCurl: using ls instead of NLST

2013-05-29 Thread Jonathan Greenberg
R-helpers:

I'm trying to retrieve the contents of a directory from an ftp site
(ideally, the file/folder names as a character vector):
ftp://e4ftl01.cr.usgs.gov/MOTA/MCD12C1.005/;
# (MODIS data)

Where I get the following error via RCurl:
require(RCurl)
url - ftp://e4ftl01.cr.usgs.gov/MOTA/MCD12C1.005/;
filenames = getURL(url,ftp.use.epsv=FALSE,ftplistonly=TRUE)
 Error in function (type, msg, asError = TRUE)  : RETR response: 550

Through some sleuthing, it turns out the ftp site does not support NLST
(which RCurl is using), but will use ls to list the directory contents --
is there any way to use ls remotely on this site?  Thanks!

--j

-- 
Jonathan A. Greenberg, PhD
Assistant Professor
Global Environmental Analysis and Remote Sensing (GEARS) Laboratory
Department of Geography and Geographic Information Science
University of Illinois at Urbana-Champaign
607 South Mathews Avenue, MC 150
Urbana, IL 61801
Phone: 217-300-1924
http://www.geog.illinois.edu/~jgrn/
AIM: jgrn307, MSN: jgrn...@hotmail.com, Gchat: jgrn307, Skype: jgrn3007

[[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] Singular design matrix in rq

2013-04-19 Thread Jonathan Greenberg
Roger:

Doh!  Just realized I had that error in the code -- raw_data is the same as
mydata, so it should be:

mydata - read.csv(singular.csv)
plot(mydata$predictor,mydata$response)
# A big cloud of points, nothing too weird
summary(mydata)
# No NAs:

#   Xresponse predictor
# Min.   :1   Min.   :0.0   Min.   : 0.000
# 1st Qu.:12726   1st Qu.:  851.2   1st Qu.: 0.000
# Median :25452   Median : 2737.0   Median : 0.000
# Mean   :25452   Mean   : 3478.0   Mean   : 5.532
# 3rd Qu.:38178   3rd Qu.: 5111.6   3rd Qu.: 5.652
# Max.   :50903   Max.   :26677.8   Max.   :69.342

fit_spl - rq(response ~ bs(predictor,df=15),tau=1,data=mydata)
# Error in rq.fit.br(x, y, tau = tau, ...) : Singular design matrix

--j



On Fri, Apr 19, 2013 at 8:15 AM, Koenker, Roger W rkoen...@illinois.eduwrote:

 Jonathan,

 This is not what we call a reproducible example... what is raw_data?  Does
 it have something to do with mydata?
 what is i?

 Roger

 url:www.econ.uiuc.edu/~rogerRoger Koenker
 emailrkoen...@uiuc.eduDepartment of Economics
 vox: 217-333-4558University of Illinois
 fax:   217-244-6678Urbana, IL 61801

 On Apr 16, 2013, at 2:58 PM, Greenberg, Jonathan wrote:

  Quantreggers:
 
  I'm trying to run rq() on a dataset I posted at:
 
 https://docs.google.com/file/d/0B8Kij67bij_ASUpfcmJ4LTFEUUk/edit?usp=sharing
  (it's a 1500kb csv file named singular.csv) and am getting the
 following error:
 
  mydata - read.csv(singular.csv)
  fit_spl - rq(raw_data[,1] ~ bs(raw_data[,i],df=15),tau=1)
   Error in rq.fit.br(x, y, tau = tau, ...) : Singular design matrix
 
  Any ideas what might be causing this or, more importantly, suggestions
 for how to solve this?  I'm just trying to fit a smoothed hull to the top
 of the data cloud (hence the large df).
 
  Thanks!
 
  --jonathan
 
 
  --
  Jonathan A. Greenberg, PhD
  Assistant Professor
  Global Environmental Analysis and Remote Sensing (GEARS) Laboratory
  Department of Geography and Geographic Information Science
  University of Illinois at Urbana-Champaign
  607 South Mathews Avenue, MC 150
  Urbana, IL 61801
  Phone: 217-300-1924
  http://www.geog.illinois.edu/~jgrn/
  AIM: jgrn307, MSN: jgrn...@hotmail.com, Gchat: jgrn307, Skype: jgrn3007




-- 
Jonathan A. Greenberg, PhD
Assistant Professor
Global Environmental Analysis and Remote Sensing (GEARS) Laboratory
Department of Geography and Geographic Information Science
University of Illinois at Urbana-Champaign
607 South Mathews Avenue, MC 150
Urbana, IL 61801
Phone: 217-300-1924
http://www.geog.illinois.edu/~jgrn/
AIM: jgrn307, MSN: jgrn...@hotmail.com, Gchat: jgrn307, Skype: jgrn3007

[[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] Singular design matrix in rq

2013-04-16 Thread Jonathan Greenberg
Quantreggers:

I'm trying to run rq() on a dataset I posted at:
https://docs.google.com/file/d/0B8Kij67bij_ASUpfcmJ4LTFEUUk/edit?usp=sharing
(it's a 1500kb csv file named singular.csv) and am getting the following
error:

mydata - read.csv(singular.csv)
fit_spl - rq(raw_data[,1] ~ bs(raw_data[,i],df=15),tau=1)
 Error in rq.fit.br(x, y, tau = tau, ...) : Singular design matrix

Any ideas what might be causing this or, more importantly, suggestions for
how to solve this?  I'm just trying to fit a smoothed hull to the top of
the data cloud (hence the large df).

Thanks!

--jonathan


-- 
Jonathan A. Greenberg, PhD
Assistant Professor
Global Environmental Analysis and Remote Sensing (GEARS) Laboratory
Department of Geography and Geographic Information Science
University of Illinois at Urbana-Champaign
607 South Mathews Avenue, MC 150
Urbana, IL 61801
Phone: 217-300-1924
http://www.geog.illinois.edu/~jgrn/
AIM: jgrn307, MSN: jgrn...@hotmail.com, Gchat: jgrn307, Skype: jgrn3007

[[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] Check if a character vector can be coerced to numeric?

2013-03-21 Thread Jonathan Greenberg
Given an arbitrary set of character vectors:

myvect1 - c(abc,3,4)
myvect2 - c(2,3,4)

I would like to develop a function that will convert any vectors that can
be PROPERLY converted to a numeric (myvect2) into a numeric, but leaves
character vectors which cannot be converted (myvect1) alone.  Is there any
simple way to do this (e.g. some function that tests if a vector is
coercible to a numeric before doing so)?

--j

-- 
Jonathan A. Greenberg, PhD
Assistant Professor
Global Environmental Analysis and Remote Sensing (GEARS) Laboratory
Department of Geography and Geographic Information Science
University of Illinois at Urbana-Champaign
607 South Mathews Avenue, MC 150
Urbana, IL 61801
Phone: 217-300-1924
http://www.geog.illinois.edu/~jgrn/
AIM: jgrn307, MSN: jgrn...@hotmail.com, Gchat: jgrn307, Skype: jgrn3007

[[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] Check if a character vector can be coerced to numeric?

2013-03-21 Thread Jonathan Greenberg
Yep, type.convert was exactly what I was looking for (with as.is=TRUE).
 Thanks!


On Thu, Mar 21, 2013 at 1:31 PM, Prof Brian Ripley rip...@stats.ox.ac.ukwrote:

 On 21/03/2013 18:20, Jonathan Greenberg wrote:

 Given an arbitrary set of character vectors:

 myvect1 - c(abc,3,4)
 myvect2 - c(2,3,4)

 I would like to develop a function that will convert any vectors that can
 be PROPERLY converted to a numeric (myvect2) into a numeric, but leaves
 character vectors which cannot be converted (myvect1) alone.  Is there any
 simple way to do this (e.g. some function that tests if a vector is
 coercible to a numeric before doing so)?

 --j


 ?type.convert

 It does depend what you mean by 'properly'.  Can
 123.456789012344567890123455 be converted 'properly'?  [See the NEWS for
 R-devel.]

 --
 Brian D. Ripley,  rip...@stats.ox.ac.uk
 Professor of Applied Statistics,  
 http://www.stats.ox.ac.uk/~**ripley/http://www.stats.ox.ac.uk/~ripley/
 University of Oxford, Tel:  +44 1865 272861 (self)
 1 South Parks Road, +44 1865 272866 (PA)
 Oxford OX1 3TG, UKFax:  +44 1865 272595

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




-- 
Jonathan A. Greenberg, PhD
Assistant Professor
Global Environmental Analysis and Remote Sensing (GEARS) Laboratory
Department of Geography and Geographic Information Science
University of Illinois at Urbana-Champaign
607 South Mathews Avenue, MC 150
Urbana, IL 61801
Phone: 217-300-1924
http://www.geog.illinois.edu/~jgrn/
AIM: jgrn307, MSN: jgrn...@hotmail.com, Gchat: jgrn307, Skype: jgrn3007

[[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] Loading a list into the environment

2013-02-02 Thread Jonathan Greenberg
Thanks all!  list2env was exactly what I was looking for.  As an FYI (and
please correct me if I'm wrong), if you want to load a list into the
current environment, use:

myvariables - list(a=1:10,b=20)
loadenv - list2env(myvariables ,envir=environment())
a
b

--j


On Fri, Feb 1, 2013 at 5:49 PM, Rui Barradas ruipbarra...@sapo.pt wrote:

 Hello,

 Something like this?

 myfun - function(x, envir = .GlobalEnv){
 nm - names(x)
 for(i in seq_along(nm))
 assign(nm[i], x[[i]], envir)
 }

 myvariables - list(a=1:10,b=20)

 myfun(myvariables)
 a
 b


 Hope this helps,

 Rui Barradas

 Em 01-02-2013 22:24, Jonathan Greenberg escreveu:

  R-helpers:

 Say I have a list:

 myvariables - list(a=1:10,b=20)

 Is there a way to load the list components into the environment as
 variables based on the component names?  i.e. by applying this theoretical
 function to myvariables I would have the variables a and b loaded into the
 environment without having to explicitly define them.

 --j




-- 
Jonathan A. Greenberg, PhD
Assistant Professor
Global Environmental Analysis and Remote Sensing (GEARS) Laboratory
Department of Geography and Geographic Information Science
University of Illinois at Urbana-Champaign
607 South Mathews Avenue, MC 150
Urbana, IL 61801
Phone: 217-300-1924
http://www.geog.illinois.edu/~jgrn/
AIM: jgrn307, MSN: jgrn...@hotmail.com, Gchat: jgrn307, Skype: jgrn3007

[[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] Loading a list into the environment

2013-02-01 Thread Jonathan Greenberg
R-helpers:

Say I have a list:

myvariables - list(a=1:10,b=20)

Is there a way to load the list components into the environment as
variables based on the component names?  i.e. by applying this theoretical
function to myvariables I would have the variables a and b loaded into the
environment without having to explicitly define them.

--j

-- 
Jonathan A. Greenberg, PhD
Assistant Professor
Global Environmental Analysis and Remote Sensing (GEARS) Laboratory
Department of Geography and Geographic Information Science
University of Illinois at Urbana-Champaign
607 South Mathews Avenue, MC 150
Urbana, IL 61801
Phone: 217-300-1924
http://www.geog.illinois.edu/~jgrn/
AIM: jgrn307, MSN: jgrn...@hotmail.com, Gchat: jgrn307, Skype: jgrn3007

[[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] Adding a line to barchart

2013-01-23 Thread Jonathan Greenberg
Great!  This really helped!  One quick follow-up -- is there a trick to
placing a label wherever the line intersects the x-axis (either above or
below the plot)?


On Tue, Jan 22, 2013 at 11:49 PM, PIKAL Petr petr.pi...@precheza.cz wrote:

 Hi
 This function adds line to each panel

 addLine - function (a = NULL, b = NULL, v = NULL, h = NULL, ..., once = F)
 {
 tcL - trellis.currentLayout()
 k - 0
 for (i in 1:nrow(tcL)) for (j in 1:ncol(tcL)) if (tcL[i,
 j]  0) {
 k - k + 1
 trellis.focus(panel, j, i, highlight = FALSE)
 if (once)
 panel.abline(a = a[k], b = b[k], v = v[k], h = h[k],
 ...)
 else panel.abline(a = a, b = b, v = v, h = h, ...)
 trellis.unfocus()
 }
   }


 addLine(v=2, col=2, lty=3)

 Petr

  -Original Message-
  From: r-help-boun...@r-project.org [mailto:r-help-bounces@r-
  project.org] On Behalf Of Jonathan Greenberg
  Sent: Tuesday, January 22, 2013 11:42 PM
  To: r-help
  Subject: [R] Adding a line to barchart
 
  R-helpers:
 
  I need a quick help with the following graph (I'm a lattice newbie):
 
  require(lattice)
  npp=1:5
  names(npp)=c(A,B,C,D,E)
  barchart(npp,origin=0,box.width=1)
 
  # What I want to do, is add a single vertical line positioned at x = 2
  that lays over the bars (say, using a dotted line).  How do I go about
  doing this?
 
  --j
 
  --
  Jonathan A. Greenberg, PhD
  Assistant Professor
  Global Environmental Analysis and Remote Sensing (GEARS) Laboratory
  Department of Geography and Geographic Information Science University
  of Illinois at Urbana-Champaign
  607 South Mathews Avenue, MC 150
  Urbana, IL 61801
  Phone: 217-300-1924
  http://www.geog.illinois.edu/~jgrn/
  AIM: jgrn307, MSN: jgrn...@hotmail.com, Gchat: jgrn307, Skype: jgrn3007
 
[[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.




-- 
Jonathan A. Greenberg, PhD
Assistant Professor
Global Environmental Analysis and Remote Sensing (GEARS) Laboratory
Department of Geography and Geographic Information Science
University of Illinois at Urbana-Champaign
607 South Mathews Avenue, MC 150
Urbana, IL 61801
Phone: 217-300-1924
http://www.geog.illinois.edu/~jgrn/
AIM: jgrn307, MSN: jgrn...@hotmail.com, Gchat: jgrn307, Skype: jgrn3007

[[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] Adding a line to barchart

2013-01-22 Thread Jonathan Greenberg
R-helpers:

I need a quick help with the following graph (I'm a lattice newbie):

require(lattice)
npp=1:5
names(npp)=c(A,B,C,D,E)
barchart(npp,origin=0,box.width=1)

# What I want to do, is add a single vertical line positioned at x = 2 that
lays over the bars (say, using a dotted line).  How do I go about doing
this?

--j

-- 
Jonathan A. Greenberg, PhD
Assistant Professor
Global Environmental Analysis and Remote Sensing (GEARS) Laboratory
Department of Geography and Geographic Information Science
University of Illinois at Urbana-Champaign
607 South Mathews Avenue, MC 150
Urbana, IL 61801
Phone: 217-300-1924
http://www.geog.illinois.edu/~jgrn/
AIM: jgrn307, MSN: jgrn...@hotmail.com, Gchat: jgrn307, Skype: jgrn3007

[[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] Best way to coerce numerical data to a predetermined histogram bin?

2012-12-06 Thread Jonathan Greenberg
Folks:

Say I have a set of histogram breaks:

breaks=c(1:10,15)

# With bin ids:

bin_ids=1:(length(breaks)-1)

# and some data (note that some of it falls outside the breaks:

data=runif(min=1,max=20,n=100)

***

What is the MOST EFFICIENT way to classify data into the histogram bins
(return the bin_ids) and, say, return NA if the value falls outside of the
bins.

By classify, I mean if the data value is greater than one break, and less
than or equal to the next break, it gets assigned that bin's ID (note that
length(breaks) = length(bin_ids)+1)

Also note that, as per this example, the bins are not necessarily equal
widths.

I can, of course, cycle through each element of data, and then move through
breaks, stopping when it finds the correct bin, but I feel like there is
probably a faster (and more elegant) approach to this.  Thoughts?

--j





-- 
Jonathan A. Greenberg, PhD
Assistant Professor
Department of Geography and Geographic Information Science
University of Illinois at Urbana-Champaign
607 South Mathews Avenue, MC 150
Urbana, IL 61801
Phone: 217-300-1924
AIM: jgrn307, MSN: jgrn...@hotmail.com, Gchat: jgrn307, Skype: jgrn3007

[[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] Best R textbook for undergraduates

2012-10-23 Thread Jonathan Greenberg
R-helpers:

I'm sure this question has been asked and answered through the ages, but
given there are some new textbooks out there, I wanted to re-pose it.  For
a course that will cover the application of R for general computing and
spatial modeling, what textbook would be best to introduce computing with R
to *undergrads*?  I understand Bivand and Pebesma's book is fine for
spatial work, but it appears to be for more advanced users -- I'd like a
companion textbook that is better for complete beginners to ALL forms of
programming (e.g. they don't know what an object is, a loop is, an if-then
statement, etc).  Suggestions?  In particular, I'd like to hear from those
of you who have TAUGHT classes using R.  Thanks!

--jonathan

-- 
Jonathan A. Greenberg, PhD
Assistant Professor
Department of Geography and Geographic Information Science
University of Illinois at Urbana-Champaign
607 South Mathews Avenue, MC 150
Urbana, IL 61801
Phone: 217-300-1924
AIM: jgrn307, MSN: jgrn...@hotmail.com, Gchat: jgrn307, Skype: jgrn3007

[[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] Completely ignoring an error in a function...

2012-10-17 Thread Jonathan Greenberg
The code base is a bit too complicated to paste in here, but the gist of my
question is this: given I have a function

myfunction - function(x)
{
# Do something A
# Do something B
# Do something C
}

Say #Do something B returns this error:
Error in cat(list(...), file, sep, fill, labels, append) :
  argument 2 (type 'list') cannot be handled by 'cat'

A standard function would stop here.  HOWEVER, I want, in this odd case, to
say keep going to my function and have it proceeed to # Do something C.
 How do I accomplish this?  I thought suppressWarnings() would do it but it
doesn't appear to.

Assume that debugging Do something B is out of the question.  Why am I
doing this?  Because in my odd case, Do something B actually does what I
needed it to, but returned an error that is irrelevant to my special case
(it creates two files, failing on the second of the two files -- but the
first file it creates is what I wanted and there is no current way to
create that single file on its own without a lot of additional coding).

--j

-- 
Jonathan A. Greenberg, PhD
Assistant Professor
Department of Geography and Geographic Information Science
University of Illinois at Urbana-Champaign
607 South Mathews Avenue, MC 150
Urbana, IL 61801
Phone: 217-300-1924
AIM: jgrn307, MSN: jgrn...@hotmail.com, Gchat: jgrn307, Skype: jgrn3007

[[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] [R-sig-hpc] Quickest way to make a large empty file on disk?

2012-09-28 Thread Jonathan Greenberg
Rui:

Quick follow-up -- it looks like seek does do what I want (I see Simon
suggested it some time ago) -- what do mean by trash your disk?  What I'm
trying to accomplish is getting parallel, asynchronous writes to a large
binary image (just a binary file) working.  Each node writes to a different
sector of the file via mmap, filling in the values as the process runs,
but the file needs to be pre-created before I can mmap it.  Running a
writeBin with a bunch of 0s would mean I'd basically have to write the file
twice, but the seek/ff trick seems to be much faster.

Do I risk doing some damage to my filesystem if I use seek?  I see there is
a strongly worded warning in the help for ?seek:

Use of seek on Windows is discouraged. We have found so many errors in the
Windows implementation of file positioning that users are advised to use it
only at their own risk, and asked not to waste the *R* developers' time
with bug reports on Windows' deficiencies. -- there's no detail here on
which errors people have experienced, so I'm not sure if doing something as
simple as just creating a file using seek falls under the discouraging
category.

As a note, we are trying to work this up on both Windows and *nix systems,
hence our wanting to have a single approach that works on both OSs.

--j


On Thu, Sep 27, 2012 at 3:49 PM, Rui Barradas ruipbarra...@sapo.pt wrote:

  Hello,

 If you really need to trash your disk, why not use seek()?

  fl - file(Test.txt, open = wb)
  seek(fl, where = 1024, origin = start, rw = write)
 [1] 0
  writeChar(character(1), fl, nchars = 1, useBytes = TRUE)
 Warning message:
 In writeChar(character(1), fl, nchars = 1, useBytes = TRUE) :
   writeChar: more characters requested than are in the string - will
 zero-pad
  close(fl)


 File Test.txt is now 1Kb in size.

 Hope this helps,

 Rui Barradas
 Em 27-09-2012 20:17, Jonathan Greenberg escreveu:

 Folks:

 Asked this question some time ago, and found what appeared (at first) to be
 the best solution, but I'm now finding a new problem.  First off, it seemed
 like ff as Jens suggested worked:

 # outdata_ncells = the number of rows * number of columns * number of bands
 in an image:
 out-ff(vmode=double,length=outdata_ncells,filename=filename)
 finalizer(out) - close
 close(out)

 This was working fine until I attempted to set length to a VERY large
 number: outdata_ncells = 17711913600.  This would create a file that is
 131.964GB.  Big, but not obscenely so (and certainly not larger than the
 filesystem can handle).  However, length appears to be restricted
 by .Machine$integer.max (I'm on a 64-bit windows box):

  .Machine$integer.max

  [1] 2147483647

 Any suggestions on how to solve this problem for much larger file sizes?

 --j


 On Thu, May 3, 2012 at 10:44 AM, Jonathan Greenberg j...@illinois.edu 
 j...@illinois.eduwrote:


  Thanks, all!  I'll try these out.  I'm trying to work up something that is
 platform independent (if possible) for use with mmap.  I'll do some tests
 on these suggestions and see which works best. I'll try to report back in a
 few days.  Cheers!

 --j



 2012/5/3 Jens Oehlschlägel jens.oehlschlae...@truecluster.com 
 jens.oehlschlae...@truecluster.com

  Jonathan,

 On some filesystems (e.g. NTFS, see below) it is possible to create
 'sparse' memory-mapped files, i.e. reserving the space without the cost of
 actually writing initial values.
 Package 'ff' does this automatically and also allows to access the file
 in parallel. Check the example below and see how big file creation is
 immediate.

 Jens Oehlschlägel



  library(ff)
 library(snowfall)
 ncpus - 2
 n - 1e8
 system.time(

  + x - ff(vmode=double, length=n, filename=c:/Temp/x.ff)
 + )
User  System verstrichen
0.010.000.02

  # check finalizer, with an explicit filename we should have a 'close'

  finalizer

  finalizer(x)

  [1] close

  # if not, set it to 'close' inorder to not let slaves delete x on slave

  shutdown

  finalizer(x) - close
 sfInit(parallel=TRUE, cpus=ncpus, type=SOCK)

  R Version:  R version 2.15.0 (2012-03-30)

 snowfall 1.84 initialized (using snow 0.3-9): parallel execution on 2
 CPUs.


  sfLibrary(ff)

  Library ff loaded.
 Library ff loaded in cluster.

 Warnmeldung:
 In library(package = ff, character.only = TRUE, pos = 2, warn.conflicts
 = TRUE,  :
   'keep.source' is deprecated and will be ignored

  sfExport(x) # note: do not export the same ff multiple times
 # explicitely opening avoids a gc problem
 sfClusterEval(open(x, caching=mmeachflush)) # opening with

  'mmeachflush' inststead of 'mmnoflush' is a bit slower but prevents OS
 write storms when the file is larger than RAM
 [[1]]
 [1] TRUE

 [[2]]
 [1] TRUE


  system.time(

  + sfLapply( chunk(x, length=ncpus), function(i){
 +   x[i] - runif(sum(i))
 +   invisible()
 + })
 + )
User  System verstrichen
0.000.00   30.78

  system.time(

  + s - sfLapply( chunk(x, length=ncpus), function(i

Re: [R] [R-sig-hpc] Quickest way to make a large empty file on disk?

2012-09-27 Thread Jonathan Greenberg
Folks:

Asked this question some time ago, and found what appeared (at first) to be
the best solution, but I'm now finding a new problem.  First off, it seemed
like ff as Jens suggested worked:

# outdata_ncells = the number of rows * number of columns * number of bands
in an image:
out-ff(vmode=double,length=outdata_ncells,filename=filename)
finalizer(out) - close
close(out)

This was working fine until I attempted to set length to a VERY large
number: outdata_ncells = 17711913600.  This would create a file that is
131.964GB.  Big, but not obscenely so (and certainly not larger than the
filesystem can handle).  However, length appears to be restricted
by .Machine$integer.max (I'm on a 64-bit windows box):
 .Machine$integer.max
[1] 2147483647

Any suggestions on how to solve this problem for much larger file sizes?

--j


On Thu, May 3, 2012 at 10:44 AM, Jonathan Greenberg j...@illinois.eduwrote:

 Thanks, all!  I'll try these out.  I'm trying to work up something that is
 platform independent (if possible) for use with mmap.  I'll do some tests
 on these suggestions and see which works best. I'll try to report back in a
 few days.  Cheers!

 --j



 2012/5/3 Jens Oehlschlägel jens.oehlschlae...@truecluster.com

 Jonathan,

 On some filesystems (e.g. NTFS, see below) it is possible to create
 'sparse' memory-mapped files, i.e. reserving the space without the cost of
 actually writing initial values.
 Package 'ff' does this automatically and also allows to access the file
 in parallel. Check the example below and see how big file creation is
 immediate.

 Jens Oehlschlägel


  library(ff)
  library(snowfall)
  ncpus - 2
  n - 1e8
  system.time(
 + x - ff(vmode=double, length=n, filename=c:/Temp/x.ff)
 + )
User  System verstrichen
0.010.000.02
  # check finalizer, with an explicit filename we should have a 'close'
 finalizer
  finalizer(x)
 [1] close
  # if not, set it to 'close' inorder to not let slaves delete x on slave
 shutdown
  finalizer(x) - close
  sfInit(parallel=TRUE, cpus=ncpus, type=SOCK)
 R Version:  R version 2.15.0 (2012-03-30)

 snowfall 1.84 initialized (using snow 0.3-9): parallel execution on 2
 CPUs.

  sfLibrary(ff)
 Library ff loaded.
 Library ff loaded in cluster.

 Warnmeldung:
 In library(package = ff, character.only = TRUE, pos = 2, warn.conflicts
 = TRUE,  :
   'keep.source' is deprecated and will be ignored
  sfExport(x) # note: do not export the same ff multiple times
  # explicitely opening avoids a gc problem
  sfClusterEval(open(x, caching=mmeachflush)) # opening with
 'mmeachflush' inststead of 'mmnoflush' is a bit slower but prevents OS
 write storms when the file is larger than RAM
 [[1]]
 [1] TRUE

 [[2]]
 [1] TRUE

  system.time(
 + sfLapply( chunk(x, length=ncpus), function(i){
 +   x[i] - runif(sum(i))
 +   invisible()
 + })
 + )
User  System verstrichen
0.000.00   30.78
  system.time(
 + s - sfLapply( chunk(x, length=ncpus), function(i) quantile(x[i],
 c(0.05, 0.95)) )
 + )
User  System verstrichen
0.000.004.38
  # for completeness
  sfClusterEval(close(x))
 [[1]]
 [1] TRUE

 [[2]]
 [1] TRUE

  csummary(s)
  5%  95%
 Min.0.04998 0.95
 1st Qu. 0.04999 0.95
 Median  0.05001 0.95
 Mean0.05001 0.95
 3rd Qu. 0.05002 0.95
 Max.0.05003 0.95
  # stop slaves
  sfStop()

 Stopping cluster

  # with the close finalizer we are responsible for deleting the file
 explicitely (unless we want to keep it)
  delete(x)
 [1] TRUE
  # remove r-side metadata
  rm(x)
  # truly free memory
  gc()



  *Gesendet:* Donnerstag, 03. Mai 2012 um 00:23 Uhr
 *Von:* Jonathan Greenberg j...@illinois.edu
 *An:* r-help r-help@r-project.org, r-sig-...@r-project.org
 *Betreff:* [R-sig-hpc] Quickest way to make a large empty file on
 disk?
  R-helpers:

 What would be the absolute fastest way to make a large empty file (e.g.
 filled with all zeroes) on disk, given a byte size and a given number
 number of empty values. I know I can use writeBin, but the object in
 this case may be far too large to store in main memory. I'm asking because
 I'm going to use this file in conjunction with mmap to do parallel writes
 to this file. Say, I want to create a blank file of 10,000 floating point
 numbers.

 Thanks!

 --j

 --
 Jonathan A. Greenberg, PhD
 Assistant Professor
 Department of Geography and Geographic Information Science
 University of Illinois at Urbana-Champaign
 607 South Mathews Avenue, MC 150
 Urbana, IL 61801
 Phone: 415-763-5476
 AIM: jgrn307, MSN: jgrn...@hotmail.com, Gchat: jgrn307, Skype: jgrn3007
 http://www.geog.illinois.edu/people/JonathanGreenberg.html

 [[alternative HTML version deleted]]

 ___
 R-sig-hpc mailing list
 r-sig-...@r-project.org
 https://stat.ethz.ch/mailman/listinfo/r-sig-hpc





 --
 Jonathan A. Greenberg, PhD
 Assistant Professor
 Department of Geography and Geographic Information Science
 University

[R] Dummies guide to getting HPC working on R

2012-06-03 Thread Jonathan Greenberg
R-folks:  Sorry for the cross-posting, but I wanted to share a link to
a (fairly long) blog post I created which tries to take the mystery
out of getting R setup for doing high performance/parallel computing
if you have to compile R from scratch:

http://lostingeospace.blogspot.com/2012/06/r-and-hpc-blas-mpi-in-linux-environment.html

Let me know if you have any comments/corrections on it.  Cheers!

--j

-- 
Jonathan A. Greenberg, PhD
Assistant Professor
Department of Geography and Geographic Information Science
University of Illinois at Urbana-Champaign
607 South Mathews Avenue, MC 150
Urbana, IL 61801
Phone: 415-763-5476
AIM: jgrn307, MSN: jgrn...@hotmail.com, Gchat: jgrn307, Skype: jgrn3007
http://www.geog.illinois.edu/people/JonathanGreenberg.html

__
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] Dummies guide to getting HPC working on R

2012-06-03 Thread Jonathan Greenberg
R-folks.  Sorry for the cross-posting, but I wanted to share a link to
a (fairly long) blog post I created which tries to take the mystery
out of getting R setup for doing high performance/parallel computing
if you have to compile R from scratch:

http://lostingeospace.blogspot.com/2012/06/r-and-hpc-blas-mpi-in-linux-environment.html

Let me know if you have any comments/corrections on it.  Cheers!

--j

-- 
Jonathan A. Greenberg, PhD
Assistant Professor
Department of Geography and Geographic Information Science
University of Illinois at Urbana-Champaign
607 South Mathews Avenue, MC 150
Urbana, IL 61801
Phone: 415-763-5476
AIM: jgrn307, MSN: jgrn...@hotmail.com, Gchat: jgrn307, Skype: jgrn3007
http://www.geog.illinois.edu/people/JonathanGreenberg.html

__
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-sig-hpc] Quickest way to make a large empty file on disk?

2012-05-03 Thread Jonathan Greenberg
Thanks, all!  I'll try these out.  I'm trying to work up something that is
platform independent (if possible) for use with mmap.  I'll do some tests
on these suggestions and see which works best. I'll try to report back in a
few days.  Cheers!

--j



2012/5/3 Jens Oehlschlägel jens.oehlschlae...@truecluster.com

 Jonathan,

 On some filesystems (e.g. NTFS, see below) it is possible to create
 'sparse' memory-mapped files, i.e. reserving the space without the cost of
 actually writing initial values.
 Package 'ff' does this automatically and also allows to access the file in
 parallel. Check the example below and see how big file creation is
 immediate.

 Jens Oehlschlägel


  library(ff)
  library(snowfall)
  ncpus - 2
  n - 1e8
  system.time(
 + x - ff(vmode=double, length=n, filename=c:/Temp/x.ff)
 + )
User  System verstrichen
0.010.000.02
  # check finalizer, with an explicit filename we should have a 'close'
 finalizer
  finalizer(x)
 [1] close
  # if not, set it to 'close' inorder to not let slaves delete x on slave
 shutdown
  finalizer(x) - close
  sfInit(parallel=TRUE, cpus=ncpus, type=SOCK)
 R Version:  R version 2.15.0 (2012-03-30)

 snowfall 1.84 initialized (using snow 0.3-9): parallel execution on 2 CPUs.

  sfLibrary(ff)
 Library ff loaded.
 Library ff loaded in cluster.

 Warnmeldung:
 In library(package = ff, character.only = TRUE, pos = 2, warn.conflicts
 = TRUE,  :
   'keep.source' is deprecated and will be ignored
  sfExport(x) # note: do not export the same ff multiple times
  # explicitely opening avoids a gc problem
  sfClusterEval(open(x, caching=mmeachflush)) # opening with
 'mmeachflush' inststead of 'mmnoflush' is a bit slower but prevents OS
 write storms when the file is larger than RAM
 [[1]]
 [1] TRUE

 [[2]]
 [1] TRUE

  system.time(
 + sfLapply( chunk(x, length=ncpus), function(i){
 +   x[i] - runif(sum(i))
 +   invisible()
 + })
 + )
User  System verstrichen
0.000.00   30.78
  system.time(
 + s - sfLapply( chunk(x, length=ncpus), function(i) quantile(x[i],
 c(0.05, 0.95)) )
 + )
User  System verstrichen
0.000.004.38
  # for completeness
  sfClusterEval(close(x))
 [[1]]
 [1] TRUE

 [[2]]
 [1] TRUE

  csummary(s)
  5%  95%
 Min.0.04998 0.95
 1st Qu. 0.04999 0.95
 Median  0.05001 0.95
 Mean0.05001 0.95
 3rd Qu. 0.05002 0.95
 Max.0.05003 0.95
  # stop slaves
  sfStop()

 Stopping cluster

  # with the close finalizer we are responsible for deleting the file
 explicitely (unless we want to keep it)
  delete(x)
 [1] TRUE
  # remove r-side metadata
  rm(x)
  # truly free memory
  gc()



  *Gesendet:* Donnerstag, 03. Mai 2012 um 00:23 Uhr
 *Von:* Jonathan Greenberg j...@illinois.edu
 *An:* r-help r-help@r-project.org, r-sig-...@r-project.org
 *Betreff:* [R-sig-hpc] Quickest way to make a large empty file on disk?
  R-helpers:

 What would be the absolute fastest way to make a large empty file (e.g.
 filled with all zeroes) on disk, given a byte size and a given number
 number of empty values. I know I can use writeBin, but the object in
 this case may be far too large to store in main memory. I'm asking because
 I'm going to use this file in conjunction with mmap to do parallel writes
 to this file. Say, I want to create a blank file of 10,000 floating point
 numbers.

 Thanks!

 --j

 --
 Jonathan A. Greenberg, PhD
 Assistant Professor
 Department of Geography and Geographic Information Science
 University of Illinois at Urbana-Champaign
 607 South Mathews Avenue, MC 150
 Urbana, IL 61801
 Phone: 415-763-5476
 AIM: jgrn307, MSN: jgrn...@hotmail.com, Gchat: jgrn307, Skype: jgrn3007
 http://www.geog.illinois.edu/people/JonathanGreenberg.html

 [[alternative HTML version deleted]]

 ___
 R-sig-hpc mailing list
 r-sig-...@r-project.org
 https://stat.ethz.ch/mailman/listinfo/r-sig-hpc





-- 
Jonathan A. Greenberg, PhD
Assistant Professor
Department of Geography and Geographic Information Science
University of Illinois at Urbana-Champaign
607 South Mathews Avenue, MC 150
Urbana, IL 61801
Phone: 415-763-5476
AIM: jgrn307, MSN: jgrn...@hotmail.com, Gchat: jgrn307, Skype: jgrn3007
http://www.geog.illinois.edu/people/JonathanGreenberg.html

[[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] Quickest way to make a large empty file on disk?

2012-05-02 Thread Jonathan Greenberg
R-helpers:

What would be the absolute fastest way to make a large empty file (e.g.
filled with all zeroes) on disk, given a byte size and a given number
number of empty values.  I know I can use writeBin, but the object in
this case may be far too large to store in main memory.  I'm asking because
I'm going to use this file in conjunction with mmap to do parallel writes
to this file.  Say, I want to create a blank file of 10,000 floating point
numbers.

Thanks!

--j

-- 
Jonathan A. Greenberg, PhD
Assistant Professor
Department of Geography and Geographic Information Science
University of Illinois at Urbana-Champaign
607 South Mathews Avenue, MC 150
Urbana, IL 61801
Phone: 415-763-5476
AIM: jgrn307, MSN: jgrn...@hotmail.com, Gchat: jgrn307, Skype: jgrn3007
http://www.geog.illinois.edu/people/JonathanGreenberg.html

[[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] Solve an ordinary or generalized eigenvalue problem in R?

2012-04-23 Thread Jonathan Greenberg
Building in Berend's suggestions I think this function should work for most
people (I'm going to wrap it into a package but figured people may want to
grab this directly):

# Please see http://www.netlib.org/lapack/double/dggev.f for a description
of inputs and outputs.
Rdggev - function(A,B,JOBVL=FALSE,JOBVR=TRUE)
{
# R implementation of the DGGEV LAPACK function (with generalized
eigenvalue computation)
# See http://www.netlib.org/lapack/double/dggev.f
 # coded by Jonathan A. Greenberg i...@estarcion.net
# Contributions from Berend Hasselman.

if( .Platform$OS.type == windows ) {
Lapack.so -
file.path(R.home(bin),paste(Rlapack,.Platform$dynlib.ext,sep=))
} else {
Lapack.so -
file.path(R.home(modules),paste(lapack,.Platform$dynlib.ext,sep=))
}
 dyn.load(Lapack.so)
 if(JOBVL)
{
JOBVL=V
} else
{
JOBVL=N
}
 if(JOBVR)
{
JOBVR=V
} else
{
JOBVR=N
}
 if(!is.matrix(A)) stop(Argument A should be a matrix)
if(!is.matrix(B)) stop(Argument B should be a matrix)
dimA - dim(A)
if(dimA[1]!=dimA[2]) stop(A must be a square matrix)
dimB - dim(B)
if(dimB[1]!=dimB[2]) stop(B must be a square matrix)
if(dimA[1]!=dimB[1]) stop(A and B must have the same dimensions)
 if( is.complex(A) ) stop(A may not be complex)
if( is.complex(B) ) stop(B may not be complex)
 # Input parameters
N=dim(A)[[1]]
LDA=N
LDB=N
LDVL=N
LDVR=N
LWORK=as.integer(max(1,8*N))
 Rdggev_out - .Fortran(dggev, JOBVL, JOBVR, N, A, LDA, B, LDB,
double(N), double(N), double(N),
array(data=0,dim=c(LDVL,N)), LDVL, array(data=0,dim=c(LDVR,N)), LDVR,
double(max(1,LWORK)), LWORK, integer(1))

names(Rdggev_out)=c(JOBVL,JOBVR,N,A,LDA,B,LDB,ALPHAR,ALPHAI,
BETA,VL,LDVL,VR,LDVR,WORK,LWORK,INFO)
 # simplistic calculation of eigenvalues (see caveat in
http://www.netlib.org/lapack/double/dggev.f)
if( all(Rdggev_out$ALPHAI==0) )
Rdggev_out$GENEIGENVALUES - Rdggev_out$ALPHAR/Rdggev_out$BETA
else
Rdggev_out$GENEIGENVALUES - complex(real=Rdggev_out$ALPHAR,
imaginary=Rdggev_out$ALPHAI)/Rdggev_out$BETA
 return(Rdggev_out)
}

Thanks!

--j

On Sun, Apr 22, 2012 at 2:27 PM, Berend Hasselman b...@xs4all.nl wrote:


 On 22-04-2012, at 21:08, Jonathan Greenberg wrote:

  Thanks all (particularly to you, Berend) -- I'll push forward with these
 solutions and integrate them into my code.  I did come across geigen while
 rooting around in the CCA code but its not formally documented (it just
 says for internal use or something along those lines) and as you found
 out above, it does not produce the same solution as the dggev.  It would be
 nice to have a more complete set of formal packages for doing LA in R
 (rather than having to hand-write .Fortran calls) but I'll leave that to
 someone with more expertise in linear algebra than me.  Something that
 perhaps matches the SciPy set of functions (both in terms of input and
 output):
 
  http://docs.scipy.org/doc/scipy/reference/linalg.html
 
  Some of these are already implemented, but clearly not all of them.

 Package CCA has package fda as dependency.
 And package fda defines a function geigen.
 The first 14 lines of this function are

 geigen - function(Amat, Bmat, Cmat)
 {
  #  solve the generalized eigenanalysis problem
  #
  #max {tr L'AM / sqrt[tr L'BL tr M'CM] w.r.t. L and M
  #
  #  Arguments:
  #  AMAT ... p by q matrix
  #  BMAT ... order p symmetric positive definite matrix
  #  CMAT ... order q symmetric positive definite matrix
  #  Returns:
  #  VALUES ... vector of length s = min(p,q) of eigenvalues
  #  LMAT   ... p by s matrix L
  #  MMAT   ... q by s matrix M

 It's not clear to me how it is used and exactly what it is doing and how
 that compares with Lapack.

 Berend




-- 
Jonathan A. Greenberg, PhD
Assistant Professor
Department of Geography and Geographic Information Science
University of Illinois at Urbana-Champaign
607 South Mathews Avenue, MC 150
Urbana, IL 61801
Phone: 415-763-5476
AIM: jgrn307, MSN: jgrn...@hotmail.com, Gchat: jgrn307, Skype: jgrn3007
http://www.geog.illinois.edu/people/JonathanGreenberg.html

[[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] Solve an ordinary or generalized eigenvalue problem in R?

2012-04-22 Thread Jonathan Greenberg
Thanks all (particularly to you, Berend) -- I'll push forward with these
solutions and integrate them into my code.  I did come across geigen while
rooting around in the CCA code but its not formally documented (it just
says for internal use or something along those lines) and as you found
out above, it does not produce the same solution as the dggev.  It would be
nice to have a more complete set of formal packages for doing LA in R
(rather than having to hand-write .Fortran calls) but I'll leave that to
someone with more expertise in linear algebra than me.  Something that
perhaps matches the SciPy set of functions (both in terms of input and
output):

http://docs.scipy.org/doc/scipy/reference/linalg.html

Some of these are already implemented, but clearly not all of them.

--j

On Sat, Apr 21, 2012 at 1:31 PM, Berend Hasselman b...@xs4all.nl wrote:


 On 21-04-2012, at 20:20, peter dalgaard wrote:

 
 
  The eigenvalues are identical upto the printed 9 digits but the
 eigenvectors appear to be quite different.
  Maybe this is what Luke meant.
 
  Berend
 
 
 
  They look quite similar to me:
 
  ev - eigen(solve(B,A) )$vectors
  ge - geigen(A, B, TRUE , TRUE)
  ev / ge$vl
   [,1] [,2]   [,3]
  [1,] 0.9324603 0.813422 -0.7423694
  [2,] 0.9324603 0.813422 -0.7423694
  [3,] 0.9324603 0.813422 -0.7423694
  ev / ge$vr
   [,1] [,2]   [,3]
  [1,] 0.9324603 0.813422 -0.7423694
  [2,] 0.9324603 0.813422 -0.7423694
  [3,] 0.9324603 0.813422 -0.7423694
 
  (and of course, eigenvectors of any sort are only defined up to a
 constant multiplier)

 Correct. I should have checked  your way and not optically.

 Berend

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




-- 
Jonathan A. Greenberg, PhD
Assistant Professor
Department of Geography and Geographic Information Science
University of Illinois at Urbana-Champaign
607 South Mathews Avenue, MC 150
Urbana, IL 61801
Phone: 415-763-5476
AIM: jgrn307, MSN: jgrn...@hotmail.com, Gchat: jgrn307, Skype: jgrn3007
http://www.geog.illinois.edu/people/JonathanGreenberg.html

[[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] Solve an ordinary or generalized eigenvalue problem in R?

2012-04-20 Thread Jonathan Greenberg
So I am a complete noob at doing this type of linking.  When I write this
statement (all the input values are assigned, but I have to confess I don't
know what to do with the output variables -- in this call they are all
assigned NA):

.Call(La_dgeev, JOBVL, JOBVR, N, A, LDA, B, LDB, ALPHAR=NA, ALPHAI=NA,
BETA=NA,
+ VL=NA, LDVL, VR=NA, LDVR, WORK=NA, LWORK, INFO=NA, PACKAGE=base)

I get:

Error in .Call(La_dgeev, JOBVL, JOBVR, N, A, LDA, B, LDB, ALPHAR = NA,  :
  C symbol name La_dgeev not in DLL for package base

I'm running this on Windows 7 x64 version of R 2.14.2.  The R_ext/Lapack.h
file states:

/* DGEEV - compute for an N-by-N real nonsymmetric matrix A, the */
/* eigenvalues and, optionally, the left and/or right eigenvectors */
La_extern void
F77_NAME(dgeev)(const char* jobvl, const char* jobvr,
const int* n, double* a, const int* lda,
double* wr, double* wi, double* vl, const int* ldvl,
double* vr, const int* ldvr,
double* work, const int* lwork, int* info);

Any ideas?

--j



On Fri, Apr 20, 2012 at 1:37 AM, Berend Hasselman b...@xs4all.nl wrote:


 On 19-04-2012, at 20:50, Jonathan Greenberg wrote:

  Folks:
 
  I'm trying to port some code from python over to R, and I'm running into
 a
  wall finding R code that can solve a generalized eigenvalue problem
  following this function model:
 
 
 http://docs.scipy.org/doc/scipy/reference/generated/scipy.linalg.eig.html
 
  Any ideas?  I don't want to call python from within R for various
 reasons,
  I'd prefer a native R solution if one exists.  Thanks!

 An old thread is here:
 http://tolstoy.newcastle.edu.au/R/help/05/06/6802.html

 R does provide eigen().
 R has the Lapack routines dggev and dgges in its library.
 You'd have to write your own .Fortran interface to those routines.

 Berend




-- 
Jonathan A. Greenberg, PhD
Assistant Professor
Department of Geography and Geographic Information Science
University of Illinois at Urbana-Champaign
607 South Mathews Avenue, MC 150
Urbana, IL 61801
Phone: 415-763-5476
AIM: jgrn307, MSN: jgrn...@hotmail.com, Gchat: jgrn307, Skype: jgrn3007
http://www.geog.illinois.edu/people/JonathanGreenberg.html

[[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] Solve an ordinary or generalized eigenvalue problem in R?

2012-04-20 Thread Jonathan Greenberg
Incidentally, if you want to test this out:

 A
 [,1] [,2] [,3]
[1,] 1457.738 1053.181 1256.953
[2,] 1053.181 1213.728 1302.838
[3,] 1256.953 1302.838 1428.269

 B
 [,1] [,2] [,3]
[1,] 4806.033 1767.480 2622.744
[2,] 1767.480 3353.603 3259.680
[3,] 2622.744 3259.680 3476.790

I THINK this is correct for the other parameters:
JOBVL=N
JOBVR=N
N=dim(A)[[1]]
LDA=N
LDB=N
LDVL=N
LDVR=N
LWORK=max(1,8*N)

.Call(La_dgeev, JOBVL, JOBVR, N, A, LDA, B, LDB, ALPHAR=NA, ALPHAI=NA,
BETA=NA,
VL=NA, LDVL, VR=NA, LDVR, WORK=NA, LWORK, INFO=NA, PACKAGE=base)
LAPACK's documentation is:
http://www.netlib.org/lapack/double/dggev.f

--j

On Fri, Apr 20, 2012 at 11:58 AM, Jonathan Greenberg j...@illinois.eduwrote:

 So I am a complete noob at doing this type of linking.  When I write this
 statement (all the input values are assigned, but I have to confess I don't
 know what to do with the output variables -- in this call they are all
 assigned NA):

 .Call(La_dgeev, JOBVL, JOBVR, N, A, LDA, B, LDB, ALPHAR=NA, ALPHAI=NA,
 BETA=NA,
 + VL=NA, LDVL, VR=NA, LDVR, WORK=NA, LWORK, INFO=NA, PACKAGE=base)

 I get:

 Error in .Call(La_dgeev, JOBVL, JOBVR, N, A, LDA, B, LDB, ALPHAR = NA,
  :
   C symbol name La_dgeev not in DLL for package base

 I'm running this on Windows 7 x64 version of R 2.14.2.  The R_ext/Lapack.h
 file states:

 /* DGEEV - compute for an N-by-N real nonsymmetric matrix A, the */
 /* eigenvalues and, optionally, the left and/or right eigenvectors */
 La_extern void
 F77_NAME(dgeev)(const char* jobvl, const char* jobvr,
 const int* n, double* a, const int* lda,
 double* wr, double* wi, double* vl, const int* ldvl,
  double* vr, const int* ldvr,
 double* work, const int* lwork, int* info);

 Any ideas?

 --j



 On Fri, Apr 20, 2012 at 1:37 AM, Berend Hasselman b...@xs4all.nl wrote:


 On 19-04-2012, at 20:50, Jonathan Greenberg wrote:

  Folks:
 
  I'm trying to port some code from python over to R, and I'm running
 into a
  wall finding R code that can solve a generalized eigenvalue problem
  following this function model:
 
 
 http://docs.scipy.org/doc/scipy/reference/generated/scipy.linalg.eig.html
 
  Any ideas?  I don't want to call python from within R for various
 reasons,
  I'd prefer a native R solution if one exists.  Thanks!

 An old thread is here:
 http://tolstoy.newcastle.edu.au/R/help/05/06/6802.html

 R does provide eigen().
 R has the Lapack routines dggev and dgges in its library.
 You'd have to write your own .Fortran interface to those routines.

 Berend




 --
 Jonathan A. Greenberg, PhD
 Assistant Professor
 Department of Geography and Geographic Information Science
 University of Illinois at Urbana-Champaign
 607 South Mathews Avenue, MC 150
 Urbana, IL 61801
 Phone: 415-763-5476
 AIM: jgrn307, MSN: jgrn...@hotmail.com, Gchat: jgrn307, Skype: jgrn3007
 http://www.geog.illinois.edu/people/JonathanGreenberg.html




-- 
Jonathan A. Greenberg, PhD
Assistant Professor
Department of Geography and Geographic Information Science
University of Illinois at Urbana-Champaign
607 South Mathews Avenue, MC 150
Urbana, IL 61801
Phone: 415-763-5476
AIM: jgrn307, MSN: jgrn...@hotmail.com, Gchat: jgrn307, Skype: jgrn3007
http://www.geog.illinois.edu/people/JonathanGreenberg.html

[[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] Solve an ordinary or generalized eigenvalue problem in R?

2012-04-20 Thread Jonathan Greenberg
Ok, I figured out a solution and I'd like to get some feedback on this from
the R-helpers as to how I could modify the following to be package
friendly -- the main thing I'm worried about is how to dynamically set the
dyn.load statement below correctly (obviously, its hard coded to my
particular install, and would only work with windows since I'm using a
.dll):

Rdggev - function(JOBVL=F,JOBVR=T,A,B)
{
# R implementation of the DGGEV LAPACK function (with generalized
eigenvalue computation)
# See http://www.netlib.org/lapack/double/dggev.f
 # coded by Jonathan A. Greenberg j...@illinois.edu
 dyn.load(C:\\Program Files\\R\\R-2.14.2\\bin\\x64\\Rlapack.dll)

if(JOBVL)
{
JOBVL=V
} else
{
JOBVL=N
}
 if(JOBVR)
{
JOBVR=V
} else
{
JOBVR=N
}
 # Note, no error checking is performed.
 # Input parameters
N=dim(A)[[1]]
LDA=N
LDB=N
LDVL=N
LDVR=N
LWORK=as.integer(max(1,8*N))
 Rdggev_out - .Fortran(dggev, JOBVL, JOBVR, N, A, LDA, B, LDB,
double(N), double(N), double(N),
array(data=0,dim=c(LDVL,N)), LDVL, array(data=0,dim=c(LDVR,N)), LDVR,
double(max(1,LWORK)), LWORK, integer(1))

names(Rdggev_out)=c(JOBVL,JOBVR,N,A,LDA,B,LDB,ALPHAR,ALPHAI,
BETA,VL,LDVL,VR,LDVR,WORK,LWORK,INFO)

Rdggev_out$GENEIGENVALUES=(Rdggev_out$ALPHAR+Rdggev_out$ALPHAI)/Rdggev_out$BETA
 return(Rdggev_out)
}



On Fri, Apr 20, 2012 at 12:01 PM, Jonathan Greenberg j...@illinois.eduwrote:

 Incidentally, if you want to test this out:

  A
  [,1] [,2] [,3]
 [1,] 1457.738 1053.181 1256.953
 [2,] 1053.181 1213.728 1302.838
 [3,] 1256.953 1302.838 1428.269

  B
  [,1] [,2] [,3]
 [1,] 4806.033 1767.480 2622.744
 [2,] 1767.480 3353.603 3259.680
 [3,] 2622.744 3259.680 3476.790

 I THINK this is correct for the other parameters:
 JOBVL=N
 JOBVR=N
 N=dim(A)[[1]]
  LDA=N
 LDB=N
 LDVL=N
  LDVR=N
 LWORK=max(1,8*N)

 .Call(La_dgeev, JOBVL, JOBVR, N, A, LDA, B, LDB, ALPHAR=NA, ALPHAI=NA,
 BETA=NA,
  VL=NA, LDVL, VR=NA, LDVR, WORK=NA, LWORK, INFO=NA, PACKAGE=base)
  LAPACK's documentation is:
 http://www.netlib.org/lapack/double/dggev.f

 --j

 On Fri, Apr 20, 2012 at 11:58 AM, Jonathan Greenberg j...@illinois.eduwrote:

 So I am a complete noob at doing this type of linking.  When I write this
 statement (all the input values are assigned, but I have to confess I don't
 know what to do with the output variables -- in this call they are all
 assigned NA):

 .Call(La_dgeev, JOBVL, JOBVR, N, A, LDA, B, LDB, ALPHAR=NA, ALPHAI=NA,
 BETA=NA,
 + VL=NA, LDVL, VR=NA, LDVR, WORK=NA, LWORK, INFO=NA, PACKAGE=base)

 I get:

 Error in .Call(La_dgeev, JOBVL, JOBVR, N, A, LDA, B, LDB, ALPHAR = NA,
  :
   C symbol name La_dgeev not in DLL for package base

 I'm running this on Windows 7 x64 version of R 2.14.2.  The
 R_ext/Lapack.h file states:

 /* DGEEV - compute for an N-by-N real nonsymmetric matrix A, the */
 /* eigenvalues and, optionally, the left and/or right eigenvectors */
 La_extern void
 F77_NAME(dgeev)(const char* jobvl, const char* jobvr,
 const int* n, double* a, const int* lda,
 double* wr, double* wi, double* vl, const int* ldvl,
  double* vr, const int* ldvr,
 double* work, const int* lwork, int* info);

 Any ideas?

 --j



 On Fri, Apr 20, 2012 at 1:37 AM, Berend Hasselman b...@xs4all.nl wrote:


 On 19-04-2012, at 20:50, Jonathan Greenberg wrote:

  Folks:
 
  I'm trying to port some code from python over to R, and I'm running
 into a
  wall finding R code that can solve a generalized eigenvalue problem
  following this function model:
 
 
 http://docs.scipy.org/doc/scipy/reference/generated/scipy.linalg.eig.html
 
  Any ideas?  I don't want to call python from within R for various
 reasons,
  I'd prefer a native R solution if one exists.  Thanks!

 An old thread is here:
 http://tolstoy.newcastle.edu.au/R/help/05/06/6802.html

 R does provide eigen().
 R has the Lapack routines dggev and dgges in its library.
 You'd have to write your own .Fortran interface to those routines.

 Berend




 --
 Jonathan A. Greenberg, PhD
 Assistant Professor
 Department of Geography and Geographic Information Science
 University of Illinois at Urbana-Champaign
 607 South Mathews Avenue, MC 150
 Urbana, IL 61801
 Phone: 415-763-5476
 AIM: jgrn307, MSN: jgrn...@hotmail.com, Gchat: jgrn307, Skype: jgrn3007
 http://www.geog.illinois.edu/people/JonathanGreenberg.html




 --
 Jonathan A. Greenberg, PhD
 Assistant Professor
 Department of Geography and Geographic Information Science
 University of Illinois at Urbana-Champaign
 607 South Mathews Avenue, MC 150
 Urbana, IL 61801
 Phone: 415-763-5476
 AIM: jgrn307, MSN: jgrn...@hotmail.com, Gchat: jgrn307, Skype: jgrn3007
 http://www.geog.illinois.edu/people/JonathanGreenberg.html




-- 
Jonathan A. Greenberg, PhD
Assistant Professor
Department of Geography and Geographic Information Science
University of Illinois at Urbana-Champaign
607 South Mathews Avenue, MC 150
Urbana, IL 61801
Phone: 415-763-5476
AIM: jgrn307, MSN: jgrn...@hotmail.com, Gchat: jgrn307, Skype: jgrn3007
http

Re: [R] Solve an ordinary or generalized eigenvalue problem in R?

2012-04-20 Thread Jonathan Greenberg
My apologies:

When reviewing my initial email I made a typo -- what I needed was dggev,
not dgeev.  I have confirmed that my function reproduces the scipy outputs
I mentioned in my first email.  The function is part of lapack.  I'm not an
R noob, I just haven't dealt with external Fortran or C calls before.

The reason I need it is that I am trying to port an existing python/IDL
algorithm to R (iMad/RADCAL, located at
http://mcanty.homepage.t-online.de/software.html).  The algorithm is fairly
complex so I'm trying to reproduce it line-by-line as closely as possible
before going back and improving its efficiency using various R
functions  (checking the inputs and the outputs between R and the python
code each step).  This algorithm does a weighted canonical correlation
analysis which does not apparently exist in other CCA R packages.

So, my main question at this point is given I can call dggev via .Fortran()
and get the outputs I want, what is the best way to package this up with a
dyn.load() statement that would work on any R install that has the lapack
libraries available to it?

--j


 Yes. Stop this.

 You are completely on the wrong track and  getting yourself into a real
 muddle.

 1. you are mixing up dgeev and dggev. You are using the dggev arguments to
 call dgeev. Even if you got it all correct this would result in nasty
 errors.
 2. La_dgeev doesn't exist in the R sources (nor does it exist in Lapack)
 and you don't need to use dgeev. See below.

 Since you are a noob I would advise you to not try and interface with
 Fortran or C at this moment.

 It is possible to interface with dggev for generalized eigenvalues but it
 is not a straightforward and easy job to do.
 I've had a look at the R and C code used in the R sources to interface
 with dgeev. It would need a lot of TLC.

 As I told you before: R provides a function eigen for calculating normal
  eigenvalues end eigenvectors.

 It's probably a good idea to explain why you need generalized eigenvalues.
 Then someone may be able to come up with suggestions and/or alternatives.

 Berend




-- 
Jonathan A. Greenberg, PhD
Assistant Professor
Department of Geography and Geographic Information Science
University of Illinois at Urbana-Champaign
607 South Mathews Avenue, MC 150
Urbana, IL 61801
Phone: 415-763-5476
AIM: jgrn307, MSN: jgrn...@hotmail.com, Gchat: jgrn307, Skype: jgrn3007
http://www.geog.illinois.edu/people/JonathanGreenberg.html

[[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] Solve an ordinary or generalized eigenvalue problem in R?

2012-04-19 Thread Jonathan Greenberg
Folks:

I'm trying to port some code from python over to R, and I'm running into a
wall finding R code that can solve a generalized eigenvalue problem
following this function model:

http://docs.scipy.org/doc/scipy/reference/generated/scipy.linalg.eig.html

Any ideas?  I don't want to call python from within R for various reasons,
I'd prefer a native R solution if one exists.  Thanks!

--j

-- 
Jonathan A. Greenberg, PhD
Assistant Professor
Department of Geography and Geographic Information Science
University of Illinois at Urbana-Champaign
607 South Mathews Avenue, MC 150
Urbana, IL 61801
Phone: 415-763-5476
AIM: jgrn307, MSN: jgrn...@hotmail.com, Gchat: jgrn307, Skype: jgrn3007
http://www.geog.illinois.edu/people/JonathanGreenberg.html

[[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] Listing the contents of an FTP directory via R?

2012-04-09 Thread Jonathan Greenberg
R-helpers:

I'd like to be able to store all the file information from an ftp site
(e.g. file and foldernames) through an R command.  Any ideas how to do
this?  Here's an example site to use:

ftp://e4ftl01.cr.usgs.gov/MOTA/MCD15A3.005

--j

-- 
Jonathan A. Greenberg, PhD
Assistant Professor
Department of Geography and Geographic Information Science
University of Illinois at Urbana-Champaign
607 South Mathews Avenue, MC 150
Urbana, IL 61801
Phone: 415-763-5476
AIM: jgrn307, MSN: jgrn...@hotmail.com, Gchat: jgrn307, Skype: jgrn3007
http://www.geog.illinois.edu/people/JonathanGreenberg.html

__
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] Listing the contents of an FTP directory via R?

2012-04-09 Thread Jonathan Greenberg
Steven:

Thanks -- I seem to be running into the problem with the link I sent along:

 getURL(ftp://e4ftl01.cr.usgs.gov/MOTA/MCD15A3.005/,verbose=TRUE,dirlistonly 
 = TRUE)
Error in function (type, msg, asError = TRUE)  : RETR response: 550

I'm wondering if it might be a passive ftp issue, but:
 getURL(ftp://e4ftl01.cr.usgs.gov/MOTA/MCD15A3.005/,verbose=TRUE,ftp.use.epsv=TRUE,
  dirlistonly = TRUE)
Error in function (type, msg, asError = TRUE)  :
  FTP response reading failed

Does not seem to work...  Thoughts?

--j

On Mon, Apr 9, 2012 at 1:32 PM, steven mosher mosherste...@gmail.com wrote:
 A couple of ways.

 using Rcurl   you can use the  curlOption of dirlistonly.

 otherwise you can read the page and parse.  I've got some code around here
 to do that.

 Steve

 On Mon, Apr 9, 2012 at 11:27 AM, Jonathan Greenberg j...@illinois.edu
 wrote:

 R-helpers:

 I'd like to be able to store all the file information from an ftp site
 (e.g. file and foldernames) through an R command.  Any ideas how to do
 this?  Here's an example site to use:

 ftp://e4ftl01.cr.usgs.gov/MOTA/MCD15A3.005

 --j

 --
 Jonathan A. Greenberg, PhD
 Assistant Professor
 Department of Geography and Geographic Information Science
 University of Illinois at Urbana-Champaign
 607 South Mathews Avenue, MC 150
 Urbana, IL 61801
 Phone: 415-763-5476
 AIM: jgrn307, MSN: jgrn...@hotmail.com, Gchat: jgrn307, Skype: jgrn3007
 http://www.geog.illinois.edu/people/JonathanGreenberg.html

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





-- 
Jonathan A. Greenberg, PhD
Assistant Professor
Department of Geography and Geographic Information Science
University of Illinois at Urbana-Champaign
607 South Mathews Avenue, MC 150
Urbana, IL 61801
Phone: 415-763-5476
AIM: jgrn307, MSN: jgrn...@hotmail.com, Gchat: jgrn307, Skype: jgrn3007
http://www.geog.illinois.edu/people/JonathanGreenberg.html

__
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] Listing the contents of an FTP directory via R?

2012-04-09 Thread Jonathan Greenberg
It seems to be choking on NLST:

require(RCurl)
getURL(ftp://e4ftl01.cr.usgs.gov/MOTA/MCD15A3.005/,verbose=TRUE,ftp.use.epsv=TRUE,
dirlistonly = TRUE)

...

 230 Guest login ok, access restrictions apply.
 PWD
 257 / is current directory.
* Entry path is '/'
 CWD MOTA
 250 CWD command successful.
 CWD MCD15A3.005
 250 CWD command successful.
 EPSV
* Connect data stream passively
 500 'EPSV': command not understood.
* disabling EPSV usage
 PASV
 227 Entering Passive Mode (152,61,133,5,177,17)
*   Trying 152.61.133.5... * connected
* Connecting to 152.61.133.5 (152.61.133.5) port 45329
 TYPE A
 200 Type set to A.
 NLST
 550 No files found.
* RETR response: 550
* Remembering we are in dir MOTA/MCD15A3.005/
* Connection #0 to host e4ftl01.cr.usgs.gov left intact
Error in function (type, msg, asError = TRUE)  : RETR response: 550

Thanks for looking into this!

--j

On Mon, Apr 9, 2012 at 1:45 PM, steven mosher mosherste...@gmail.com wrote:
 Ya I hit the same error with my code that reads directories.
 I'll try some other stuff . I think I hit this error before I  with usgs.


 On Mon, Apr 9, 2012 at 11:40 AM, Jonathan Greenberg j...@illinois.edu
 wrote:

 Steven:

 Thanks -- I seem to be running into the problem with the link I sent
 along:

 
  getURL(ftp://e4ftl01.cr.usgs.gov/MOTA/MCD15A3.005/,verbose=TRUE,dirlistonly
  = TRUE)
 Error in function (type, msg, asError = TRUE)  : RETR response: 550

 I'm wondering if it might be a passive ftp issue, but:
 
  getURL(ftp://e4ftl01.cr.usgs.gov/MOTA/MCD15A3.005/,verbose=TRUE,ftp.use.epsv=TRUE,
  dirlistonly = TRUE)
 Error in function (type, msg, asError = TRUE)  :
  FTP response reading failed

 Does not seem to work...  Thoughts?

 --j

 On Mon, Apr 9, 2012 at 1:32 PM, steven mosher mosherste...@gmail.com
 wrote:
  A couple of ways.
 
  using Rcurl   you can use the  curlOption of dirlistonly.
 
  otherwise you can read the page and parse.  I've got some code around
  here
  to do that.
 
  Steve
 
  On Mon, Apr 9, 2012 at 11:27 AM, Jonathan Greenberg j...@illinois.edu
  wrote:
 
  R-helpers:
 
  I'd like to be able to store all the file information from an ftp site
  (e.g. file and foldernames) through an R command.  Any ideas how to do
  this?  Here's an example site to use:
 
  ftp://e4ftl01.cr.usgs.gov/MOTA/MCD15A3.005
 
  --j
 
  --
  Jonathan A. Greenberg, PhD
  Assistant Professor
  Department of Geography and Geographic Information Science
  University of Illinois at Urbana-Champaign
  607 South Mathews Avenue, MC 150
  Urbana, IL 61801
  Phone: 415-763-5476
  AIM: jgrn307, MSN: jgrn...@hotmail.com, Gchat: jgrn307, Skype: jgrn3007
  http://www.geog.illinois.edu/people/JonathanGreenberg.html
 
  __
  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.
 
 



 --
 Jonathan A. Greenberg, PhD
 Assistant Professor
 Department of Geography and Geographic Information Science
 University of Illinois at Urbana-Champaign
 607 South Mathews Avenue, MC 150
 Urbana, IL 61801
 Phone: 415-763-5476
 AIM: jgrn307, MSN: jgrn...@hotmail.com, Gchat: jgrn307, Skype: jgrn3007
 http://www.geog.illinois.edu/people/JonathanGreenberg.html





-- 
Jonathan A. Greenberg, PhD
Assistant Professor
Department of Geography and Geographic Information Science
University of Illinois at Urbana-Champaign
607 South Mathews Avenue, MC 150
Urbana, IL 61801
Phone: 415-763-5476
AIM: jgrn307, MSN: jgrn...@hotmail.com, Gchat: jgrn307, Skype: jgrn3007
http://www.geog.illinois.edu/people/JonathanGreenberg.html

__
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] Best way to search r- functions and mailing list?

2012-04-05 Thread Jonathan Greenberg
R-helpers:

It looks like http://finzi.psych.upenn.edu/search.html has stopped
spidering the mailing lists -- this used to be my go-to site for
searching for R solutions.  Are there any good replacements for this?
I want to be able to search both functions and mailing lists at the
same time.  Cheers!

--j

-- 
Jonathan A. Greenberg, PhD
Assistant Professor
Department of Geography
University of Illinois at Urbana-Champaign
607 South Mathews Avenue, MC 150
Urbana, IL 61801
Phone: 415-763-5476
AIM: jgrn307, MSN: jgrn...@hotmail.com, Gchat: jgrn307, Skype: jgrn3007
http://www.geog.illinois.edu/people/JonathanGreenberg.html

__
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] Parallel writes in R

2012-04-02 Thread Jonathan Greenberg
R-helpers:

I'm curious what support R has for parallel writes to a binary file?
If I want to use snow to have each node write different rows of a
flat binary file (possibly out of sequence), are there any
tricks/issues I should be aware of?

--j

-- 
Jonathan A. Greenberg, PhD
Assistant Professor
Department of Geography
University of Illinois at Urbana-Champaign
607 South Mathews Avenue, MC 150
Urbana, IL 61801
Phone: 415-763-5476
AIM: jgrn307, MSN: jgrn...@hotmail.com, Gchat: jgrn307, Skype: jgrn3007
http://www.geog.illinois.edu/people/JonathanGreenberg.html

__
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] Ignoring version numbers when installing packages...

2012-03-30 Thread Jonathan Greenberg
R-helpers:

I'm trying to install a package from r-forge, and I'm wondering if
there is a way to force R to install a package, even if the package
requires a certain version of R (short of modifying the DESCRIPTION
file)?  Cheers!

--j

-- 
Jonathan A. Greenberg, PhD
Assistant Professor
Department of Geography
University of Illinois at Urbana-Champaign
607 South Mathews Avenue, MC 150
Urbana, IL 61801
Phone: 415-763-5476
AIM: jgrn307, MSN: jgrn...@hotmail.com, Gchat: jgrn307, Skype: jgrn3007
http://www.geog.illinois.edu/people/JonathanGreenberg.html

__
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] Ignoring version numbers when installing packages...

2012-03-30 Thread Jonathan Greenberg
Follow-up:

r-forge seems to have some weirdnesses with version numbers, and since
this is an incubation site, there are occasions where the version
numbers were put in based on whatever the programmer was using at a
time (e.g. other versions were simply not tested, so they erred on the
safe side).  I understand that the internals may have changed, but I
would argue that 9/10 times if something is working on R 2.14.1 but
not 2.14.2 it has nothing to do with some incompatibility, just that
the package hasn't been updated in some time and tested against the
new version.

So, to follow-up, the only way to override the version installation
check is to modify the DESCRIPTION file?   There's no flag either in
install.packages() or R CMD INSTALL that will force the installation
even if the version check fails?

--j

On Fri, Mar 30, 2012 at 11:41 AM, Duncan Murdoch
murdoch.dun...@gmail.com wrote:
 On 30/03/2012 12:05 PM, Jonathan Greenberg wrote:

 R-helpers:

 I'm trying to install a package from r-forge, and I'm wondering if
 there is a way to force R to install a package, even if the package
 requires a certain version of R (short of modifying the DESCRIPTION
 file)?  Cheers!


 You don't give details, so the explanation is uncertain, but the answer is
 clear: don't do that.

 If you are trying to install a binary build, don't do that.  It might appear
 to work but fail in messy ways if you use it in the wrong version of R.
  Some packages link to R internals, and those might have changed.

 If you are trying to install from source, but the author said you need a
 particular version of R, then you could modify the DESCRIPTION file:  but
 presumably the author had a reason to ask for a particular version, so don't
 do that either.

 Duncan Murdoch





-- 
Jonathan A. Greenberg, PhD
Assistant Professor
Department of Geography
University of Illinois at Urbana-Champaign
607 South Mathews Avenue, MC 150
Urbana, IL 61801
Phone: 415-763-5476
AIM: jgrn307, MSN: jgrn...@hotmail.com, Gchat: jgrn307, Skype: jgrn3007
http://www.geog.illinois.edu/people/JonathanGreenberg.html

__
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] Creating a list from all combinations of two lists

2011-11-21 Thread Jonathan Greenberg
R-helpers:

Say I have two lists of arbitrary elements, e.g.:

 list1=list(c(1:3),R is fun!,c(3:6))

list2=list(c(10:5),c(5:3),c(13,5),I am so confused)


I would like to produce a single new list that is composed of all
combinations of the top level of list1 and list2, e.g.:

listcombo=list(list(list1[[1]],list2[[1]]),list(list1[[1]],list2[[2]]
),...,list(list1[[length(list1)]],list2[[length(list2]]))

What is the most efficient way to do this?  Thanks!

--j

-- 
Jonathan A. Greenberg, PhD
Assistant Professor
Department of Geography
University of Illinois at Urbana-Champaign
607 South Mathews Avenue, MC 150
Urbana, IL 61801
Phone: 415-763-5476
AIM: jgrn307, MSN: jgrn...@hotmail.com, Gchat: jgrn307, Skype: jgrn3007
http://www.geog.illinois.edu/people/JonathanGreenberg.html

[[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] How do I query ... in a function call?

2011-11-21 Thread Jonathan Greenberg
This is probably a very noobish question, but if I want to create a
function that allows an undetermined number of, say, numeric vectors to be
fed to it, I would use:

myfunction = function(...)
{
# Do something

}

Right?  If so, how do I a) count the number of vectors fed to the
function, and b) how do I treat those vectors as variables, e.g. for the
call:

myfunction(c(1:10),c(2:11),c(3:13))

Thanks!

--j

-- 
Jonathan A. Greenberg, PhD
Assistant Professor
Department of Geography
University of Illinois at Urbana-Champaign
607 South Mathews Avenue, MC 150
Urbana, IL 61801
Phone: 415-763-5476
AIM: jgrn307, MSN: jgrn...@hotmail.com, Gchat: jgrn307, Skype: jgrn3007
http://www.geog.illinois.edu/people/JonathanGreenberg.html

[[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] Setting hostname in the .Renvironment

2011-11-20 Thread Jonathan Greenberg
This is a follow-up to a question I asked a few years back.  We have a pair
of computers that share a common home directory (and therefor a common
.Renviron) with identical hardware, but very different sets of libraries
such that using a shared R_LIBS between two computers does not work.
 They both use this as the default library for user installations:

'~/R/x86_64-pc-linux-gnu-library/2.13'

I would like to mod the .Renviron in such a way so

'~/R/hostname-1/x86_64-pc-linux-gnu-library/2.13'
'~/R/hostname-2/x86_64-pc-linux-gnu-library/2.13'

How can I modify my R_LIBS_USER in the .Renviron to match this?  The
hostname would need to be dynamically set based on which computer I log
into, but I tried something like this:

R_LIBS_USER=~/lib/R/library/$HOSTNAME_%p_%a_%o_R%V

and R did not resolve the $HOSTNAME environment variable even though I can
(from bash) echo $HOSTNAME and it return the correct name.

Thoughts?  Thanks!

--j


-- 
Jonathan A. Greenberg, PhD
Assistant Professor
Department of Geography
University of Illinois at Urbana-Champaign
607 South Mathews Avenue, MC 150
Urbana, IL 61801
Phone: 415-763-5476
AIM: jgrn307, MSN: jgrn...@hotmail.com, Gchat: jgrn307, Skype: jgrn3007
http://www.geog.illinois.edu/people/JonathanGreenberg.html

[[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] setMethods/setGeneric problem when R CMD CHECK'ing a package

2011-08-24 Thread Jonathan Greenberg
R-helpers:

I'm trying to build a package, but I'm a bit new to the whole S3/S4
methods concept.  I'm trying to add a new definition of the zoo
function as.yearmon, but I'm getting the following error when it
gets to this point during a package install:

***

R CMD INSTALL STARStools
* installing to library
‘/Library/Frameworks/R.framework/Versions/2.13/Resources/library’
WARNING: omitting pointless dependence on 'R' without a version requirement
* installing *source* package ‘STARStools’ ...
** R
** inst
** preparing package for lazy loading
Loading required package: sp
raster version 1.9-5 (28-July-2011)
Geospatial Data Abstraction Library extensions to R successfully loaded
Loaded GDAL runtime: GDAL 1.8.0, released 2011/01/12
Path to GDAL shared files:
/Library/Frameworks/GDAL.framework/Versions/1.8/Resources/gdal
Loaded PROJ.4 runtime: Rel. 4.7.1, 23 September 2009
Path to PROJ.4 shared files: (autodetected)

Attaching package: 'zoo'

The following object(s) are masked from 'package:base':

as.Date

Creating a new generic function for as.Date in STARStools
Creating a new generic function for as.list in STARStools
Error in setGeneric(f, where = where) :
  must supply a function skeleton, explicitly or via an existing function
Error : unable to load R code in package 'STARStools'
ERROR: lazy loading failed for package ‘STARStools’
* removing 
‘/Library/Frameworks/R.framework/Versions/2.13/Resources/library/STARStools’
* restoring previous
‘/Library/Frameworks/R.framework/Versions/2.13/Resources/library/STARStools’

***

# Note that these require statements do not appear in the code, but
appear in the DESCRIPTION file:
require(sp)
require(zoo)

# Here are the class definitions (filename AAAclassdefinitions.R):
setClass(SpatialPointsDataFrameList,representation(list=list),contains=c(SpatialPointsDataFrame))
setClass(SpatialPointsDataFrameListZoo,contains=c(SpatialPointsDataFrameList))

# And here is where it is getting hung up. filename
as.yearmon.SpatialPointsDataFrameListZoo_SpatialPointsDataFrameListZoo.R

setMethod(as.yearmon,
signature(x = SpatialPointsDataFrameListZoo),
as.yearmon.SpatialPointsDataFrameListZoo
)

# Filename as.yearmon.SpatialPointsDataFrameListZoo.R
as.yearmon.SpatialPointsDataFrameListZoo=function(x,...)
{

newlist=mapply(zoo:::as.yearmon,x@list,MoreArgs=list(...),simplify=FALSE)
x@list=newlist
return(x)
}

Thoughts?

--j

-- 
Jonathan A. Greenberg, PhD
Assistant Project Scientist
Center for Spatial Technologies and Remote Sensing (CSTARS)
Department of Land, Air and Water Resources
University of California, Davis
One Shields Avenue
Davis, CA 95616
Phone: 415-763-5476
AIM: jgrn307, MSN: jgrn...@hotmail.com, Gchat: jgrn307

__
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] Easier ways to create .Rd files?

2011-08-24 Thread Jonathan Greenberg
Thanks Kevin!  Got started with roxygen tonight!  Cheers!

On Tue, Aug 23, 2011 at 6:28 PM, Kevin Wright kw.s...@gmail.com wrote:
 I like the roxygen2 package for combining code and documentation.  If you
 use Emacs + ESS, it will even create much of the roxygen code for you (and
 auto-revise it if you change the function arguments).

 Kevin Wright

 On Tue, Aug 23, 2011 at 6:55 PM, Jonathan Greenberg greenb...@ucdavis.edu
 wrote:

 R-helpers:

 Are there any ways to auto-generate R-friendly (e.g. will pass a
 compilation check) .Rd files given a set of .R code?  How about GUIs
 that help properly format the .Rd files?  Thanks!  I want a basic set
 of .Rd files that I can update as I go, but as with most things my
 documentation typically lags behind my coding by a few days.

 --j

 --
 Jonathan A. Greenberg, PhD
 Assistant Project Scientist
 Center for Spatial Technologies and Remote Sensing (CSTARS)
 Department of Land, Air and Water Resources
 University of California, Davis
 One Shields Avenue
 Davis, CA 95616
 Phone: 415-763-5476
 AIM: jgrn307, MSN: jgrn...@hotmail.com, Gchat: jgrn307

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





-- 
Jonathan A. Greenberg, PhD
Assistant Project Scientist
Center for Spatial Technologies and Remote Sensing (CSTARS)
Department of Land, Air and Water Resources
University of California, Davis
One Shields Avenue
Davis, CA 95616
Phone: 415-763-5476
AIM: jgrn307, MSN: jgrn...@hotmail.com, Gchat: jgrn307

__
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] setMethods/setGeneric problem when R CMD CHECK'ing a package

2011-08-24 Thread Jonathan Greenberg
Hmm, so I moved the function call to the same file as the methods
call, and placed it above the method in the file -- but I'm getting
the same error.  Is there something odd about as.yearmon in the zoo
package that it might not be getting defined as a generic function?
If so, how would I go about creating a generic?
setGeneric(as.yearmon) doesn't seem to cut it.

Here's the new file contents:

as.yearmon.SpatialPointsDataFrameListZoo=function(x,...)
{

newlist=mapply(zoo:::as.yearmon,x@list,MoreArgs=list(...),simplify=FALSE)
x@list=newlist
return(x)
}

setMethod(as.yearmon,
signature(x = SpatialPointsDataFrameListZoo),
as.yearmon.SpatialPointsDataFrameListZoo
)

--j

2011/8/24 Uwe Ligges lig...@statistik.tu-dortmund.de:


 On 24.08.2011 10:30, Jonathan Greenberg wrote:

 R-helpers:

 I'm trying to build a package, but I'm a bit new to the whole S3/S4
 methods concept.  I'm trying to add a new definition of the zoo
 function as.yearmon, but I'm getting the following error when it
 gets to this point during a package install:

 Thhis seesm more appropiate for the R-devel rather than the R-help list.
 Anyway, see below.


 ***

 R CMD INSTALL STARStools
 * installing to library
 ‘/Library/Frameworks/R.framework/Versions/2.13/Resources/library’
 WARNING: omitting pointless dependence on 'R' without a version
 requirement
 * installing *source* package ‘STARStools’ ...
 ** R
 ** inst
 ** preparing package for lazy loading
 Loading required package: sp
 raster version 1.9-5 (28-July-2011)
 Geospatial Data Abstraction Library extensions to R successfully loaded
 Loaded GDAL runtime: GDAL 1.8.0, released 2011/01/12
 Path to GDAL shared files:
 /Library/Frameworks/GDAL.framework/Versions/1.8/Resources/gdal
 Loaded PROJ.4 runtime: Rel. 4.7.1, 23 September 2009
 Path to PROJ.4 shared files: (autodetected)

 Attaching package: 'zoo'

 The following object(s) are masked from 'package:base':

     as.Date

 Creating a new generic function for as.Date in STARStools
 Creating a new generic function for as.list in STARStools
 Error in setGeneric(f, where = where) :
   must supply a function skeleton, explicitly or via an existing function
 Error : unable to load R code in package 'STARStools'
 ERROR: lazy loading failed for package ‘STARStools’
 * removing
 ‘/Library/Frameworks/R.framework/Versions/2.13/Resources/library/STARStools’
 * restoring previous

 ‘/Library/Frameworks/R.framework/Versions/2.13/Resources/library/STARStools’

 ***

 # Note that these require statements do not appear in the code, but
 appear in the DESCRIPTION file:
 require(sp)
 require(zoo)

 ??? Not valid in the DESCRIPTION file. Either use this in  your code or
 import from the corresponding Namespaces which you will have to do anyway
 for the next R release.



 # Here are the class definitions (filename AAAclassdefinitions.R):

 setClass(SpatialPointsDataFrameList,representation(list=list),contains=c(SpatialPointsDataFrame))

 setClass(SpatialPointsDataFrameListZoo,contains=c(SpatialPointsDataFrameList))

 # And here is where it is getting hung up. filename
 as.yearmon.SpatialPointsDataFrameListZoo_SpatialPointsDataFrameListZoo.R

 setMethod(as.yearmon,
     signature(x = SpatialPointsDataFrameListZoo),
        as.yearmon.SpatialPointsDataFrameListZoo
 )

 You try to register the method pointing to a function definition that does
 not exist at this point (since you define it below). Just move the
 definition up.

 Uwe Ligges



 # Filename as.yearmon.SpatialPointsDataFrameListZoo.R
 as.yearmon.SpatialPointsDataFrameListZoo=function(x,...)
 {

  newlist=mapply(zoo:::as.yearmon,x@list,MoreArgs=list(...),simplify=FALSE)
        x@list=newlist
        return(x)
 }

 Thoughts?

 --j





-- 
Jonathan A. Greenberg, PhD
Assistant Project Scientist
Center for Spatial Technologies and Remote Sensing (CSTARS)
Department of Land, Air and Water Resources
University of California, Davis
One Shields Avenue
Davis, CA 95616
Phone: 415-763-5476
AIM: jgrn307, MSN: jgrn...@hotmail.com, Gchat: jgrn307

__
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] Easier ways to create .Rd files?

2011-08-23 Thread Jonathan Greenberg
R-helpers:

Are there any ways to auto-generate R-friendly (e.g. will pass a
compilation check) .Rd files given a set of .R code?  How about GUIs
that help properly format the .Rd files?  Thanks!  I want a basic set
of .Rd files that I can update as I go, but as with most things my
documentation typically lags behind my coding by a few days.

--j

-- 
Jonathan A. Greenberg, PhD
Assistant Project Scientist
Center for Spatial Technologies and Remote Sensing (CSTARS)
Department of Land, Air and Water Resources
University of California, Davis
One Shields Avenue
Davis, CA 95616
Phone: 415-763-5476
AIM: jgrn307, MSN: jgrn...@hotmail.com, Gchat: jgrn307

__
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] Best way to setClass and setMethod for an R package?

2011-08-20 Thread Jonathan Greenberg
Folks:

I'm putting together an R package, and I was wondering where,
specifically, I put both class definitions (via setClass) as well as
setMethod calls?  Is there a particular file name I need to use?
Thanks!

--j

-- 
Jonathan A. Greenberg, PhD
Assistant Project Scientist
Center for Spatial Technologies and Remote Sensing (CSTARS)
Department of Land, Air and Water Resources
University of California, Davis
One Shields Avenue
Davis, CA 95616
Phone: 415-763-5476
AIM: jgrn307, MSN: jgrn...@hotmail.com, Gchat: jgrn307

__
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] Data frame to list?

2011-08-10 Thread Jonathan Greenberg
Answered my own question.  ?split

Never mind!

--j

On Wed, Aug 10, 2011 at 7:35 PM, Jonathan Greenberg
greenb...@ucdavis.edu wrote:
 R-helpers:

 Is there an easy way to transfer a data frame to a list, where each
 list element is a dataframe containing a single row from the original
 data frame?

 --j

 --
 Jonathan A. Greenberg, PhD
 Assistant Project Scientist
 Center for Spatial Technologies and Remote Sensing (CSTARS)
 Department of Land, Air and Water Resources
 University of California, Davis
 One Shields Avenue
 Davis, CA 95616
 Phone: 415-763-5476
 AIM: jgrn307, MSN: jgrn...@hotmail.com, Gchat: jgrn307




-- 
Jonathan A. Greenberg, PhD
Assistant Project Scientist
Center for Spatial Technologies and Remote Sensing (CSTARS)
Department of Land, Air and Water Resources
University of California, Davis
One Shields Avenue
Davis, CA 95616
Phone: 415-763-5476
AIM: jgrn307, MSN: jgrn...@hotmail.com, Gchat: jgrn307

__
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] Data frame to list?

2011-08-10 Thread Jonathan Greenberg
R-helpers:

Is there an easy way to transfer a data frame to a list, where each
list element is a dataframe containing a single row from the original
data frame?

--j

-- 
Jonathan A. Greenberg, PhD
Assistant Project Scientist
Center for Spatial Technologies and Remote Sensing (CSTARS)
Department of Land, Air and Water Resources
University of California, Davis
One Shields Avenue
Davis, CA 95616
Phone: 415-763-5476
AIM: jgrn307, MSN: jgrn...@hotmail.com, Gchat: jgrn307

__
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] Data frame to list

2011-07-28 Thread Jonathan Greenberg
I'm hoping this is an easy problem that I'm missing something obvious.  Given:

x=c(1,1,1,2,2,3,3,3)
y=c(1:length(x))
dataframe=data.frame(x,y)

I would like to convert this to a list for use with certain functions,
where each entry of the list is a subsetted dataframe based on
dataframe$x

I can do this brute force by a for-next loop:

unique_x=unique(dataframe$x)
unique_x_N=length(unique_x)
dataframe_to_list=vector(mode=list,length=unique_x_N)
for(i in 1:unique_x_N)
{
dataframe_to_list[[i]]=subset(dataframe,x==unique_x[i])

}

My R-gut is telling me there's a much more efficient way of doing this
-- is it right?

--j

__
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] Data frame to list

2011-07-28 Thread Jonathan Greenberg
Yep, my R-gut was right!  Thanks Jean and Greg!

--j

On Thu, Jul 28, 2011 at 1:29 PM, Jean V Adams jvad...@usgs.gov wrote:


 Try this:

 split(dataframe, dataframe$x)

 Jean


 `·.,,  (((º   `·.,,  (((º   `·.,,  (((º

 Jean V. Adams
 Statistician
 U.S. Geological Survey
 Great Lakes Science Center
 223 East Steinfest Road
 Antigo, WI 54409  USA


  From: Jonathan Greenberg j...@illinois.edu To: r-help 
 r-help@r-project.org Date: 07/28/2011 03:22 PM Subject:
 [R] Data frame to list
 Sent by: r-help-boun...@r-project.org
 --



 I'm hoping this is an easy problem that I'm missing something obvious.
  Given:

 x=c(1,1,1,2,2,3,3,3)
 y=c(1:length(x))
 dataframe=data.frame(x,y)

 I would like to convert this to a list for use with certain functions,
 where each entry of the list is a subsetted dataframe based on
 dataframe$x

 I can do this brute force by a for-next loop:

 unique_x=unique(dataframe$x)
 unique_x_N=length(unique_x)
 dataframe_to_list=vector(mode=list,length=unique_x_N)
 for(i in 1:unique_x_N)
 {
 dataframe_to_list[[i]]=subset(dataframe,x==unique_x[i])

 }

 My R-gut is telling me there's a much more efficient way of doing this
 -- is it right?

 --j

 __
 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.htmlhttp://www.r-project.org/posting-guide.html
 and provide commented, minimal, self-contained, reproducible code.




[[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] Querying the path separator?

2011-06-30 Thread Jonathan Greenberg
Unfortunately, no.  .Platform$file.sep on a windows box is the /.
For this DOS program it needs to be the classic backslash.

Ok, we'll hack this a bit (query the platform and test if it is
windows), but now I'm running into escape character problems.  Given:

files1=*.las
files1_formatted=file.path(getwd(),files1)
files1_formatted
[1] X:/pathto/*.las

I want files1_formatted to read:
X:\pathto\*.las

Using:
sub(/,\,files1_formatted)
Doesn't work (in fact, its not a complete statement -- I assume since
its waiting for something to follow the / ).  What's the trick with
this?

--j



On Tue, Jun 28, 2011 at 11:05 PM, Berend Hasselman b...@xs4all.nl wrote:

 Jonathan Greenberg wrote:

 The problem is that I'm trying to create a path to use with a system()
 call, and the command window will not work with the forward slash,
 only with the standard backslash.  I do understand that within R it
 will work with either way, but not via the system call.  I'm trying to
 create a generic system() call that will work with an external
 executable that is available on both windows and unix machines.


 Would .Platform$file.sep help you?
 I can't test this.

 Berend

 --
 View this message in context: 
 http://r.789695.n4.nabble.com/Querying-the-path-separator-tp3631806p3632161.html
 Sent from the R help mailing list archive at Nabble.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.




-- 
Jonathan A. Greenberg, PhD
Assistant Project Scientist
Center for Spatial Technologies and Remote Sensing (CSTARS)
Department of Land, Air and Water Resources
University of California, Davis
One Shields Avenue
Davis, CA 95616
Phone: 415-763-5476
AIM: jgrn307, MSN: jgrn...@hotmail.com, Gchat: jgrn307

__
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] Querying the path separator?

2011-06-28 Thread Jonathan Greenberg
Hopefully this is a pretty easy fix -- I need to have R query the path
separator for some code I'm trying to write (it involves using a
system() call) -- the call requires a path and a wildcard, e.g.:

command=mycommand /path/to/*.files in the case of unix or,
command=mycommand.exe C:\\path\\to\\*.files on a windows box

System.which is working correctly, so the mycommand vs
mycommand.exe part is working fine.  The issue is that the /path/to
should be set to getwd(), but this strips the trailing path separator.
 How do I go about querying the correct path separator for the system,
so I can include it in a paste command (via sep=)?  Thanks!

--j

-- 
Jonathan A. Greenberg, PhD
Assistant Project Scientist
Center for Spatial Technologies and Remote Sensing (CSTARS)
Department of Land, Air and Water Resources
University of California, Davis
One Shields Avenue
Davis, CA 95616
Phone: 415-763-5476
AIM: jgrn307, MSN: jgrn...@hotmail.com, Gchat: jgrn307

__
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] Querying the path separator?

2011-06-28 Thread Jonathan Greenberg
Thanks Henrik, but as the help for this function states:

Note
The components are separated by / (not \) on Windows.

, the slashes it uses are incorrect for use in a CMD window on a
Windows box (they need to be \ but file.path uses /).  I suppose I can
do a query as to whether the platform is Windows (in which case use \)
or other (in which case use /) -- there isn't a more clever way of
doing this?

--j

On Tue, Jun 28, 2011 at 7:10 PM, Henrik Bengtsson h...@biostat.ucsf.edu wrote:
 See file.path().

 /Henrik

 On Tue, Jun 28, 2011 at 6:59 PM, Jonathan Greenberg
 greenb...@ucdavis.edu wrote:
 Hopefully this is a pretty easy fix -- I need to have R query the path
 separator for some code I'm trying to write (it involves using a
 system() call) -- the call requires a path and a wildcard, e.g.:

 command=mycommand /path/to/*.files in the case of unix or,
 command=mycommand.exe C:\\path\\to\\*.files on a windows box

 System.which is working correctly, so the mycommand vs
 mycommand.exe part is working fine.  The issue is that the /path/to
 should be set to getwd(), but this strips the trailing path separator.
  How do I go about querying the correct path separator for the system,
 so I can include it in a paste command (via sep=)?  Thanks!

 --j

 --
 Jonathan A. Greenberg, PhD
 Assistant Project Scientist
 Center for Spatial Technologies and Remote Sensing (CSTARS)
 Department of Land, Air and Water Resources
 University of California, Davis
 One Shields Avenue
 Davis, CA 95616
 Phone: 415-763-5476
 AIM: jgrn307, MSN: jgrn...@hotmail.com, Gchat: jgrn307

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





-- 
Jonathan A. Greenberg, PhD
Assistant Project Scientist
Center for Spatial Technologies and Remote Sensing (CSTARS)
Department of Land, Air and Water Resources
University of California, Davis
One Shields Avenue
Davis, CA 95616
Phone: 415-763-5476
AIM: jgrn307, MSN: jgrn...@hotmail.com, Gchat: jgrn307

__
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] Querying the path separator?

2011-06-28 Thread Jonathan Greenberg
The problem is that I'm trying to create a path to use with a system()
call, and the command window will not work with the forward slash,
only with the standard backslash.  I do understand that within R it
will work with either way, but not via the system call.  I'm trying to
create a generic system() call that will work with an external
executable that is available on both windows and unix machines.

--j



On Tue, Jun 28, 2011 at 10:02 PM, Jeff Newmiller
jdnew...@dcn.davis.ca.us wrote:
 Windows will work with either separator.
 ---
 Jeff Newmiller The . . Go Live...
 DCN:jdnew...@dcn.davis.ca.us Basics: ##.#. ##.#. Live Go...
 Live: OO#.. Dead: OO#.. Playing
 Research Engineer (Solar/Batteries O.O#. #.O#. with
 /Software/Embedded Controllers) .OO#. .OO#. rocks...1k
 ---
 Sent from my phone. Please excuse my brevity.

 Jonathan Greenberg greenb...@ucdavis.edu wrote:

 Thanks Henrik, but as the help for this function states:

 Note
 The components are separated by / (not \) on Windows.

 , the slashes it uses are incorrect for use in a CMD window on a
 Windows box (they need to be \ but file.path uses /).  I suppose I can
 do a query as to whether the platform is Windows (in which case use \)
 or other (in which case use /) -- there isn't a more clever way of
 doing this?

 --j

 On Tue, Jun 28, 2011 at 7:10 PM, Henrik Bengtsson h...@biostat.ucsf.edu
 wrote:
  See file.path().
 
  /Henrik
 
  On Tue, Jun 28, 2011 at 6:59 PM, Jonathan Greenberg
  greenb...@ucdavis.edu wrote:
  Hopefully this is a pretty easy fix -- I need to have R query the path
  separator for some code I'm trying to write (it involves using a
 
  
 system() call) -- the call requires a path and a wildcard, e.g.:
 
  command=mycommand /path/to/*.files in the case of unix or,
  command=mycommand.exe C:\\path\\to\\*.files on a windows box
 
  System.which is working correctly, so the mycommand vs
  mycommand.exe part is working fine.  The issue is that the /path/to
  should be set to getwd(), but this strips the trailing path separator.
   How do I go about querying the correct path separator for the system,
  so I can include it in a paste command (via sep=)?  Thanks!
 
  --j
 
  --
  Jonathan A. Greenberg, PhD
  Assistant Project Scientist
  Center for Spatial Technologies and Remote Sensing (CSTARS)
  Department of Land, Air and Water Resources
  University of California, Davis
  One S
  hields
 Avenue
  Davis, CA 95616
  Phone: 415-763-5476
  AIM: jgrn307, MSN: jgrn...@hotmail.com, Gchat: jgrn307
 
 
 
  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.
 
 



 --
 Jonathan A. Greenberg, PhD
 Assistant Project Scientist
 Center for Spatial Technologies and Remote Sensing (CSTARS)
 Department of Land, Air and Water Resources
 University of California, Davis
 One Shields Avenue
 Davis, CA 95616
 Phone: 415-763-5476
 AIM: jgrn307, MSN: jgrn...@hotmail.com, Gchat: jgrn307

 
 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.




-- 
Jonathan A. Greenberg, PhD
Assistant Project Scientist
Center for Spatial Technologies and Remote Sensing (CSTARS)
Department of Land, Air and Water Resources
University of California, Davis
One Shields Avenue
Davis, CA 95616
Phone: 415-763-5476
AIM: jgrn307, MSN: jgrn...@hotmail.com, Gchat: jgrn307

__
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] Passing a function as a parameter...

2010-09-22 Thread Jonathan Greenberg
R-helpers:

If I want to pass a character name of a function TO a function, and then
have that function executed, how would I do this?  I want
an arbitrary version of the following, where any function can be used (e.g.
I don't want the if-then statement here):

apply_some_function - function(data,function_name)
{
  if(function_name==mean)
{
return(mean(data))
}
if(function_name==min)
{
return(min(data))
}

}

apply_some_function(1:10,mean)
apply_some_function(1:10,min)

Basically, I want the character name of the function used to actually
execute that function.  Thanks!

--j

[[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] Removing inter-bar spaces in barchart

2010-08-26 Thread Jonathan Greenberg
Oops, small typo, should be:


barchart_test_heights=sin(c(1:100))
barchart_test_bins=c(c(1:50),c(1:50))
groups=c(rep(1,50),rep(2,50))

# Wish below didn't have spaces!
barchart(barchart_test_bins~barchart_test_heights,groups=groups)

On Wed, Aug 25, 2010 at 4:46 PM, Jonathan Greenberg
greenb...@ucdavis.edu wrote:
 I apologize, let me add some data to play with:

 barchart_test_heights=sin(c(1:100))
 barchart_test_bins=c(1:100)
 groups=c(rep(1,50),rep(2,50))

 I have pre-calculated histogram data and the bins they belong to.  I
 would like to plot the two histograms superimposed on one-another,
 having group 1 bars for a given bin be next to group 2 bars, something
 along the lines of:

 barchart(barchart_test_bins~barchart_test_heights,groups=groups)

 except with no space between the bars (and a key for the groups).

 --j

 P.S. And yes I was talking about barchart() from lattice -- however, I
 am happy to use another function if that makes this easier.

 On Wed, Aug 25, 2010 at 1:55 PM, David Winsemius dwinsem...@comcast.net 
 wrote:

 On Aug 24, 2010, at 10:20 PM, Jonathan Greenberg wrote:

 Rhelpers:

 I'm trying to make a barchart of a 2-group dataset
 (barchart(x~y,data=data,groups=z,horizontal=FALSE)).  My problem is
 that I can't, for the life of me, seem to get rid of the inter-bar
 space -- box.ratio set to 1 doesn't do much.  Any ideas?  I'd
 ideally want zero space between the bars.  Thanks!

 You didn't provide any data (nor did you illustrate with one of the
 available datasets that are used in examples.)

 Compare these two outputs:

 barchart(yield ~ year, data = barley,
         groups = variety,   ylab = Barley Yield (bushels/acre),
        )

 barchart(yield ~ variety, data = barley,
         groups = year,   ylab = Barley Yield (bushels/acre),
        )

 ... and notice that the variables in the group have no separation of their
 bars whereas the rhs variables do. This is the opposite of what I expected,
 so perhaps you think as I did and reversing the roles ofy and z  might
 help?

 --

 David Winsemius, MD
 West Hartford, CT





 --
 Jonathan A. Greenberg, PhD
 Assistant Project Scientist
 Center for Spatial Technologies and Remote Sensing (CSTARS)
 Department of Land, Air and Water Resources
 University of California, Davis
 One Shields Avenue
 Davis, CA 95616
 Phone: 415-763-5476
 AIM: jgrn307, MSN: jgrn...@hotmail.com, Gchat: jgrn307




-- 
Jonathan A. Greenberg, PhD
Assistant Project Scientist
Center for Spatial Technologies and Remote Sensing (CSTARS)
Department of Land, Air and Water Resources
University of California, Davis
One Shields Avenue
Davis, CA 95616
Phone: 415-763-5476
AIM: jgrn307, MSN: jgrn...@hotmail.com, Gchat: jgrn307

__
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] Removing inter-bar spaces in barchart

2010-08-26 Thread Jonathan Greenberg
I apologize, let me add some data to play with:

barchart_test_heights=sin(c(1:100))
barchart_test_bins=c(1:100)
groups=c(rep(1,50),rep(2,50))

I have pre-calculated histogram data and the bins they belong to.  I
would like to plot the two histograms superimposed on one-another,
having group 1 bars for a given bin be next to group 2 bars, something
along the lines of:

barchart(barchart_test_bins~barchart_test_heights,groups=groups)

except with no space between the bars (and a key for the groups).

--j

P.S. And yes I was talking about barchart() from lattice -- however, I
am happy to use another function if that makes this easier.

On Wed, Aug 25, 2010 at 1:55 PM, David Winsemius dwinsem...@comcast.net wrote:

 On Aug 24, 2010, at 10:20 PM, Jonathan Greenberg wrote:

 Rhelpers:

 I'm trying to make a barchart of a 2-group dataset
 (barchart(x~y,data=data,groups=z,horizontal=FALSE)).  My problem is
 that I can't, for the life of me, seem to get rid of the inter-bar
 space -- box.ratio set to 1 doesn't do much.  Any ideas?  I'd
 ideally want zero space between the bars.  Thanks!

 You didn't provide any data (nor did you illustrate with one of the
 available datasets that are used in examples.)

 Compare these two outputs:

 barchart(yield ~ year, data = barley,
         groups = variety,   ylab = Barley Yield (bushels/acre),
        )

 barchart(yield ~ variety, data = barley,
         groups = year,   ylab = Barley Yield (bushels/acre),
        )

 ... and notice that the variables in the group have no separation of their
 bars whereas the rhs variables do. This is the opposite of what I expected,
 so perhaps you think as I did and reversing the roles ofy and z  might
 help?

 --

 David Winsemius, MD
 West Hartford, CT





-- 
Jonathan A. Greenberg, PhD
Assistant Project Scientist
Center for Spatial Technologies and Remote Sensing (CSTARS)
Department of Land, Air and Water Resources
University of California, Davis
One Shields Avenue
Davis, CA 95616
Phone: 415-763-5476
AIM: jgrn307, MSN: jgrn...@hotmail.com, Gchat: jgrn307

__
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] Removing inter-bar spaces in barchart

2010-08-25 Thread Jonathan Greenberg
Rhelpers:

I'm trying to make a barchart of a 2-group dataset
(barchart(x~y,data=data,groups=z,horizontal=FALSE)).  My problem is
that I can't, for the life of me, seem to get rid of the inter-bar
space -- box.ratio set to 1 doesn't do much.  Any ideas?  I'd
ideally want zero space between the bars.  Thanks!

--j

-- 
Jonathan A. Greenberg, PhD
Assistant Project Scientist
Center for Spatial Technologies and Remote Sensing (CSTARS)
Department of Land, Air and Water Resources
University of California, Davis
One Shields Avenue
Davis, CA 95616
Phone: 415-763-5476
AIM: jgrn307, MSN: jgrn...@hotmail.com, Gchat: jgrn307

__
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] Evaluating a string

2010-07-01 Thread Jonathan Greenberg
Rhelpers:

How do I get R to evaluate a string, as if it was an R statement, e.g.:

a=3
b=2
operator=-
statement_string=paste(a,operator,b,sep=)

--j

__
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] using zoo() to coerce time series to a different reference frame

2010-06-29 Thread Jonathan Greenberg
Folks:

I have two sets of dates, and one set of data:

***

require(chron)
require(zoo)
reference_dates=seq.dates(01/01/92, 12/31/92, by = months)
data_dates=seq.dates(01/15/91, 12/15/93, by = months)
data=1:length(data_dates)

reference_zoo=zoo(order.by=reference_dates)
data_zoo=zoo(data,data_dates)

***

What I would like is to have a zoo object that uses the index from
reference_dates, but grabs the data for each of the dates (using a
spline interpolation) from data_zoo object.  I feel like my solution
is a bit slow, can someone let me know if there is a quicker way to do
this?  Thanks:

***

reference_data_zoo_merge=merge(reference_zoo,data_zoo)
reference_data_zoo_data=na.spline(reference_data_zoo_merge)
reference_data_zoo_data=merge(reference_zoo,reference_data_zoo_data,all=FALSE)

***

--j

__
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] seq.dates in reverse?

2010-06-29 Thread Jonathan Greenberg
Pardon the barrage of time series related questions, but another issue
I'm trying to solve is how to determine a sequence of dates a la
seq.dates() except going BACKWARDS in time, e.g. if seq.dates()
allowed for the to variables to be set alone, rather than the from=.
 Ultimately, I'd like to have a set of dates preceding a given date in
predefined intervals (the same ones seq.dates() uses would be fine).
Thoughts?  Would there be an easy way to reverse engineer a starting
date given the by= variable and the length=?  With the exception
of using by=days, I'm a bit unfamiliar with how to easily determine
what date was, say, 4 months ago without doing a lot of string hacking
(seq.dates() conveniently keeps the days of the month constant when
generate date sequences, which is what I'd like).

--j

__
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] exists() and functions

2010-06-25 Thread Jonathan Greenberg
Always nice to answer my own question 3 minutes later.  The missing()
function does what I want.  Still, why DOES this exists() statement
fail?  Do functions auto create the variables once they are called,
regardless of whether or not they are assigned?

--j

On Fri, Jun 25, 2010 at 1:05 PM, Jonathan Greenberg
greenb...@ucdavis.edu wrote:
 I'm a bit confused about how exists() work within a function -- I want
 to test for unassigned variables, but I'm doing tests in the main
 environment to figure out the function, so the variables DO exist in
 the parent environment of a function call.

 Why does:
 myfunction - function(variable_outside_function)
 {
        print(exists(variable_outside_function,inherit=FALSE))
        print(exists(another_variable_outside_function,inherit=FALSE))
 }

 myfunction()

 Return:
 [1] TRUE
 [1] FALSE

 I didn't assign anything to variable_outside_function, so I'm unclear
 why it thinks it exists...

 --j


__
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] exists() and functions

2010-06-25 Thread Jonathan Greenberg
I'm a bit confused about how exists() work within a function -- I want
to test for unassigned variables, but I'm doing tests in the main
environment to figure out the function, so the variables DO exist in
the parent environment of a function call.

Why does:
myfunction - function(variable_outside_function)
{
print(exists(variable_outside_function,inherit=FALSE))
print(exists(another_variable_outside_function,inherit=FALSE))
}

myfunction()

Return:
[1] TRUE
[1] FALSE

I didn't assign anything to variable_outside_function, so I'm unclear
why it thinks it exists...

--j

__
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] RSQLite and fetching rows from multiple tables

2010-06-21 Thread Jonathan Greenberg
I'm trying to use RSQLite statement to cycle through a large database
in chunks via the fetch(...,n=2).  As far as I can tell,
however, it keeps re-fetching the same beginning set of rows -- any
ideas what might be wrong with the following code?  The select
statement is pulling from multiple tables.  I apologize in advance --
the DB is about 4gb so I can't make it easily available, but I'm
guessing someone can tell what I'm doing wrong just from the example
code below:

climate_query=dbSendQuery(con,SELECT
PPT_PRISM.data_vector,TMIN_PRISM.data_vector,TMAX_PRISM.data_vector,RAD_RSUN.data_vector,DEM_25M.data_vector,UWIND_NARR.data_vector,VWIND_NARR.data_vector,PPT_PRISM.date_vector,TMIN_PRISM.date_vector,TMAX_PRISM.date_vector,RAD_RSUN.date_vector,DEM_25M.date_vector,UWIND_NARR.date_vector,VWIND_NARR.date_vector
FROM PPT_PRISM,TMIN_PRISM,TMAX_PRISM,RAD_RSUN,DEM_25M,UWIND_NARR,VWIND_NARR)

while(!dbHasCompleted(climate_query)){
climate_data_fetch - fetch(climate_query, n = db_fetch_n)
print(climate_data_fetch[1,1]
print(dbGetRowCount(climate_query))
# I want to do something with the climate_data_fetch
chunk here, write out the results to a new table, and go to the next
set of rows.
}
dbClearResult(climate_query)

The first print statement shows the same thing over and over again,
and the second print statement (dbGetRowCount) eventually exceeds the
total number of rows in each of the tables.

Is the issue that I'm selecting from multiple tables at once (they all
have the same length)?  If so, what would be a better approach to
doing this?  Is there a way to control fetch so it pulls a range of
rows?

--j

__
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] Fastest way to merge matrix columns into a comma delimited string?

2010-06-15 Thread Jonathan Greenberg
Folks:

Say I have a matrix:

test=matrix(c(1,2,3),nrow=10,ncol=3)

I would like to have an output character vector where each line is
row's values delimited by commas, e.g.:

1,2,3
2,3,1
3,1,2
...
1,2,3

What is the fastest way of doing this?  I can paste() row-by-row but
this seems an inefficient approach to doing this.  Thanks!  I'm not
asking how to write a CSV file, mind you, I want the array as an R
data.frame or vector.

--j

__
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] Matrix to database -- best practices/efficiency?

2010-06-08 Thread Jonathan Greenberg
Its a race!  I decided to go ahead and time everyone's results, and
all of the method's (except mine) are around the same speed.  I ran
them a few times and Gabor's application of melt() tends to be a tad
bit faster than the other two, although that is far from conclusive --
do these methods share code in common?  Should I expect one to of
these to have a smaller during-processing footprint than the others?
Thanks again!

--j

# My terrible approach:
my_matrix=matrix(c(1:60),nrow=600,ncol=100)
id_m=seq(10,6000,by=10)
id_n=seq(100,1,by=100)

system.time(
for (a in 1:length(id_m))
{
for (b in 1:length(id_n))
{
if ((a==1)  (b==1))
{
my_database=c(id_m[a],id_n[b],my_matrix[a,b])
} else
{

my_database=rbind(my_database,c(id_m[a],id_n[b],my_matrix[a,b]))
}
}
}
)
   user  system elapsed
173.601  10.288 202.433

# Gabor's method with reshape
library(reshape)
my_matrix = 
matrix(c(1:60),nrow=600,ncol=100,dimnames=list(seq(10,6000,by=10),seq(100,1,by=100)))
system.time(
my_database - melt(my_matrix)
)

   user  system elapsed
  0.006   0.006   0.014

# Jorge's method with as.data.frame.table
my_matrix = 
matrix(c(1:60),nrow=600,ncol=100,dimnames=list(seq(10,6000,by=10),seq(100,1,by=100)))
system.time(
my_database - as.data.frame.table(my_matrix)
)

   user  system elapsed
  0.027   0.005   0.036

# Bill's method with expand.grid
my_matrix=matrix(c(1:60),nrow=600,ncol=100)
id_m=seq(10,6000,by=10)
id_n=seq(100,1,by=100)
system.time(
my_database - cbind(
expand.grid(id_m = id_m, id_n = id_n),
mat = as.vector(my_matrix)
)
)

   user  system elapsed
  0.007   0.006   0.020

On Mon, Jun 7, 2010 at 9:30 PM,  bill.venab...@csiro.au wrote:
 I think what you are groping for is something like this

 my_matrix - matrix(1:60, nrow = 6)
 id_a - seq(10,60,by=10)
 id_b - seq(100,1000,by=100)
 my_database - cbind(
  expand.grid(id_a = id_a, id_b = id_b),
  mat = as.vector(my_matrix)
 )


 -Original Message-
 From: r-help-boun...@r-project.org [mailto:r-help-boun...@r-project.org] On 
 Behalf Of Jonathan Greenberg
 Sent: Tuesday, 8 June 2010 12:34 PM
 To: r-help
 Subject: [R] Matrix to database -- best practices/efficiency?

 I have a matrix of, say, M and N dimensions:

 my_matrix=matrix(c(1:60),nrow=6,ncol=10)

 I have two id vectors corresponding to the rows and columns, e.g.:

 id_m=seq(10,60,by=10)
 id_n=seq(100,1000,by=100)

 I would like to create a proper database (let's say a data.frame for
 this example -- i'm going to be loading these into an SQLite database,
 but we'll leave that complication out of this discussion for now) of m
 x n rows, and 3 columns, where the 3 columns relate to the values from
 m, n, and my_matrix respectively, e.g. a single row follows the form:

 c(id_m[a],id_n[b],my_matrix[a,b])

 I can, of course, for-loop this thing with an if-then, e.g.:

 ***

 for (a in 1:length(id_m))
 {
        for (b in 1:length(id_n))
        {
                if ((a==1)  (b==1))
                {
                        my_database=c(id_m[a],id_n[b],my_matrix[a,b])
                } else
                {
                        
 my_database=rbind(my_database,c(id_m[a],id_n[b],my_matrix[a,b]))
                }
        }
 }

 ***

 But my gut is telling me this is an incredibly inefficient way of
 doing this -- is there a faster approach to doing this same process?
 Thanks!

 --j

 __
 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] Matrix to database -- best practices/efficiency?

2010-06-07 Thread Jonathan Greenberg
I have a matrix of, say, M and N dimensions:

my_matrix=matrix(c(1:60),nrow=6,ncol=10)

I have two id vectors corresponding to the rows and columns, e.g.:

id_m=seq(10,60,by=10)
id_n=seq(100,1000,by=100)

I would like to create a proper database (let's say a data.frame for
this example -- i'm going to be loading these into an SQLite database,
but we'll leave that complication out of this discussion for now) of m
x n rows, and 3 columns, where the 3 columns relate to the values from
m, n, and my_matrix respectively, e.g. a single row follows the form:

c(id_m[a],id_n[b],my_matrix[a,b])

I can, of course, for-loop this thing with an if-then, e.g.:

***

for (a in 1:length(id_m))
{
for (b in 1:length(id_n))
{
if ((a==1)  (b==1))
{
my_database=c(id_m[a],id_n[b],my_matrix[a,b])
} else
{   

my_database=rbind(my_database,c(id_m[a],id_n[b],my_matrix[a,b]))
}
}
}

***

But my gut is telling me this is an incredibly inefficient way of
doing this -- is there a faster approach to doing this same process?
Thanks!

--j

__
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 and ATLAS

2010-05-27 Thread Jonathan Greenberg
Peter and Dirk:

Thanks for the quick response -- I'm trying to get multiple CPU
responses as Peter indicated should happen, but those R commands only
illicit a single CPU response.

When I check the libraries:

ldd /usr/lib/R/bin/exec/R
linux-vdso.so.1 =  (0x7fffd05ff000)
libR.so = /usr/lib/R/lib/libR.so (0x7f5f3b667000)
libc.so.6 = /lib/libc.so.6 (0x7f5f3b313000)
libblas.so.3gf = /usr/lib/libblas.so.3gf (0x7f5f3a7fe000)
libgfortran.so.3 = /usr/lib/libgfortran.so.3 (0x7f5f3a512000)
libm.so.6 = /lib/libm.so.6 (0x7f5f3a29)
libreadline.so.6 = /lib/libreadline.so.6 (0x7f5f3a04b000)
libpcre.so.3 = /lib/libpcre.so.3 (0x7f5f39e1c000)
libbz2.so.1.0 = /lib/libbz2.so.1.0 (0x7f5f39c0c000)
libz.so.1 = /usr/lib/libz.so.1 (0x7f5f399f4000)
libdl.so.2 = /lib/libdl.so.2 (0x7f5f397f)
/lib64/ld-linux-x86-64.so.2 (0x7f5f3bbec000)
libgcc_s.so.1 = /lib/libgcc_s.so.1 (0x7f5f395da000)
libpthread.so.0 = /lib/libpthread.so.0 (0x7f5f393bd000)
libncurses.so.5 = /lib/libncurses.so.5 (0x7f5f39177000)

Following /usr/lib/libblas.so.3gf :
ls -l /usr/lib/libblas.so.3gf
/usr/lib/libblas.so.3gf - /etc/alternatives/libblas.so.3gf

And again following this:
ls -l /etc/alternatives/libblas.so.3gf
/etc/alternatives/libblas.so.3gf - /usr/lib/atlas-base/atlas/libblas.so.3gf

So it appears to be properly linked to Atlas.  Note that I got this
same response from both the binary install of r-base (apt-get install
r-base) and the source build of r-base-dev (apt-get source -b
r-base-dev).  Also, I did a tuned install of ATLAS 3.8.3 using:

apt-get source atlas -t unstable
cd atlas-3.8.3
DEFAULTS=n fakeroot debian/rules custom

I did notice during the VERY long compilation that it seemed to
correctly identify that I have 4 CPUs.

Can someone confirm that the test:

a = matrix(rnorm(5000*5000), 5000, 5000)
b = matrix(rnorm(5000*5000), 5000, 5000)
c = a%*%b

Should illicit a multi-CPU response with R/ATLAS?  If so, any
suggestions on how to tweak my install to get it working?  Thanks!

--j

On Wed, May 26, 2010 at 3:17 PM, Peter Langfelder
peter.langfel...@gmail.com wrote:
 If you didn't specify an external BLAS when you ran R configure
 script, you are not using ATLAS. If you're not sure and you still have
 the output of the configure script, at the end it'll say whether it
 uses an external BLAS.

 Alternatively, you may also want to generate two random 5000x5000
 matrices and do their multiplication

 a = matrix(rnorm(5000*5000), 5000, 5000)
 b = matrix(rnorm(5000*5000), 5000, 5000)
 c = a%*%b

 While the calculation is running, in a separate terminal, run top and
 watch how much CPU R takes. AFAIK standard installation of R is single
 threaded and will only use one CPU (up to 100%). ATLAS is
 multithreaded and (unless you configured it otherwise) it will use all
 available processors, so if you have a 4-core machine, you will see
 CPU usage of nearly 400%. Note though that this will not discriminate
 ATLAS from other multi-threaded BLASes.

 HTH,

 Peter


 On Wed, May 26, 2010 at 2:16 PM, Jonathan Greenberg
 greenb...@ucdavis.edu wrote:
 Rhelpers:

 I recently installed the 64-bit version of R on my Debian system, and
 afterwards was asked if it was compiled using ATLAS.  Is there a way
 to test to see if R is using ATLAS?

 --j

 __
 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-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] R and ATLAS

2010-05-26 Thread Jonathan Greenberg
Rhelpers:

I recently installed the 64-bit version of R on my Debian system, and
afterwards was asked if it was compiled using ATLAS.  Is there a way
to test to see if R is using ATLAS?

--j

__
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] Comparing histograms?

2010-05-13 Thread Jonathan Greenberg
Rhelpers:

I'm curious what the appropriate analysis to use for testing the
hypothesis that two histograms are statistically different from one
another?  Thanks!

--j

__
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] RSQLite equivalent of .schema?

2010-05-12 Thread Jonathan Greenberg
Rhelpers:

(Thanks for the previous help with getting a where statement
working).  Now on to my next question -- our database guru has asked
me to run .schema on an sqlite database, and I was wondering if
there is an equivalent in R to do this?  Thanks!

--j

__
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] dbSendQuery with R variables

2010-05-10 Thread Jonathan Greenberg
Rhelpers:

I'd like to modify this RSQLite statement:

rs_stations-dbSendQuery(con_stations, select * from stations)

so that stations is actually an R variable, e.g.:

stations=c(stationA,stationB)

How would I modify the above statement to query from stations[[1]]
(aka stationA)?

--j

__
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] R and screen (UNIX question)

2010-03-03 Thread Jonathan Greenberg
I'm having a mixed experience with using R and UNIX's screen function
-- sometimes when I close a connection that used screen, the R process
is killed (which, in theory, it shouldn't be -- it should be running
in the background).  Does anyone have any ideas on how well (or not) R
behaves with screen, and if there any tricks to using R and SOME type
of background program that doesn't require permanent connection?

--j

__
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] Using auto.key with two variable plots

2010-01-30 Thread Jonathan Greenberg

Rhelpers:

   Having a problem solving this.  I have an xyplot call that looks 
like this:


   
print(xyplot(temp_species_EAM_Pred_Pop$x+temp_species_NULL_Pred_Pop$x~temp_species_EAM_Pred_Pop$Action,main=current_species,

   xlab=Action,ylab=Predicted Pop,
   xlim=c(xmin,xmax),ylim=c(ymin,ymax),
   auto.key=list(corner=c(1,1

This is just a scatterplot with two response variables sharing the same 
predictor variable (temp_species_EAM_Pred_Pop$Action).  Right now, the 
key has the words temp_species_EAM_Pred_Pop$x and 
temp_species_NULL_Pred_Pop$x next to their symbols.  I would like to 
rename these in the key, say EAM and NULL -- using the group= 
command doesn't work (since these aren't really different groups).  What 
is the right way to rename these variables in the key?  Is using 
auto.key the right approach?


Thanks!

--j

--

Jonathan A. Greenberg, PhD
Postdoctoral Scholar
Center for Spatial Technologies and Remote Sensing (CSTARS)
University of California, Davis
One Shields Avenue
The Barn, Room 250N
Davis, CA 95616
Phone: 415-763-5476
AIM: jgrn307, MSN: jgrn...@hotmail.com, Gchat: jgrn307

__
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] Data frame of different sized lists in a function call

2010-01-28 Thread Jonathan Greenberg
I'm hoping to get some best practice feedback for constructing a 
function call which takes an undefined set of DIFFERENT length vectors 
-- e.g. say we have two lists:


list1=c(1:10)
list2=c(2:4)

lists = data.frame(list1,list2) coerces those two to be the same length 
(recycling list2 to fill in the missing rows) -- what is a quick way of 
having each of those lists retain their original lengths?  my function 
ultimately should look like:



myfunction = function(lists) {

...

}

I'm hoping this can be done with a single line, so the user doesn't have 
to pre-construct the data.frame before running the function, if at all 
possible.


Thanks!

--j

--

Jonathan A. Greenberg, PhD
Postdoctoral Scholar
Center for Spatial Technologies and Remote Sensing (CSTARS)
University of California, Davis
One Shields Avenue
The Barn, Room 250N
Davis, CA 95616
Phone: 415-763-5476
AIM: jgrn307, MSN: jgrn...@hotmail.com, Gchat: jgrn307

__
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] x,y plot question (two sets of labels)

2010-01-20 Thread Jonathan Greenberg
I'm trying to figure out the best way to do a scatterplot using the 
following data as an example:


plothelp_x=1:10
plothelp_A1=sin(plothelp_x)
plothelp_A2=tan(plothelp_x)
plothelp_B=c(A,B,C,A,B,C,A,B,C,A)

(note that all 4 of these vectors have 10 entries each)

What I would like is to have two plots on the same graph:

1) plothelp_A1 vs. plothelp_x
2) plothelp_A2 vs. plothelp_x

I want plot #1 to have a set symbol SHAPE (say, crosses) and plot #2 a 
different symbol shape (say, dots).  On top of that, I want all points 
to be color coded based on plothelp_B, e.g. all As are black, all Bs are 
red, all Cs are blue; e.g a sin point with the letter A should be a 
black cross, a tan point with the letter C should be a red dot.  
Finally, I'd like two have TWO keys in the graph showing a) what the 
symbol shapes represent (e.g. cross=sin, dot=tan), and b) what the 
colors mean.


Thanks for any help you can give me!

--j

--

Jonathan A. Greenberg, PhD
Postdoctoral Scholar
Center for Spatial Technologies and Remote Sensing (CSTARS)
University of California, Davis
One Shields Avenue
The Barn, Room 250N
Davis, CA 95616
Phone: 415-763-5476
AIM: jgrn307, MSN: jgrn...@hotmail.com, Gchat: jgrn307

__
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] Finally, the first R spam!

2010-01-11 Thread Jonathan Greenberg

I got that same email from Steve Blum:

Hi folks,

Which is the best statistical package out there. I am out of work and looking to get the best buck for my money. 


Tx - ed


--j



Max Kuhn wrote:

... and this one I received this morning:

  

Hi folks, Which is the best statistical package out there. I am out of work
and looking to get the best buck for my money.

Thanks,
Mike.




I guess this is still better than those AOL disks.


On Thu, Jan 7, 2010 at 3:49 AM, Liviu Andronic landronim...@gmail.com wrote:
  

On 1/7/10, David Croll david.cr...@gmx.ch wrote:


 Just for fun (or concern): I received a R spam mail. Perhaps the first in
history...

  

No, not quite first. There was one before on Inference with R, at least.
Liviu

__
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] Safe way to automatically install required packages...

2009-11-02 Thread Jonathan Greenberg

R-helpers:

   I'm working on an r-package that I want to make as easy-to-use as 
possible for a novice R-user, which includes automatically installing 
required packages.   I, myself, am a novice R-packager, so the solution 
I came up with was to embed:


print(Loading required packages...)
if (!require(reshape)) { install.packages(reshape) }
if (!require(reshape)) {
   print(Could not install package 'reshape', please contact your 
sysadmin.)

   return()
}

   in the code proper, and put together the package using 
package.skeleton() and R CMD build.


   I'm guessing there's a better way to do this -- any suggestions? 


--j

--

Jonathan A. Greenberg, PhD
Postdoctoral Scholar
Center for Spatial Technologies and Remote Sensing (CSTARS)
University of California, Davis
One Shields Avenue
The Barn, Room 250N
Davis, CA 95616
Phone: 415-763-5476
AIM: jgrn307, MSN: jgrn...@hotmail.com, Gchat: jgrn307

__
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] Aggregate and cross tabulation

2009-10-27 Thread Jonathan Greenberg

R-helpers:

   I have a data frame containing 4 factor variables (let's say A,B,C, 
and D) and 1 numerical variable (N).  I would like to produce a 
cross-tabulated data frame in which A,B,C are individual columns, each 
factor of D is its own column, and the field is calculated as a given 
function of N (I would like to have two output data frames, one with the 
mean(N) and one with the sum(N), e.g.:


A,B,C,D1,D2,
   ...,DM
A1   B1   C1   mean(N{A1,B1,C1,D1)})   mean(N{A1,B1,C1,D2)})
   mean(N{A1,B1,C1,DM)})
A2   B1   C1   mean(N{A2,B1,C1,D1)})   mean(N{A2,B1,C1,D2)})
   mean(N{A2,B1,C1,DM)})

etc...

I can mostly do this with aggregate, e.g.
output = aggregate(N,list(A,B,C,D),mean), but I can't get that last step 
of cross-tabulating the Ds to column headers.  table() and xtabs() 
appear to just count, rather than giving me access to sum() and mean().  
Any ideas?  Ideally I'd like to do this in a single step, as the 
aggregate output (above) produces a much larger data frame than a 
cross-tabulated output would (in my particular case).


--j

--

Jonathan A. Greenberg, PhD
Postdoctoral Scholar
Center for Spatial Technologies and Remote Sensing (CSTARS)
University of California, Davis
One Shields Avenue
The Barn, Room 250N
Davis, CA 95616
Phone: 415-763-5476
AIM: jgrn307, MSN: jgrn...@hotmail.com, Gchat: jgrn307

__
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] splitting a vector of strings...

2009-10-22 Thread Jonathan Greenberg
Quick question -- if I have a vector of strings that I'd like to split 
into two new vectors based on a substring that is inside of each string, 
what is the most efficient way to do this?  The substring that I want to 
split on is multiple characters, if that matters, and it is contained in 
every element of the character vector.


--j

--

Jonathan A. Greenberg, PhD
Postdoctoral Scholar
Center for Spatial Technologies and Remote Sensing (CSTARS)
University of California, Davis
One Shields Avenue
The Barn, Room 250N
Davis, CA 95616
Phone: 415-763-5476
AIM: jgrn307, MSN: jgrn...@hotmail.com, Gchat: jgrn307

__
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] splitting a vector of strings...

2009-10-22 Thread Jonathan Greenberg

William et al:

   Thanks!  I think I have a somewhat more complicated issue due to the 
type of string I'm using -- the split is  |  (space pipe space) -- how 
do I code that based on your sub code below?  Using  | * doesn't seem 
to be working.  Thanks!


--j

William Dunlap wrote:

-Original Message-
From: r-help-boun...@r-project.org 
[mailto:r-help-boun...@r-project.org] On Behalf Of Jonathan Greenberg

Sent: Thursday, October 22, 2009 7:35 PM
To: r-help
Subject: [R] splitting a vector of strings...

Quick question -- if I have a vector of strings that I'd like 
to split 
into two new vectors based on a substring that is inside of 
each string, 
what is the most efficient way to do this?  The substring 
that I want to 
split on is multiple characters, if that matters, and it is 
contained in 
every element of the character vector.



strsplit and sub can both be used for this.  If you know
the string will be split into 2 parts then 2 calls to sub
with slightly different patterns will do it.  strsplit requires
less fiddling with the pattern and is handier when the number
of parts is variable or large.  strsplit's output often needs to
be rearranged for convenient use.

E.g., I made 100,000 strings with a 'qaz' in their middles with
  x-paste(X,sample(1e5),sep=)
  y-sub(X,Y,x)
  xy-paste(x,y,sep=qaz)
and split them by the 'qaz' in two ways:
  system.time(ret1-list(x=sub(qaz.*,,xy),y=sub(.*qaz,,xy)))
  # user  system elapsed 
  # 0.220.000.21 
 
system.time({tmp-strsplit(xy,qaz);ret2-list(x=unlist(lapply(tmp,`[`,

1)),y=unlist(lapply(tmp,`[`,2)))})
   user  system elapsed 
  # 2.420.002.20 
  identical(ret1,ret2)

  #[1] TRUE
  identical(ret1$x,x)  identical(ret1$y,y)
  #[1] TRUE

Bill Dunlap
Spotfire, TIBCO Software
wdunlap tibco.com 

  

--j

--

Jonathan A. Greenberg, PhD
Postdoctoral Scholar
Center for Spatial Technologies and Remote Sensing (CSTARS)
University of California, Davis
One Shields Avenue
The Barn, Room 250N
Davis, CA 95616
Phone: 415-763-5476
AIM: jgrn307, MSN: jgrn...@hotmail.com, Gchat: jgrn307

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




--

Jonathan A. Greenberg, PhD
Postdoctoral Scholar
Center for Spatial Technologies and Remote Sensing (CSTARS)
University of California, Davis
One Shields Avenue
The Barn, Room 250N
Davis, CA 95616
Phone: 415-763-5476
AIM: jgrn307, MSN: jgrn...@hotmail.com, Gchat: jgrn307

__
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] Stochastic (transition) matrices: how to determine distributions and variance?

2009-08-30 Thread Jonathan Greenberg
(apologies for the cross-posting, and for this being a more general 
stats question rather than a specific-to-R one.  I assure you I will be 
doing the actual analysis in R :)


I am trying to determine the distribution and variance for a classic 
stochastic (transition) matrix problem such that:


let x(t) be an initial state vector consisting of counts of classes A, B 
and C:

x(t) = [A(t),B(t),C(t)]
T is the stochastic (transition) matrix for these classes consisting of 
the transition probabilities between each combination of A,B and C:


  pAA pBA pCA
T=   pAB pBB pCB
  pAC pBC pCC

By doing matrix multiplication of Tx(t) we can determine the *mean* 
counts of these classes at t+1 such that:

x mean (t+1) = Tx(t) = [A mean (t+1),B mean (t+1),C mean (t+1)]

What I want to know is what is a) what is the *distribution* of 
A(t+1),B(t+1) and C(t+1), and what is the variance around these mean 
values?  Since pXY are stochastic probabilities, it seems that the 
distribution and variance should be calculable.


Thanks!

--j

--

Jonathan A. Greenberg, PhD
Postdoctoral Scholar
Center for Spatial Technologies and Remote Sensing (CSTARS)
University of California, Davis
One Shields Avenue
The Barn, Room 250N
Davis, CA 95616
Cell: 415-794-5043
AIM: jgrn307, MSN: jgrn...@hotmail.com, Gchat: jgrn307

__
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] Best R text editors?

2009-08-27 Thread Jonathan Greenberg
Quick informal poll: what is everyone's favorite text editor for working 
with R?  I'd like to hear from people who are using editors that have 
some level of direct R interface (e.g. Tinn-R, Komodo+SciViews).  Thanks!


--j

--

Jonathan A. Greenberg, PhD
Postdoctoral Scholar
Center for Spatial Technologies and Remote Sensing (CSTARS)
University of California, Davis
One Shields Avenue
The Barn, Room 250N
Davis, CA 95616
Cell: 415-794-5043
AIM: jgrn307, MSN: jgrn...@hotmail.com, Gchat: jgrn307

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


  1   2   >