How to Import a CSV to an R Notebook
Want to share your content on R-bloggers? click here if you have a blog, or here if you don't.
Adding a file to your R notebook is a simple 2 step process.
1. “Import” file to notebook session.
This makes sure your dataset is isolated in one state so that it doesn’t change as you analyze it. Remember, you can always load the latest content if you choose to later on.
To import the file, click on the “Load Files” button in your notebook. That will list all the files available for import from your current project.
Click on the button next to the file (on the left). Once it’s loaded into the notebook session, the button will turn green.
2. Reading the file.
We can now read the CSV dataset using the read.csv() function that comes with R.
And that’s it! The head() function allows you to see the first few lines of the dataset. That way we can check if it has been loaded. You can now use the dataset variable to access the entire CSV dataset.
All files from this post are located here so you can copy them and run again: https://www.datazar.com/project/p820a77e6-1555-4549-8a6f-96ca99c29ff8/files
How to Import a CSV to an R Notebook was originally published in Datazar Blog on Medium, where people are continuing the conversation by highlighting and responding to this story.
R-bloggers.com offers daily e-mail updates about R news and tutorials about learning R and many other topics. Click here if you're looking to post or find an R/data-science job.
Want to share your content on R-bloggers? click here if you have a blog, or here if you don't.