Liming - here's a workaround that I've been successful with. It produces
a simple histogram from a set of numbers.
from rpy import *
#let x be some set of random numbers
x = [24,60,18,63,32,47,88,64,72,87,100,16,37,46,50,\
64,11,45,77,35,38,39,84,90,6,87,25,67,51,71,52,\
98,57,5,65,75,8,68,35,75,95,29,50,44,30,1,92,93,\
56,56]
#create the plot document. there are other file formats that can be
substituted (e.g. jpeg)
r.png("C:/urbansim/temp/histogram_example.png", width=400, height=350)
# write the graphic to the plot document
r.hist(x, xlab="frequency", ylab="count", main="histogram example using
R", col="pink")
#turn the graphics device off.
r.dev_off()
This last step turns the graphic device off so that it can't freeze, and
then you can obviously open the output for further review via Window's
Explorer or your preferred graphics software.
brian
Brian Voigt
Spatial Analysis Lab
220 Aiken Center
University of Vermont
Burlington, VT 05405
Liming Wang wrote:
> Brian,
> I'm using rpy-1.0rc2 with R2.4.1. If I remember it right, we have
> identical problem on Windows for earlier version of rpy too - it works
> fine on Linux or MacOS. It will be great if you can share your code,
> we may incorporate it in future revision of the opus document.
>
> Thanks,
> Liming.
>
> On 6/20/07, *Brian Miles* <Brian.Miles_at_uvm.edu
> <mailto:Brian.Miles_at_uvm.edu>> wrote:
>
>
> Hi Liming,
>
> What versions of rpy and R were you using when you replicated it?
> I'm wondering if this is a problem in newer versions of rpy/R and
> that maybe using rpy 0.4.6 (which is referenced in the Opus
> documentation) with a correspondingly old version of R, would be a
> workaround.
>
> If this is the case, could you post the versions of rpy and R that
> you use with Opus? (version 0.4.6 of rpy at least does not seem to
> be available for download)
>
> Another workaround we've found is to direct the R output to a file
> instead of to the screen. Let me know if you would like some
> example code.
>
> Thanks,
>
> Brian
>
> On Jun 20, 2007, at 1:38 PM, Liming Wang wrote:
>
>> Brian,
>> I can replicate the problem you encountered on a Windows
>> computer. So far I don't have better suggestion than leaving the
>> R graphical window open. It should not interfere with other
>> tasks in python shell, when you finish working in the python
>> shell, exit it (ctrl + Z) will close the R graphical window.
>>
>> Liming.
>>
>> On 6/15/07, *Brian Miles* < Brian.Miles_at_uvm.edu
>> <mailto:Brian.Miles_at_uvm.edu>> wrote:
>>
>>
>> Hello,
>>
>> When we run the following code (from chapter 6, p. 47 of the
>> user guide):
>>
>> import os
>> import urbansim
>> us_path = urbansim.__path__[0]
>> from opus_core.storage_factory import StorageFactory
>> storage = StorageFactory().get_storage('tab_storage',
>> storage_location = os.path.join(us_path, 'data/tutorial'))
>> from urbansim.datasets.household_dataset import HouseholdDataset
>> households = HouseholdDataset(in_storage = storage,
>> in_table_name = 'households', id_name='household_id')
>> households.r_histogram("income")
>>
>> from the python interpreter, we get an R window with the
>> correct plot, but the window the plot is in freezes--it
>> cannot be closed without forcibly killing the parent python
>> process.
>>
>> We are running rpy 1.0-RC2 and have tried by R 2.2.1 and
>> 2.4.1 with the same results. (Version 0.4.6/0.99.0 of rpy is
>> no longer available on the rpy site. The only version that
>> is, 1.0-RC2, is supposed to work with R 2.0.0 through R
>> 2.4.1) We are using Enthought Python 2.4.3 under Windows.
>>
>> Has anyone else experienced this? Is there any way that the
>> version of rpy (0.4.6) recommended in the Opus install
>> instructions (
>> http://www.urbansim.org/opus/candidate-releases/opus-2007-04-25/docs/windows_install.html),
>> as well as the corresponding version of R, could be made
>> available so that we're sure we're running a configuration
>> that has been tested?
>>
>> Thanks,
>>
>> Brian Miles
>> Graduate Assistant
>> Spatial Analysis Lab - Rubenstein School of Environment and
>> Natural Resources
>> University of Vermont
>>
>>
>>
>>
>>
>> _______________________________________________
>> Users mailing list
>> Users_at_urbansim.org <mailto:Users_at_urbansim.org>
>> http://www.urbansim.org/mailman/listinfo/users
>>
>>
>
>
> ------------------------------------------------------------------------
>
> _______________________________________________
> Users mailing list
> Users_at_urbansim.org
> http://www.urbansim.org/mailman/listinfo/users
>
Received on Thu Jun 21 2007 - 08:21:12 PDT
This archive was generated by hypermail 2.2.0 : Thu Jun 21 2007 - 08:21:13 PDT