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
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 6 days ago.
Improve this question
I'm lost : i'd like to convert chararcter to date using as.Date() in R. I genuinely don't know what i missed with such a simple code. Here is an example
week_dates <- as.Date("06/20/2022", format ="%d/%m/%Y")
week_dates return only NA. Any idea what i missed ?
Thanks in advance !
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 don't understand why I am having the Error(function(classes, fdef, mtable): unable to find an inherited method for function 'Summary' for signature '"prcomp"'.
I have checked through my code and the packages and everything looks very much okay.
One needs to use lower case summary. The code has capital S in Summary
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 would like to calculate Mann Attached imageKendall statistics in R. i have an excel sheet with rainfall and years. how would i best get it
Looking at the attached image you should not put Book1$Mean in quotes. Try using:
MannKendall(Book1$Mean)
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 am returning to some old code where I had used the following syntax:
y[df$myvar %between% c(1,100)]
but get the error
could not find function "%between%"
This code used to work, and I have updated R in the mean time. any thoughts?
As Pascal pointed out, you should load the package data.table first:
library(data.table)
Then you'll be able to use it.
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'm trying to do a simple calculation with my mean function. When I input mean(1, 10, 100), R returns 1, which is obviously not the correct average. It always returns the first entry of my vector. What went wrong?
You should use mean(c(1,10,100))
See http://www.rdocumentation.org/packages/base/functions/c