r-project.org
Subject: Re: [R] Can't compute row means of two columns of a dataframe.
[External Email]
John,
Maybe you can clarify what you want the output to look like. It took me a while
to realize what you may want as it is NOT properly described as wanting rowsums.
There is a standard functi
une 8, 2024 1:38 PM
To: r-help@r-project.org (r-help@r-project.org)
Subject: [R] Can't compute row means of two columns of a dataframe.
[External Email]
I have a data frame with three columns, TotalInches, Low20, High20. For each
row of the dataset, I am trying to compute the mean of L
warnings may relate to that.
-Original Message-
From: R-help On Behalf Of Sorkin, John
Sent: Saturday, June 8, 2024 1:38 PM
To: r-help@r-project.org (r-help@r-project.org)
Subject: [R] Can't compute row means of two columns of a dataframe.
I have a data frame with three columns, T
Incidentally, FWIW, for means, rowMeans() is a lot faster:
xxxz$av20 <- rowMeans(xxxz[,c("Low20","High20")])
Bert
On Sat, Jun 8, 2024 at 10:47 AM Bert Gunter wrote:
> Use apply(), not by().
>
> xxxz$av20 <- apply(xxxz[,c("Low20","High20")],1, mean)
>
> -- Bert
>
> On Sat, Jun 8, 2024 at 10:3
Use apply(), not by().
xxxz$av20 <- apply(xxxz[,c("Low20","High20")],1, mean)
-- Bert
On Sat, Jun 8, 2024 at 10:38 AM Sorkin, John
wrote:
> I have a data frame with three columns, TotalInches, Low20, High20. For
> each row of the dataset, I am trying to compute the mean of Low20 and
> High20.
I have a data frame with three columns, TotalInches, Low20, High20. For each
row of the dataset, I am trying to compute the mean of Low20 and High20.
xxxz <- structure(list(TotalInches =
c(58, 59, 60, 61, 62, 63, 64, 65,
66, 67, 68, 69, 70, 71, 72, 73, 74, 7
6 matches
Mail list logo