cancel
Showing results for 
Search instead for 
Did you mean: 
Reply
Highlighted
fcivardi Advocate I
Advocate I

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
Microsoft

Re: Fields name with space in R

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

 

Thanks, Avi

BeardyGeorge Helper I
Helper I

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
Announcing the New Spanish Forum

Announcing the New Spanish Forum

Do you need help in Spanish? Check out our new Spanish community section.

MBAS Gallery 2020

MBAS Gallery 2020

Watch Microsoft Business Applications Summit sessions on-demand.

‘Better Together’ Integration Forum Launch

‘Better Together’ Integration Forum Launch

We've launched a how-to forum where you can learn about how Power BI integrates with other Power Platform products.

Top Solution Authors
Top Kudoed Authors