r - Generate a data frame from a set of strings -


I have a set of strings, as in a file:

  • Sony BRAVIA TV 32 T 550
  • Sony BRAVIA TV 40 S 530
  • SONY BRAVIA TV40 S530 SONY BRAVIA TV42 S530A SONY BRAVIA TV 42 S530A SONY BRAVIA TV32 S550A SONY LG TV TV T400A
  • Sony LCD TV 22 BX300
  • Li>
  • Sony LCD TV 26 bx 300
  • Sony LCD TV v19bx 300
  • Star TV 21 model 2103
  • TeleStar 14 1486 Color TV
  • Teleteer TV 14 1486
  • Teleteer TV 14 1486

Let me tell these stars There is a need to change into a data frame, where each unique word in the above list becomes the name of the column. Any suggestions?

Believing that your strings are arranged in a vector, and that you actually Each column wants a unique word, you can do something like that.

  strVec & lt; - c ("Sony Baviya TV32T 550", "Sony BRAVIA TV 40S530", "Sony BRAVIA TV 40S 530", "SONY" unique (Listed) # get unique words mydf "" Unique ( Randomly (X, "") stripplit (x, "")) #split strings & lt; - data.frame (matrix (nrow = 0, ncol = length (unique word) on unlisted (word) )) # # Create new DF colnames (mydf) & lt; - uniqueWords # Give it the right colnames  

Comments

Popular posts from this blog

Member with no value in F# -

java - Joda Time Interval Not returning what I expect -

c# - Showing a SelectedItem's Property -