environment - What is the difference between with and within in R? -


I use "with" instead of "always" in the context of my research, but basically I thought That they were similar. Just now I am typing "wrong" to "inside" and returning results are quite different. I am wondering why?

I am using baseball data in the plyr package, so I first need the library

  (plyr)   

Again, I want to select all the rows from an ID " ansonca01 " First of all, as I said, I have used " within ", and have run the function as follows:

 Within  (baseball, Baseball [id == "ansonca01"]   

I found very strange results, which basically include everything:

  id year work Team LG G Now BH X2B X3B HR RBI SB CS Bbi Ebb Hbp sh sf gidp 4 ansonca01 1871 1 RC1 25 120 29 39 11 3 0 16 6 2 2 1 NA NA NA NA NA 44 Compulsory 0101 1871 1 WS3 32 162 45 45 9 4 0 29 8 0 NA NA NA NA NA NA 68 MA Thebo01 1871 1 FW1998 15 24 3 1 0 10 2 1 2 NA NA NA 99 Stellowsi 1871 1 NY 2 33 161 35 58 5 1 1 34 4 2 3 NA NA NA NA 102 SUT OEZ 1871 1 Cl 1 29 128 35 45 3 7 3 23 3 1 1 0 NA NA NA NA 106 Whitade 01 1871 1 CL1 29 146 40 47 6 5 1 21 2 2 4 1 NA NA NA NA 113 yorkto01 1871 1 TRO 29 145 36 37 5 7 2 23 2 2 9 1 NA NA NA NA .........   

Then instead of " " instead of " < / ", with

  (baseball, baseball [id ==" ansonka 01 ",])   

and resumed TS which I expected

  ID team of the year, LGG now bh x2b x 3b hr rbi sb cs bbi so ebb hbp sh gipp 4 esconsa 01 1871 1 rc 1 25 120 2 9 39 11 3 16 16 2 2 1 NA NA NA NA 121 121 NSNACCA 1972 1 PH1 461 217 60 90 10 7 0 50 6 6 16 3 NA NA NA 276 Asananka 01 1873 1 PH 1 52 254 53 101 9 2 0 36 0 2 5 1 NA NA NA NA NA 398 ansonca01 1874 1 PH1 55 25 9 51 87 8 3 0 37 6 4 4 NA NA NA NA NA 525 ansonca01 1875 1 PH1 69 326 84 106 15 3 58 58 6 6 2 2 NA NA NA NA NA  / former> 

I have a support (s) By examining and analyzing the inner documents, and receiving the following:

with a generic function that evaluates the expression in the local environment created with the data in the form of parents in the environment In the atmosphere of the collar. It is useful for simplifying the call for modeling work. (Note: If the data is already an environment then it is used with its existing parent.)

Note that the expression Within, the work should take place in the construction work and not in the user's jurisdiction.

is similar within, except that it examines the environment after evaluation of the expression and makes related modifications to the data (this data may fail in the case of the case if the data frames that are created Can not be stored in), and gives it back to be used as an option for change inside.

With this explanation of the differences, I did not find why I got different results with such a simple operation. Anyone have ideas?

is quite clear about words and return values ​​(and well matches everyday meanings With the word "????" and "virtual"):

value:

for ???? with â ????, the value of the evaluation ???? expr one ???? Since nothing has been amended in your code, therefore inside a code, modified object. Returns, it returns expr .

Here is an example where expr modifies the object object:

  & gt; Head (speed ([car, speed] [20] & lt; - 1))   
  Distribute speed 1 1 2 2 1 10 3 1 4 4 7 22 5 1 16 6 1 10    

Comments

Popular posts from this blog

c - Mpirun hangs when mpi send and recieve is put in a loop -

python - Apply coupon to a customer's subscription based on non-stripe related actions on the site -

java - Unable to get JDBC connection in Spring application to MySQL -