Hi there!

I am totally new with R studio.

I wanted to count all the behaviours I have recorded to make a nice plot but I am getting the following error:

Error in data.frame(treatment, incTime, count.o, count.gb, count.cann, :

arguments imply differing number of rows: 1, 25, 0

This is the code I am using:

```
column.count.df <- data.frame(Treatment = character(),
IncubationTime = character(),
count.o = integer(),
count.gb = integer(),
count.cann = integer(),
count.bu = integer(),
count.rem = integer (),
count.totalgroomers = integer(),
numFocals = integer(),
scanTime = double())
TIME_POINTS <- c(12, 15, 18, 21, 24)
TREATMENTS <- c("0% Blastospores-","100% P. entomophila","Ringer", "40% P. entomophila", "40% Blastospores-", "100% Blastospores+")
for (incTime in TIME_POINTS) {
for ( treatment in TREATMENTS) {
count.o <- apply(subset(behavData, data$Time.point == incTime & data$Treatment == treatment),
2, function(x) length(which(x=="o")))
count.cann <- apply(subset(behavData, data$Time.point == incTime & data$Treatment == treatment),
2, function(x) length(which(x=="c")))
count.bu <- apply(subset(behavData, data$Time.point == incTime & data$Treatment == treatment),
2, function(x) length(which(x=="bu")))
count.rem <- apply(subset(behavData, data$Time.point == incTime & data$Treatment == treatment),
2, function(x) length(which(x=="r")))
count.gb <- apply(subset(behavData, data$Time.point == incTime & data$Treatment == treatment),
2, function(x) length(which(grepl("gb", x))))
count.totalgroomers <- sapply(apply(subset(behavData, data$Time.point == incTime & data$Treatment == treatment),
2, function(x) strtoi(substring(grep("gb", x, value = TRUE), 3,3))),
function (x) sum(x))
colData <- data.frame(treatment,
incTime,
count.o,
count.gb,
count.cann,
count.bu,
count.rem,
count.totalgroomers,
numFocals = count.o + count.cann + count.rem + count.gb + count.bu, # non-visible termites don't count
seq(0, 2, 1/12))
names(colData) <- names(column.count.df)
column.count.df <- rbind(column.count.df, colData)
}
}
```

So in general the error is coming from the colData.

I would really appreciate if you can help me.

Best regards,

Alejandra