How to replace vector occurring numbers? [closed] - r

Closed. This question does not meet Stack Overflow guidelines. It is not currently accepting answers.
Questions asking for code must demonstrate a minimal understanding of the problem being solved. Include attempted solutions, why they didn't work, and the expected results. See also: Stack Overflow question checklist
Closed 9 years ago.
Improve this question
Let's say I have a vector of 10 elements called numbers in R
numbers <- c(0,1,1,1,0,0,1,0,1,0)
and I want to replace each occurrence of 1 to 5?

this should work
v[v==1]<-5

Related

Integral Coefficients [closed]

Closed. This question does not meet Stack Overflow guidelines. It is not currently accepting answers.
This question does not appear to be about programming within the scope defined in the help center.
Closed 11 months ago.
Improve this question
I am reviewing a proof at the moment and there is terminology that I do not understand. What does it mean for a polynomial to have "integral coefficients"?
"Integral coefficients" means that the coefficients of your final answer will be integers, unless there is a markedly different context in which the question is being asked.
You can have a look at the definition here.

Hex - how many in the series 000 through to FFF? [closed]

Closed. This question does not meet Stack Overflow guidelines. It is not currently accepting answers.
This question appears to be off-topic because it lacks sufficient information to diagnose the problem. Describe your problem in more detail or include a minimal example in the question itself.
Closed 9 years ago.
Improve this question
I am trying to find out how many combinations are possible for 000 through to FFF under hex format? thanks
There are 16 choices for each of the 3 digits, so:
16*16*16 = 4096

Find maximum of two variables in R [closed]

Closed. This question does not meet Stack Overflow guidelines. It is not currently accepting answers.
Questions asking for code must demonstrate a minimal understanding of the problem being solved. Include attempted solutions, why they didn't work, and the expected results. See also: Stack Overflow question checklist
Closed 9 years ago.
Improve this question
I have this R code, and i want to assign to the Max Variable the maximum value of A and B
, would be something like :
Max<-(A,B)
How can i do it in R?
I searched but i couldn't find a max function.
Thanks
The function is literally max:
Max <- max(A, B)

R - count number of list components [closed]

Closed. This question does not meet Stack Overflow guidelines. It is not currently accepting answers.
Questions asking for code must demonstrate a minimal understanding of the problem being solved. Include attempted solutions, why they didn't work, and the expected results. See also: Stack Overflow question checklist
Closed 9 years ago.
Improve this question
I know that in R, you can index through a list with double brackets, i.e. mylist[[1]]. How do you count the number of elements in that list (not the number of elements in each list item, but the maximum n in mylist[[n]])? I tried NROW, NCOL, dim, among others.
Some example code for the desired behavior of some function num.items(list):
require(testthat)
mylist <- list(array(rnorm(4),dim=c(2,2)),array(rnorm(4),dim=c(2,2)))
expect_that( num.items(mylist), equals(2) )
length?
> length(mylist)
[1] 2

How to compute N number of Pi [closed]

Closed. This question does not meet Stack Overflow guidelines. It is not currently accepting answers.
Questions asking for code must demonstrate a minimal understanding of the problem being solved. Include attempted solutions, why they didn't work, and the expected results. See also: Stack Overflow question checklist
Closed 8 years ago.
Improve this question
I have found this formula for computing Pi value:
But I need to compute only(for example - 1000th) number of Pi value. How I can do it with provided formula?
Thanks.
What you want is called a "spigot algorithm". Take a look at [1] in the section "BBP digit-extraction algorithm for pi". Good luck and have fun.
[1] http://en.wikipedia.org/wiki/Bailey%E2%80%93Borwein%E2%80%93Plouffe_formula

Resources