2
I tried to run an example, but gave the error below:
Calculate asset returns log
r <- diff(log(prices)) Error in Math.factor(prices) n <- length(r) Error: Object 'r' not found
Someone knows how to fix it?
2
I tried to run an example, but gave the error below:
Calculate asset returns log
r <- diff(log(prices)) Error in Math.factor(prices) n <- length(r) Error: Object 'r' not found
Someone knows how to fix it?
1
‘log’ not meaningful for factors
means that you tried to apply the logarithm to an object of the type fator
.
Example of the problem:
nn <- factor("4233")
log(nn)
Error in Math.factor(nn) : ‘log’ not meaningful for factors
Quick fix in this case:
log(as.numeric(as.character(nn)))
[1] 8.350666
Example of Other Errors:
b <- factor("Caracter")
log(b)
Error in Math.factor(b) : ‘log’ not meaningful for factors
Note that if you try to apply the log
a character also will not rotate:
a <- "Caracter"
log(a)
Error in log(a) : non-numeric argument to mathematical function
Only numeric type objects can be logged:
c <- 3
log(c)
[1] 1.098612
Browser other questions tagged r
You are not signed in. Login or sign up in order to post.
its price vector is of the type
factor
and not of the numeric type as it is necessary to use the functionlog
. My guess is you read the base and forgot to use the argumentdec = ","
to specify that your decimal separator is,
.– Daniel Falbel
Thank you very much Daniel! I transformed the data into numerics by the function: prices <- as.Nonumeric(as.Haracter(prices))
– JPA
please post the reply @JPA, or who helped you
– Artur_Indio