Às 03:27 de 19/02/2024, Steven Yen escreveu:
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
[[alternat
f <- function (filename) {
data<- read.csv(filename)
..
}
for (filename in paste0("data", 1:24, ".csv")) f(filename)
Depending on what exactly you have in your file system,
for (filename in system("ls data*.csv", TRUE)) f(filename)
might work.
On Mon, 19 Feb 2024 at 16:33, Steven Yen wrote
Steven,
It depends what you want to do. What you are showing seems to replace the
values stored in "data" each time.
Many kinds of loops will do that, with one simple way being to store all the
filenames in a list and loop on the contents of the list as arguments to
read.csv.
Since you show f
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 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<-rea
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]]
__
В Sat, 17 Feb 2024 11:15:43 -0700
"Reed A. Cartwright" пишет:
> I'm wrapping a function in R and I want to record all the arguments
> passed to it, including default values and missing values.
This is hard if not impossible to implement for the general case
because the default arguments are eval
Hi Reed,
I need to stress before giving my answer that no solution can handle
everything. These scenarios will always lead to problems:
* if any of the formal arguments rely on the current state of the call stack
* if any of the formal arguments rely on a variable that is only
defined later in
I'm wrapping a function in R and I want to record all the arguments
passed to it, including default values and missing values. I want to
be able to snoop on function calls in sourced scripts as part of a
unit testing framework.
I can capture the values fine, but I'm having trouble evaluating them
8 matches
Mail list logo