[R] Looping

Peter Langfelder peter@|@ng|e|der @end|ng |rom gm@||@com
Mon Feb 19 04:55:59 CET 2024


Try

for (ind in 1:24)
{
   data = read.csv(paste0("data", ind, ".csv"))
   ...
}


Peter

On Mon, Feb 19, 2024 at 11:33 AM Steven Yen <styen using ntu.edu.tw> wrote:
>
> I need to read csv files repeatedly, named data1.csv, data2.csv,… data24.csv, 24 altogether. That is,
>
> data<-read.csv(“data1.csv”)
>> data<-read.csv(“data24.csv”)
>>
> Is there a way to do this in a loop? Thank you.
>
> Steven from iPhone
>         [[alternative HTML version deleted]]
>
> ______________________________________________
> R-help using r-project.org mailing list -- To UNSUBSCRIBE and more, see
> https://stat.ethz.ch/mailman/listinfo/r-help
> PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
> and provide commented, minimal, self-contained, reproducible code.



More information about the R-help mailing list