Reputation: 1129
I have data in this format:
Count, Thread1, Thread2, Thread3, Thread4,
10420162, 589768
46530936, 1164357
55563161, 275521, 12289
56741671, 25158, 28020
57792881, 44468, 91248
(As the additional threads come in to play, data appears in their columns)
I would like to plot the sum (running total) of the Thread data against the Count eg when x is 0, y is 0; when x is 10420162, y is 589768; when x is 46530936, y is 1754125; when x is 55563161, y is 2041935 and so on.
Not clear how I can do this - presumably it requires at least two steps - to sum the data and then plot it?
Upvotes: 0
Views: 214
Reputation: 12875
Your calculated numbers don't match mine so I have a feeling I didn't understand your questions correctly. Or did you calculate it wrong?
df <- read.csv(tex`t`Connection('Count, Thread1, Thread2, Thread3, Thread4,
10420162, 589768
46530936, 1164357
55563161, 275521, 12289
56741671, 25158, 28020
57792881, 44468, 91248'), header=TRUE)
dfcumsum <- data.frame(
count = df$Count ,
cumthreadsum = cumsum(rowSums(df[,-1], na.rm = TRUE))
)
Output -
> dfcumsum
count cumthreadsum
1 10420162 589768
2 46530936 1754125
3 55563161 2041935
4 56741671 2095113
5 57792881 2230829
The most elementary plot would be plot(dfcumsum$cumthreadsum)
Upvotes: 1