[R] Boxplot using a shapefile

Boris Steipe boris.steipe at utoronto.ca
Mon Jun 15 19:52:29 CEST 2015


Your workflow in principle is:

- read the image into an object for which you can obtain values-per-pixel in a 2D structure;
- read the shapefile and convert into a polygon;
- determine the bounding box of the polygon;
- use the inout() function of the splancs package to get a list of booleans for the
    points in the bounding box, TRUE if they are _inside_ the polygon;
- subset your image points to those for which inout() returns TRUE;
- plot as boxplot().

The CRAN taskview http://cran.r-project.org/web/views/MedicalImaging.html has a section on general image processing, guiding you to helpful packages.

Ask again if you get stuck - but(!):
- see here for some hints on how to ask questions productively:
  http://adv-r.had.co.nz/Reproducibility.html
  http://stackoverflow.com/questions/5963269/how-to-make-a-great-r-reproducible-example
- ... and please read the posting guide and don't post in HTML.


B.


On Jun 15, 2015, at 7:19 AM, Preethi Balaji <preet.balaji20 at gmail.com> wrote:

> Dear all,
> 
> I am trying to generate boxplots by giving a shapefile and an image as
> input. The shapefile takes the pixel values from the image and shows
> the distribution of pixels in the form of a boxplot.
> 
> Can somebody please tell me how I can execute this in R?
> 
> Many thanks!
> 
> -- 
> 
> Regards,
> Preethi Malur Balaji | PhD Student
> University College Cork | Cork, Ireland.
> 
> ______________________________________________
> R-help at 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.



More information about the R-help mailing list