Search icon CANCEL
Subscription
0
Cart icon
Cart
Close icon
You have no products in your basket yet
Save more on your purchases!
Savings automatically calculated. No voucher code required
Arrow left icon
All Products
Best Sellers
New Releases
Books
Videos
Audiobooks
Learning Hub
Newsletters
Free Learning
Arrow right icon
Arrow up icon
GO TO TOP
Introduction to R for Business Intelligence

You're reading from  Introduction to R for Business Intelligence

Product type Book
Published in Aug 2016
Publisher Packt
ISBN-13 9781785280252
Pages 228 pages
Edition 1st Edition
Languages
Author (1):
Jay Gendron Jay Gendron
Profile icon Jay Gendron
Toc

Table of Contents (19) Chapters close

Introduction to R for Business Intelligence
Credits
About the Author
Acknowledgement
About the Reviewers
www.PacktPub.com
Preface
1. Extract, Transform, and Load 2. Data Cleaning 3. Exploratory Data Analysis 4. Linear Regression for Business 5. Data Mining with Cluster Analysis 6. Time Series Analysis 7. Visualizing the Datas Story 8. Web Dashboards with Shiny References
Other Helpful R Functions R Packages Used in the Book
R Code for Supporting Market Segment Business Case Calculations

Loading data into business systems for analysis


You have imported and transformed data. It resides within your R environment as a data frame. Now you will need to provide it to marketing. The following are two common ways to export data from R into a file for use elsewhere in an organization:

  • Writing data to a CSV file

  • Writing data to a tab-delimited text file

These methods are similar, but they produce different results. Knowing about them and their differences will help you decide the format you would like to use.

Writing data to a CSV file

CSV files are common among data applications. Other data applications, such as Excel, can read these types of file. CSV files are also useful because database systems can typically import them into their environment, just as you imported a CSV into the R environment. The write.csv() function is used to write a data frame to a CSV file. In this example, the input parameters include report and the name of the output file, revenue_report.csv:

write.csv(report, "revenue_report.csv", row.names = FALSE) 

You also used a row.names = FALSE parameter. Very often, your dataset will not contain row names. This parameter prevents R from adding a column of numerical identifiers to the CSV file. There are many other parameters you can use with write.csv(). Learn more about them by typing ?write.csv in the R console.

Writing data to a tab-delimited text file

There may be times when you would like to have your data read by a data application that does not import CSV files. Recall that in the Extracting data from sources section, that read.csv() had a more flexible counterpart, read.table(). The write.table() function provides you with greater flexibility on how the final file is composed:

write.table(report, "revenue_report.txt", row.names = FALSE, sep = "\t") 

The write.table() function uses a syntax that is very similar to write.csv(). You see the addition of sep = "\t". This tells R to separate data with the tab character when creating the text file. There are many other parameters you can use with write.table(). Learn more about them by typing ?write.table in the R console.

You have been reading a chapter from
Introduction to R for Business Intelligence
Published in: Aug 2016 Publisher: Packt ISBN-13: 9781785280252
Register for a free Packt account to unlock a world of extra content!
A free Packt account unlocks extra newsletters, articles, discounted offers, and much more. Start advancing your knowledge today.
Unlock this book and the full library FREE for 7 days
Get unlimited access to 7000+ expert-authored eBooks and videos courses covering every tech area you can think of
Renews at $15.99/month. Cancel anytime