R: Ggvis - add_tooltip for bar chart - r
i'm having troubles using the add_tooltip from ggvis.
I just want to put a tool tip for the sessions by source to my plot.
I'm having troubles understanding the html function that needs to be created for add_tooltip()
I understand i need an "ID" within my data (you can see my data at the bottom). Please, may someone explane this part. I don't understand how ggvis uses the ID for the plot.
Visitas_Por_Fuente$id <- 1:nrow(Visitas_Por_Fuente) #Create the ID column.
Visitas_Por_Fuente %>%
ggvis(~Fuentes, ~sessions) %>%
layer_bars(width = 0.8, fill = ~Fuentes) %>%
add_tooltip(mysessions ,"hover")
mysessions <- function(x) {
if(is.null(x)) return(NULL)
#notice below the id column is how ggvis can understand which session to show
row <- Visitas_Por_Fuente[Visitas_Por_Fuente$id == x$id, ]
#prettyNum shows the number with thousand-comma separator
paste0("Sessions:", " ",prettyNum(row$sessions, big.mark=",",scientific=F))
}
The graph is shown, but when hovering says:
Warning: Unhandled error in observer: non-character argument
observe({
value <- session$input[[id]]
if (is.null(value))
return()
if (!is.list(value$data))
return()
df <- value$data
class(df) <- "data.frame"
attr(df, "row.names") <- .set_row_names(1L)
fun(data = df, location = list(x = value$pagex, y = value$pagey),
session = session)
})
My data:
structure(list(Fuentes = structure(c(3L, 5L, 6L, 6L, 4L, 5L,
5L, 5L, 5L, 7L, 7L, 1L, 6L, 7L, 5L, 5L, 4L, 5L, 5L, 5L, 5L, 5L,
5L, 6L, 7L, 3L, 5L, 6L, 6L, 5L, 6L, 5L, 5L, 5L, 5L, 7L, 7L, 6L,
1L, 6L, 5L, 5L, 4L, 5L, 5L, 4L, 6L, 5L, 5L, 5L, 5L, 7L, 3L, 5L,
6L, 6L, 4L, 6L, 5L, 5L, 4L, 4L, 5L, 7L, 7L, 6L, 7L, 5L, 4L, 5L,
4L, 2L, 2L, 6L, 5L, 5L, 5L, 6L, 7L, 3L, 6L, 4L, 6L, 4L, 5L, 5L,
5L, 5L, 4L, 5L, 7L, 7L, 1L, 6L, 7L, 5L, 5L, 4L, 5L, 5L, 4L, 2L,
2L, 5L, 5L,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 4L, 5L, 5L, 4L, 4L, 5L, 5L, 5L, 3L, 6L, 6L, 5L, 5L,
7L, 6L, 5L, 5L, 5L, 5L, 7L, 5L, 4L, 2L, 5L, 5L, 5L, 5L, 5L, 6L,
7L, 3L, 4L, 6L, 5L, 5L, 4L, 5L, 5L, 7L, 1L, 6L, 5L, 5L, 5L, 5L,
5L, 5L, 5L, 4L, 4L, 5L, 6L, 3L, 6L, 6L, 6L, 5L, 5L, 5L, 5L, 7L,
6L, 5L, 5L, 5L, 5L, 5L, 5L, 6L, 3L, 6L, 4L, 6L, 5L, 5L, 7L, 7L,
5L, 6L, 5L, 5L, 5L, 5L), .Label = c("Adwords", "CampaƱas", "Directo",
"Email", "Referencias", "SEO", "Social Media"), class = "factor"),
sessions = c(197L, 1L, 7L, 13L, 1L, 1L, 10L, 1L, 3L, 3L,
5L, 3L, 566L, 1L, 27L, 159L, 7L, 1L, 6L, 1L, 1L, 4L, 1L,
6L, 10L, 129L, 1L, 7L, 2L, 1L, 10L, 1L, 5L, 6L, 9L, 1L, 28L,
1L, 7L, 386L, 1L, 146L, 1L, 89L, 41L, 9L, 1L, 1L, 1L, 6L,
3L, 4L, 182L, 1L, 5L, 8L, 2L, 1L, 1L, 4L, 1L, 1L, 2L, 3L,
2L, 524L, 4L, 26L, 1L, 152L, 4L, 2L, 3L, 1L, 2L, 2L, 1L,
5L, 10L, 142L, 1L, 1L, 8L, 1L, 3L, 1L, 1L, 1L, 1L, 7L, 4L,
13L, 3L, 375L, 3L, 2L, 147L, 1L, 101L, 29L, 4L, 1L, 1L, 2L,
3L, 1L, 1L, 2L, 1L, 7L, 5L, 5L, 224L, 3L, 12L, 1L, 7L, 2L,
1L, 4L, 141L, 4L, 632L, 2L, 2L, 32L, 1L, 138L, 1L, 1L, 9L,
5L, 1L, 1L, 1L, 2L, 1L, 6L, 3L, 139L, 4L, 1L, 9L, 1L, 1L,
5L, 9L, 8L, 36L, 1L, 537L, 1L, 2L, 5L, 3L, 174L, 1L, 106L,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, 1L, 68L, 1L, 1L, 4L,
2L, 1L, 2L, 1L, 1L, 241L, 1L, 1L, 4L, 9L, 37L, 1L, 1L, 66L,
1L, 1L, 7L, 5L, 4L, 2L, 1L, 2L, 197L, 47L, 39L, 19L, 1L)), .Names = c("Fuentes",
"sessions"), class = "data.frame", row.names = c(NA, -1724L))
In general, you need to give the layer a "key" to be returned when hovering or clicking it which is then used as input for the tooltip function.
A problem I see here is that you are producing a bar chart (i.e. values are summed up per "Fuente" type) but you want to use a tooltip for each single observation (row) in your data. So the problem is that in your chart you don't display each data point (observation) separated and hence it will be difficult, when hovering over a bar, to know what specific data point (observation) you want to return for the tooltip.
In order to show how it might work for layer_points with observation-specific tooltips, I adapted your code like this:
Visitas_Por_Fuente$id <- 1:nrow(Visitas_Por_Fuente) #Create the ID column.
mysessions <- function(x) {
if(is.null(x)) return(NULL)
# get the current session info, based on "id" that is hovered over:
current_session <- Visitas_Por_Fuente[Visitas_Por_Fuente$id == x$id, "sessions"]
# format the value with prettyNum if you like:
paste0("Sessions:", " ",prettyNum(current_session, big.mark=",",scientific=F))
}
Visitas_Por_Fuente %>%
ggvis(~Fuentes, ~sessions) %>%
layer_points(fill = ~Fuentes, key := ~id) %>% # define a key
add_tooltip(mysessions ,"hover")
Here's another version with tool tips for a bar chart showing the total number of sessions per "Fuente" type when hovering over a bar (this is possible because it doesn't require to know what single data point is used - instead we use "Fuente" as key):
mysessions <- function(x) {
if(is.null(x)) return(NULL)
# compute the total number of sessions of the "Fuente" type that is hovered over
total_sessions <-
sum(Visitas_Por_Fuente[Visitas_Por_Fuente$Fuentes == x$Fuentes, "sessions"])
# format the value with prettyNum if you like:
paste0("Total number of Sessions:", " ",
prettyNum(total_sessions, big.mark=",",scientific=F))
}
Visitas_Por_Fuente %>%
ggvis(~Fuentes, ~sessions) %>%
layer_bars(width = 0.8, fill = ~Fuentes, key := ~Fuentes) %>%
add_tooltip(mysessions ,"hover")
Related
Table function giving me long tabulations instead of wide in r (needed for chi-square analysis)
I'm struggling to get my dataset to work with the table function in r. I have two unique columns as factors that I am trying to tabulate into one column for student ethnicity and nine columns for the ethnicity that they drew. I can manually make this work, but I want a contingency table to work through chi-squared analysis with. I've tried everything I can think of and cannot make this work. Whenever I have used the table function, it looks like this: Predict_Table <- table(Student_Ethnicity, PreDAS_Ethnicity) I want my data to look like this (but obviously with more columns - and it has to be able to work with a chi-squared analysis): My Dataset (Predict_DAS): structure(list(Student_Ethnicity = structure(c(1L, 1L, 1L, 1L, 2L, 1L, 1L, 3L, 1L, 1L, 4L, 1L, 1L, 4L, 5L, 4L, 1L, 4L, 2L, 5L, 5L, 2L, 5L, 4L, 4L, 5L, 1L, 1L, 1L, 4L, 4L, 1L, 4L, 5L, 4L, 1L, 4L, 1L, 4L, 1L, 1L, 6L, 7L, 4L, 1L, 2L, 5L, 6L, 1L, 6L, 6L, 1L, 5L, 4L, 8L, 1L, 1L, 3L, 1L, 2L, 7L, 4L, 1L, 4L, 8L, 8L, 5L, 1L, 5L, 5L, 4L, 4L, 4L, 1L, 1L, 4L, 4L, 1L, 4L, 4L, 3L, 1L, 5L, 1L, 9L, 3L, 1L, 1L, 4L, 1L, 8L, 1L, 1L, 3L, 4L, 1L, 1L, 4L, 7L, 4L, 3L, 9L, 6L, 1L, 1L, 6L, 4L, 1L, 1L, 1L, 4L, 4L, 5L, 3L, 4L, 4L, 8L, 1L, 1L, 4L, 1L, 4L, 1L, 2L, 3L, 3L, 3L, 7L, 5L, 1L, 1L, 1L, 7L, 2L, 1L, 8L, 1L, 5L, 3L, 2L), .Label = c("White/Caucasian", "Other", "Multiple", "Black/African American", "Hispanic/Latinx", "American Indian or Alaskan Native", "No Selection", "Native Hawaiian or Pacific Islander", "Asian"), class = "factor"), PreDAS_Ethnicity = structure(c(1L, 1L, 9L, 1L, 2L, 7L, 1L, 7L, 7L, 1L, 4L, 1L, 7L, 7L, 5L, 4L, 7L, 9L, 2L, 7L, 7L, 7L, 1L, 7L, 7L, 5L, 7L, 1L, 7L, 4L, 4L, 1L, 1L, 5L, 7L, 5L, 7L, 1L, 4L, 1L, 1L, 7L, 9L, 1L, 1L, 7L, 5L, 2L, 1L, 4L, 7L, 1L, 7L, 4L, 7L, 1L, 9L, 3L, 1L, 1L, 7L, 7L, 7L, 4L, 7L, 7L, 7L, 1L, 4L, 2L, 4L, 7L, 4L, 1L, 7L, 4L, 7L, 7L, 7L, 4L, 3L, 4L, 5L, 4L, 9L, 3L, 1L, 1L, 4L, 1L, 7L, 7L, 1L, 7L, 9L, 7L, 1L, 4L, 7L, 4L, 4L, 4L, 7L, 1L, 7L, 1L, 4L, 1L, 7L, 1L, 7L, 4L, 7L, 2L, 7L, 7L, 7L, 1L, 1L, 4L, 1L, 4L, 1L, 2L, 1L, 1L, 7L, 7L, 1L, 7L, 1L, 4L, 4L, 4L, 2L, 7L, 1L, 4L, 7L, 7L), .Label = c("White/Caucasian", "Other", "Multiple", "Black/African American", "Hispanic/Latinx", "American Indian or Alaskan Native", "No Selection", "Native Hawaiian or Pacific Islander", "Asian"), class = "factor")), class = "data.frame", row.names = c(NA, -140L))
Your code would not work because R would not be able to find the variables in your data frame, e.g. Predict_Table <- table(Student_Ethnicity, PreDAS_Ethnicity) # Error in table(Student_Ethnicity, PreDAS_Ethnicity) : # object 'Student_Ethnicity' not found This does what you want, but the order of the categories is not alphabetical so you must have specified the order when you created the factors: Predict_Table <- with(Predict_DAS, table(Student_Ethnicity, PreDAS_Ethnicity))
Eliminating Predictor Variables and Comparing Classification methods to find the best model
I am currently working with a dataset with a binary response variable with 2 levels. I have approx 32 predictor variables - some factors and some numeric. I used glm and based on the p values removed some of the predictor variables that I thought were insignificant. However, when I run the deviance test I always get zero and my ROC curve is upside down - this can be corrected by putting the TPR on the x axis but I think this is incorrect. Can anyone provide any suggestions on what I could potentially be doing wrong? Thanks a million! The code below represents the categories I think are significant. They are all categorical. data_analysis <- glm(PainDiagnosis~PainLocation+Criterion2+Criterion6+Criterion8+ Criterion9+Criterion13, data=dat, family="binomial") summary(data_analysis) coef(data_analysis) anova(data_analysis, test="Chisq") resDev_glm <- residuals(fit_glm, type = "deviance") testDev_glm <- sum(resDev_glm^2) modMat_glm <- model.matrix(fit_glm) # model matrix NO_glm <- nrow(unique(modMat_glm)) # number of unique observations m_glm <- length(fit_glm$coefficients) # number of parameters nrow(dat) NO_glm testDev_glm 1 - pchisq(testDev_glm, NO_glm-m_glm) library(ROCR) predObj <- prediction(fitted(fit_glm), dat$PainDiagnosis) perf <- performance(predObj, "tpr", "fpr") plot(perf) abline(0,1, col = "darkorange2", lty = 2) # add bisect line 2L, 2L, 1L, 1L, 1L, 1L), .Label = c("Female", "Male"), class = "factor"), DurationCurrent = structure(c(5L, 4L, 5L, 6L, 2L, 3L, 6L, 6L, 6L, 2L, 3L, 6L, 2L, 4L, 1L, 4L, 3L, 2L, 4L, 6L, 6L, 6L, 6L, 4L, 6L, 6L, 3L, 5L, 3L, 3L, 4L, 5L, 6L, 6L, 2L, 3L, 5L, 4L, 6L, 5L, 4L, 5L, 6L, 6L, 5L, 6L, 3L, 6L, 4L, 6L, 2L, 4L, 2L, 6L, 3L, 2L, 5L, 3L, 3L, 6L, 2L, 5L, 4L, 6L, 2L, 1L, 4L, 6L, 6L, 2L, 6L, 3L, 4L, 4L, 3L, 2L, 3L, 3L, 3L, 5L, 6L, 5L, 2L, 6L, 5L, 6L, 5L, 5L, 4L, 3L, 5L, 6L, 6L, 3L, 3L, 3L, 3L, 6L, 4L, 5L, 2L, 3L, 5L, 4L, 4L, 4L, 6L, 6L, 2L, 6L, 4L, 3L, 6L, 6L, 6L, 6L, 6L, 6L, 6L, 6L, 6L, 6L, 6L, 6L, 6L, 6L, 6L, 6L, 6L, 6L, 6L, 6L, 6L, 5L, 6L, 6L, 6L, 6L, 6L, 6L, 6L, 6L, 6L, 6L, 6L, 6L, 6L, 6L, 6L, 6L, 6L, 6L, 6L, 6L, 4L, 5L, 3L, 6L, 6L, 6L, 6L, 6L, 6L, 6L, 6L, 6L, 6L, 6L, 5L, 6L, 5L, 6L, 4L, 4L, 4L, 1L, 5L, 1L, 6L, 2L, 1L, 2L, 6L, 6L, 5L, 4L, 3L, 6L, 2L, 2L, 2L, 1L, 6L, 6L, 6L, 2L, 6L, 3L, 6L, 6L, 2L, 6L, 1L, 3L, 3L, 5L, 3L, 1L, 2L, 3L, 6L, 6L, 6L, 6L, 6L, 6L, 6L, 6L, 1L, 6L, 5L, 6L, 6L, 6L, 1L, 2L, 2L, 5L, 6L, 2L, 6L, 6L, 6L, 4L, 6L, 3L, 2L, 6L, 6L, 6L, 6L, 1L, 1L, 2L, 6L, 6L, 6L, 3L, 6L, 6L, 3L, 4L, 6L, 6L, 1L, 3L, 6L, 4L, 2L, 6L, 4L, 6L, 6L, 2L, 3L, 6L, 3L, 2L, 2L, 6L, 3L, 6L, 6L, 5L, 1L, 3L, 1L, 4L, 4L, 6L, 6L, 1L, 6L, 1L, 4L, 6L, 6L, 6L, 6L, 6L, 6L, 5L, 6L, 3L, 6L, 6L, 3L, 6L, 6L, 5L, 6L, 6L, 5L, 6L, 5L, 6L, 6L, 3L, 6L, 6L, 6L, 4L, 6L, 6L, 6L, 6L, 6L, 3L, 5L, 6L, 5L, 4L, 6L, 6L, 6L, 6L, 5L, 4L, 5L, 6L, 2L, 2L, 4L, 6L, 6L, 4L, 6L, 4L, 6L, 4L, 6L, 6L, 3L, 4L, 2L, 3L, 5L, 6L, 2L, 6L, 2L, 3L, 2L, 2L, 4L, 2L, 5L, 4L, 4L, 5L, 6L, 3L, 5L, 3L, 1L, 6L, 6L, 4L, 2L, 4L, 4L, 6L, 6L, 5L, 1L, 6L, 2L, 6L, 2L, 1L), .Label = c("0-3 weeks", "4-6 weeks", "7-12 weeks", "4-6 months", "7-12 months", "> 1 year"
Create new conditional columns with factors using fewer scripts
I would like to know if there is a way to more elegantly rewrite this piece of script. I have tried case_when but it throws an error message when I try to have several of them within one mutate function. Here is the dput for the file structure(list(todays_date = structure(c(1L, 1L, 1L, 1L, 2L, 2L, 4L, 3L, 3L, 3L, 4L, 4L, 4L, 4L, 2L, 2L, 4L, 4L, 4L, 4L, 4L, 4L, 4L, 4L, 4L, 1L, 1L, 2L, 2L, 3L, 3L, 2L, 2L, 3L, 3L, 2L, 2L, 2L, 2L, 2L, 2L, 2L, 2L, 2L, 2L, 4L, 4L, 4L, 4L, 4L, 4L, 4L, 4L, 4L, 4L, 2L, 4L, 4L, 2L, 2L, 2L, 2L, 5L, 5L, 5L, 5L, 5L, 5L, 5L, 5L, 4L, 4L, 5L, 5L, 5L, 2L, 5L, 5L, 5L, 4L, 4L, 4L, 4L, 5L, 5L, 5L, 5L, 5L, 5L, 5L, 5L, 5L, 5L, 6L, 6L, 6L, 6L, 6L, 6L, 6L, 6L, 5L, 5L, 5L, 6L, 6L, 6L, 6L, 6L, 6L, 6L, 6L, 6L, 6L, 6L, 6L, 6L, 6L, 6L, 6L, 6L, 6L, 6L, 6L, 6L, 7L, 7L, 7L, 7L, 7L, 7L, 7L, 7L, 7L, 7L, 7L, 7L, 7L, 6L, 6L, 6L, 6L, 6L, 6L, 6L, 6L, 6L, 6L, 6L, 7L, 7L, 7L, 7L, 7L, 8L, 8L, 8L, 8L, 8L, 8L, 9L, 9L, 8L, 9L, 9L, 9L, 9L), .Label = c("04/11/2019", "05/11/2019", "06/11/2019", "07/11/2019", "08/11/2019", "12/11/2019", "13/11/2019", "14/11/2019", "15/11/2019"), class = "factor"), p_initials = structure(c(34L, 54L, 1L, 71L, 16L, 77L, NA, 55L, 56L, 122L, 20L, 53L, 116L, 48L, 36L, 14L, 44L, 55L, 89L, 96L, 105L, 83L, 92L, 98L, 38L, 5L, 70L, 47L, 10L, 10L, 107L, 67L, 70L, 24L, 25L, 32L, 65L, 24L, 124L, 87L, 75L, 80L, 26L, 31L, 112L, 40L, 45L, 117L, 10L, 23L, 11L, 69L, 7L, 8L, 6L, 79L, 81L, 46L, 108L, 13L, 3L, 61L, 82L, 65L, 90L, 102L, 101L, 59L, 93L, 70L, 74L, 29L, 62L, 78L, 67L, 13L, 64L, 119L, 22L, 43L, 10L, 38L, 50L, 104L, 3L, 2L, 125L, 13L, 88L, 4L, 96L, 106L, 84L, 109L, 17L, 74L, 10L, 91L, 63L, 89L, 7L, 120L, 12L, 38L, 95L, 27L, 9L, 86L, 42L, 99L, 70L, 110L, 103L, 74L, 111L, 72L, 85L, 68L, 76L, 73L, 70L, 21L, 77L, 37L, 8L, 66L, 70L, 123L, 94L, 61L, 115L, 25L, 120L, 67L, 119L, 19L, 71L, 21L, 34L, 57L, 42L, 57L, 100L, 18L, 30L, 19L, 105L, 113L, 39L, 60L, 15L, 33L, 95L, 121L, 52L, 97L, 102L, 5L, 58L, 81L, 114L, 119L, 28L, 3L, 7L, 51L, 35L), .Label = c("BA", "BB", "BD", "BE", "BH", "BI", "BM", "BS", "BY", "CA", "CB", "CD", "CE", "CF", "CG", "CGA", "CGG", "CI", "CK", "CL", "CM", "CO", "CP", "CS", "CT", "CZ", "DK", "DO", "DPH", "DT", "GA", "GB", "GG", "IA", "IB", "Ik", "IK", "IM", "IP", "IS", "ITF", "KA", "KB", "KBA", "KF", "KG", "KJ", "KK", "KM", "KO", "KP", "KR", "KS", "KY", "NB", "ND", "NF", "NG", "NI", "NJ", "NK", "NKD", "NL", "NM", "NR", "NRBS", "NT", "NWD", "NY", "OA", "OB", "OC", "OD", "OH", "OHD", "OI", "OJ", "OK", "OL", "OM", "OP", "OPI", "OS", "OSP", "OT", "OTL", "PR", "PS", "SA", "SG", "SH", "SJ", "SLP", "SM", "SP", "SS", "TA", "TBC", "TE", "TG", "TKP", "TM", "TMB", "TP", "TR", "TS", "WJ", "WR", "YH", "YKI", "YM", "ZA", "ZB", "ZE", "ZH", "ZK", "ZM", "ZN", "ZP", "ZS", "ZSS", "ZT", "ZTM", "ZTN", "ZZ"), class = "factor"), village = structure(c(2L, 2L, 2L, 2L, 3L, 3L, 8L, 1L, 1L, 1L, 8L, 8L, 8L, 8L, 6L, 6L, 8L, 8L, 8L, 8L, 8L, 1L, 1L, 1L, 8L, 2L, 2L, 4L, 4L, 4L, 4L, 4L, 4L, 4L, 4L, 4L, 4L, 4L, 4L, 4L, 4L, 4L, 4L, 4L, 4L, 4L, 4L, 4L, 4L, 4L, 2L, 2L, 2L, 2L, 2L, 4L, 4L, 4L, 4L, 4L, 4L, 4L, 5L, 5L, 5L, 5L, 1L, 1L, 1L, 1L, 8L, 8L, 5L, 5L, 5L, 3L, 5L, 5L, 5L, 4L, 4L, 4L, 4L, 2L, 2L, 7L, 7L, 7L, 4L, 4L, 4L, 7L, 7L, 6L, 6L, 6L, 6L, 1L, 1L, 1L, 1L, 7L, 7L, 7L, 8L, 8L, 6L, 6L, 6L, 6L, 6L, 6L, 6L, 6L, 6L, 6L, 6L, 6L, 6L, 6L, 1L, 4L, 4L, 4L, 4L, 3L, 6L, 6L, 8L, 3L, 3L, 3L, 3L, 3L, 3L, 4L, 4L, 4L, 3L, 1L, 1L, 1L, 1L, 3L, 3L, 3L, 3L, 3L, 3L, 8L, 8L, 8L, 8L, 8L, 1L, 1L, 4L, 2L, 3L, 3L, 3L, 3L, 2L, 2L, 2L, 7L, 7L), .Label = c("banembanto", "bankore", "damzoussi", "pissy", "sabsin", "tanghin", "toundou", "watenga"), class = "factor"), compound_id = c("40080", "40093", "40113", "040127", "240043", "240060", "250035", "230047", "230033", "230049", "250014", "250031", "250002", "250051", "220040", "220080", "250056", "250045", "250061", "250042", "250811", "230068", "230104", "230144", "250062", "40144", "40814", "030015", "030022", "030108", "30156", "30001", "30002", "30052", "30089", "30069", "30083", "030094", "30144", "30161", "30192", "30004", "030006", "030025", "30055", "30202", "30205", "30239", "30259", "30809", "40053", "40086", "40109", "040116", "40823", "30197", "30216", "30237", "30159", "30167", "30219", "30223", "260041", "260803", "260055", "260015", "230098", "230102", "230111", "230145", "250805", "250810", "260004", "260023", "260032", "240065", "260025", "260075", "260049", "30012", "030023", "030030", "30057", "40055", "40118", "80044", "80068", "80075", "30203", "30229", "30238", "80001", "80007", "220041", "220042", "220022", "220083", "230115", "230048", "230097", "230072", "80055", "80803", "80807", "250809", "250806", "220034", "220019", "220064", "220840", "220001", "220118", "220175", "220834", "220070", "220099", "220098", "220141", "220805", "220849", "230174", "030110", "30146", "30190", "30215", "240006", "220097", "220823", "250016", "240010", "240042", "240049", "240080", "240073", "240067", "30265", "30822", "30823", "240004", "230040", "230057", "230078", "230158", "240021", "240053", "240054", "240064", "240066", "240086", "250009", "250028", "250039", "250053", "250063", "230150", "230164", "30828", "40094", "240007", "240013", "240071", "240078", "040018", "040125", "40147", "80034", "80049"), new_compound_id = c(40080L, NA, NA, NA, NA, NA, NA, NA, 230033L, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, 30156L, NA, NA, 30052L, NA, NA, NA, NA, NA, NA, 30192L, NA, NA, NA, NA, 30202L, NA, NA, NA, NA, 40053L, NA, NA, NA, NA, 30197L, 30216L, 30237L, NA, NA, 30219L, 30223L, NA, NA, 260055L, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, 260075L, 260049L, NA, NA, NA, NA, NA, NA, NA, 80068L, NA, 30203L, 30229L, NA, NA, 80007L, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, 220840L, NA, NA, NA, NA, NA, NA, NA, NA, 220805L, NA, NA, NA, NA, 30190L, NA, NA, NA, NA, 250016L, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, 30828L, 40094L, NA, NA, NA, NA, NA, NA, NA, NA, NA), num_sleep_space = c(2L, 3L, 2L, 2L, 3L, 4L, 2L, 3L, 6L, 4L, 8L, 5L, 1L, 2L, 4L, 4L, 3L, 6L, 3L, 10L, 2L, 3L, 9L, 8L, 2L, 2L, 2L, 2L, 2L, 2L, 3L, 3L, 3L, 3L, 3L, 3L, 2L, 2L, 3L, 4L,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4L, 4L, 4L, 4L, 4L, 4L, 4L, 4L, 4L, 4L, 4L, 4L, 4L, 6L, 6L, 6L, 7L, 6L, 21L, 2L, 2L, 21L, 21L, 21L, 21L, 21L, 21L, 21L, 21L, 12L, 14L, 14L, 12L, 15L, 17L, 11L, 16L, 14L, 14L, 11L, 14L, 21L, 2L, 2L, 2L, 2L, 2L, 4L, 21L, 9L, 9L, 23L, 23L, 23L, 23L, 23L, 14L, 1L, 14L, 14L, 14L, 13L, 14L, 14L, 4L, 4L, 4L, 21L, 21L, 21L, 21L, 21L, 9L, 21L, 21L, 21L, 21L, 21L, 21L, 23L, 23L, 23L, 23L, 23L, 4L, 4L, 4L, 4L, 14L, 12L, 16L, 18L, 14L, 14L, 14L, 23L, 23L, 14L, 4L, 4L, 2L, 14L, 12L, 14L, 14L, 14L, 16L, 12L, 12L, 14L, 12L, 14L, 14L, 14L, 14L, 14L, 14L, 14L, 18L, 4L, 2L, 19L, 19L, 16L, 20L, 2L, 3L, 5L, 2L, 2L), .Label = c("12/07/2019", "15/06/2019", "15/07/2019", "16/06/2019", "16/07/2019", "17/06/2019", "17/10/2019", "18/06/2019", "19/06/2019", "20/06/2019", "20/07/2019", "21/07/2019", "22/06/2019", "22/07/2019", "23/06/2019", "23/07/2019", "24/06/2019", "24/07/2019", "25/06/2019", "25/07/2019", "29/06/2019", "29/10/2019", "30/06/2019" ), class = "factor"), note_net_type.brand_net_given = structure(c(6L, 6L, 6L, 6L, 6L, 6L, 6L, 9L, 9L, 9L, 9L, 9L, 2L, 6L, 6L, 6L, 6L, 6L, 6L, 6L, 6L, 6L, 6L, 6L, 1L, 1L, 1L, 1L, 1L, 6L, 6L, 6L, 6L, 6L, 6L, 6L, 6L, 6L, 6L, 6L, 6L, 6L, 6L, 6L, 6L, 6L, 6L, 6L, 6L, 6L, 6L, 6L, 6L, 6L, 6L, 3L, 5L, 6L, 7L, 7L, 7L, 7L, 7L, 7L, 7L, 1L, 6L, 9L, 9L, 6L, 12L, 1L, 11L, 12L, 6L, 6L, 6L, 6L, 6L, 7L, 7L, 7L, 7L, 7L, 7L, 6L, 6L, 6L, 6L, 6L, 6L, 6L, 6L, 6L, 8L, 6L, 6L, 6L, 6L, 6L, 6L, 6L, 6L, 6L, 7L, 7L, 7L, 7L, 4L, 7L, 3L, 7L, 7L, 7L, 7L, 7L, 6L, 6L, 6L, 6L, 6L, 7L, 7L, 4L, 7L, 6L, 12L, 13L, 12L, 6L, 6L, 6L, 6L, 6L, 6L, 7L, 7L, 7L, 9L, 9L, 9L, 9L, 9L, 9L, 9L, 9L, 9L, 9L, 9L, 9L, 9L, 9L, 9L, 9L, 12L, 12L, 7L, 7L, 1L, 12L, 12L, 12L, 10L, 7L, 5L, 7L, 7L), .Label = c("", "Pema.net", "PERMA .NET", "PERMA,NET", "PERMA. NET", "Perma.net", "PERMA.NET", "Perman.net", "Permanet", "PERMANET", "Permanet.2", "PERMANET.2", "PERMANT.2" ), class = "factor"), note_net_type.help_hang_net = structure(c(1L, 1L, 1L, 1L, 1L, 1L, 1L, 2L, 2L, 2L, 2L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 2L, 1L, 2L, 1L, 1L, 1L, 1L, 1L, 2L, 2L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 2L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 2L, 1L, 2L, 2L, 1L, 2L, 2L, 2L, 2L, 2L, 2L, 2L, 2L, 2L, 2L, 2L, 2L, 2L, 2L, 1L, 2L, 2L, 1L, 1L, 2L, 2L, 2L, 2L, 2L, 2L, 1L, 2L, 2L, 1L, 1L, 2L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 2L, 2L, 2L, 2L, 2L, 2L, 2L, 2L, 2L, 2L, 2L, 2L, 1L, 2L, 1L, 1L, 1L, 1L, 1L, 2L, 1L, 1L, 2L, 2L, 2L, 1L, 1L, 1L, 1L, 1L, 1L, 2L, 1L, 1L, 2L, 2L, 2L, 2L, 2L, 2L, 2L, 2L, 2L, 2L, 2L, 2L, 2L, 2L, 2L, 2L, 2L, 2L, 1L, 1L, 2L, 2L, 2L, 2L, 2L, 2L, 2L, 2L, 2L), .Label = c("no", "yes"), class = "factor"), net_shape = structure(c(1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L), .Label = "rectangular", class = "factor"), other_net_shape = c(NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA), num_old_net = c(2L, 3L, 2L, 2L, 4L, 6L, 3L, 3L, 4L, 2L, 4L, 5L, 1L, 3L, 6L, 4L, 3L, 2L, 4L, 4L, 3L, 1L, 4L, 4L, 3L, 0L, 2L, 0L, 1L, 3L, 2L, 3L, 2L, 3L, 2L, 5L, 4L, 3L, 6L, 6L, 4L, 5L, 6L, 4L, 6L, 5L, 6L, 6L, 5L, 4L, 4L, 4L, 3L, 6L, 6L, 3L, 3L, 3L, 2L, 1L, 3L, 3L, 4L, 3L, 4L, 4L, 3L, 4L, 6L, 5L, 1L, 3L, 4L, 5L, 4L, 5L, 0L, 0L, 2L, 4L, 3L, 4L, 4L, 5L, 4L, 2L, 3L, 2L, 2L, 3L, 3L, 3L, 2L, 1L, 3L, 2L, 2L, 2L, 2L, 3L, 2L, 5L, 4L, 5L, 3L, 3L, 7L, 2L, 3L, 2L, 3L, 3L, 3L, 3L, 2L, 3L, 4L, 2L, 3L, 2L, 4L, 4L, 4L, 4L, 4L, 4L, 2L, 3L, 2L, 4L, 2L, 2L, 5L, 5L, 1L, 4L, 3L, 3L, 5L, 3L, 4L, 5L, 7L, 7L, 7L, 7L, 8L, 3L, 7L, 5L, 3L, 3L, 4L, 3L, 9L, 8L, 4L, 4L, 6L, 4L, 1L, 1L, 4L, 5L, 4L, 3L, 3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L, 4L, 4L, 3L, 5L, 7L, 8L, 7L, 5L, 10L, 10L, 6L, 2L, 4L, 6L, 4L, 10L, 5L, 5L, 5L, 5L, 6L, 12L, 5L, 5L, 4L, 7L, 5L, 5L, 5L, 4L, 5L, 5L, 5L, 6L, 5L, 9L, 5L, 5L, 5L, 6L, 9L, 9L, 6L, 10L, 6L, 5L, 5L, 11L, 10L, 3L, 6L, 5L, 5L, 11L, 8L, 5L, 9L, 10L, 18L, 12L, 12L, 19L, 6L, 15L, 10L, 9L, 7L, 10L, 8L, 22L, 30L, 5L, 6L, 19L, 11L, 5L, 15L, 7L, 7L, 6L, 5L, 6L)), class = "data.frame", row.names = c(NA, -167L)) and the script I want to rewrite comp_df <- comp_df %>% mutate(`sleep space category` = ifelse(num_sleep_space == 1, "1", ifelse(num_sleep_space >=2 & num_sleep_space <=4 ,"2-4",ifelse(num_sleep_space >=5 & num_sleep_space <=9, "5-9", ifelse(num_sleep_space >9, ">9", NA)))), `sleep space category` = factor(`sleep space category` , levels=c("1","2-4","5-9",">9")), `number of nets given` = ifelse(note_net_type.num_net_given == 1, "1", ifelse(note_net_type.num_net_given >=2 & note_net_type.num_net_given <=4 ,"2-4", ifelse(note_net_type.num_net_given >=5 & note_net_type.num_net_given <=9,"5-9", ifelse(note_net_type.num_net_given >9, ">9", NA)))), `number of nets given` = factor(`number of nets given`, levels = c("1","2-4","5-9",">9")), `net surplus/gap` = num_sleep_space - note_net_type.num_net_given, `number of household members` = ifelse(hh_member_count >= 1 & hh_member_count<= 5, "1-5", ifelse(hh_member_count >=6 & hh_member_count <=10,"6-10",ifelse(hh_member_count >10, ">10", NA)))) %>% mutate(`number of household members` = factor(`number of household members`, levels = c("1-5","6-10",">10")))
I can see why you want to refactor your code! You are trying to reinvent the cut function using ifelse statements and without taking advantage of the ability to seperate logic out into simple chunks using functions. Your whole complex code can be replaced with this: cut4 <- function(x) cut(x, c(0, 1.5, 4.5, 9.5, 20), c("1", "2-4", "5-9", ">9")) cut3 <- function(x) cut(x, c(0, 5.5, 10.5, 50), c("1-5", "6-10", ">10")) comp_df <- comp_df %>% mutate(`sleep space category` = cut4(num_sleep_space), `number of nets given` = cut4(note_net_type.num_net_given), `net surplus/gap` = num_sleep_space - note_net_type.num_net_given, `number of household members` = cut3(hh_member_count))
How do I draw a line over the Poisson curve?
How do I draw a line over my Poisson curve in R? This is the code I used for my plot; plot(dogbites$daily.dogbites, dpois(dogbites$daily.dogbites, dogbites_lambda),ylab="prob(x)", main="Poisson dog bites") and this is the plot I got: I'm hoping to get something like this: May I know what code can I use for this? Edit: I tried lines function and type = "o" but I got this instead > dput(dogbites) structure(list(daily.dogbites = c(1L, 0L, 0L, 0L, 1L, 0L, 0L, 0L, 0L, 1L, 0L, 0L, 0L, 1L, 3L, 0L, 6L, 9L, 15L, 3L, 4L, 3L, 7L, 6L, 1L, 2L, 3L, 4L, 2L, 5L, 3L, 1L, 6L, 2L, 0L, 0L, 3L, 3L, 6L, 1L, 3L, 2L, 2L, 5L, 6L, 7L, 4L, 10L, 4L, 18L, 4L, 3L, 2L, 5L, 4L, 3L, 2L, 6L, 4L, 6L, 6L, 1L, 2L, 5L, 10L, 4L, 4L, 3L, 0L, 3L, 4L, 2L, 3L, 3L, 5L, 5L, 5L, 8L, 13L, 10L, 12L, 4L, 5L, 3L, 3L, 5L, 4L, 2L, 6L, 4L, 2L, 1L, 3L, 3L, 7L, 5L, 3L, 2L, 5L, 6L, 5L, 3L, 6L, 5L, 3L, 6L, 5L, 9L, 7L, 8L, 12L, 5L, 2L, 6L, 8L, 4L, 2L, 3L, 6L, 6L, 7L, 6L, 5L, 3L, 3L, 6L, 4L, 3L, 6L, 2L, 2L, 6L, 2L, 4L, 5L, 3L, 4L, 5L, 9L, 12L, 9L, 16L, 7L, 3L, 2L, 3L, 0L, 1L, 1L, 2L, 2L, 2L, 3L, 1L, 2L, 3L, 6L, 4L, 6L, 2L, 6L, 5L, 8L, 3L, 3L, 6L, 7L, 5L, 9L, 18L, 22L, 0L, 7L, 5L, 7L, 1L, 5L, 2L, 4L, 1L, 4L, 5L, 3L, 9L, 5L, 4L, 2L, 4L, 4L, 0L, 4L, 4L, 5L, 4L, 9L, 8L, 9L, 7L, 4L, 13L, 12L, 24L, 7L, 4L, 5L, 10L, 2L, 2L, 3L, 8L, 8L, 4L, 6L, 6L, 3L, 7L, 6L, 2L, 6L, 5L, 2L, 1L, 7L, 0L, 8L, 11L, 2L, 10L, 3L, 7L, 9L, 10L, 7L, 2L, 2L, 5L, 2L, 1L, 8L, 4L, 4L, 5L, 3L, 3L, 2L, 4L, 7L, 3L, 2L, 1L, 3L, 7L, 9L, 8L, 2L, 4L, 8L, 7L, 4L, 9L, 21L, 3L, 2L, 1L, 5L, 3L, 4L, 3L, 3L, 4L, 4L, 2L, 5L, 5L, 2L, 3L, 1L, 4L, 4L, 0L, 1L, 7L, 4L, 2L, 2L, 1L, 5L, 6L, 3L, 7L, 7L, 14L, 4L, 1L, 4L, 6L, 6L, 1L, 2L, 3L, 2L, 0L, 8L, 3L, 1L, 5L, 1L, 4L, 3L, 5L, 7L, 0L, 3L, 3L, 5L, 2L, 4L, 7L, 6L, 7L, 9L, 19L, 5L, 0L, 3L, 0L, 1L, 3L, 4L, 1L, 5L, 2L, 4L, 3L, 6L, 3L, 4L, 7L, 5L, 9L, 3L, 7L, 6L, 5L, 3L, 6L, 5L, 3L, 5L, 8L, 12L, 5L, 17L, 3L, 3L, 2L, 4L, 5L, 4L, 2L, 2L, 1L, 3L, 5L, 4L, 3L, 2L, 1L, 2L, 4L, 2L, 1L, 1L, 1L, 2L, 2L, 1L, 1L )), class = "data.frame", row.names = c(NA, -378L)) > dput(dogbites_lambda) 4.50529100529101
You need to sort the data by the x axis values set.seed(42) x = sample(1:25) y = dpois(x, 5) graphics.off() plot(sort(x), y[order(x)], type = "o")
Negative Binomial in R: glm.nb: In sqrt(1/i) : NaNs produced, and other problems
I am running a negative binomial regression. I would like to know why I have the following errors: In sqrt(1/i) : NaNs produced It appears that there are some negative values in "i", but how do I avoid that? Another one is: In loglik(n, th, mu, Y, w) : value out of range in 'lgamma' It is probably a consequences of the first error, so if I fix the first one, the second might be gone. Or maybe not. In some other cases I am able to calculate the regression but the following output seems strange for me: (Dispersion parameter for Negative Binomial(10684331573) family taken to be 1) Null deviance: 8779.49 on 359 degrees of freedom Residual deviance: 270.32 on 200 degrees of freedom AIC: 2074.7 Number of Fisher Scoring iterations: 1 Theta: 10684331573 Std. Err.: 615849693813 2 x log-likelihood: -1752.749 Do these numbers seem okay? I mean the dispersion parameter, theta and standard error. They look enormously big to me and therefore I am not sure if the results are okay. I never had any problems like that using poisson regression, but then I realized that I have an overdispersed data and that is why I am using negative binomial. However, I am having a lot of troubles with this one. Here is the code: negbin <- glm.nb(Freq ~ cluster*gender*agecombined*educ, maxit=100) mod.good <- step(negbin, direction='both', maxit=100) And here is the dput of the whole dataset: structure(list(gender = structure(c(1L, 2L, 1L, 2L, 1L, 2L, 1L, 2L, 1L, 2L, 1L, 2L, 1L, 2L, 1L, 2L, 1L, 2L, 1L, 2L, 1L, 2L, 1L, 2L, 1L, 2L, 1L, 2L, 1L, 2L, 1L, 2L, 1L, 2L, 1L, 2L, 1L, 2L, 1L, 2L, 1L, 2L, 1L, 2L, 1L, 2L, 1L, 2L, 1L, 2L, 1L, 2L, 1L, 2L, 1L, 2L, 1L, 2L, 1L, 2L, 1L, 2L, 1L, 2L, 1L, 2L, 1L, 2L, 1L, 2L, 1L, 2L, 1L, 2L, 1L, 2L, 1L, 2L, 1L, 2L, 1L, 2L, 1L, 2L, 1L, 2L, 1L, 2L, 1L, 2L, 1L, 2L, 1L, 2L, 1L, 2L, 1L, 2L, 1L, 2L, 1L, 2L, 1L, 2L, 1L, 2L, 1L, 2L, 1L, 2L, 1L, 2L, 1L, 2L, 1L, 2L, 1L, 2L, 1L, 2L, 1L, 2L, 1L, 2L, 1L, 2L, 1L, 2L, 1L, 2L, 1L, 2L, 1L, 2L, 1L, 2L, 1L, 2L, 1L, 2L, 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L, 5L, 5L, 5L, 5L, 5L, 5L, 5L, 5L, 5L, 5L, 5L, 5L, 5L, 5L, 5L, 5L, 5L, 5L, 5L, 5L, 5L, 5L, 5L, 5L, 5L, 5L, 5L, 5L, 5L, 5L, 5L, 5L, 5L, 5L, 5L, 5L, 5L, 5L, 5L, 5L, 5L, 5L, 5L, 5L, 5L, 5L, 5L, 5L, 5L, 5L, 5L, 5L, 5L), .Label = c("E", "A", "B", "C", "D" ), class = "factor"), Freq = c(27L, 18L, 48L, 29L, 18L, 19L, 14L, 10L, 2L, 1L, 2L, 0L, 48L, 36L, 69L, 54L, 33L, 15L, 12L, 4L, 5L, 1L, 0L, 0L, 2L, 4L, 12L, 14L, 17L, 17L, 23L, 32L, 16L, 17L, 18L, 6L, 4L, 2L, 17L, 7L, 8L, 4L, 5L, 0L, 1L, 0L, 0L, 0L, 53L, 42L, 82L, 58L, 81L, 60L, 42L, 35L, 16L, 14L, 22L, 6L, 83L, 40L, 62L, 54L, 43L, 46L, 26L, 12L, 15L, 3L, 3L, 3L, 11L, 13L, 11L, 23L, 16L, 18L, 11L, 5L, 1L, 3L, 1L, 1L, 26L, 44L, 34L, 54L, 25L, 41L, 19L, 17L, 10L, 3L, 3L, 0L, 4L, 4L, 7L, 14L, 22L, 31L, 14L, 34L, 14L, 33L, 14L, 20L, 7L, 11L, 22L, 11L, 14L, 8L, 8L, 1L, 2L, 0L, 1L, 2L, 29L, 65L, 34L, 84L, 36L, 65L, 28L, 39L, 16L, 15L, 16L, 9L, 25L, 51L, 12L, 38L, 23L, 29L, 22L, 19L, 7L, 5L, 5L, 1L, 7L, 16L, 14L, 35L, 6L, 27L, 8L, 5L, 1L, 1L, 1L, 0L, 24L, 57L, 29L, 53L, 24L, 28L, 11L, 9L, 7L, 2L, 0L, 0L, 3L, 7L, 1L, 8L, 2L, 18L, 5L, 13L, 10L, 11L, 5L, 10L, 3L, 1L, 5L, 13L, 4L, 2L, 2L, 1L, 1L, 0L, 0L, 0L, 14L, 51L, 21L, 77L, 23L, 50L, 25L, 31L, 17L, 16L, 13L, 13L, 19L, 52L, 24L, 59L, 18L, 44L, 9L, 20L, 6L, 3L, 7L, 2L, 14L, 28L, 34L, 47L, 29L, 47L, 15L, 13L, 9L, 3L, 2L, 0L, 46L, 75L, 124L, 81L, 67L, 45L, 33L, 15L, 9L, 4L, 5L, 3L, 0L, 10L, 6L, 19L, 12L, 28L, 22L, 37L, 31L, 41L, 26L, 31L, 7L, 6L, 21L, 13L, 6L, 7L, 8L, 2L, 2L, 1L, 0L, 0L, 67L, 89L, 116L, 159L, 99L, 102L, 64L, 80L, 42L, 25L, 25L, 8L, 108L, 123L, 60L, 97L, 68L, 66L, 44L, 35L, 12L, 5L, 9L, 2L, 7L, 3L, 53L, 15L, 33L, 3L, 8L, 3L, 4L, 0L, 0L, 0L, 48L, 19L, 76L, 40L, 55L, 11L, 16L, 1L, 4L, 1L, 2L, 0L, 6L, 7L, 21L, 22L, 18L, 23L, 32L, 37L, 40L, 13L, 23L, 10L, 4L, 2L, 19L, 2L, 8L, 3L, 6L, 0L, 1L, 0L, 1L, 0L, 68L, 37L, 90L, 42L, 76L, 38L, 47L, 16L, 29L, 5L, 18L, 2L, 82L, 32L, 62L, 27L, 44L, 22L, 20L, 8L, 8L, 2L, 1L, 0L)), .Names = c("gender", "agecombined", "educ", "cluster", "Freq"), row.names = c(NA, -360L), class = "data.frame")