Re: [R] categorizing data

2022-05-29 Thread David Carlson via R-help
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 solutions ima

Re: [R] categorizing data

2022-05-29 Thread Roy Mendelssohn - NOAA Federal via R-help
t; 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- >> Fr

Re: [R] categorizing data

2022-05-29 Thread Janet Choate
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 ideas: &g

Re: [R] categorizing data

2022-05-29 Thread Avi Gross via R-help
? 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 ideas

Re: [R] categorizing data

2022-05-29 Thread Rui Barradas
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 <-

Re: [R] categorizing data

2022-05-29 Thread Bill Dunlap
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

Re: [R] categorizing data

2022-05-29 Thread Tom Woolman
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