Re: data =

Duncan Murdoch <[email protected]>
Newsgroups gmane.comp.lang.r.general
Message-ID <[email protected]>
On 2025-10-03 7:54 p.m., R Jerome Anderson wrote:
> I can code summary(midterm_df$hv109) and I get the summary of variable
> hv109. No problem.
> 
> Yet when I write the code:
> 
> summary(hv109, data = midterm_df)
> 
> I get this error:
> 
> Error in h(simpleError(msg, call)) : error in evaluating the argument
> 'object' in selecting a method for function 'summary': object 'hv109' not
> found
> 
> If I write the code summary('hv109', data = midterm_df), R treats hv109 as
> if it were a character variable. It is not.
> 
> Page 521 in Andrews *Doing Data Science in R* shows the data = [df]
> command. I thought it was straightforward. Why doesn't my code work?
> 
> Any help w/ this would be appreciated.

Not all functions support a `data` argument.  You can read about the 
`summary()` function using `?summary`, and none of the variations shown 
there have `data` as an argument.

For cases like this, you can use the `with()` function, e.g.

   with(midterm_df, summary(hv109))

`with()` temporarily attaches the columns of the dataframe as separate 
variables.

Duncan Murdoch
lmpx.com only provides a reader for public news (NNTP) servers. It is not affiliated with the servers or forums shown here and is not responsible for the content of articles, which is written by their respective authors.