search for: totalinches

Displaying 3 results from an estimated 3 matches for "totalinches".

2024 Jun 08
3
Can't compute row means of two columns of a dataframe.
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, 75, 76), Low20 = c(84, 87, 90,...
2024 Jun 08
1
Can't compute row means of two columns of a dataframe.
...0.33333 103.66667 106.33333 109.00000 112.33333 115.00000 [13] 118.00000 121.33333 124.00000 127.33333 130.66667 134.00000 137.00000 It does not add the means to the original data.frame if you wanted it there but that is easy enough to do. > xxxz$Average20 <-rowMeans(xxxz) > head(xxxz) TotalInches Low20 High20 Average20 1 58 84 111 84.33333 2 59 87 115 87.00000 3 60 90 119 89.66667 4 61 93 123 92.33333 5 62 96 127 95.00000 6 63 99 131 97.66667 Your construct is more complex and it looks like you...
2024 Jun 08
1
Can't compute row means of two columns of a dataframe.
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 <jsorkin at som.umaryland.edu> 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. > > xxxz <- structure(list(TotalInches = > c(58, 59, 60, 61, 62, 63, 64, 65, > 66, 67, 68, 69, 70, 71, 72, 73, 74, 75, 76), Low20 = > c(8...