[R] some help
jim holtman
jholtman at gmail.com
Mon Nov 26 18:09:34 CET 2012
try this: (provide sample data next time)
> # create some test data
> x <- data.frame(LST = runif(1000), NDVI = runif(1000, 0, 1))
> head(x,10) # show some data
LST NDVI
1 0.86542839 0.95129647
2 0.88910058 0.75971649
3 0.44086718 0.86532140
4 0.99879370 0.05511501
5 0.02401490 0.92282834
6 0.56026534 0.80915721
7 0.65051596 0.03606430
8 0.25897388 0.61624609
9 0.07873261 0.85179368
10 0.09829056 0.91198307
> # create partition values
> partition <- seq(0, 1, .01)
> # add column to the data to define the partition
> x$part <- cut(x$NDVI, partition)
> head(x)
LST NDVI part
1 0.8654284 0.95129647 (0.95,0.96]
2 0.8891006 0.75971649 (0.75,0.76]
3 0.4408672 0.86532140 (0.86,0.87]
4 0.9987937 0.05511501 (0.05,0.06]
5 0.0240149 0.92282834 (0.92,0.93]
6 0.5602653 0.80915721 (0.8,0.81]
> # now compute range (min/mx) for the data
> xRange <- tapply(x$LST, x$part, range)
> head(xRange, 10)
$`(0,0.01]`
[1] 0.01945995 0.83500402
$`(0.01,0.02]`
[1] 0.02267906 0.69770971
$`(0.02,0.03]`
[1] 0.01287795 0.75275416
$`(0.03,0.04]`
[1] 0.1402162 0.9960408
$`(0.04,0.05]`
[1] 0.007688249 0.691519845
$`(0.05,0.06]`
[1] 0.1047314 0.9987937
$`(0.06,0.07]`
[1] 0.002181767 0.990990999
$`(0.07,0.08]`
[1] 0.08271319 0.87609409
$`(0.08,0.09]`
[1] 0.1174585 0.8931750
$`(0.09,0.1]`
[1] 0.2331289 0.8485212
On Mon, Nov 26, 2012 at 9:56 AM, dattel_palme <dattel_palme at yahoo.de> wrote:
> Hey
>
> The code need some corrections and I would kindly ask for help.
>
> Say:
> I have a table with two columns:
> col1=LST and col2=NDVI
> i would like to sort all data by NDVI.
> in reality the NDVI ranges between 0 and 1 (although some values might be
> minus also).
> I want to sort by NDVI values and then make 100 intervals of 0.01 ndvi.
> therefore the first inerval is 0.01-0.02, the second 0.02-0.03 and so on..
> for each interval I would like to get the highest (max) and lowest (min)
> value of LST.
> It would be very helpful if this values can be written in a seperate
> table/file.
>
> Thanks you very much for help!
> Stefan
>
>
>
> --
> View this message in context: http://r.789695.n4.nabble.com/some-help-tp4648316p4650844.html
> Sent from the R help mailing list archive at Nabble.com.
>
> ______________________________________________
> R-help at 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.
--
Jim Holtman
Data Munger Guru
What is the problem that you are trying to solve?
Tell me what you want to do, not how you want to do it.
More information about the R-help
mailing list