I have a data frame data
, which contains information about crypto currencies. I need to find a way to create a vector with symbols of cryptos, which absolute value of market capitalization change in 24h in percentage is at least 10. I have the following function:
pos_MCchange <- data$market_cap_change_percentage_24h >= 10
neg_MCchange <- data$market_cap_change_percentage_24h <= -10
vector <- c((data$symbol[pos_MCchange]), (data$symbol[neg_MCchange]))
It returns exactly what is required, but the symbols appear in the different order than in the data frame. Short example to illustrate my problem:
data
# symbol market_cap_change_percentage_24h
# 1 a 11
# 2 b 9
# 3 c -15
# 4 d -5
# 5 e 12
# 6 f 6
# 7 g -14
My function would return: c(11, 12, -15, -14)
. Yet, I want it to be like c(11, -15, 12, -14)
.
Is it possible to create the vector in a way that symbols (with the corresponding market cap. change) would appear in the same order as they are in the data frame? Please, let me know.