The final goal is to create a txt where each row is different.
For this I have different variables with different values that are going to be combined.
The solution I provide does not seem the most appropriate because if the number of values is greater the code to write would be very long, perhaps a for
, the problem that I see that the first line of the output is different to the following, and that would be repeated for a new value of the variable people.
Code
personas <- data.table(c("Luis","Pedro","Mar"))
año <- "2018"
mes <-"05"
dia <- "23"
dia2 <- data.table(c("lunes","martes","miercoles","jueves","Viernes"))
salida <-data.table(paste(año,mes,dia,personas[1],"&",sep=""),
paste(año,mes,dia,personas[1],dia2[1],"&",sep=""),
paste(año,mes,dia,personas[1],dia2[2],"&",sep=""),
paste(año,mes,dia,personas[1],dia2[3],"&",sep=""),
paste(año,mes,dia,personas[1],dia2[4],"&",sep=""),
paste(año,mes,dia,personas[1],dia2[5],"&",sep=""),
paste(año,mes,dia,personas[2],dia2[1],"&",sep=""),
paste(año,mes,dia,personas[2],dia2[2],"&",sep=""),
paste(año,mes,dia,personas[2],dia2[3],"&",sep=""),
paste(año,mes,dia,personas[2],dia2[4],"&",sep=""),
paste(año,mes,dia,personas[2],dia2[5],"&",sep=""),
paste(año,mes,dia,personas[3],dia2[1],"&",sep=""),
paste(año,mes,dia,personas[3],dia2[2],"&",sep=""),
paste(año,mes,dia,personas[3],dia2[3],"&",sep=""),
paste(año,mes,dia,personas[3],dia2[4],"&",sep=""),
paste(año,mes,dia,personas[3],dia2[5],"&",sep=""))
salida
salida2 <- t(salida)
The output I get is:
[,1]
V1 "20180524Luis&"
V2 "20180524Luislunes&"
V3 "20180524Luismartes&"
V4 "20180524Luismiercoles&"
V5 "20180524Luisjueves&"
V6 "20180524LuisViernes&"
V7 "20180524Pedrolunes&"
V8 "20180524Pedromartes&"
V9 "20180524Pedromiercoles&"
V10 "20180524Pedrojueves&"
V11 "20180524PedroViernes&"
V12 "20180524Marlunes&"
V13 "20180524Marmartes&"
V14 "20180524Marmiercoles&"
V15 "20180524Marjueves&"
V16 "20180524MarViernes&"
There would be no export to txt
where you would remove the row and column names.
Could someone give me another better solution?
Thank you.