Hi there!
I've been trying to code my first function with no succes and i think that the solution might be in front of me.
This is a simplificcation of my data
Ticker | metric1 | metric2 | metric3 |
---|---|---|---|
HD | 1 | 3 | 4 |
WMT | 6 | 8 | 2 |
NVDA | 1 | 2 | 3 |
I would like to make a list of every "Ticker" and thieir possible values, like this.
HD | 1 |
---|---|
WMT | 6 |
NVDA | 1 |
HD | 3 |
HD | 4 |
WMT | 8 |
WMT | 2 |
NVDA | 2 |
NVDA | 3 |
To do so, i created my first function but when i try to rbind the information i dont have dataframes, only a list of items and i can work with it.
metrica <- function(x) {
x <- yahoo %>% select('Ticker','metric'=x+1)
}
n <- length(colnames(yahoo))-1
total <- rbind(lapply(1:n,metrica))
Why is it displayed as a list? There is something wrong with my code?
Thank you!