Excel R

How to quickly build R data frame from scratch with Excel

If you know some of the Excel text functions, you can quickly build R data frame from scratch. Also, you should understand how to build a data frame in R, what kind of functions will be necessary.

My data in Excel looks like this.

R data frame from scratch

For this data R data frame, I can build in this manner. As you see, I should concatenate all the data elements in each column.

Joining text strings in Excel

First of all my date format is not the handiest for usage in R. You can deal with it later or make some changes in Excel with TEXT function and format code “yyyy-mm-dd”.

Starting from here, I can use Excel text combining capabilities and build necessary formulas for later usage in R.

I used & symbol for overall concatenation, CHAR(34) that returns double quotes and TEXTJOIN (that is a relatively new function) that can concatenate array as shown in the picture below.

The result looks like this.

After the same process for other columns, you can copy results to R and add some formatting if necessary.

If you are a beginner in R then post about how to switch from Excel to R might be useful.



0 comments on “How to quickly build R data frame from scratch with Excel

Leave a Reply

Your email address will not be published. Required fields are marked *