Sergey V.
Sergey V.

Reputation: 1028

Get the specific value of default nonatomic parameter

I need to use the function capwords() from SGP in the way to get approach to use the value of default parameter special.words extended with my additional words. I.e. I need to do somthing like:

capwords("What do you think about chat GPT version IV", c(formals(capwords)$special.words,"GPT"))

But instead

"What Do You Think About Chat GPT Version IV"

I've got "Iv" instead of "IV"

"What Do You Think About Chat GPT Version Iv"

But "IV" is the part of special.words list.

And this because of class(formals(capwords)$special.words) is "call".

But how to get the specific value of special.words as the list but not the call?

I can do that by using eval():

> capwords("What do you think about chat GPT version IV", c(eval(formals(capwords)$special.words),"GPT"))

[1] "What Do You Think About Chat GPT Version IV"

But I don't want.

This is not only about capwords() function but in general there are the same behaviour for any function with default parameter.

So, are there other ways to do so except eval()?

Upvotes: 0

Views: 30

Answers (0)

Related Questions