Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

I have imported the data in R, how to make a scatter plot?

Tags:

r

I'm new to R, and have imported my dataset as follows (dots mean that there is remaining data):

> num.csv <- read.csv("c:/num.csv", header=T)
> print(num.csv)
            X.Y
1     22500;482
2       25842;1
3       27221;1
4       32757;1
5       40152;1
.       .
.       .
.       .

How can I make a scatter plot for this data?

Thanks.

like image 908
Simplicity Avatar asked Aug 05 '11 13:08

Simplicity


1 Answers

First, the data needs to be in separate columns. While the file is labeled "csv", you appear to be using semicolons to separate instead of commas. Either reformat the file or try:

num.csv <- read.csv("c:/num.csv", header=T, sep=";")

Then you can use one of the various plotting packages with R to make a plot. For example:

install.packages("ggplot2"); #ggplot2 is not part of the standard install...
library(ggplot2);
qplot(X, Y, data=num.csv);

I have not tested the above, it depends on how your data frame comes out of read.csv.

like image 148
patrickmdnet Avatar answered Oct 14 '22 03:10

patrickmdnet