Closed. This question is not reproducible or was caused by typos. It is not currently accepting answers.
This question was caused by a typo or a problem that can no longer be reproduced. While similar questions may be on-topic here, this one was resolved in a way less likely to help future readers.
Closed 2 years ago.
Improve this question
I am trying to compute this in R
When I tried
exp(1)^ln(1.89)/10
I get the error: Error in ln(1.89) : could not find function "ln"
I was wondering if ln is ^
I tried exp(1)^(1.89/10) but I get a value of 1.208041 and the answer should be 1.066.
Am I translating the equation into R correctly?
log() is the function you are looking for
T_val <- 2 # some value
exp(log(1.89) / 10 * T_val)
You should log and not ln. Moreover, parenthesis are important due to operator precedence (^ versus / and *).
Related
Closed. This question is not reproducible or was caused by typos. It is not currently accepting answers.
This question was caused by a typo or a problem that can no longer be reproduced. While similar questions may be on-topic here, this one was resolved in a way less likely to help future readers.
Closed 1 year ago.
Improve this question
When I am running the following lines, there is an error saying Error in toSrting(m) : could not find function "toSrting". I have no idea what happened since toString usually works well but not here:
m <- 1
for(m in 1:60000){
toSrting(m)
paste("trainxr", m) <- raster(trainxr[m,,])
strtoi(m)
m <- m + 1
}
Thank you for your help.
I've never used R but I think string is spelled wrong.
Closed. This question is not reproducible or was caused by typos. It is not currently accepting answers.
This question was caused by a typo or a problem that can no longer be reproduced. While similar questions may be on-topic here, this one was resolved in a way less likely to help future readers.
Closed 2 years ago.
Improve this question
I'm trying to use the match function in function with a for loop and it isn't working. Here is an example of the exact error I'm getting.
a <- c(1:10)
b <- c(2:11)
match(a,b)
It doesn't work. Here is the error I'm getting:
Error in match(a, b) : unused argument (b)
Then I tried something simpler:
match(2,a)
And it gives me this:
Error in match(2, a) : unused argument (a)
I really need this function for my code, can anyone tell me what I've done wrong?
Closed. This question is not reproducible or was caused by typos. It is not currently accepting answers.
This question was caused by a typo or a problem that can no longer be reproduced. While similar questions may be on-topic here, this one was resolved in a way less likely to help future readers.
Closed 4 years ago.
Improve this question
I am doing an exercise to create a function. One of the questions is:
"We can estimate the cumulative risk of an certain event using the
exponential formula
1-exp(-1/10000*t) where t is the time to the event. Create a function ans(t), which returns the risk at time t.
and I am using this command:
function(t){ans(t)<-1-exp(-1/10000*t)return(ans(t))}
but it is giving wrong answer. Can someone help me to understand this please?
The proper format to define a function is this:
ans<-function(t){
answer<-1-exp(-1/10000*t)
return(answer)
}
ans(1)
#[1] 9.9995e-05
Closed. This question is not reproducible or was caused by typos. It is not currently accepting answers.
This question was caused by a typo or a problem that can no longer be reproduced. While similar questions may be on-topic here, this one was resolved in a way less likely to help future readers.
Closed 6 years ago.
Improve this question
This is the R command I used to create a decision tree,
k <- C5.0(data1[1:16000,-32],as.factor(data2{1:16000,32])
but this output I get for error:
Error: unexpected '{' in "k <- C5.0(data1[1:16000,-32],as.factor(data2{"
Did I forget a bracket? I couldn't figure out why
Try
k <- C5.0(data1[1:16000,-32],as.factor(data2[1:16000,32]))
You used { instead of [ at the end and you also forgot to include another ) to wrap up your C5.0 function.
Closed. This question is not reproducible or was caused by typos. It is not currently accepting answers.
This question was caused by a typo or a problem that can no longer be reproduced. While similar questions may be on-topic here, this one was resolved in a way less likely to help future readers.
Closed 7 years ago.
Improve this question
I have an error
> for (i in 1:(cutoff_size-1)){work$group[i]=rep(c(0,1),c([i]-1,cutoff_size-[i]-1))}
Error: unexpected '[' in:"for (i in 1:(cutoff_size-1)){work$group[i]=rep(c(0,1),c(["
'cutoff_size' is numeric.
How can I solve this problem?
for (i in 1:(cutoff_size-1)){work$group[i]=rep(c(0,1),c(i-1,cutoff_size-i-1))}
this is probably what you're looking for.
[] are used to refer to position in array/data table/list.
If you're using it in a mathematical operation, you do not need the [] around the i.