How do I formulate an R related statement? -


how write statement "between 0 , 15" r? transforming variable categorical variable, , requirement 1 of categories recode new categorical variable old variable (eg. x) becomes new.variable <- x between 0 , 15.

edit - clarification of question

i have been given data set , instruction are:

growth patterns generated transforming x variable new categorical variable, can named "growth". first category assigned islands in x variable between 15 50. question, main headache how write "between 15 50" in r language. have:

growth$mediumgrowth.islands <- growth$sasiaurban.x[growth$sasiaurban.x ???] 

it's not entirely clear me want achieve, believe want cut:

x <- 0:20 cut(x,c(-inf,3,9,18,inf)) # [1] (-inf,3]  (-inf,3]  (-inf,3]  (-inf,3]  (3,9]     (3,9]     (3,9]     (3,9]     (3,9]     (3,9]     (9,18]    (9,18]    (9,18]    (9,18]    (9,18]    (9,18]    # [17] (9,18]    (9,18]    (9,18]    (18, inf] (18, inf] # levels: (-inf,3] (3,9] (9,18] (18, inf] 

or possibly findinterval:

findinterval(x,c(-inf,3,9,18,inf)) #[1] 1 1 1 2 2 2 2 2 2 3 3 3 3 3 3 3 3 3 4 4 4 

Comments

Popular posts from this blog

sublimetext3 - what keyboard shortcut is to comment/uncomment for this script tag in sublime -

java - No use of nillable="0" in SOAP Webservice -

ubuntu - Laravel 5.2 quickstart guide gives Not Found Error -