Photo by Aron Visuals on Unsplash

In this short article, I summarize different techniques in data import to R. A spectrum of approaches that trade-off speed vs convenience is presented for my readers to choose from.

Assuming the data files are all stored on Folder F:\BDMA\data\. The most user-friendly data import approach is an interactive method; that is, it allows you to open folders to locate the data file like a regular file-open operation. Make sure you notice a flashing window on the taskbar that invites you to choose the destination file.

df.name=read.csv(file.choose())

Another you-import-what-you-see approach is through copy & paste.

Suppose you want ‘directly’ copy…


I have introduced pipe operations in Part 1. I will walk through the other powerful weapon in R programming: functions. The idea is that, anything you expect to do multiple times, you shall consider using functions, e.g., to run multiple multiple regressions, or to make a series of similar plots. With pipe operations embedded within functions, you really take full advantage of R programming.

Let's begin with a simple example. Suppose you are given a small arithmetic homework by your kid to find out the sum of squares of all the integers between a given number, say 4, and 100…


Yes, that’s correct. R beginners can quickly upgrade their R programming capabilities by mastering two things: pipe operations (%>%) and write-your-own functions, for plotting, data wrangling, regression results extraction, and many more.

Suppose you just started to learn how to empower R for your work-like some of my MBA students who heard of MSE for the first from me, and now you are happy for writing code in R-Studio that work, e.g., run a logistic regression-based classification. In that case, it is time to accelerate your R coding skills. I mean to do the same job with easier, shorter, clearer…


R users still use Excel, particularly when working with people who solely rely on Excel. The task to share analytical results generated by R to Excel is frequent in many organizations. Hence, a convenient and versatile passage between R and Excel is highly desirable. Here is how to establish such a passage.

Although R allows exporting results to csv format, which Excel can open, several major challenges remain. First, you can insert only one sheet to a csv file, no more. Second, all non-standard characters (e.g., Chinese or Japanese) are not displayed properly because csv files cannot deal with Unicode/UTF-8…

Martinqiu

I teach BDMA (big data and marketing analytics) at Lazaridis School of Business, Wilfrid Laurier University, in Waterloo, Canada.

Get the Medium app

A button that says 'Download on the App Store', and if clicked it will lead you to the iOS App store
A button that says 'Get it on, Google Play', and if clicked it will lead you to the Google Play store