[R] coercion of LHS to a list
Diego Kuonen
Diego at kuonen.com
Tue Nov 7 18:07:41 CET 2000
Pete Phillips wrote:
> If I try to create a new column at the R command line, as follows:
>
> nebdata$logconc<-nebdata$Volt*nebcal.fm$coefficients[2]+nebcal.fm$coefficients[1]
why not simply take the following:
nebdata <- data.frame(nebdata,
logconc = nebdata$Volt*nebcal.fm$coefficients[2]
+nebcal.fm$coefficients[1])
> Also, is it possible for me to reference a single figure in the data
> frame eg: the intersect of Volt and ABal (0.4208) without having to
> resort to this:
> nebdata[1:1, c(2)]
you can think of a data frame to be like a matrix, i.e. if u want to
access the element in the i-th line and j-th column, you simply take
nebdata[i, j]
for instance in your case
nebdata[1, 2]
or
nebdata[nebdata$Volt=="ABal", 2]
or by attaching the data frame
attach(nebdata)
nebdata[Volt=="ABal", 2]
detach(nebdata)
Greets
Diego
--
Diego Kuonen http://wap.kuonen.com http://stat.kuonen.com
http://www.Statoo.ch Kya aap statooed hai? http://www.Statoo.com
-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-
r-help mailing list -- Read http://www.ci.tuwien.ac.at/~hornik/R/R-FAQ.html
Send "info", "help", or "[un]subscribe"
(in the "body", not the subject !) To: r-help-request at stat.math.ethz.ch
_._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._
More information about the R-help
mailing list