Quantcast
Channel: R-bloggers
Viewing all articles
Browse latest Browse all 12081

How to Import a CSV to an R Notebook

$
0
0

(This article was first published on R Language in Datazar Blog on Medium, and kindly contributed to R-bloggers)

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.

Dialog box for importing file.

Click on the button next to the file (on the left). Once it’s loaded into the notebook session, the button will turn green.

File loaded.

2. Reading the file.

We can now read the CSV dataset using the read.csv() function that comes with R.

Reading the file into the notebook and dispaying the top to check.

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.

var vglnk = { key: '949efb41171ac6ec1bf7f206d57e90b8' }; (function(d, t) {var s = d.createElement(t); s.type = 'text/javascript'; s.async = true;s.src = '//cdn.viglink.com/api/vglnk.js';var r = d.getElementsByTagName(t)[0]; r.parentNode.insertBefore(s, r); }(document, 'script'));

To leave a comment for the author, please follow the link and comment on their blog: R Language in Datazar Blog on Medium.

R-bloggers.com offers daily e-mail updates about R news and tutorials on topics such as: Data science, Big Data, R jobs, visualization (ggplot2, Boxplots, maps, animation), programming (RStudio, Sweave, LaTeX, SQL, Eclipse, git, hadoop, Web Scraping) statistics (regression, PCA, time series, trading) and more...


Viewing all articles
Browse latest Browse all 12081

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>