How to extract a number into digits using R? -
suppose have number: 4321
and want extract digits: 4, 3, 2, 1
how do this?
alternatively, strsplit
:
x <- as.character(4321) as.numeric(unlist(strsplit(x, ""))) [1] 4 3 2 1
suppose have number: 4321
and want extract digits: 4, 3, 2, 1
how do this?
alternatively, strsplit
:
x <- as.character(4321) as.numeric(unlist(strsplit(x, ""))) [1] 4 3 2 1
Comments
Post a Comment