Situatie
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 Markdownfile is “.Rmd”. To import that excel file into the R markdown we can use thereadxl package of R programming language.
Solutie
Pasi de urmat
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”.
Open a new markdown file by clicking on File -> New File -> R Markdown in R Studio.
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
# Importing Excel File into R Markdown
### Using readxl package
“`{r}
library(readxl)
sample <- read_excel(“C:\\Users\\GFG19449\\Documents\\GFGCourse.xlsx”)
View(sample)
“`
Leave A Comment?