writing following function to add special character to an integer for example '19991221'
. When I run the following function, it returns NULL
value. Tried to implement Return value from function when iterating in a loop R which still returns NULL.
data is read from *.csv
fileloc=read.csv('*.csv')
m<-for (row in fileloc[1]) {
x<-(sub("(..)$", "/\\1", row))
y<-(sub("(.....)$", "/\\1", x))
}
> m
NULL
sample data:
V1
1 19991221
2 19910703
3 19850326
4 19890328
5 19610912
Desired Result:
V1
1 1999/12/21
2 1991/07/03
3 1985/03/26
4 1989/03/28
5 1961/09/12