Skip to content

Latest commit

 

History

History
145 lines (113 loc) · 5.23 KB

stache.org

File metadata and controls

145 lines (113 loc) · 5.23 KB

Collective efficacy

Helped a neighbor

code

nR <- nrow(df)
HelpedNeighbor <- df[,'HelpedNeighbor']

HelpedNeighbor_data <- rep(-1,nR)

HelpedNeighbor_data[is.na(HelpedNeighbor)] <- NA
HelpedNeighbor_data[as.numeric(HelpedNeighbor)==1] <-NA
HelpedNeighbor_data[as.numeric(HelpedNeighbor)==2] <-2
HelpedNeighbor_data[as.numeric(HelpedNeighbor)==3] <- 3
HelpedNeighbor_data[as.numeric(HelpedNeighbor)==4] <- 4

HelpedNeighbor_data[as.numeric(HelpedNeighbor)==5] <- NA
HelpedNeighbor_data[as.numeric(HelpedNeighbor)==6] <- NA
HelpedNeighbor_data[as.numeric(HelpedNeighbor)==7] <- NA
HelpedNeighbor_data[as.numeric(HelpedNeighbor)==8] <- 1

  HelpedNeighborf <- factor(HelpedNeighbor_data,levels = 1:4,
                         labels=c("last-wk","last-month",
                             "last-year","never"), ordered=TRUE)



HelpedNeighborTtl <- table(HelpedNeighborf)
HelpedNeighborPct <- round(100*prop.table(HelpedNeighborTtl),0)
#jpeg("resp_marginals/ctOnPol.jpg")

barplot(HelpedNeighborPct, main="Percent helped a neighbor in the last 12 months",col = "steel blue")

#dev.off()

graph

graph

Time since neighbor conflict

code

nR <- nrow(df)
lastNeighborConflictTime <- df[,'lastNeighborConflictTime']

lastNeighborConflictTime_data <- rep(-1,nR)

lastNeighborConflictTime_data[is.na(lastNeighborConflictTime)] <- NA
lastNeighborConflictTime_data[as.numeric(lastNeighborConflictTime)==1] <-NA
lastNeighborConflictTime_data[as.numeric(lastNeighborConflictTime)==2] <-3
lastNeighborConflictTime_data[as.numeric(lastNeighborConflictTime)==3] <- 2
lastNeighborConflictTime_data[as.numeric(lastNeighborConflictTime)==4] <- 1

lastNeighborConflictTime_data[as.numeric(lastNeighborConflictTime)==5] <- NA
lastNeighborConflictTime_data[as.numeric(lastNeighborConflictTime)==6] <- NA
lastNeighborConflictTime_data[as.numeric(lastNeighborConflictTime)==7] <- NA
lastNeighborConflictTime_data[as.numeric(lastNeighborConflictTime)==8] <- 4

lastNeighborConflictTimef <- factor(lastNeighborConflictTime_data,levels = 1:4,
                         labels=c("never","last-year",
                             "last-month","last-wk"), ordered=TRUE)


lastNeighborConflictTimeTtl <- table(lastNeighborConflictTimef)
lastNeighborConflictTimePct <- round(100*prop.table(lastNeighborConflictTimeTtl),0)
#jpeg("resp_marginals/ctOnPol.jpg")

barplot(lastNeighborConflictTimePct, main="Percent had a neighbor conflict in the last 12 months",col = "steel blue")

#dev.off()

graph

Grouped Efficacy

    efficacy_components <- c(
    "Helped a neighbor","Helped by a neighbor",
"Conflict with a neighbor (reversed)")

    ctdata <- matrix(c(HelpedNeighborPct,
                     HelpedByNeighborPct,
                     lastNeighborConflictTimePct),byrow=TRUE,nrow=3)
    colnames(ctdata)<-names(HelpedNeighborPct)
    row.names(ctdata)<-efficacy_components
    #pdf("grouped_scenario/civilTrust.pdf")
    #jpeg("grouped_scenario/civilTrust.jpg")
    city_col <- c("darkblue",
                    "steelblue",
                    "red")


  ctdataPct <- round(100*prop.table(as.table(ctdata),1),0)
    barplot(ctdataPct,
            main=paste("Construct of efficacy"),
            col=city_col,
            beside = TRUE)
    legend(x="top",legend = efficacy_components, fill = city_col,cex = 1.0)

    #dev.off()