What's the most pain-free way to fit logistic growth curves in R? This isn't as easy to Google as some other things as, to be clear, I'm not talking about logistic regression in the sense of using regression to predict categorical variables.
I'm talking about fitting a logistic growth curve to given data points. To be specific, $x$ is a given year from 1958 to 2012 and $y$ is the estimated global CO2 ppm (parts per million of carbon dioxide) in November of year $x$.
Right now it's accelerating but it's got to level off at some point. So I want a logistic curve.
I haven't found a relatively straightforward way to do this yet.
 A: See the nls() function. It has a self starting logistic curve model function via SSlogis(). E.g. from the ?nls help page
DNase1 <- subset(DNase, Run == 1)
      
## using a selfStart model
fm1DNase1 <- nls(density ~ SSlogis(log(conc), Asym, xmid, scal), 
                  DNase1)

I suggest you read the help pages for these functions and probably the linked references if possible to find out more.
A: I had the same question a little while ago. This is what I found:
Fox and Weisberg wrote a great supplemental article using the nls function (both with and without the self-starting option mentioned by Gavin). It can be found here.
From that article, I ended up writing a function for my class to use when fitting a logistic curve to their data:
### Log fit - be sure to use quotes around the variable names in 
### the call
log.fit <- function(dep, ind, yourdata){
#Self-starting ...

y <- yourdata[, dep]
x <- yourdata[, ind]

log.ss <- nls(y ~ SSlogis(x, phi1, phi2, phi3))

#C
C <- summary(log.ss)$coef[1]
#a
A <- exp((summary(log.ss)$coef[2]) * (1/summary(log.ss)$coef[3]))
#k
K <- (1 / summary(log.ss)$coef[3])

plot(y ~ x, main = "Logistic Function", xlab=ind, ylab=dep)
lines(0:max(x), predict(log.ss, data.frame(x=0:max(x))), col="red")

r1 <- sum((x - mean(x))^2)
r2 <- sum(residuals(log.ss)^2)

r_sq <- (r1 - r2) / r1

out <- data.frame(cbind(c(C=C, a=A, k=K, R.value=sqrt(r_sq))))
names(out)[1] <- "Logistic Curve"

return(out)
}

