0

I am plotting a time series. I have a csv file that has 11 variables(columns) and the header name is in the first row of the data. My focus is on time (x-axis) and CO(y axis). Time and CO is the first and second column respectively. There are some zero values in the CO column.As such, I want to remove the rows in the data that have zeros in the "CO" column.

Here is an example of what I am taking about:

   Time           CO    C    D       E      F   G   H    I   J        K
2016-11-10 6:10   0.04  2.5 20.5    99675   1   62  0.3  2  10.3    126
2016-11-10 6:20   0     0   20.4    99645   1   65  0.3  2  12.4    126
2016-11-10 6:30   0     0   20.5    99735   1   67  0.3  2  12.4    126
2016-11-10 6:40   0.05  0   20.7    99725   0   69  0.3  2  12.4    126
2016-11-10 10:00  0     2.5 31      99251   1   46  0.3  3  13.6    0
2016-11-10 10:10  0.043 2   33      99445   1   45  0.3  3  18      0
2016-11-10 10:20  0.045 2   33      99541   1   43  0.3  3  18      0
2016-11-10 10:30  0     2   33.8    99206   1   43  0.3  3  18      0

I want the result below:

   Time           CO    C    D       E      F   G   H    I   J        K
2016-11-10 6:10   0.04  2.5 20.5    99675   1   62  0.3  2  10.3    126
2016-11-10 6:40   0.05  0   20.7    99725   0   69  0.3  2  12.4    126
2016-11-10 10:10  0.043 2   33      99445   1   45  0.3  3  18      0
2016-11-10 10:20  0.045 2   33      99541   1   43  0.3  3  18      0

In the past, i had the zero values at the end of my data so i just did the code below:

data1<- read.csv("path",nrows=485)

In this case, there are zeros mixed throught out the data and i am not sure what to do.

Help on how to remove the zeros based on CO column will be aprreciated.

Thank you.

Mah
  • 91
  • 8

1 Answers1

0

As you haven't said that your dataset is massive, you may as well just read in the whole CSV then take the appropriate subset of it.

data1 <- read.csv("path") data1 <- subset(data1, CO != 0)

mm689
  • 359
  • 2
  • 10