I would like to remove the last 4 characters for the column "Name" for every row. This is what I have tried.
hof_pitching.final[, Name := substring(hof_pitching.final$Name, 0, (length(hof_pitching.final$Name) - 4))]
Any help would be appreciated.
I would like to remove the last 4 characters for the column "Name" for every row. This is what I have tried.
hof_pitching.final[, Name := substring(hof_pitching.final$Name, 0, (length(hof_pitching.final$Name) - 4))]
Any help would be appreciated.
 
    
    Perhaps you're looking for nchar?
require(data.table)
DT <- data.table(x=1:5, y=paste0("V", 10000:10004))
DT[, z := substring(y, 0, nchar(y)-4L)]
# > DT
#    x      y  z
# 1: 1 V10000 V1
# 2: 2 V10001 V1
# 3: 3 V10002 V1
# 4: 4 V10003 V1
# 5: 5 V10004 V1
