Hard to help without a reproducible example. But this should work:
gn1 <- unlist(lapply(pL,function(i){
n <- nrow(subset(ttable, IDENTIFIER==i))
gn <- if (n < 1) i else seq(n)
}))
z I run your code I get gn
data.frame. You run mine you get gn1
vector. I cbind
the 2 for comparison.
cbind(as.data.frame(gn1),gn)
gn1 X.GSTT4.
1 GSTT4 GSTT4
2 AHRR AHRR
3 HAX1 HAX1
4 DNM1L DNM1L
5 MEIS1 MEIS1
6 SLC17A3 SLC17A3
7 CES2 CES2
8 MLL2 MLL2
9 IKBKB IKBKB
10 GSTA4 GSTA4
As you seed the 2 columns are identical.