Probably it´s a nonsense but I´ve been playing around with paste and paste0 with no success.
My data frame looks like this
stck <-structure(list(haul = 1:11,
year = c(1983L, 1983L, 1983L, 1983L, 1983L, 1983L, 1983L, 1983L, 1983L, 1983L, 1983L)),
row.names = c(NA, 11L), class = "data.frame")
and I´m trying to generate a code like this: N83_01, N83_02, ...., N83_10
Namely, I want to create a code pasting the two last number of the year plus the haul number (in "two-number" format).
Hitherto, I couldn´t find the way to paste "N". This is what I have
stck$cod_lance <- as.factor(ifelse (stck$lance >=1 & stck$lance <10, paste(str_sub(stck$fecha, 3, 4), stck$lance, sep="_0"),
paste(str_sub(stck$fecha, 3, 4), stck$lance, sep="_")))
How can I get the right output?. Thanks in advance.