Re: [R] Unexpected behavior when giving a value to a new variable based on the value of another variable

2014-09-02 Thread Angel Rodriguez
Thank you for the explanation, Peter. Angel -Mensaje original- De: peter dalgaard [mailto:pda...@gmail.com] Enviado el: lun 01/09/2014 20:10 Para: Angel Rodriguez CC: r-help Asunto: Re: [R] Unexpected behavior when giving a value to a new variable based on the value of another variable

Re: [R] Unexpected behavior when giving a value to a new variable based on the value of another variable

2014-09-01 Thread peter dalgaard
ed). > > Best regards, > > Angel Rodriguez-Laso > > > -Mensaje original- > De: John McKown [mailto:john.archie.mck...@gmail.com] > Enviado el: vie 29/08/2014 14:46 > Para: Angel Rodriguez > CC: r-help > Asunto: Re: [R] Unexpected behavior when giv

Re: [R] Unexpected behavior when giving a value to a new variable based on the value of another variable

2014-09-01 Thread Angel Rodriguez
been oversimplified). Best regards, Angel Rodriguez-Laso -Mensaje original- De: John McKown [mailto:john.archie.mck...@gmail.com] Enviado el: vie 29/08/2014 14:46 Para: Angel Rodriguez CC: r-help Asunto: Re: [R] Unexpected behavior when giving a value to a new variable based on the value of an

Re: [R] Unexpected behavior when giving a value to a new variable based on the value of another variable

2014-08-29 Thread Jeff Newmiller
One clue is the help file for "$"... ?" $" In particular there see the discussion of character indices and the "exact" argument. You can also find this discussed in the Introduction to R document that comes with the software.

Re: [R] Unexpected behavior when giving a value to a new variable based on the value of another variable

2014-08-29 Thread John McKown
On Fri, Aug 29, 2014 at 3:53 AM, Angel Rodriguez wrote: > > Dear subscribers, > > I've found that if there is a variable in the dataframe with a name very > similar to a new variable, R does not give the correct values to this latter > variable based on the values of a third value: > > > > Any

Re: [R] Unexpected behavior when giving a value to a new variable based on the value of another variable

2014-08-29 Thread jim holtman
You are being bitten by the "partial matching" of the "$" operator (see ?"$" for a better explanation). Here is solution that works: **original** > N <- structure(list(V1 = c(67, 62, 74, 61, 60, 55, 60, 59, 58), V2 = c(NA, 1, > 1, 1, 1,1,1,1,NA)), + .Names = c("age","sample

[R] Unexpected behavior when giving a value to a new variable based on the value of another variable

2014-08-29 Thread Angel Rodriguez
Dear subscribers, I've found that if there is a variable in the dataframe with a name very similar to a new variable, R does not give the correct values to this latter variable based on the values of a third value: > M <- structure(list(V1 = c(67, 62, 74, 61, 60, 55, 60, 59, 58)),.Names = >