Skip to content
Prev 343542 / 398506 Next

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

You are being bitten by the "partial matching" of the "$" operator
(see  ?"$" for a better explanation).  Here is solution that works:


**original**
+                     .Names = c("age","samplem"), row.names = c(NA,
-9L), class = "data.frame")
age samplem sample
1  67      NA      1
2  62       1      1
3  74       1      1
4  61       1      1
5  60       1      1
6  55       1      1
7  60       1      1
8  59       1      1
9  58      NA     NA
+                     .Names = c("age","samplem"), row.names = c(NA,
-9L), class = "data.frame")
age samplem sample
1  67      NA      1
2  62       1     NA
3  74       1      1
4  61       1     NA
5  60       1     NA
6  55       1     NA
7  60       1     NA
8  59       1     NA
9  58      NA     NA

Jim Holtman
Data Munger Guru

What is the problem that you are trying to solve?
Tell me what you want to do, not how you want to do it.


On Fri, Aug 29, 2014 at 4:53 AM, Angel Rodriguez
<angel.rodriguez at matiainstituto.net> wrote: