Dear all, I have a table like this:> a <- read.csv("test.csv", header = TRUE, sep = ";") > aUTM pUrb pUrb_class 1 NF1885 20,160307 NA 2 NF1886 51,965649 NA 3 NF1893 26,009581 NA 4 NF1894 3,141484 NA 5 NF1895 64,296826 NA 6 NF1896 14,174068 NA 7 NF1897 40,985589 NA 8 NF1898 34,054325 NA 9 NF1899 20,657632 NA 10 NF1982 54,712737 NA 11 NF1983 56,016067 NA 12 NF1984 5,977961 NA What I wanted to do is to obtain classified values for "pUrb_class" in relation to "pUrb" as if: pUrb <20 --- pUrb_class = 1 pUrb 20-40 --- pUrb_class = 2 pUrb 40-60 --- pUrb_class = 3 .... Can anyone help me? Thanks in advance, Carlos
Dear all, I have a table like this: a <- read.csv("test.csv", header = TRUE, sep = ";") a UTM pUrb pUrb_class 1 NF1885 20,160307 NA 2 NF1886 51,965649 NA 3 NF1893 26,009581 NA 4 NF1894 3,141484 NA 5 NF1895 64,296826 NA 6 NF1896 14,174068 NA 7 NF1897 40,985589 NA 8 NF1898 34,054325 NA 9 NF1899 20,657632 NA 10 NF1982 54,712737 NA 11 NF1983 56,016067 NA 12 NF1984 5,977961 NA What I wanted to do is to obtain classified values for "pUrb_class" in relation to "pUrb" as if: pUrb <20 --- pUrb_class = 1 pUrb 20-40 --- pUrb_class = 2 pUrb 40-60 --- pUrb_class = 3 .... Can anyone help me? Thanks in advance, Carlos
Hi Carlos, Take a look at ?cut, ?ifelse and ?transform for some ideas. Also, the function recode in car might help. HTH, Jorge On Thu, Mar 4, 2010 at 7:35 AM, Carlos Guerra <> wrote:> Dear all, > > I have a table like this: > > > a <- read.csv("test.csv", header = TRUE, sep = ";") > > a > > UTM pUrb pUrb_class > 1 NF1885 20,160307 NA > 2 NF1886 51,965649 NA > 3 NF1893 26,009581 NA > 4 NF1894 3,141484 NA > 5 NF1895 64,296826 NA > 6 NF1896 14,174068 NA > 7 NF1897 40,985589 NA > 8 NF1898 34,054325 NA > 9 NF1899 20,657632 NA > 10 NF1982 54,712737 NA > 11 NF1983 56,016067 NA > 12 NF1984 5,977961 NA > > What I wanted to do is to obtain classified values for "pUrb_class" in > relation to "pUrb" as if: > > pUrb <20 --- pUrb_class = 1 > pUrb 20-40 --- pUrb_class = 2 > pUrb 40-60 --- pUrb_class = 3 > .... > > Can anyone help me? > > Thanks in advance, > Carlos > ______________________________________________ > R-help@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. >[[alternative HTML version deleted]]