If I invent data that matches what your code needs, it runs for me without any changes.
There is probably an easier way to do what you want but I am not sure what your goal is. In particular, I am not sure why you add an NA at the end of each sub vector.
lemna <- data.frame(Sample.ID = c(1,1,1,2,2,2,2,3,3,3),
N = c(2,5,8, 3,9,13,15, 1,2,3),
t = c(10, 14, 18, 12, 14, 16, 17, 23, 29, 36))
samples <- c("1", "2","3")
dN <- c()
dt <- c()
for (i in 1:length(samples)) {
sub_data = subset(lemna, as.character(lemna$Sample.ID) == samples[i])
dN = c(dN, sub_data$N[2:nrow(sub_data)] - sub_data$N[1:(nrow(sub_data)-1)], NA)
dt = c(dt, sub_data$t[2:nrow(sub_data)] - sub_data$t[1:(nrow(sub_data)-1)], NA)
}
dN
#> [1] 3 3 NA 6 4 2 NA 1 1 NA
dt
#> [1] 4 4 NA 2 2 1 NA 6 7 NA
Created on 2020-10-16 by the reprex package (v0.3.0)