I have a pretty standard table, usually when I do something like this to read in a column from the table it works fine, but for some reason this time it didn't.
x <- dataFile$columnName
Here is what I get:
[1] 61 71 83 55 44 78 57 46 41 36 45 48 38 33 54 62 60 44 70 49 57 86 41 71 59 52 51 62 45 43
54 Levels: 33-87 36-81 38-79 41-70 41-85 43-47 44-51 44-62 45-51 ... 43
I just want the top part, without all the levels in it.
-----------
Edit (in preparation for this being closed): rather than leaving what is now misleading information in the comments (in case this shows up in someone's search), the top part is just a set of factor levels. If you just wanted those values (as text) you would use: as.character(x)
. If you wanted the characters before the minus sign if one were present, you could use:
as.numeric( sub("\\-.+$", "", as.character(x) ) )
Using as.numeric(x)
would generally return values from 1 to 54 and is meaningless unless you only want an index.