Skip to main content
replaced http://gis.stackexchange.com/ with https://gis.stackexchange.com/
Source Link

I am following the very simple code found in this question:

Converting shapefile to raster: Character attributesConverting shapefile to raster: Character attributes

to create a new numeric variable based on a factor. My problem is that the new numeric attribute has a complete different series of numbers than the factor column.

For example, instead of reading: 18001, 18002, 18003, it converts these numbers into 786, 894, 895: I have tried as.numeric and as.integer, and none of these work.

For further details, the shapefile column is described as:

commune_5m@data$NUMERO: Factor w/ 1842 levels "18001", "18002", ...: 786 894 895

I am following the very simple code found in this question:

Converting shapefile to raster: Character attributes

to create a new numeric variable based on a factor. My problem is that the new numeric attribute has a complete different series of numbers than the factor column.

For example, instead of reading: 18001, 18002, 18003, it converts these numbers into 786, 894, 895: I have tried as.numeric and as.integer, and none of these work.

For further details, the shapefile column is described as:

commune_5m@data$NUMERO: Factor w/ 1842 levels "18001", "18002", ...: 786 894 895

I am following the very simple code found in this question:

Converting shapefile to raster: Character attributes

to create a new numeric variable based on a factor. My problem is that the new numeric attribute has a complete different series of numbers than the factor column.

For example, instead of reading: 18001, 18002, 18003, it converts these numbers into 786, 894, 895: I have tried as.numeric and as.integer, and none of these work.

For further details, the shapefile column is described as:

commune_5m@data$NUMERO: Factor w/ 1842 levels "18001", "18002", ...: 786 894 895
improved formatting
Source Link
mgri
  • 16.3k
  • 6
  • 48
  • 80

I am following the very simple code found in this question:

Converting shapefile to raster: Character attributes

to create a new numeric variable based on a factor. My probleproblem is that the new numeric attribute has a complete different series of numbers than the factor column. 

For example, instead of reading: 18001, 18002, 18003, it converts these numbers into 786, 894, 895. I do not understand what is going on.: I have tried as.numeric and as.integer, and none of these work. For

For further details, the shapefile column is described as: commune_5m@data$NUMERO: Factor w/ 1842 levels "18001", "18002", ...: 786 894 895

any help would be really appreciated!

commune_5m@data$NUMERO: Factor w/ 1842 levels "18001", "18002", ...: 786 894 895

I am following the very simple code found in this question

Converting shapefile to raster: Character attributes

to create a new numeric variable based on a factor. My proble is that the new numeric attribute has a complete different series of numbers than the factor column. For example, instead of reading: 18001, 18002, 18003, it converts these numbers into 786, 894, 895. I do not understand what is going on. I have tried as.numeric and as.integer, and none of these work. For further details, the shapefile column is described as: commune_5m@data$NUMERO: Factor w/ 1842 levels "18001", "18002", ...: 786 894 895

any help would be really appreciated!

I am following the very simple code found in this question:

Converting shapefile to raster: Character attributes

to create a new numeric variable based on a factor. My problem is that the new numeric attribute has a complete different series of numbers than the factor column. 

For example, instead of reading: 18001, 18002, 18003, it converts these numbers into 786, 894, 895: I have tried as.numeric and as.integer, and none of these work.

For further details, the shapefile column is described as:

commune_5m@data$NUMERO: Factor w/ 1842 levels "18001", "18002", ...: 786 894 895
Source Link

Converting character attribute to numeric attribute

I am following the very simple code found in this question

Converting shapefile to raster: Character attributes

to create a new numeric variable based on a factor. My proble is that the new numeric attribute has a complete different series of numbers than the factor column. For example, instead of reading: 18001, 18002, 18003, it converts these numbers into 786, 894, 895. I do not understand what is going on. I have tried as.numeric and as.integer, and none of these work. For further details, the shapefile column is described as: commune_5m@data$NUMERO: Factor w/ 1842 levels "18001", "18002", ...: 786 894 895

any help would be really appreciated!