[R] "With" question

Jeff Newmiller jdnewmil at dcn.davis.CA.us
Wed Sep 18 00:22:09 CEST 2013


You seem to be applying the syntax for the within function to the with function. You should compare the documentation for them and choose your approach accordingly.
Also once inside a code block of any type, simply typing a variable name no longer prints it, so you need to use the appropriate function (print or cat).
---------------------------------------------------------------------------
Jeff Newmiller                        The     .....       .....  Go Live...
DCN:<jdnewmil at dcn.davis.ca.us>        Basics: ##.#.       ##.#.  Live Go...
                                      Live:   OO#.. Dead: OO#..  Playing
Research Engineer (Solar/Batteries            O.O#.       #.O#.  with
/Software/Embedded Controllers)               .OO#.       .OO#.  rocks...1k
--------------------------------------------------------------------------- 
Sent from my phone. Please excuse my brevity.

David Arnold <dwarnold45 at suddenlink.net> wrote:
>All,
>
>Trying to avoid using attach and detach while teaching class in Intro
>Stats.
>
>data=read.delim("dataset1.dat",header=TRUE)
>with(data,{
>  sort(age)
>  length(age)
>  (age[10]+age[11])/2
>})
>
>However, this code only produces output for the last line between the
>curly
>braces. Granted, as we type the lines in one at a time and execute the
>code,
>we'll see each output. And, we can fix the problem by adding a print to
>each
>line.
>
>Wonder if there are any other suggestions?
>
>David
>
>
>
>--
>View this message in context:
>http://r.789695.n4.nabble.com/With-question-tp4676379.html
>Sent from the R help mailing list archive at Nabble.com.
>
>______________________________________________
>R-help at r-project.org mailing list
>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