0
votes

This is my R script:

#!/usr/bin/env Rscript 

library (ggplot2)

data = read.table ("downloads.txt", header=T)
data$number = factor (data$Size)
data$PITtype = factor (data$PITtype)

g.all <- ggplot (data, aes (x=Time, y=number, color=PITtype)) +
  geom_point (size=2) +
  geom_line () +
  ylab ("# Pending Downloads") +
  theme_bw ()

png ("pendingDownloads_graph.png", width=800, height=800)
print (g.all)
x = dev.off ()

and this a set of data that I used:

Time PITtype Size
3   SimplePIT 60
6.25    SimplePIT 127
9.5 SimplePIT 197
12.75   SimplePIT 249
16  SimplePIT 319
19.25   SimplePIT 381
22.5    SimplePIT 459
25.75   SimplePIT 531
29  SimplePIT 594
32.25   SimplePIT 668
35.5    SimplePIT 723
38.75   SimplePIT 774
42  SimplePIT 851
45.25   SimplePIT 902
48.5    SimplePIT 959
51.75   SimplePIT 1020
55  SimplePIT 1092
58.25   SimplePIT 1167
61.5    SimplePIT 1223
64.75   SimplePIT 1283
68  SimplePIT 1337
71.25   SimplePIT 1420
74.5    SimplePIT 1515
77.75   SimplePIT 1607
81  SimplePIT 1662
84.25   SimplePIT 1728
87.5    SimplePIT 1792
90.75   SimplePIT 1854
94  SimplePIT 1931

I got this strange graph (see the 'y' axes that is all black) http://i40.tinypic.com/2dvivdf.png and this error: geom_path: Each group consist of only one observation. Do you need to adjust the group aesthetic?

What's up?

1
Because youve created number as a factor, and each number is unique, you've got a factor with as many levels as rows. What are you trying to do here? Why create a factor?Spacedman
I don't know to use R, I only override a script. I only want to have how the size increse in time.user2369478

1 Answers

2
votes

You don't need to create the number column, and you don't even need ggplot2. You can do:

> plot(data$Size, data$Time)

to get a simple scatter plot.

The ggplot2 solution is a bit prettier, and since you only have one PITtype there's no point including it:

> ggplot(data,aes(x=Time,y=Size))+geom_point()+geom_line()

If you have data with more than on PITtype and want to colour the points differently, include it:

> ggplot(data,aes(x=Time,y=Size,col=PITtype))+geom_point()+geom_line()

But you should probably read some basic R documentation where you will find answers faster than here.