Rows: 424 Columns: 18
── Column specification ────────────────────────────────────────────────────────
Delimiter: ","
chr (10): ticker, name, asset_class, sub_asset_class, region, market, locat...
dbl (6): gross_expense_ratio_percent, net_expense_ratio_percent, net_asset...
dttm (2): incept_date, net_assets_as_of
ℹ Use `spec()` to retrieve the full column specification for this data.
ℹ Specify the column types or set `show_col_types = FALSE` to quiet this message.
Create a sorted bar chart of the 10 smallest ETFs.
Hint: for sorting the bar chart, look up fct_reorder() . Make sure your chart has meaningful titles and labels, including numbers of an appropriate magnitude.
library (ggplot2)library(forcats)# Step 1: Select the 10 smallest ETFs based on assets under managementsmallest_etfs <- blackrock_etf_screener %>%arrange(net_assets_usd) %>%head(10)# Step 2: Sort the ETFs based on their assets under managementsmallest_etfs <- smallest_etfs %>%mutate(name =fct_reorder(name, net_assets_usd))# Step 3: Create a bar chartggplot(smallest_etfs, aes(x = name, y = net_assets_usd)) +geom_bar(stat ="identity", fill ="skyblue") +labs(title ="Top 10 Smallest ETFs",x ="ETF Name",y ="Net Assets ($)") +theme(axis.text.x =element_text(angle =45, hjust =1)) +coord_flip() # Flip the coordinates for horizontal bars
Problem 3
Find the funds in the bottom quintile of the MSCI ESG quality score.
calculate the number of funds by total assets by asset class and sub asset class.
# Step 1: Identify the bottom quintile of funds based on the MSCI ESG quality scorebottom_quintile <- blackrock_etf_screener %>%filter(!is.na(msci_esg_quality_score_0_10)) %>%arrange(msci_esg_quality_score_0_10) %>%slice(1:ceiling(n() *0.2)) # Step 2: Group the data by asset class and sub-asset classgrouped_data <- bottom_quintile %>%group_by(asset_class, sub_asset_class) %>%summarize(total_assets =sum(net_assets_usd))
`summarise()` has grouped output by 'asset_class'. You can override using the
`.groups` argument.
# Step 3: Display the number of funds by total assets by asset class and sub-asset classprint(grouped_data)
# A tibble: 9 × 3
# Groups: asset_class [3]
asset_class sub_asset_class total_assets
<chr> <chr> <dbl>
1 Equity All Cap 95486052602.
2 Equity Large Cap 1852506812.
3 Equity Large/Mid Cap 42421984678.
4 Equity Small Cap 187292555389.
5 Fixed Income Corporates 41339182.
6 Fixed Income Credit 408038372.
7 Fixed Income Government 17560711395.
8 Fixed Income High Yield 38239624578.
9 Real Estate Real Estate Securities 7145439523.
Problem 4
1,average net expense ratio by region
factoid1 <- blackrock_etf_screener %>%group_by(region) %>%summarise(Avg_Expense_Ratio =mean(net_expense_ratio_percent)) %>%ggplot(aes(x = region, y = Avg_Expense_Ratio)) +geom_bar(stat ="identity", fill ="skyblue") +labs(title ="Average Expense Ratio by region",x ="region",y ="Average Expense Ratio")print (factoid1)
2.distribution of fund sizes
factoid2 <-ggplot(blackrock_etf_screener, aes(x = net_assets_usd)) +geom_histogram(fill ="skyblue", color ="black") +labs(title ="Distribution of Fund Sizes",x ="Net assets USD",y ="Frequency")print (factoid2)
`stat_bin()` using `bins = 30`. Pick better value with `binwidth`.