[R] (no subject)

Daniel Nordlund djnordlund at frontier.com
Mon Mar 14 19:43:38 CET 2011


> -----Original Message-----
> From: r-help-bounces at r-project.org [mailto:r-help-bounces at r-project.org]
> On Behalf Of Andreas Emanuelsson
> Sent: Monday, March 14, 2011 9:25 AM
> To: r-help at r-project.org
> Subject: [R] (no subject)
> 
> Hi everyone, I have problems with a double for loop and the program
> response: "Error in 1:mass[j] : NA/NaN argument"
> 
> I'm trying to create a very simple script to generate a vector full of
> objects with the value [fuel] and in the amount [mass] for a hist plot.
> 
> H=1
> for (j in 1:63)
>                              {for (i in 1:mass[j])
>                                                           {
> H[length(H)+1]=fuel[j]}
>                              }
> 
> What does the error mean?(where do I find explanations for such issues?
> 
>  Why does not a simple for loop work?
> 
> Error in 1:mass[j] : NA/NaN argument
> 
> Thank you very much for your time if you can help me!
> 
> /Andreas
> 
> 

You haven't provided a reproducible example, so we can't be sure exactly what is going wrong.  However, I might hazard a guess that for some value of j, mass[j] does not exist.  What is the length of the vector mass?  Are there any NA in mass?

Dan

Daniel Nordlund
Bothell, WA USA



More information about the R-help mailing list