Reputation: 1
> betas <- betas %>%
+ matrix(data= models, nrow = 5, ncol = num_factors +1, byrow = T, dimnames = list) %>%
+ data.frame(row.names = FAANG)%>%
+ colnames(betas) <- c("Constant", "Mkt_RF", "SMB", "HML", "RMW", "CMA")
Error in matrix(., data = models, nrow = 5, ncol = num_factors + 1, byrow = T, :
unused argument (.)
when i type in this code, it kept showing me that the matrix(., got error of unused argument(.), while i did not put any symbol before data.
betas <- betas %>%
matrix(unlist(models),nrow = num_factors, ncol = num_factors +1, byrow = T) %>%
data.frame(row.names = FAANG)%>%
colnames(betas) <- c("Constant", "Mkt_RF", "SMB", "HML", "RMW", "CMA")
Error in matrix(., unlist(models), nrow = num_factors, ncol = num_factors + :
'dimnames' must be a list
this is the original code from the course of https://www.coursera.org/learn/using-r-for-regression-and-machine-learning-in-investment/lecture/Uq7v7/l5-understanding-machine-learning-concepts (free course), but it did not work as well.
Upvotes: 0
Views: 42
Reputation: 86
You pipe betas
to matrix()
but at the same time you provide all parameters to matrix()
. Hence, there's no parameter that will use betas
which is piped as .
Piping puts your input as the first parameter. You can read more here.
In your second example, unlist(models)
will be assigned to the dimnames
parameter since it's the only parameter left.
Upvotes: 1