I don't know if I have a logical error, but my substr()
function is keep returning an empty string? My initial thought was that I am cutting the string wrong, however even with a lower starting value, I am getting null string in my dataframe column.
I have looked at this PHP question to get some information, but didn't work: PHP: substr returns empty string
Reproducible example-
#Original Data set str() output
#'data.frame': 9245 obs. of 3 variables:
#$ Latitude : num 29.7 29.7 29.7 29.6 29.7 ...
#$ Longitude : num -82.3 -82.4 -82.3 -82.4 -82.3 ...
#$ Census Code: chr "120010011003032" "120010010004035" "120010002003009" "120010015213000" ...
#For example, even if I do this:
base::substr("120010011003032", 6, 1)
#Output : ""
#Desired output: 001100
I needed to cut census codes to generate tract information, and the tract information is usually first two being the state, next three the county, and the following six the tract.
base::substr("120010011003032", 6, 11)
"001100"