Dream to Learn is shutting down...

We are very sorry to say that Dream to Learn will be shutting down as of December 28th, 2019. If you have content that you wish to keep, you should make a copy of it before that date.


0COMMENTS0RECOMMENDS

Import / Export - Understanding the Basics with CSV

35
POSTED IN: Data Analytics & Visualization Blog

We had a good "Study Group" session this Sunday - and spent much of the session covering the basics of syntax, and how to get our own data into R.  

The code can be found in the links below.  A few highlights of what we covered included

  1. READ.CSV - explored the different settings the function can receive - for example in:  LOG <- read.csv("PEAR - Log Example Microsoft.csv", skip=3, stringsAsFactors = FALSE) we saw how we can 'trim' the first three rows (junk header) and import the good data starting on Row 4
  2. TRIM TAIL - with ---  end2 <- dim(log)[1] //   end1 <- end2-4 // log <- log[-c(end1:end2),]   we saw how we can take the length of a variable log file, figure out how many rows were in it, and then 'trim' of the LAST rows of the file - in this case last four (end2-4) to delete last five rows
  3. WRITE - we saw how we can, once we finish our work - can export the file in the format we want with write.csv(log, file = "Pear_Log_Export.csv", row.names=FALSE) - in this case, row.names=FALSE ensures we don't end up with index numbers in the first column
  4. CSV formats - Dan noted that when he saved CSV local, it inserted extra 'white lines' between each row - we're not sure why (Unicode?) but will take a look this week to try to figure it out - and also find a way to remove the extra blank lines in CSV.  We did a quick experiment with remove white space / blanks, but no luck , so more homework

Sample files

  

R Newbies - CSV/LOG Cleanup Script

   
  

R Newbies - R Code Example - Excel tasks in R - Part 1

   
  

R Newbies - Reaching for Pivot Tables in R

  

Interested in more content by this author?

About the Author

Ryan Anderson

Ryan Anderson

Hi! I like to play with data, analytics and hack around with robots and gadgets in my garage. Lately I've been learning about machine learning.

About this blog

Description is...<br/>Data Analytics & Visualization Blog - Generating insights from Data since 2013

Created: July 25, 2014

Englishfrançais

Up Next