LengthCT <- c(75,85,91.6,95,NA,105.5,106)
Tb <- c(0,0,1,NA,0,0,0)
mean(LengthCT, na.rm = TRUE)
## [1] 93.01667
Farm <- c(rep("MO",4),"LN","SE","QM")
Month <- c(11,7,7,NA,9,9,11)
Boar <- cbind(Farm,Month,LengthCT,Tb)
dim(Boar)
## [1] 7 4
dim
gives the size(rows, columns) of the dataframe: \(7 \times 4\)
nr <- nrow(Boar)
nr
## [1] 7
nrow
gives the number of rows in the dataframe: 7
nc <- ncol(Boar)
nc
## [1] 4
ncol
gives the number of columns in the dataframe: 4
Year <- c(00,00,01,NA,03,03,02)
Sex <- c(1,2,2,2,1,2,2)
LengthClass <- rep(1,7)
Ecervi <- c(rep(0,3),NA,rep(0,3))
df <- data.frame(Farm,Month,Year,Sex,LengthClass,LengthCT,Ecervi,Tb)
df
## Farm Month Year Sex LengthClass LengthCT Ecervi Tb
## 1 MO 11 0 1 1 75.0 0 0
## 2 MO 7 0 2 1 85.0 0 0
## 3 MO 7 1 2 1 91.6 0 1
## 4 MO NA NA 2 1 95.0 NA NA
## 5 LN 9 3 1 1 NA 0 0
## 6 SE 9 3 2 1 105.5 0 0
## 7 QM 11 2 2 1 106.0 0 0