How to import an Excel file into Rmarkdown?
Last Updated :
07 Feb, 2023
In this article, we are going to learn how to import excel file into Rmarkdown in R programming language.
Excel file is a file where the data is stored in the form of rows and columns. The R markdown is a file where we can embed the code and its documentation in the same file and are able to knit it out the required format like HTML Page(default),PDF, etc, The extension of the R Markdown file is “.Rmd”. To import that excel file into the R markdown we can use the readxl package of R programming language.
Steps to Import Excel File into Rmarkdown:
Step 1: First we need to create and save an excel file that needs to be imported. We have created the below excel file with name “GFGCourse”.
Step 2: Open a new markdown file by clicking on File -> New File -> R Markdown in R Studio.
Step 3: Next we need to insert the code snippet in the R markdown under (“`) so that while knitting the markdown file the R Interpreter considers the lines present in between (“`) as R Code and produces output accordingly. Therefore, the data present in Sample.Rmd is given as
R
```{r}
library (readxl)
sample <- read_excel ( "C:\\Users\\GFG19449\\Documents\\GFGCourse.xlsx" )
View (sample)
```
|
Output: When we knit that Rmd file which contains the above data then the output can be produced as follows:
Like Article
Suggest improvement
Share your thoughts in the comments
Please Login to comment...