, there may well be a reason.
> >> I note that the particular example shown just happens to create almost a
> >> magic square as the sum of rows and columns and the major diagonal happen
> >> to be 0, albeit the reverse diagonal is all 50's.
> >> Again, there are many
are
>> never equal or is there some requirement for how to handle a tie? And note
>> there are base R functions called min() and max() and you can ask for
>> things like:
>>
>> if ( current == min(mydata[1,])) ...
>>
>>
>> -Original Message-
&
u can ask for
> things like:
>
> if ( current == min(mydata[1,])) ...
>
>
> -Original Message-
> From: Tom Woolman
> To: Janet Choate
> Cc: r-help@r-project.org
> Sent: Sun, May 29, 2022 3:42 pm
> Subject: Re: [R] categorizing data
>
>
> Some
a tie? And note there are
base R functions called min() and max() and you can ask for things like:
if ( current == min(mydata[1,])) ...
-Original Message-
From: Tom Woolman
To: Janet Choate
Cc: r-help@r-project.org
Sent: Sun, May 29, 2022 3:42 pm
Subject: Re: [R] categorizing data
Some
Hello,
Here is a way. Define a function to change the values and call it in a
apply loop. But Tom's suggestions are more reasonable, you should have a
good reason why to change the data.
x <- '
tree shrub grass
32 11 47
23 41 26
49 23 18'
orig <- read.table(te
You could write a function that deals with one row of your data, based on
the order() function. E.g.,
> to_10_30_50
function(x) {
stopifnot(is.numeric(x), length(x)==3, sum(x)==90, all(x>0))
c(10,30,50)[order(x)]
}
> to_10_30_50(c(23,41,26))
[1] 10 50 30
Then loop over the row
Some ideas:
You could create a cluster model with k=3 for each of the 3 variables,
to determine what constitutes high/medium/low centroid values for each
of the 3 types of plant types. Centroid values could then be used as the
upper/lower boundary ranges for high/med/low.
Or utilize a hist
7 matches
Mail list logo