Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- > as.numeric("1.560,65")
- [1] NA
- Warning message:
- NAs introduced by coercion
- > as.numeric("1.560")
- [1] 1.56
- > as.numeric("1.560")>2
- [1] FALSE
- as.numeric(gsub(",", "\.", gsub("\.","", "1.560,65")))
- [1] 1560.65
- formatC(1560.65, format = "f", big.mark = ".", decimal.mark = ",")
- [1] "1.560,6500"
- str_numbers <- c("1.560,65", "134,2","123","0,32")
- as.numeric(gsub(",", "\.", gsub("\.", "", str_numbers)))
- > (tmp <- gsub("\.", "", str_numbers))
- [1] "1560,65" "134,2" "123" "0,32"
- > gsub(",", "\.", tmp)
- [1] "1560.65" "134.2" "123" "0.32"
- nums <- c("1.560,65", "134,2","123","0,32")
- library(readr)
- parse_number(nums, locale = locale(decimal_mark = ','))
- [1] 1560.65 134.20 123.00 0.32
Add Comment
Please, Sign In to add comment