R code_function with ()

3

What does this line of code mean?

with(epilepsy,by(seizures/timeadj,list(treat,expind),mean)) 

The data is from the faraway package.

    
asked by anonymous 24.05.2017 / 19:03

1 answer

4

The with function is a convenience function that allows you to access the data.frame columns without having to repeat the data.frame name at all times.

The code:

with(epilepsy, by(seizures/timeadj, list(treat,expind), mean))

It's the same as:

by(epilepsy$seizures/epilepsy$timeadj, list(epilepsy$treat, epilepsy$expind), mean)

Note that without with you need to repeat the name of data.frame epilepsy every time you reference your columns.

    
24.05.2017 / 19:33