Lack of context and examples is making this hard to follow, but my stabs at 
answers are

1) cut cannot guarantee that all numeric inputs will have unique factor results 
if you use two columns to define the ranges. That is, the ranges could overlap 
(multiple answers), or there could be gaps (no answer). I think the short 
answer is "no" if I understand you.

I don't understand why you don't just remove 500 from the breaks vector if you 
don't want it there.

2) I suspect cut is the answer to your question, since you give it a numeric 
vector and breaks specification, and the resulting answer has one element for 
every numeric in the vector you gave it. It is common to assign the result of 
cut to a new column in your data frame. However, I may have misunderstood your 
question.

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

doggysaywhat <chwh...@ucsd.edu> wrote:

>Hello Jeff, thank you for the reply.  I tried the cut function and I
>had two
>questions.  How do I have the cut function take the first position in
>the
>start column in df1 as the first cut point and the first position in
>column
>2 as the second cut point.  The break variable seems to want a single
>vector.  I tried compressing both vectors into one where I had say
>
>
>200
>700
>500
>1000
>etc
>
>then cut gives me the 200-500 range, 500-700, and 700-1000.  In this
>case I
>wanted the range, 200-700, and 500-1000.  
>
>Is there a way to define the first point of each cut as positions along
>the
>START vector and all second points of the cut as positions along the
>END
>vector?
>
>I also had one additional question.  When playing around with this, I
>noticed that I had to do this for the Pos column in the second data
>frame. 
>But, when I get the ranges, how do I have it return the values in C0 or
>C1
>in df2 that are in the same rows as those of the ranges?
>
>Thanks again for the help.
> 
>
>--
>View this message in context:
>http://r.789695.n4.nabble.com/Averaging-within-a-range-of-values-tp4291958p4293410.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.

______________________________________________
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