[R] repace values in raster based on values in another raster

2012-09-04 Thread sean_parks
Hi,

I am attempting to create a new raster based on values of another raster.

In the Arc world, this is called a conditional statement or con
statement.

I am having quite a bit of difficulty figuring this out in R.

Here is some pseudo-code:
if (fire.did.not.occurr == 1)
then (new. raster = landuse.raster)

Here is some real code and the associated error:
 landuse.raster - raster(C:/temp/landuse.raster.tif)
 new.raster - landuse.raster
 new.raster[new.raster  0] - NA 
 new.raster[fire.did.not.occurr == 1] - landuse.raster
Error in x@data@values[i] - value : 
  incompatible types (from S4 to integer) in subassignment type fix

If I replace the landuse.raster with a specific number in the final
command, then the operation works, but I would like to replace with the
values in the landuse.raster.

Please help.

FYI: Please know that I have searched the forums and have not found anything
helpful. Perhaps I am using incorrect search criteria.

Thanks,
Sean





--
View this message in context: 
http://r.789695.n4.nabble.com/repace-values-in-raster-based-on-values-in-another-raster-tp4642245.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.


Re: [R] sample weight for box plot?

2010-01-06 Thread sean_parks

Thanks David.  I used the wtd.quantile in Hmisc. Works great and is easy for
a newbie like me.

I am attempting to send the quantile values to boxplot, and it works for the
most part.  My problem is that one of my extreme values appears as a dot
instead of the whisker.  It basically looks like an outlier dot. I
attached the image.

Here is my specific example:
bxp.data - c(0,0.9,3.5,9.4,30.6)
boxplot(bxp.data)

http://n4.nabble.com/file/n1008453/boxplot.example.bmp 


If anyone has any ideas to make my extreme valu behave like a proper
whisker, please let me know.

Thanks,
Sean




David Winsemius wrote:
 
 
 On Oct 28, 2009, at 8:00 PM, Sean Parks wrote:
 

 Hi,

 I would like to make a box and whisker plot but use a sample weight  
 for each
 observation.  I've searched around a bit and have not found a method  
 of
 doing this.

 Anyone have any advice?
 
 There are a variety of ways to get weighted quantiles. Two that have  
 come up in recent r-help postings are the facilities in the quantreg  
 package and wtd.quantile in Hmisc. Once you have calculated the five  
 numbers that define a box-whisker plot they can be passed to bxp.
 
 ?bxp

 -- 
 
 David Winsemius, MD
 Heritage Laboratories
 West Hartford, CT
 
 __
 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.
 
 

-- 
View this message in context: 
http://n4.nabble.com/sample-weight-for-box-plot-tp847253p1008453.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.