# Reading data, and a graph

**Learning R**, and kindly contributed to R-bloggers]. (You can report issue about the content on this page here)

Want to share your content on R-bloggers? click here if you have a blog, or here if you don't.

First, I import the data into R with the following command:

states <- read.table("C:/Data/states.txt", header=TRUE, sep = "\t")

Next I ‘attach’ the data frame with the following command:

attach (states)

OK, now that I’ve got my data into R, what can I do with it?

First, I’ll run some correlations and see what’s going on.

cor (read2children, publicedexp)

[1] 0.4211508

cor (hincome, publicedexp)

[1] 0.6547179

cor (read2children, hincome)

[1] 0.4094883

Let’s look at the data a different way, by using scatterplots to see the relationships.

plot is the R command for, well, plotting. It’s very powerful and you can do lots of things with it. First I’ll do a very simple scatterplot of education expenditures and children read to.

plot (publicedexp, read2children)

**leave a comment**for the author, please follow the link and comment on their blog:

**Learning R**.

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.