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

Fields name with space in R

Simple example:

Fields name containing a space, moved into a dataframe with the new R visualization: 

#Create Dataframe

#dataset <-data.frame (Order Quantity, Gross Profit)

 

How can I reference those fields? e.g plot(Order Quantity, Gross Profit)? R variables cannot have spaces.

Thanks

Francesco

 

2 REPLIES 2
Microsoft Avi_Sander
Microsoft

Re: Fields name with space in R

Try dataset["Order Quantity"]. this should do the trick.

 

Thanks, Avi

Highlighted
BeardyGeorge Regular Visitor
Regular Visitor

Re: Fields name with space in R

I managed to find the solution, which can be found here. The R code to automatically od what you requested for all columns is:

names(dataset) <- gsub(" ","_",names(dataset))

Helpful resources

Announcements
Exclusive LIVE Community Event #3 – Ask Arun Anything

Exclusive LIVE Community Event #3 – Ask Arun Anything

Join us in the third Triple A event!

Meet the 2020 Season 1 Power BI Super Users!

Meet the 2020 Season 1 Power BI Super Users!

It’s the start of a new Super User season! Learn all about the new Super Users and brand-new tiered recognition system.

Super User Challenge: Can You Solve These?

Super User Challenge: Can You Solve These?

We're celebrating the start of the New Super User season with our first ever Super User 'Can You Solve These?' challenge.

Power BI Desktop Update - February 2020

Power BI Desktop Update - February 2020

We are super excited for our update this month, as we are releasing two of our top community requests!

Power Platform Online Conference

Power Platform Online Conference

Join us for the first ever Power Platform Online Conference!

Top Solution Authors