Displaying 3 results from an estimated 3 matches for "average20".
2024 Jun 08
1
Can't compute row means of two columns of a dataframe.
...00000 89.66667 92.33333 95.00000 97.66667 100.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
You...
2024 Jun 08
3
Can't compute row means of two columns of a dataframe.
...09, 112, 116, 119, 122, 126, 129,
133, 137, 141, 144), High20 = c(111, 115, 119, 123, 127, 131,
135, 140, 144, 148, 153, 157, 162, 167, 171, 176, 181, 186, 191
)), class = "data.frame", row.names = c(NA, -19L))
xxxz
str(xxxz)
xxxz$Average20 <- by(xxxz[,c("Low20","High20")],xxxz[,"TotalInches"],mean)
warnings()
When I run the code above, I don't get the means by row. I get the following warning messages, one for each row of the dataframe.
Warning messages:
1: In mean.default(data[x, , drop = FALSE...
2024 Jun 08
1
Can't compute row means of two columns of a dataframe.
...133, 137, 141, 144), High20 = c(111, 115, 119, 123,
> 127, 131,
> 135, 140, 144, 148, 153, 157, 162, 167, 171, 176, 181,
> 186, 191
> )), class = "data.frame", row.names = c(NA, -19L))
> xxxz
> str(xxxz)
> xxxz$Average20 <- by(xxxz[,c("Low20","High20")],xxxz[,"TotalInches"],mean)
> warnings()
>
> When I run the code above, I don't get the means by row. I get the
> following warning messages, one for each row of the dataframe.
>
> Warning messages:
> 1: In me...