Intro to Visual Studio 2015 R Ingesting Data Files

This blog post is second in a series on Intro to Visual Studio 2015 R Project.  In this blog we'll discuss data and how to connect to files.
We start off in the Visual Studio 2015 IDE.  From the R Interactive window, we enter the command:
getwd() to get the "working directory" of our project.
Once we know that, we can add our files to the folder, or we can set the working directory using the command:
Now we defined our folder, we can add our files here.
Back in the IDE, we enter our command to ingest the contents of our file.  In this case, we start off with a CSV or comma separated value file
mydata = read.csv("Income1.csv")
The variable "mydata" contains the contents of our file.  If we want to view the contents, we type the command:

This spawns a new pop up window displaying the data:

You can double click a cell, change the value by copy, paste or delete, or typing manually, close the window, reopen, you'll see the new value(s) still appear.

Now we try a .txt file:

Auto = read.table("Auto.txt", header = T, na.strings = "?")


To see it's dimensions, type:


we get back:

[1] 397 9

To see the first 4 rows:


To get rid of Null Values (NA):

Auto = na.omit(Auto)

[1] 392 9

You may notice 7 less rows as before due to the Null rows.

To display the field names:


We get:

[1] "mpg" "cylinders" "displacement" "horsepower" "weight" "acceleration" "year" "origin"
[9] "name"    

And that sums up our Intro to Visual Studio 2015 R Ingest Data Files.
To reference the first blog in the series, check out:


Thanks for reading~!

Bloom Consulting Since Year 2000