[R] with and evaluation

Jeff Newmiller jdnewmil at dcn.davis.ca.us
Fri Sep 9 04:17:39 CEST 2016


You don't say where any of this code you are looking at came from, but I suspect [1]. If you feel the author of that site is failing to explain their answers sufficiently, please communicate that to them, not us. 

I agree that the documentation file for with() is rather opaque to a beginner and could be extended, but the jargon is referring to some valuable concepts that you should find a way to learn about (e.g. [2]). 

As Duncan pointed out,  most of your diatribe was destroyed by your use of HTML format email, so if you can fix that problem and pose your questions calmly and with complete context in the email then someone might be interested in discussing them further with you. 

[1] http://r-exercises.com/
[2] http://r-adv.had.co.nz
-- 
Sent from my phone. Please excuse my brevity.

On September 8, 2016 4:07:54 PM PDT, Duncan Murdoch <murdoch.duncan at gmail.com> wrote:
>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
>
>______________________________________________
>R-help at r-project.org mailing list -- To UNSUBSCRIBE and more, see
>https://stat.ethz.ch/mailman/listinfo/r-help
>PLEASE do read the posting guide
>http://www.R-project.org/posting-guide.html
>and provide commented, minimal, self-contained, reproducible code.



More information about the R-help mailing list