[R] with and evaluation

Duncan Murdoch
Thu, 08 Sep 2016 23:07:54 -0000

On 08/09/2016 6:57 PM, Carl Sutton via R-help wrote:
> Hi
> I have doing the R-exercises to improve my R programming capabilities.
Data.frame exercise 4 showed me that I have  a language problem.  Here's the
problem and my "solution".
> #  Exercise 4#  Create a simple data frame from 3 vectors. Order the entire
data frame by the#  first column.df2 <- data.frame(a = 5:1,b = letters[1:5],
c = runif(5))order(df2$a) Naturally the order function did nothing.
> Per "help"Description
> order returns a permutation which rearranges its first argument into
ascending or descending order, breaking ties by further arguments. sort.list is
the same, using only one argument.See the examples for how to use these
functions to sort data frames, etc.
> Usage
> order(..., na.last = TRUE, decreasing = FALSE,      method =
c("shell", "radix"))
> sort.list(x, partial = NULL, na.last = TRUE, decreasing = FALSE,
method = c("shell", "quick", "radix"))Arguments
> ... a sequence of numeric, complex, character or logical vectors, all of
the same length, or a classed R object.
> Well, doesn't ... mean any legal object?  I gave it a legal object and
got nada.And the answer absolutely has me screaming "Say
What"df2[with(df2,order(a)),]
>
> What's with "with?  It is one function I do not use because I find
it incomprehensible.  To witEvaluate an R expression in an environment
constructed from data, possibly modifying (a copy of) the original data.
>
> First of all, if I'm not modifying data (or as a subset activity
creating data), why an I doing whatever it is I'm doing? ("possibly
modifying (a copy of) the original data.")
> Evaluate.  According to the thesarus A) assess(v), b) appraise, c) gage.
> OK, am I in a safe area?  I'll evaluate that.  Do I desire future
social contact with this person?  I'll evaluate that.In no way do I ever
evaluate an equation.  I may attempt to solve it.  I may do a computer program
to do the calculations and return a result.  I will probably evaluate the result
as to whether or not it helps solve the problem.  Think in terms of an income
tax return.  But evaluate an R expression?  No clue what that might mean.
> The remainder of the definition is also obtuse.  an R expression in an
environment constructed from data.  Why would one make an environment without
data?  Obviously I am missing the point.  My own created function makes a new
environment, but I only created it to crunch numbers.  If it doesn't crunch
numbers it's useless.
> The point is, I do not understand the definition of "with" and
thus have no idea how to use it.  I guess computerese is analogous to taxlawese.
Familiar words have entirely different meanings.
> Carl Sutton CPA
>
> 	[[alternative HTML version deleted]]

This is really hard to read, because you posted in HTML.  If you don't
get a useful answer, please try again in plain text.

Duncan Murdoch