Replace

temp <- strsplit(vec,NULL)

By

temp <- lapply(strsplit(vec,NULL), as.integer)