Length of vector x

Length of vector x

by Mahnoor Hamid -
Number of replies: 3

Hi,

I am having trouble with setting the length of the vector x to equal n. I tried x <- vector(length=n) and x -> length(x) but I am getting an error saying object 'n' not found. How can I troubleshoot this?


Thanks

In reply to Mahnoor Hamid

Re: Length of vector x

by Erik Spence -
Why are you trying to set the length of the vector? The length of the vector is whatever it happens to be, it's not something you specify.
In reply to Erik Spence

Re: Length of vector x

by Mahnoor Hamid -
I was trying to define n because I kept getting the error about object 'n' not found. Now when I am using length(x) <- n, I do get an output but it is not a number (I've gotten NaN, NA, or Inf). How can I fix that?
In reply to Mahnoor Hamid

Re: Length of vector x

by Erik Spence -
If n is the length of x, why are you defining the length of x to be n? You're doing it backwards.