cancel
Showing results for 
Search instead for 
Did you mean: 
Reply
stephaniesmall
Regular Visitor

Power Bi & R Script Problem with Stringr displacing columns unintentionally

I built an r script using stringr that should build 2 columns, Salesforce & CRM1. It is performing as expected except for in some rows, it is moving & deleting data from cells that are not being called in the following code: 

 

library(stringr)

SFDC <- c("SFDC|Salesforce")

Dynamics <- c("Dynamics|Microsoft|365")

Oracle <-c("Oracle|On Demand|Ondemand")

SAP <- c("SAP|Siebel")

InHouse <- c("in house|internal|inhouse|proprietary")

Unknown <- c("don't know|unknown|not sure|not mention|can't remember")

None <- c("none|no crm|N/A")

dataset$salesforce <- str_replace_all(

  str_replace_all(

  str_replace_all(

  str_replace_all(

  str_replace_all(

  str_replace_all(

  str_replace_all(dataset$new_crmused, regex(SFDC, ignore_case=TRUE), "Salesforce"),

      regex(Dynamics, ignore_case=TRUE), "Dynamics"),

      regex(Oracle, ignore_case=TRUE), "Oracle"),

      regex(SAP, ignore_case=TRUE), "SAP Siebel"),

      regex(InHouse, ignore_case = TRUE), "In House System"),

      regex(Unknown, ignore_case = TRUE), "Unknown"),

      regex(None, ignore_case=TRUE), "None")

dataset$CRM1 <- str_extract(dataset$salesforce,"Salesforce|Dynamics|Oracle|SAP Siebel|In House System|Unknown|None")

 

Does anyone have any ideas why it is doing this?

1 REPLY 1
Community Support
Community Support

Re: Power Bi & R Script Problem with Stringr displacing columns unintentionally

Hi @stephaniesmall 

I'm not the expert of R, please check if it works as expected on R side, if not, you could ask questions in R forums.

 

Best Regards
Maggie

Helpful resources

Announcements
New Ranks Launched March 24th!

New Ranks Launched March 24th!

The time has come: We are finally able to share more details on the brand-new ranks coming to the Power BI Community!

‘Better Together’ Contest Finalists Announced!

‘Better Together’ Contest Finalists Announced!

Congrats to the finalists of our ‘Better Together’-themed T-shirt design contest! Click for the top entries.

Arun 'Triple A' Event Video, Q&A, and Slides

Arun 'Triple A' Event Video, Q&A, and Slides

Missed the Arun 'Triple A' event or want to revisit it? We've got you covered! Check out the video, Q&A, and slides now.

Join THE global Microsoft Power Platform event series.

Join THE global Power Platform event series.

Attend for two days of expert-led learning and innovation on topics like AI and Analytics, powered by Dynamic Communities.

Community Summit North America

Community Summit North America

Innovate, Collaborate, Grow. The top training and networking event across the globe for Microsoft Business Applications

Top Solution Authors
Top Kudoed Authors