Skip to content
Prev 363956 / 398500 Next

understanding with

Like others on the list I have no interest in wading through your
block of HTML-mangled text.

But if your question is clearly stated by the subject line, then it's
quite straightforward.

with() saves you typing and often increases code clarity by telling R
where to look for named variables

# This example is best done in a clean R session

# Given some R objects

myLongDataframeName <- data.frame(x = runif(10), y = runif(10))

x <- 1:10
y <- 1:10

cor(myLongDataframeName$x, myLongDataframeName$y) # uses the data
frame columns named x and y
cor(x, y) # uses the R objects named x and y

# Here's the magic of with():

with(myLongDataframeName, cor(x, y)) # uses the data frame columns named x and y


On Fri, Sep 9, 2016 at 12:46 AM, Carl Sutton via R-help
<r-help at r-project.org> wrote: