Your privacy matters: This site uses cookies to analyze site usage and provide social media features. Learn More.

How Do You Create a Simple Hello World R Visual?

If you want to go beyond what is available in Power BI through DAX and the standard and custom visuals, you may want to experiment with R transformations, calculations, machine learning, and charts. This is how to create a very basic R visual in Power BI:

Steps:

  1. Check you R installation. Open your favorite R editor, for example RStudio. Check the path to your R installation – you might need this is step 2. In RStudio, click Tools, Global Options… and look at General, R version. Try this next R snippet to check a built-in dataset and display a chart:




  2. Enable R in Power BI Desktop. Click the drop-down just to the left of the Home tab in Power BI Desktop. Then choose Options and settings, Options, R scripting (under GLOBAL). The Detected R home directories: may already be pointing to the path in step 1. If not, click Other, then Browse and navigate to the correct R directory. Click OK when done.

    enable r in power bi


  3. Create a dummy table to activate the R script visual in Power BI Desktop.
    1. On the Home tab, click Enter Data, then Load. This creates a table called Table1 with a column called Column1 that contains no data!
    2. Click the R script visual icon under Visualizations and Enable.
    3. Click Column1 under Table1 in Fields. Column1 should appear in the Values section under Visualizations and the R script editor will be activated with a data frame called dataset.
    4. In the editor enter plot(mtcars$mpg, mtcars$wt) and click the Run script button.



      r script visual


  1. Save your pbix file and publish to PowerBI.com. Both save and publish are in the drop-down just to the left of the Home tab. You can now view and share your R visual. It is visible in your report in PowerBI.com, if you pin either the visual or the whole report to a dashboard. If you share the report or the dashboard it will also be visible to other users. As I write (January 2018), it will not yet work in Publish to Web or in Power BI Report Server.

  2. Next steps. This example is very simple! For more complex visuals I recommend R Graphics Cookbook by Winston Chang. And this example used a built-in dataset, mtcars – try and use 'real' data by using columns from your own tables in the Values section, then you can derive plots based on the data frame called dataset.

Contact Us:

Accelebrate’s training classes are available for private groups of 3 or more people at your site or online anywhere worldwide.

Don't settle for a "one size fits all" public class! Have Accelebrate deliver exactly the training you want, privately at your site or online, for less than the cost of a public class.

For pricing and to learn more, please contact us.

Contact Us

Toll-free in US/Canada:
877 849 1850
International:
+1 678 648 3113

Toll-free in US/Canada:
866 566 1228
International:
+1 404 420 2491

925B Peachtree Street, NE
PMB 378
Atlanta, GA 30309-3918
USA

Subscribe to our Newsletter:

Never miss the latest news and information from Accelebrate:

Microsoft Partner

Please see our complete list of
Microsoft Official Courses

Recent Training Locations

Alabama

Huntsville

Montgomery

Birmingham

Alaska

Anchorage

Arizona

Phoenix

Tucson

Arkansas

Fayetteville

Little Rock

California

San Francisco

Oakland

San Jose

Orange County

Los Angeles

Sacramento

San Diego

Colorado

Denver

Boulder

Colorado Springs

Connecticut

Hartford

DC

Washington

Florida

Fort Lauderdale

Miami

Jacksonville

Orlando

Saint Petersburg

Tampa

Georgia

Atlanta

Augusta

Savannah

Idaho

Boise

Illinois

Chicago

Indiana

Indianapolis

Iowa

Ceder Rapids

Des Moines

Kansas

Wichita

Kentucky

Lexington

Louisville

Louisiana

Banton Rouge

New Orleans

Maine

Portland

Maryland

Annapolis

Baltimore

Hagerstown

Frederick

Massachusetts

Springfield

Boston

Cambridge

Michigan

Ann Arbor

Detroit

Grand Rapids

Minnesota

Saint Paul

Minneapolis

Mississippi

Jackson

Missouri

Kansas City

St. Louis

Nebraska

Lincoln

Omaha

Nevada

Reno

Las Vegas

New Jersey

Princeton

New Mexico

Albuquerque

New York

Buffalo

Albany

White Plains

New York City

North Carolina

Charlotte

Durham

Raleigh

Ohio

Canton

Akron

Cincinnati

Cleveland

Columbus

Dayton

Oklahoma

Tulsa

Oklahoma City

Oregon

Portland

Pennsylvania

Pittsburgh

Philadelphia

Rhode Island

Providence

South Carolina

Columbia

Charleston

Spartanburg

Greenville

Tennessee

Memphis

Nashville

Knoxville

Texas

Dallas

El Paso

Houston

San Antonio

Austin

Utah

Salt Lake City

Virginia

Richmond

Alexandria

Arlington

Washington

Tacoma

Seattle

West Virginia

Charleston

Wisconsin

Madison

Milwaukee

Alberta

Edmonton

Calgary

British Columbia

Vancouver

Nova Scotia

Halifax

Ontario

Ottawa

Toronto

Quebec

Montreal

Puerto Rico

San Juan

© 2013-2019 Accelebrate, Inc. All Rights Reserved. All trademarks are owned by their respective owners.