[R] Extending a vector

Mark O. Kimball mok2 at physics.buffalo.edu
Sat Apr 3 01:03:55 CEST 2004


On Friday 02 April 2004 04:52 pm, you wrote:

>> I believe this should be an easy thing to do...
>>
>> I have a function I repeatably call which takes input parameters and
>> outputs columns to various data frames. I also wish to keep a summary
>> of
>> certain values as I call the function. I though keeping the values in
>> a
>> vector then appending the vector by the new amounts would be the way
>> to
>> do this.
>>
>> Example: (this is what I want even thought the below syntax is wrong)
>>
>> a <- 1
>> print(a) --> 1
>>
>> a <- c(a,2)
>> print(a) --> 1,2
>>
>> a <- c(a,2,4,5)
>> print(a) --> 1,2,2,4,5
>>
>> Any help would be greatly appreciated...

>
> Looks fine to me. Why do you think the syntax is incorrect? Works for
> me in
> 1.8 on Windows.
>
> > a <- 1
> > a
>
> [1] 1
>
> > a <- c(a,2)
> > a
>
> [1] 1 2
>
> > a <- c(a,2,4,5)
> > a
>
> [1] 1 2 2 4 5
>
>
> steve

Entirely my fault... I forgot about the function scope rules and needed
to use:

        vector <<- stuff to add 

instead of: 

        vector <- stuff to add

Thanks for the help...

Marko
-- 
Mark O. Kimball
Gasparinilab, University of Buffalo  |  Low temp physics
mok2 at physics.buffalo.edu  |  URL: enthalpy.physics.buffalo.edu
lab phone: 716-645-2017x122  Fax: 716-645-2507




More information about the R-help mailing list