I have one more simple question that hopefully someone can help. I have a series of data that have a repeating name structure. I would like to go through them and do some analysis. Here is the hard code of what I want to do using some fake data:
The first action I would like to automate is converting 0 values ββto "NA". Here is the hacked version, but I would ideally automate it depending on how many Tankxxx.df sound frames I have:
#Convert zeros to NA Tank001.df[Tank001.df==0] <- NA Tank002.df[Tank002.df==0] <- NA Tank003.df[Tank003.df==0] <- NA
Finally, I would like to complete a series of data queries, a simple example of which would be the number of values ββless than 5 in each data frame:
#Return the number of values smaller than 5 Tank001.less.than.5 <- numeric(length(Tank001.df)) for (i in 1:(length(Tank001.df))) {Tank001.less.than.5[i] <- sum(Tank001.df[[i]] < 5,na.rm=TRUE)} Tank002.less.than.5 <- numeric(length(Tank002.df)) for (i in 1:(length(Tank002.df))) {Tank002.less.than.5[i] <- sum(Tank002.df[[i]] < 5,na.rm=TRUE)} Tank003.less.than.5 <- numeric(length(Tank003.df)) for (i in 1:(length(Tank003.df))) {Tank003.less.than.5[i] <- sum(Tank003.df[[i]] < 5,na.rm=TRUE)}
Ideally, I would also like to know how to write the results of such simple calculations to a new data frame. In this case, for example, Less.than. 5 $ TankXXX, etc.
Any help would be greatly appreciated.
source share