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 3 years ago.
Improve this question
How to get module of a vector like: V = (5, 3).
I want the return value to be positive.
And if the vector is 3d? like: V2 = (5,4,3). What's the formula to get it?
you can get the value that way: (it will be always positive)
Value = square root (first element^2 + second element^2 ,... )
Related
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 1 year ago.
Improve this question
I tried using recursive tree method.
and got a geometric series.
That follows :
kn^2(1+ (3/2) +(3/2)^2 +...+(3/2)^b)
The sum = a(r^m -1)/r-1.
b = log n.
Then what to do I got confused.
Have you heard of the Master's Theorem? Your example is a relatively simple subcase (no logarithms). The result is:
T = Theta(n^2)
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 1 year ago.
Improve this question
In the first line, there is ^ notation between (epsilon*d/2^r) and (t = r).
What does ^ mean?
The "^" symbol in this context means "and" (which may be known as && in C++ or C#).
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 8 years ago.
Improve this question
I have a matrix
B = matrix(c(1,2,4,1,4,2,1,3.5,4.2,2,2.2,6.5,3,1.2,7.7,1,2.1,1.6,3,5.2,8.2),
nrow = 7)
with 3 columns: the color column (colors from 1-5, representing blue,red,green,yellow,black), the x column and the y column.
I want to plot every points (x,y) with the color from the color column.
First question: what software is best to do so?
Second question: how can I do it with R?
Simple question finds simple answer:
plot(B[,2], B[,3], col=c("blue","red","green","yellow","black")[B[,1]])
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)
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