[R] How to extract or sort values from one column

Ben Tupper btupper @end|ng |rom b|ge|ow@org
Fri Jan 31 15:52:14 CET 2020


Welcome to R!

You could try using findInterval() which will quickly determine into
which interval your values belong.

# your break points define the intervals
brks <- c( 0.2, 0.4, 0.7)

# make an example data frame
n <- 100
x <- data.frame(
  x = seq_len(n),
  y = runif(n, min = 0, max = 1))

# compute the interval associations and add it to the
# data frame
x$group <- findInterval(x$y, brks)

# show the groupings
plot(x$x, x$y, pch = 1 + x$group)

Cheers,
Ben


On Fri, Jan 31, 2020 at 9:21 AM pooja sinha <pjsinha07 using gmail.com> wrote:
>
> Hi All,
>
> I have a .csv file with four columns (Chrom, Start_pos, End_pos & Value).
> The value column range from 0 to 1.0 having more than 2.8 million rows. I
> need to write a code from which I can extract the values from 0.2-0.4 &
> 0.7-1.0. Could anyone help me in writing the code because I am new to R and
> it takes lot of time manually to sort based on values.
>
> The only part I know is I can read the .csv file and after that I don’t
> know how to proceed further.
>
>
> Thanks,
>
> Puja
>
>         [[alternative HTML version deleted]]
>
> ______________________________________________
> R-help using 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.



-- 
Ben Tupper
Bigelow Laboratory for Ocean Science
West Boothbay Harbor, Maine
http://www.bigelow.org/
https://eco.bigelow.org



More information about the R-help mailing list