[R] Rows classification problem

Henrique Dallazuanna wwwhsd at gmail.com
Thu Mar 4 15:22:33 CET 2010


Try this:

a$pUrb_class <- cut(a$pUrb, c(-Inf, 20, 40, 60, Inf), labels = 1:4)

On Thu, Mar 4, 2010 at 11:11 AM, Carlos Guerra
<carlosguerra.amb at gmail.com> 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 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.
>



-- 
Henrique Dallazuanna
Curitiba-Paraná-Brasil
25° 25' 40" S 49° 16' 22" O



More information about the R-help mailing list