[R] Cannot calculate mean() for double vector
jasonkrupert at yahoo.com
Fri Oct 16 19:35:38 CEST 2009
Have you tried:
What is the result of the following:
Abit hard since you don't provide the data, but there may be an NA or character value that is causing the error.
Hope this helps at a bit.
--- On Fri, 10/16/09, Reuben Bellika <rubenyi at gmail.com> wrote:
> From: Reuben Bellika <rubenyi at gmail.com>
> Subject: [R] Cannot calculate mean() for double vector
> To: r-help at r-project.org
> Date: Friday, October 16, 2009, 12:06 PM
> I've been using R recently to analyze
> some data, but I'm having a
> problem using the mean() function.
> I imported the original data set as a vector of integers, x
> and then
> calculated a exponential moving average of the data, x_ema.
> This part
> worked fine.
> Then, I tried to find the mean squared error between the
> series and the moving average, using mse = mean((x -
> x_ema)^2). This
> gives N/A as a result, which seems to be the result of the
> function. When I run mean() on x_ema, which is of data type
> double, it
> always returns N/A. I can find the mean of the original
> integer data
> just fine, as well as for a simple test vector of 10
> doubles, but it
> never seems to return a usable result for the x_ema vector.
> Is this
> because the vector is too long? (Both x and x_ema contain
> around 40000
> values). Am I running into some memory limit? I can do
> calculations with x_ema just fine, it's only the mean()
> function that
> doesn't seem to work. All the information in the help seems
> indicate that this operation should work without a
> If it matters at all, I'm using R 2.9.2 running on Windows
> I'd appreciate any help or suggestions as to what might be
> Thank you,
> Reuben Bellika
> R-help at r-project.org
> mailing list
> PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
> and provide commented, minimal, self-contained,
> reproducible code.
More information about the R-help