Quantcast
Channel: Active questions tagged r - Stack Overflow
Viewing all articles
Browse latest Browse all 201839

How to assign a numerical code to a string based on a set of keywords in R

$
0
0

For example, I have an array of data in which some text descriptions are given as follows:

  1. big Pool House

  2. 1 storey Warehouse

  3. multiple Storage pool

Now, I want to code the text descriptions based on the sub-strings. For example, if there is string "pool" in a text, then I want to assign a numerical code (say, 101) to the whole text description.

If there are multiple strings in a text description (say, "storage" and "pool"), then I want to assign multiple codes to those descriptions and concatenate/paste the codes. For example, in case of the description - "multiple Storage pool" , I would assign the code (say, 102) to storage and 101 to pool. So, the result should be (102, 101).

Could anyone please suggest an R algorithm for this?


Viewing all articles
Browse latest Browse all 201839

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>