On Sun, Jun 10, 2012 at 11:44:33AM -0700, t_o_b_y wrote:
> Dear R users:
>
>
>
> I want to convert some character vectors into numeric vectors.
>
> > head(price)
> [1] "15450 EUR" "7900 EUR" "13800 EUR" "3990 EUR" "4500 EUR"
> [6] "4250 EUR"
>
> >head(mileage)
> [1] "21000 km" "119000 km"
Hello,
Works with me.
x <- c("21000 km", "119000 km", "36600 km", "92000 km", "140200 km",
"9 km")
sub("[[:blank:]]*km", "", x)
as.numeric(sub("km", "", x)) # for numeric, don't worry with blanks
Hope this helps,
Rui Barradas
Em 10-06-2012 19:44, t_o_b_y escreveu:
Dear R users:
I w
Dear R users:
I want to convert some character vectors into numeric vectors.
> head(price)
[1] "15450 EUR" "7900 EUR" "13800 EUR" "3990 EUR" "4500 EUR"
[6] "4250 EUR"
>head(mileage)
[1] "21000 km" "119000 km" "36600 km" "92000 km" "140200 km"
[6] "9 km"
in the first example I can us
3 matches
Mail list logo