From lachmann at eva.mpg.de  Thu Aug  5 23:35:53 2010
From: lachmann at eva.mpg.de (Michael Lachmann)
Date: Thu, 5 Aug 2010 14:35:53 -0700 (PDT)
Subject: [Rd] Assignment of individual values to data frame columns:
 intentional or unintentional behavior?
In-Reply-To: <4C5AFFA3.7050800@bht-berlin.de>
References: <4C5AE5A9.9060905@bht-berlin.de>
	<AANLkTimEyxOM-tevXE1FVDfYScqT-z3dNX9TEc8xez7P@mail.gmail.com>
	<4C5AFFA3.7050800@bht-berlin.de>
Message-ID: <1281044153678-2315641.post@n4.nabble.com>



Ulrike Gr?mping wrote:
> 
> 
> However, given the documentation that partial matching is not used on 
> the left-hand side, I would have expected even more that the assignment
> 
> sw$Fert[1] <- 10
> 
> works differently, because I am using it on the left-hand side. 
> Probably, extraction ([1]) is done first here, so that the right-hand 
> side won. At least, this is very confusing.
> 
> 

I totally agree! I think that 
sw <- data.frame(Fertility=1:5)
sw$Fert[1] <- 10

should work either like

sw$Fert2[1] <- 10

i.e. create new column, containing just 10.
or like

sw$Fertility[1] <- 10

i.e. replace the 1st item in sw$Fertility by 10.

-- 
View this message in context: http://r.789695.n4.nabble.com/Assignment-of-individual-values-to-data-frame-columns-intentional-or-unintentional-behavior-tp2315105p2315641.html
Sent from the R devel mailing list archive at Nabble.com.



[Rd] Assignment of individual values to data frame columns: intentional or unintentional behavior?
Michael Lachmann