 # Help needed wtih these codes!

I can't make this function right
proportion <- function(v,i,j) for(v in i:j){proportion<-return(proportion for(v in i:j)}
I'm trying to make function proportion, wich would return from v values between i:j

Hi, welcome!

Please have a look to our homework policy, homework inspired questions are welcome but they should not include verbatim instructions from your course.

1 Like

For part one i've tried to make these codes, but have i done it too complicated or where i've gone wrong?

``````proportion <-funktion(v=1,i=0,j=1)[values <-runif(v=V,min=i, max=j)int_values <-round(values),return(int_values)]

proportion= random_integers <-funktion(v,i,j)[values <-runif(v=v,min=i, max=j)int_values <-round(values),return(int_values)]``````

Iäm unsure how to make this on work: how to get it return values from v between i:j
proportion <- function(v) for(v in i:j){proportion<-return(v, i;j)

your function doesnt take v , i and j, it only takes v. .
...and it does nothing with it...`proportion <- return(proportion)` doesnt relate to v in anyway, its sort of a strange function that returns itself.

Oh yes, that's it. Now i have to manage make it return values between i and j.

I progressed a bit with sekond part:
proportion <- function(100000) rbinom(n=100000, size=64, prob=1/2)

do you have questions about that ?

Yes, i tried to make my funtion based on it.

proportion <- function(v) for(v in i:j){proportion<-return(proportion)}

Thanks to you i see now that it doesen't return anything. Still can't make it work
proportion <- function(v, i, j) {proportion<-return(proportion for(v in i:j)}

Does this look better?
proportion <- function(v) {proportion (rep(i:j))<-return(v, i:j)}

ok, lets step back from your attempt at function making and see if we can straightforwardly answer some questions relating to the requirements. I expect the first one will be easy , and the second one might require more thought.

1 ) What are the desired parameters for your function 'proportion' ? list them.
2) in R how would one check whether numbers are between other numbers ?
what would you type on the console to check that 4 was between 3 and 5 ?
what would you type to check that 0 was (or wasnt) between 3 and 5 ?

It seems that rather than reply to me, you are reposting the verbatim homework...
I don't know other way to describe it and this was not copy of my homework, i was describing with my own words what i need to do 