Re: [R] Can't compute row means of two columns of a dataframe.

2024-06-08 Thread Ebert,Timothy Aaron
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 function called rowMe

Re: [R] Can't compute row means of two columns of a dataframe.

2024-06-08 Thread Ebert,Timothy Aaron
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 Lo

Re: [R] Can't compute row means of two columns of a dataframe.

2024-06-08 Thread avi.e.gross
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, Tot

Re: [R] Can't compute row means of two columns of a dataframe.

2024-06-08 Thread Bert Gunter
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

Re: [R] Can't compute row means of two columns of a dataframe.

2024-06-08 Thread Bert Gunter
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.

[R] Can't compute row means of two columns of a dataframe.

2024-06-08 Thread Sorkin, John
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,