Displaying 1 result from an estimated 1 matches for "deck1".
Did you mean:
deck
2010 Mar 16
1
Changing global variables from functions
Hey all,
I'm relatively new to the R-environment. I'm having a bit of trouble with
encapsulation.
I have a globally declared variable that doesn't update it when I change it
in a function. For example when I run the following function
>deckn<-NULL
>deck1<-1 #52 card deck
>deck<-function()
{
#Creating a standard deck
deck1<-c(1:52)
deckn<-deck1
#Creating n decks
for (i in 2:num_decks)
{
deckn<-c(deckn,52*i+deck1-1)
}
}
>deckn
>NULL
it returns NULL for deckn instead of a vector of values. Is there an easy...