t I think your
sample code DOES and am not too sure it is exactly what you want.
From: Kai Yang
Sent: Tuesday, November 15, 2022 1:53 PM
To: 'R-help Mailing List' ; avi.e.gr...@gmail.com
Subject: Re: [R] add specific fields in for loop
Hello Bert and Avi,
S
ode DOES and am not too sure it is exactly what you want.
From: Kai Yang
Sent: Tuesday, November 15, 2022 1:53 PM
To: 'R-help Mailing List' ; avi.e.gr...@gmail.com
Subject: Re: [R] add specific fields in for loop
Hello Bert and Avi,
Sorry, it is typo. it should be:
for
Hi Rui,
This is a great help.
Thank you,
Kai
On Tuesday, November 15, 2022 at 11:48:12 AM PST, Rui Barradas
wrote:
Às 19:39 de 15/11/2022, Kai Yang escreveu:
> Hello Rui,
> Yes, it should be the one I want. I modified the code as:
>
> for(i in grep("data", names(df))) {
> try2.un$ab
Às 19:39 de 15/11/2022, Kai Yang escreveu:
Hello Rui,
Yes, it should be the one I want. I modified the code as:
for(i in grep("data", names(df))) {
try2.un$ab2 <-
ifelse(grepl("ab2", [i]), [i], NA)
}
But I got error message:
Error: unexpected '[' in:
" try2.un$ab2 <-
ifelse(gre
Hello Rui,
Yes, it should be the one I want. I modified the code as:
for(i in grep("data", names(df))) {
try2.un$ab2 <-
ifelse(grepl("ab2", [i]), [i], NA)
}
But I got error message:
Error: unexpected '[' in:
" try2.un$ab2 <-
ifelse(grepl("ab2",["
I think I use [i] in a wrong way.
Às 16:18 de 15/11/2022, Kai Yang via R-help escreveu:
Hi Team,
I can write a for loop like this:
for (i in columns(df)){
..
}
But it will working on all column in dataframe df. If I want to work on some of
specific fields (say: the fields' name content 'date'), how should I modify the
f
d a certain way or that are of
certain types.
Avi
-Original Message-
From: R-help On Behalf Of Kai Yang via R-help
Sent: Tuesday, November 15, 2022 11:18 AM
To: R-help Mailing List
Subject: [R] add specific fields in for loop
Hi Team,
I can write a for loop like this:
for (i in columns(d
rt or end a certain way or that are of
certain types.
Avi
-Original Message-
From: R-help On Behalf Of Kai Yang via R-help
Sent: Tuesday, November 15, 2022 11:18 AM
To: R-help Mailing List
Subject: [R] add specific fields in for loop
Hi Team,
I can write a for loop like thi
There is no function columns() in base R.
Is 'date' an object that contains column names or indices? Or do you mean
that it is a string that appears in the column names you wish to loop over?
A small reprex should be easy to provide to show us explicitly what you
want. Please do so -- unless, of c
Hi Team,
I can write a for loop like this:
for (i in columns(df)){
..
}
But it will working on all column in dataframe df. If I want to work on some of
specific fields (say: the fields' name content 'date'), how should I modify the
for loop? I changed the code below, but it doesn't work.
f
10 matches
Mail list logo