Re: [R] tibble question with a mean

2018-09-21 Thread Erin Hodgess
Nice! I didn’t realize you could do all that! Thanks! On Fri, Sep 21, 2018 at 10:32 AM William Dunlap wrote: > Since you are using tibbles you may want to go whole-hog and use the dplyr > package as well. > > > xt <- > tibble(x=LETTERS[1:4],y=1:4,z=log2(1:4),a=c("dog","cat","tree","ferret"))

Re: [R] tibble question with a mean

2018-09-21 Thread William Dunlap via R-help
Since you are using tibbles you may want to go whole-hog and use the dplyr package as well. > xt <- tibble(x=LETTERS[1:4],y=1:4,z=log2(1:4),a=c("dog","cat","tree","ferret")) > xt %>% summarize(yMean=mean(y), zMean=mean(z), aLast=last(a)) # A tibble: 1 x 3 yMean zMean aLast 1 2.5 1.15 fer

Re: [R] tibble question with a mean

2018-09-20 Thread Erin Hodgess
nt: Thursday, September 20, 2018 8:08 PM > To: Erin Hodgess > Cc: r-help > Subject: Re: [R] tibble question with a mean > > I don't know tibble, so I'll do the same with a plain data frame: > > a = > > data.frame(x=LETTERS[1:4],y=1:4,z=rnorm(4),a=c(&qu

Re: [R] tibble question with a mean

2018-09-20 Thread David L Carlson
ailto:r-help-boun...@r-project.org] On Behalf Of Peter Langfelder Sent: Thursday, September 20, 2018 8:08 PM To: Erin Hodgess Cc: r-help Subject: Re: [R] tibble question with a mean I don't know tibble, so I'll do the same with a plain data frame: a = data.frame(x=LETTERS[1:4],y=1:4,z=rnorm(4

Re: [R] tibble question with a mean

2018-09-20 Thread Peter Langfelder
I don't know tibble, so I'll do the same with a plain data frame: a = data.frame(x=LETTERS[1:4],y=1:4,z=rnorm(4),a=c("dog","cat","tree","ferret")) > a x y z a 1 A 1 -0.08264865dog 2 B 2 0.32344426cat 3 C 3 -0.80416061 tree 4 D 4 1.27052529 ferret > mean(a[2:3]) [1] NA

[R] tibble question with a mean

2018-09-20 Thread Erin Hodgess
Hello! Here is a toy tibble problem: xt <- tibble(x=LETTERS[1:4],y=1:4,z=rnorm(4),a=c("dog","cat","tree","ferret")) str(xt) Classes ‘tbl_df’, ‘tbl’ and 'data.frame': 4 obs. of 4 variables: $ x: chr "A" "B" "C" "D" $ y: int 1 2 3 4 $ z: num 0.3246 0.0504 0.339 0.4872 $ a: chr "dog" "cat"