The CCI30 Crypto Index is a cryptocurrency index that tracks the performance of the top 30 cryptocurrencies by market capitalization. It was created in 2017 by a team of researchers and analysts from the CryptoCompare and MVIS indices.
The CCI30 Crypto Index is designed to provide a broad-based and representative measure of the cryptocurrency market’s overall performance. It includes a diverse range of cryptocurrencies, such as Bitcoin, Ethereum, Litecoin, Ripple, and many others. The index is weighted by market capitalization, with each cryptocurrency’s weight determined by its market capitalization relative to the total market capitalization of all 30 cryptocurrencies.
The CCI30 Crypto Index has become a popular benchmark for the cryptocurrency market, as it offers a comprehensive view of the market’s performance, rather than just focusing on one particular cryptocurrency. It is often used by investors, traders, and researchers to analyze trends and make investment decisions.
One notable feature of the CCI30 Crypto Index is that it is rebalanced every quarter. This means that the composition of the index is adjusted to reflect changes in the market capitalization of the constituent cryptocurrencies. This helps to ensure that the index remains representative of the overall cryptocurrency market.
Overall, the CCI30 Crypto Index provides a useful tool for tracking the performance of the cryptocurrency market. It is a valuable resource for investors, traders, and researchers who are interested in this exciting and rapidly evolving field.
Let’s break it down step by step:
- The first line of the code loads the “dplyr” package, which provides a set of functions for data manipulation.
- The second line of the code reads the HTML code from the website “https://cci30.com/” using the “read_html” function from the “xml2” package.
- The next two blocks of code extract two tables from the HTML document using the “html_node” function from the “rvest” package. The tables are located at two different XPaths in the HTML document.
- The extracted tables are then converted into tibbles using the “as_tibble” function from the “tibble” package. The tibbles are further transformed by selecting only the columns from the second to the fifth column using the “select” function from the “dplyr” package.
- The column names of the tibbles are then set using the “set_names” function from the “purrr” package.
- Finally, the two tibbles are combined using the “union” function from the “dplyr” package, and the resulting tibble is printed to the console.
In summary, the code is extracting two tables from a website, transforming them into tibbles, selecting a subset of columns, renaming the columns, and combining them into a single tibble.
cci30 <- xml2::read_html("https://cci30.com/") tbl1 <- cci30 |> rvest::html_node(xpath = "/html/body/div/div/div/div/div/div/table") |> rvest::html_table(header = 1) |> tibble::as_tibble() |> dplyr::select(2:5) |> purrr::set_names( "Coin","Price","Mkt Cap","Daily Change" ) tbl2 <- cci30 |> rvest::html_node(xpath = "/html/body/div/div/div/div/div/div/table") |> rvest::html_table(header = 1) |> tibble::as_tibble() |> dplyr::select(2:5) |> purrr::set_names( "Coin","Price","Mkt Cap","Daily Change" ) tbl <- tbl1 |> dplyr::union(tbl2) |> knitr::kable() tbl
|Coin||Price||Mkt Cap||Daily Change|
|UNUS SED LEO||$3.35||$3,195,413,769||-0.55%|