Hi everybody,
I would appreciate any help with this code.
I would like to calculate the mean of the variable "share_outstanding" by each stock ticker by yearly. The code here doesn't work.
average <- input %>% group_by(ticker, year) %>%
summarize(year_share_oustanding = mean(share_outstanding))
Warning message:
In mean.default(share_outstanding) :
argument is not numeric or logical: returning NA
My data is something like that, about 300 stock tickers for ten years.
Thank you in advance.
year = c(2010L, 2010L, 2010L, 2010L, 2010L, 2010L, 2010L,
2010L, 2010L, 2010L, 2010L, 2010L, 2010L, 2010L,
2010L),
share_outstanding = c("9900000", "9900000", "9900000", "9900000",
"9900000", "9900000", "9900000", "9900000",
"9900000", "9900000", "9900000", "9900000", "9900000",
"9900000", "9900000"),
year_share_oustanding = c(NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA,
NA, NA, NA),
ticker = as.factor(c("AAA", "AAA", "AAA", "AAA", "AAA",
"AAA", "AAA", "AAA", "AAA", "AAA",
"AAA", "AAA", "AAA", "AAA", "AAA")),
date = as.factor(c("7/15/2010", "7/16/2010", "7/19/2010",
"7/20/2010", "7/21/2010", "7/22/2010",
"7/23/2010", "7/26/2010", "7/27/2010",
"7/28/2010", "7/29/2010", "7/30/2010",
"8/2/2010", "8/3/2010", "8/4/2010"))
)