I have a data frame of ecological data where some entries are lower than what is in chemistry called LOQ (limit of quantificantion). These measurements are reported as "less than LOQ". What I want to do is to change these values to half of the LOQ. I could probably find code to remove the "<", but then I wouldn't know which of the entries to divide by 2.
#creating df
x1 <- c(1,2,"<1")
x2 <- c(3,"<4",3)
x3 <- c(1,2,3)
df <- data.frame(x1,x2,x3)
df
x1 x2 x3
1 1 3 1
2 2 <4 2
3 <1 3 3
I want the results to be as:
##### result #######
x1 <- c(1,2,0.5)
x2 <- c(3,2,3)
x3 <- c(1,2,3)
result <- data.frame(x1,x2,x3)
x1 x2 x3
1 1.0 3 1
2 2.0 2 2
3 0.5 3 3
So that, basically, the < sign is ignored and the remaining values are divided by 2. Any ideas on how to do this?