Thanks for the help!
Isaac
From: Marc Schwartz
Sent: Thursday, February 14, 2019 11:05:23 AM
To: Isaac Barnhart
Cc: R-help
Subject: Re: [R] Finding the Mean of a Specific Set of Columns
On Feb 14, 2019, at 9:31 AM, Isaac Barnhart wrote:
>
> I am
onderdag 14 februari 2019 15:32
To: r-help@r-project.org
Subject: [R] Finding the Mean of a Specific Set of Columns
I am having trouble finding the mean of a specific part of my dataset. Here is
a sample of it:
plot lai leaf
1 104 82 1
2 104 167 2
3 104 248 3
4 104 343 4
5 104 377 5
6 105 64 1
7 10
On Feb 14, 2019, at 9:31 AM, Isaac Barnhart wrote:
>
> I am having trouble finding the mean of a specific part of my dataset. Here
> is a sample of it:
>
> plot lai leaf
> 1 104 82 1
> 2 104 167 2
> 3 104 248 3
> 4 104 343 4
> 5 104 377 5
> 6 105 64 1
> 7 105 139 2
> 8 105 211 3
> 9 105 296 4
>
Hi,
You might try your hand at the tidyverse collection of tools which are veddy
nice for this kind of wrangling. https://www.tidyverse.org/
Does this do the trick?
## START
library(readr)
library(dplyr)
txt <- "row plot lai leaf
1 104 82 1
2 104 167 2
3 104 248 3
4 104 343 4
5 104 377 5
6 105
Hi Isaac,
I am sure you will get lots of answers to this. Here is one using the dplyr
package.
Assuming that your data frame is called 'a', then
library(dplyr)
b <- dplyr::group_by(a,plot) %>% dplyr::summarise( mean(lai) )
b
# A tibble: 4 x 2
plot `mean(lai)`
1 104243.
2 10
I am having trouble finding the mean of a specific part of my dataset. Here is
a sample of it:
plot lai leaf
1 104 82 1
2 104 167 2
3 104 248 3
4 104 343 4
5 104 377 5
6 105 64 1
7 105 139 2
8 105 211 3
9 105 296 4
10 105 348 5
11 106 94 1
12 106 167 2
13 106 243 3
14 106 281 4
15 106 332 5
16 10
6 matches
Mail list logo