Use lappy to convert the columns which you want to convert.
r
# V1 V2 V3 V4 V5
# 1 C 1 1 0 16
# 2 A 1 1 16 0
# 3 A 1 1 16 0
str(r)
# 'data.frame': 3 obs. of 5 variables:
# $ V1: chr "C" "A" "A"
# $ V2: chr "1" "1" "1"
# $ V3: chr "1" "1" "1"
# $ V4: chr "0" "16" "16"
# $ V5: chr "16" "0" "0"
Here is the code to convert all columns except the first to numeric.
r[-1] <- lapply(r[-1], as.numeric)
r
# V1 V2 V3 V4 V5
# 1 C 1 1 0 16
# 2 A 1 1 16 0
# 3 A 1 1 16 0
str(r)
# 'data.frame': 3 obs. of 5 variables:
# $ V1: chr "C" "A" "A"
# $ V2: num 1 1 1
# $ V3: num 1 1 1
# $ V4: num 0 16 16
# $ V5: num 16 0 0
If you want to know more about the Data Science then do check out the following Data Science which will help you in understanding Data Science from scratch