Con respecto a convertir las comas por puntos, claro que se puede, tu columna evidentemente como esta importada debería ser una cadena, por lo que es simple usando gsub()
:
as.numeric(gsub(",", ".", c("1,2", "3.14")))
[1] 1.20 3.14
Y en tu caso, algo así
datos$dist <- as.numeric(gsub(",", ".", datos$dist))
Sin embargo, esto es todavía más sencillo, si usas read.csv()
para leer el archivo, esta función cuenta con el parámetro dec
con el cual establecer el separador de decimales, por ejemplo dec = ","
Ahora, con respecto a los rangos, en primer lugar, si a cut()
le indicas la cantidad de rangos que quieres, este los calcula automáticamente, pero no al azar, se calculan básicamente para que cada rango tenga aproximadamente la misma longitud. Sin embargo, nada te impide definir tus propios rangos, claro que previamente debes conocer los limites de tu vector:
> x <- sample(1:9, 100, replace = TRUE) * runif(10)
> x
[1] 4.38291731 2.27174776 0.02358342 2.69440256 0.13633384 0.13181449 2.59019489 4.75009701
[9] 3.02371568 4.23916332 0.97398162 1.62267697 0.02358342 3.23328308 0.13633384 0.08238405
[17] 0.64754872 0.67858529 1.88982230 3.53263610 1.94796325 2.59628315 0.10612541 1.07776103
[25] 0.09088923 0.01647681 4.53284107 6.10726758 0.75592892 4.23916332 2.43495406 1.62267697
[33] 0.10612541 2.69440256 0.09088923 0.11533768 4.53284107 1.35717057 1.88982230 4.23916332
[41] 4.38291731 2.92081855 0.03537514 2.15552205 0.18177846 0.14829130 2.59019489 4.75009701
[49] 1.13389338 2.82610888 1.94796325 2.59628315 0.07075027 1.07776103 0.04544461 0.08238405
[57] 3.23774362 1.35717057 1.88982230 2.82610888 2.43495406 2.92081855 0.03537514 3.77216359
[65] 0.27266768 0.09886087 3.23774362 2.03575586 3.02371568 0.70652722 0.97398162 2.92081855
[73] 0.08254199 0.53888051 0.09088923 0.14829130 5.18038979 2.03575586 1.13389338 2.11958166
[81] 2.43495406 2.27174776 0.08254199 3.23328308 0.31811230 0.06590724 3.23774362 2.03575586
[89] 1.13389338 2.11958166 2.43495406 0.32453539 0.10612541 2.69440256 0.36355691 0.01647681
[97] 0.64754872 0.67858529 3.40168014 6.35874498
> cut(x, breaks=c(0,2,4,6,8,10))
[1] (4,6] (2,4] (0,2] (2,4] (0,2] (0,2] (2,4] (4,6] (2,4] (4,6] (0,2] (0,2] (0,2] (2,4] (0,2] (0,2]
[17] (0,2] (0,2] (0,2] (2,4] (0,2] (2,4] (0,2] (0,2] (0,2] (0,2] (4,6] (6,8] (0,2] (4,6] (2,4] (0,2]
[33] (0,2] (2,4] (0,2] (0,2] (4,6] (0,2] (0,2] (4,6] (4,6] (2,4] (0,2] (2,4] (0,2] (0,2] (2,4] (4,6]
[49] (0,2] (2,4] (0,2] (2,4] (0,2] (0,2] (0,2] (0,2] (2,4] (0,2] (0,2] (2,4] (2,4] (2,4] (0,2] (2,4]
[65] (0,2] (0,2] (2,4] (2,4] (2,4] (0,2] (0,2] (2,4] (0,2] (0,2] (0,2] (0,2] (4,6] (2,4] (0,2] (2,4]
[81] (2,4] (2,4] (0,2] (2,4] (0,2] (0,2] (2,4] (2,4] (0,2] (2,4] (2,4] (0,2] (0,2] (2,4] (0,2] (0,2]
[97] (0,2] (0,2] (2,4] (6,8]
Levels: (0,2] (2,4] (4,6] (6,8] (8,10]
>
Nota: Si eventualmente no tienes claro los límites superiores e inferiores, podrías hacer algo así: cut(x, breaks=c(-Inf,2,4,6,8,Inf))