'How to assign values to string when the data is very large R [duplicate]
How to assign values to string when the data is very large.
Currently I assign values to character vectors manually as illustrated below, however, when the amount of data is very large it becomes tedious to do that process manually. Is there a function that allows me to do it?
c("a" = 100, "b" = 200, "c"=300, ..., "aaaaaa" = n)
Solution 1:[1]
Is there any particular meaning to your numbering? If you just need numerical values for strings, you can use as.factor and as.numeric as outlined in this post:
R: Encode character variables into numeric
However, if you need a specific encoding you will have specify the associated labels necessary; there isn't enough information in your question to help with this further, but the documentation is here:
https://www.rdocumentation.org/packages/base/versions/3.6.2/topics/factor
Sources
This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.
Source: Stack Overflow
| Solution | Source |
|---|---|
| Solution 1 | Jonathan Graves |
