'Counting the number of cells in a column that contain a specific string (in R)

I have a dataframe in R. I would like to count the number of cells in a column that contain a specific string.

Using the example data below, I want to count how many cells in the column a contain the string "purple." (2)

I imagine something like this: sum(df$a %contains% "purple")

a <- c("red, white", "white", "blue, purple", "purple")
b <- c("white", "white, yellow", "purple", "purple, blue, yellow")
df <- data.table(a, b)


Solution 1:[1]

You could do with str_count

sum(stringr::str_count(df$a, pattern = "purple"))

Solution 2:[2]

No, this is not currently available. You’d think and hope it would be, but it’s not.

The limitation isn’t on the PowerAutomate/LogicApps side, it’s actually on the Microsoft Graph API side. It doesn’t support assigning the task to a specific person.

There is no work around using the API’s, what’s available via the Graph API is all there is.

Your only other solution would be to use something like PowerAutomate Desktop but that’s a lot of work for something so small. You need to tack it on to the end of your current flow but you’ll need a license for PAD, you’ll need a PC that runs PAD and you’ll need to create your PAD flow.

My suggestion would be to send an email to someone after the to-do item is created so they can assign it. That’s about the best you can do for now I’d say.

Solution 3:[3]

As opposed to the answer of Skin, there is a possibility to get this to work.

If you make a PowerApps app where a user uploads the document to SharePoint, the flow that is shared with the user will run using their OAUTH2 connection, i.e. they create a connection to their own To-Do list and this is automatically taken care of.

Using your automated task, the answer is no indeed, Graph API hasn't opened up their associates route yet sadly.

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 Julian
Solution 2 Skin
Solution 3 Iona Varga