1
I have a script with five variables.
Suppose the variables and their data types/classes are the following:
- var1(date)
- var2(date)
- var3(date)
- var4(date)
- var5(Numeric)
I would like to import a spreadsheet with each column/ input corresponding to the name and type of variables in a dataframe. So:
df <- xlsx("planilha.xlsx", sheet = "nome_plan")
It would be possible to iterate the entire code for each of the dataframe lines?
Something like:
for (i in df) {
executar_script(i)
}
Fernando, anything is possible, but it would be easier to suggest if we know what you have and what you want. Describe your problem better.
– Daniel Ikenaga
Follow the whole script: https://pastebin.com/dEt9EMhz. The five variables are commented at the beginning.
– Fernando Vieira
I have my doubts whether the people here will want to read and understand a script with 376 lines that they did not write. Try to reduce your question to something simpler and reproducible. Preferably by giving a.
– Marcus Nunes
Reinforcing the previous comment, no one will stop to understand a 300+ line sript just to answer a question about loop; write a simple test script and post it along with an example of data. But what you can do in your case is write your script as a function, saving it in a separate file. Click with
source
and use family functionsapply
to apply it to the various elements of a list or date..– Carlos Eduardo Lagosta
Carlos, I’ll do it. Thank you
– Fernando Vieira