TMOTTM
TMOTTM

Reputation: 3381

Why is my R filename NULL and not what I define it to be?

In this example:

nsims = c(10, 100, 500, 1000)
nsim = 1000
l    = 0.2

for(steps in nsims)
{   
    means <- data.frame(v=1000)

    for(i in 1:nsim)
    {   
        means[i, 1] <- mean(  rexp(40, l)  )
    }

    fn <- cat( "./means-", str_pad(steps, 4, pad="0"), ".png", "\n", sep="")

    print(fn)
}

The output for fn ends up being NULL.

Whats the problem about that? I mean I clearly define fn to have a character value.

Upvotes: 0

Views: 80

Answers (1)

Scott C Wilson
Scott C Wilson

Reputation: 20016

The R cat function outputs the value. It doesn't assign it. Instead, use paste.

Upvotes: 2

Related Questions