I am trying to load the data from the state education access database into the data frame in R. The database provides information about schools in the state, and each school has a 12-digit identification number. When I
This number appears to be scientific notation (which is here It is apologetic for not keeping a good understanding of inner workings). When I try to convert them back to an integer, because they are in the database I get a bunch of NAs and integers that do not match the original. Is there any other data type that I should use? Is there any way to recover the original intent or import them from the beginning? Thank you very much for your help! Your problem is that an integer value is only 2 * 10 ^ 9 (i.e. ~ 9 digits long) Can handle the number up to. Your school ID number is 12 digits long, and thus the class should be numeric or double. But all this is irrelevant, because the numbers will be properly controlled by R. It seems to me that you have a problem with display of this number. You have several options here: Display as string: Specify a string Use the formatting function. It will still convert to show the value as a character, but gives you the flexibility of formatting. For example, use the format: Other functions Formatting that works similarly includes sprintf, prettyNum, and formatC. In short, try and do not convert the type when you want to display your results, then use one of these functions if you are actually a type of If you want to convert, then I suggest that you change the number to as.ccharacter () - the reason for this is that I suspect you will not arithmetic on these numbers, so they are essentially a string string. Demofactors & lt; - Loading table with sqlQuery (connection, "SELECT * FROM 'demographic factor" WHERE YEAR = 2010 ")
demo.factor $ ENTITY_CD & lt; Using as.integer (demo.factors $ ENTITY_CD)
x = 999999999999 as.character (x) [1] "999999999999"
format (X, scientific = false, width = 12) [1] "999999999999"
Comments
Post a Comment