Lauren,

I think (?) you mean to say that you wish to create a factor and control the
range of values assigned to each level.

The "breaks" argument can specify either the number of intervals you desire
OR the values you wish to use to define levels of your factor.  See '?cut'
and the following example:

> #A numeric vector
> x <- 1:10
> 
> #Assign equal number of values
> #2 each of 2 automatically 
> #determined intervals
> levels1 <- cut(x,breaks=2)
> 
> #User-specified intervals
> levels2 <- cut(x,breaks=c(0,3,Inf))
> 
> data.frame(x,levels1,levels2)
    x     levels1 levels2
1   1 (0.991,5.5]   (0,3]
2   2 (0.991,5.5]   (0,3]
3   3 (0.991,5.5]   (0,3]
4   4 (0.991,5.5] (3,Inf]
5   5 (0.991,5.5] (3,Inf]
6   6    (5.5,10] (3,Inf]
7   7    (5.5,10] (3,Inf]
8   8    (5.5,10] (3,Inf]
9   9    (5.5,10] (3,Inf]
10 10    (5.5,10] (3,Inf]

'Inf' is an easy way to create an interval that contains all values larger
than some cutoff.

Good luck with your analysis,

Glen


Gough Lauren wrote:
> 
> I have a numeric pixel image which I would like to divide into factors
> for analysis in Spatstat.  I have found that I can use cut.im() function
> to divide the range of pixel values into a series of equal length
> intervals (e.g. if my pixels values range from 0 to 60,
> cut.im(X.im,breaks=2) will produce two factors one containing pixel
> values 0-30 and one containing pixel values of 30 - 60, or thereabouts).
> 
> However, I would like to specify the pixel value at which the factors
> are created - e.g. create one factor containing pixel values of 0-5 and
> another factor containing all other pixel values.  I have been
> struggling to work out how to do this using either cut.im() or
> cut.default().  Can anyone help?
> 


-----
Glen Sargeant
Research Wildlife Biologist
-- 
View this message in context: 
http://n4.nabble.com/Dividing-a-pixel-image-into-factors-cut-im-cut-default-tp948346p948676.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.

Reply via email to