我有一个包含若干领域的数据框架。 其中一个领域是“萨摩亚”,由于各种投入,我的样本用各种格式命名。 以下是一些例子:
"12" "250" "1248" "1_100111" "16_100111" "125_081811" "1249_100111"
The above examples represent the majority of the samples. I would like to change all of the samples to a 4 digit format so they can be easily sorted. The final result of the above examples would be:
"0012" "0250" "1248" "0001" "0016" "0125" "1249"
Thus, in some cases zeros must be added and in other cases, the date marker must be cut off. It is very important that the changes are made within the context of a data frame and returned in the same format.