IRD,
It would certainly be more helpful to us if you showed more of your code or
what the dataset IWJR.missing is. Here's a couple of suggestions though.
I can see what you are doing is picking a random sample of this dataset.
Is the IWJR.missing object a data frame or a vector or what? Typically you
use length with vectors and nrow with data frames. Also if you have a
vector then the appropriate line for this is,
IWJR.missing[sample(1:length(IWJR.missing),1)]
Since vectors have no columns. Remember that in data frames and matrices
you can refer to a data point by its row and column number [ row , column ]
, but you don't have columns in vector objects so you would refer to a data
point by it's location in the vector [ location ]
You can check this with is.vector or is.data.frame if you're not sure.
Also, generally this error can occur if R thinks you are referring to a data
point that is outside the range of your data. For example in a data frame
of 100 rows, R would give this error if you asked for the 101 st row. Check
to make sure that you're aren't select something outside your dataset.
Still my first guess is that you have mistaken what the object IWJR.missing
is. Try looking at that first.
Adrienne Wootten
NCSU
On Mon, Oct 18, 2010 at 12:35 AM, IRD <ird_ubru@hotmail.com> wrote:
>
> Dear All
> I have problem with this:
>
> > IWJR.temp <-IWJR.missing[sample(1:length(IWJR.missing),1),]
> Error: subscript out of bounds
>
> How I can solved this.
> Thanks
> IRD
>
> ______________________________________________
> R-help@r-project.org mailing list
> https://stat.ethz.ch/mailman/listinfo/r-help
> PLEASE do read the posting guide
> http://www.R-project.org/posting-guide.html
> and provide commented, minimal, self-contained, reproducible code.
>
[[alternative HTML version deleted]]