The first problem:
I have an input data file that contains dates in ddmmyy
format, on which I must operate, and when I import it in R it recognizes it as a factor. What I have done is to convert it to a character using as.character
and then I have transformed it to date using as.date
, for example
df1$fcontrol<-as.Date(df1$fcontrol, format="%d%m%Y")
df2$fparto<-as.Date(df2$fparto, format="%d%m%Y")
df1$Var1<-as.numeric(df1$fcontrol - df2$fparto)
In all cases, the new date format in my work and output files is no longer "ddmmyy"
but "yymmdd"
and I do not know why it happens, if clearly in the order format I am specifying ddmmyy
. What should I do?
The second problem
This is the output format I want my data to have:
ES06000011030003012012210220121360 4.07 4.38 678
ES06000011030003012012200320121460 3.46 4.81 20
ES0600001103000301201219042012 980 3.69 5.46 54
ES0600001103000301201212072012 660 32
Where the first 14 positions represent an ID, the next 8 are a date, the next 8 are another date, the next 4 parameters are of interest, the next 5 are parameters with a decimal separation, the next 5 are parameters3 with a decimal separation and the next 5 parameters4.
In R what I get using
write.table(Datos, "Datos_TD_LCR.DAT", row.names = FALSE, col.names=FALSE, quote = FALSE, sep="")
is something of the type
ES060000110300030120122102201213604.074.38678
ES060000110300030120122003201214603.464.8120
ES06000011030003012012190420129803.695.4654
ES0600001103000301201212072012660NANA32
And I do not know how to get what I need.