COSTDataExpo2013 / DaSilvaAlvarez

This repository contains supplementary material for the paper "Clicks and Cliques. Exploring the Soul of the Community" to enable the reader to reproduce the analysis.
1 stars 0 forks source link

Code style #4

Open hadley opened 9 years ago

hadley commented 9 years ago

A bit of whitespace and indenting makes code like this easier to read:

soul <- mutate(soul,QD1gr=cut(QD1, breaks=c(0,30,40,50,60,70,80,99), include.lowest=T),
               QD2gr=cut(QD2, breaks=c(0,10,20,50  ,99), include.lowest=T),prop.res =QD2/QD1,
               prop.gr=cut(prop.res, breaks=c(0,0.25,0.5,1,5.5),include.lowest=T))

# vs

soul <- mutate(soul,
  QD1gr = cut(QD1, breaks = c(0, 30, 40, 50, 60, 70, 80, 99), include.lowest = T),
  QD2gr = cut(QD2, breaks = c(0, 10, 20, 50, 99), include.lowest = T),
  prop.res = QD2 / QD1,
  prop.gr = cut(prop.res, breaks = c(0, 0.25, 0.5, 1 , 5.5), include.lowest = T)
)
hadley commented 9 years ago

Adopting a consistent code style makes it much easier to scan the doc. This block jumped out at me because of the indented pieces, but I don't think the indentation actually means anything.

aux <- read.csv("incomePC.csv", header=T)
aux <- subset(aux, X=='Estimate')
aux[,4] <- as.numeric(as.character(aux[,4]))
  aux1 <- subset(aux,select=-c(1,3),subset=!community%in%c('Gary','Philadelphia'))
  aux2 <- apply(subset(aux,community=='Gary',select=-c(1,2,3)),2,mean)
  aux2 <- data.frame(community='Gary',t(aux2))