Jump to content

How to create a new column with all the words starting with a string eg. create a new column from column "A"s text containing only words starting with "te"

Abhinav Karthik

Recommended Posts

For example, if i want to create a new column from the data in column A -> all words starting with the letters "te". Ideally if there are two words starting with "te", I would like to return the first instance. Please see example below:


Exisiting Column A










texting from new phone

telephone call is enough

what do you want to tell

the tennis ball is new





















Link to comment
Share on other sites

You can create your own expression function and use it for the calculated column. There are several ways to extract parts of a string with R using regular expressions. For convenience I use the stringr package for my example. Make sure you have it installed. If not, go to TOOLS -> TERR TOOLS -> Package Management -> Load -> and install stringr (You could also use stringi package or base R)

Then creat an expression gunction. Go to DATA -> Data Function Properties -> Expression Functions -> New

Name: StringExtract, Type: Column function, Return type: String, Category: Text functions


Link to comment
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
  • Create New...