I have a data frame that is 200 rows by 6 columns. I am interested in computing the total times that a value in Col A is less than a specific number. The number can be hard coded. I do not know where to begin...
For a slightly more complex problem, use the "which" to tell the "sum" where to sum: if DF is the data frame:
Ozone Solar.R Wind Temp Month Day
1 41 190 7.4 67 5 1
2 97 267 6.3 92 7 8
3 97 272 5.7 92 7 9
Example: sum the values of Solar.R (Column 2) where Column1 or Ozone>30 AND Column 4 or Temp>90
sum(DF[which(DF[,1]>30 & DF[,4]>90),2])
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With