[R] abbreviate function using 'with'

e-letter inpost at gmail.com
Thu Feb 13 23:53:01 CET 2014


On 13/02/2014, Rolf Turner <r.turner at auckland.ac.nz> wrote:
>
> What you've written is simply not (anything like!) R syntax.  You should
> learn to speak R if you are going to use R.
>

Agree; was reviewing the help text examples invoked by '?with'.

> In this particular instance
>
> 	testsum <- sum(testcsv[2,2:4])
>
> should give what you want.   The use of with() is uncalled for in this
> context.  The with() function allows you to refer to (e.g.) columns of
> a data frame by name, as if these columns were objects in your workspace
> ("global environment").  That is *not* what you are doing, or need to do
> here.
>

Forgive the example. The objective is to use the function 'with' to
refer to specific indices of a dataframe. In retrospect, the example
given was poor because actually, I want to understand the syntax to
specify particular indices within a single dataframe, without having
to state the dataframe repeatedly.

>
> P. S.:  Please read fortune("people who don't exist") and change your
> modus operandi.
>

Never heard of fortune, but understand the latin:
http://www.michaeleisen.org/blog/?p=1554




More information about the R-help mailing list