I have some data with id, time_to_event, event, therapy start and therapy stop variables.
Here is a reproducible example:
data <- structure(list(id = structure(c(1L, 3L, 9L, 2L, 5L, 10L, 7L,
8L, 4L, 6L), .Label = c("1", "4", "2", "9", "5", "10", "7", "8",
"3", "6"), class = "factor"), event = c("Death", "Death", "Death",
"Y", "Death", "Y", "Y", "Y", "Death", "X"), time_to_event = c(89L,
83L, 74L, 88L, 78L, 72L, 77L, 76L, 79L, 78L), start = c(18L,
3L, 13L, 16L, 10L, 6L, 20L, 11L, 14L, 9L), stop = c(89L, 83L,
74L, 88L, 78L, 72L, 77L, 76L, 79L, 78L)), row.names = c(NA, -10L
), class = "data.frame")
I computed a plot, which shows the type of event as geom_point and the time of the therapy as geom_segment with start and stop. Here is the code:
colors <- c("X" = "dodgerblue3",
"Y" = "red2",
"Death" = "black") # Defining the colors for the event type
event_symbols <- c("X" = "\u25CF",
"Y" = "\u25CF",
"Death" = "\u2020") # <-- Problem: When I use the shape 84 (T) the code is plotted. When I use "/u2020", I get the above-mentioned error message
five_day_lines <- seq(0, 90, 5)
day_lines <- 1:90
day_lines <- day_lines[!day_lines %in% five_day_lines]
data$id <- factor(data$id, levels = data$id[order(data$time_to_event, decreasing = T)])
ggplot(data = data) +
geom_hline(yintercept = five_day_lines, color = "grey", alpha = .35) +
geom_hline(yintercept = day_lines, color = "grey", alpha = .25) +
geom_segment(aes(x = id, xend = id, y = start, yend = stop), color = "dimgray", size = 1) +
geom_point(aes(x = id, y = time_to_event, shape = event, color = event), size = 3) +
scale_y_continuous(limits = c(0,90), breaks = c(seq(0, 90, 5)), name = "Days after study inclusion") +
scale_x_discrete(name = "ID") +
coord_flip() +
scale_color_manual(values = colors, breaks = c()) +
scale_shape_manual(values = event_symbols, breaks = c("X", "Y", "Death"),
guide = guide_legend(override.aes = list(color = c("dodgerblue3", "red2", "black")))) +
theme(legend.position = "bottom",
legend.title = element_text(size=12, face="bold"),
panel.background = element_blank(),
legend.background = element_blank()) +
labs(color="Medication", shape="Event type")
The plot looks like the following:
My question is, whether it is possible to add a gap in the geom_segment at a certain point, let's say at half of the length of the segments. Ideally, the break should look like a 'typical' gap in a plot axis like the following from https://rstudio-pubs-static.s3.amazonaws.com/235467_5abd31ab564a43c9ae0f18cdd07eebe7.html:
Here, we can see a kind of double slash. I had the idea of taking the double slash unicode character (Link) but this, I think, would simply generate a new layer and would disregard the desired gap or 'interruption' of the geom_segment. Is there a smart way to compute such a gap, where the geom_segment ends at the one slash and starts again at the 2nd slash? Ideally, it works with the double slash but if there is another way with another appropriate shape or something else, I would be fine with that.
I would be grateful, if there is a smart solution for this problem.
Thanks a lot.
I don't think there exists specialised layers in ggplot2 or extensions that deal with gaps specifically. One can of course abuse the arrow argument in geom_segment() to draw a stumpy arrow at the extremes of a segment, but that probably doesn't alleviate the necessity to use a second layer. Below you'll find a simplified example of that.
library(ggplot2)
data <- structure(list(
id = structure(c(1L, 3L, 9L, 2L, 5L, 10L, 7L, 8L, 4L, 6L),
.Label = c("1", "4", "2", "9", "5", "10", "7", "8", "3", "6"),
class = "factor"),
event = c("Death", "Death", "Death", "Y", "Death", "Y", "Y", "Y", "Death", "X"),
time_to_event = c(89L, 83L, 74L, 88L, 78L, 72L, 77L, 76L, 79L, 78L),
start = c(18L, 3L, 13L, 16L, 10L, 6L, 20L, 11L, 14L, 9L),
stop = c(89L, 83L, 74L, 88L, 78L, 72L, 77L, 76L, 79L, 78L)),
row.names = c(NA, -10L),
class = "data.frame"
)
gap_start <- 30
gap_stop <- 50
ggplot(data, aes(x = start, xend = stop, y = id, yend = id)) +
geom_segment(aes(xend = gap_start), arrow = arrow(90, unit(1, "mm"))) +
geom_segment(aes(x = gap_stop), arrow = arrow(90, unit(1, "mm"), ends = "first"))
Created on 2021-07-14 by the reprex package (v1.0.0)
Related
I have two datasets (I will eventually be working with eight) that I have combined to create a scatter plot. The issue is, now I've plotted the scatter graph, I do not know how to separate the data I've combined so the colours represent the individual datasets. This is my code...
#Here is what I've combined:
t<-rbind(test202, test342)
#Here is plotting the scatter-plot
```{r}
g<-ggplot(t,aes(x=percentage,y=as.numeric(area), col = area, group = area ))+
geom_point()+
labs(x=expression(paste("Percentage (%)")),
y=expression(paste("Area (m"^2,")"))
)+
scale_y_continuous(breaks = seq(0, 20, by = 1)) +
theme_bw() +
theme(element_blank())
g
``
I've tried googling this but cannot seem to find any specific code to fix this. I've attached a picture of the final product and of 't's contents.
contents of 't' scatter-plot of 't'
EDIT: dput(t)
t <- structure(list(percentage = structure(c(1L, 2L, 3L, 4L, 5L, 6L,
7L, 8L, 9L, 10L, 11L, 12L, 13L, 14L, 1L, 2L, 3L, 4L, 5L, 6L,
7L, 8L, 9L, 10L, 11L, 12L, 13L, 14L), .Label = c("30", "35",
"40", "45", "50", "55", "60", "65", "70", "75", "80", "85", "90",
"95"), class = "factor"), area = c(1.0068507612755, 1.28144642344154,
1.55604208560758, 1.92216963516231, 2.28829718471704, 2.65442473427176,
3.20361605860385, 3.75280738293594, 4.39353059465671, 5.30884946854352,
6.49876400459638, 7.96327420281528, 10.068507612755, 13.6382512209135,
1.12935650675177, 1.4004020683722, 1.67144762999262, 1.98766745188312,
2.34906153404369, 2.75562987647432, 3.16219821890496, 3.65911508187574,
4.15603194484652, 4.74329732835744, 5.37573697213844, 6.18887365699971,
7.22788164321134, 8.89932927320397)), row.names = c(NA, -28L), class = "data.frame")
Looks like you are just losing track of the source of the data when you rbind the rows together. Since you say you have more dfs to join eventiually I will provide a dplyr solution.
library(dplyr)
library(ggplot2)
t <- dplyr::bind_rows(list(test202 = test202,
test342 = test342),
.id = 'source')
ggplot(t, aes(x = percentage,
y = as.numeric(area),
col = source,
group = source ))+
geom_point()+
labs(x = expression(paste("Percentage (%)")),
y = expression(paste("Area (m"^2,")"))
)+
scale_y_continuous(breaks = seq(0, 20, by = 1)) +
theme_bw() +
theme(element_blank())
I am trying to use geom_label_repel to add labels to a couple of data points on a plot. In this case, they happen to be outliers on box plots. I've got most of the code working, I can label the outlier, but for some reason I am getting multiple labels (equal to my sample size for the entire data set) mapped to that point. I'd like just one label for this outlier.
Example:
Here is my data:
dput(sus_dev_data)
structure(list(time_point = structure(c(1L, 1L, 1L, 1L, 1L, 1L,
1L, 1L, 1L, 2L, 2L, 2L, 2L, 2L, 2L, 2L, 2L, 2L, 3L, 3L, 3L, 3L,
3L, 3L, 3L, 3L, 3L), .Label = c("3", "8", "12"), class = "factor"),
days_to_pupation = c(135L, 142L, 143L, 155L, 149L, 159L,
153L, 171L, 9L, 67L, 53L, 49L, 72L, 67L, 55L, 64L, 60L, 122L,
53L, 51L, 49L, 53L, 50L, 56L, 44L, 47L, 60L)), row.names = c(1L,
2L, 3L, 4L, 5L, 6L, 8L, 9L, 10L, 11L, 12L, 13L, 14L, 15L, 16L,
17L, 18L, 20L, 21L, 22L, 23L, 24L, 26L, 27L, 28L, 29L, 30L), class = "data.frame")
and my code...
####################################################################################################
# Time to pupation statistical analysis
####################################################################################################
## linear model
pupation_Model=lm(sus_dev_data$days_to_pupation~sus_dev_data$time_point)
pupationANOVA=aov(pupation_Model)
summary(pupationANOVA)
# Tukey test to study each pair of treatment :
pupationTUKEY <- TukeyHSD(x=pupationANOVA, which = 'sus_dev_data$time_point',
conf.level=0.95)
## Function to generate significance labels on box plot
generate_label_df <- function(pupationTUKEY, variable){
# Extract labels and factor levels from Tukey post-hoc
Tukey.levels <- pupationTUKEY[[variable]][,4]
Tukey.labels <- data.frame(multcompLetters(Tukey.levels, reversed = TRUE)['Letters'])
#I need to put the labels in the same order as in the boxplot :
Tukey.labels$treatment=rownames(Tukey.labels)
Tukey.labels=Tukey.labels[order(Tukey.labels$treatment) , ]
return(Tukey.labels)
}
#generate labels using function
labels<-generate_label_df(pupationTUKEY , "sus_dev_data$time_point")
#rename columns for merging
names(labels)<-c('Letters','time_point')
# obtain letter position for y axis using means
pupationyvalue<-aggregate(.~time_point, data=sus_dev_data, max)
#merge dataframes
pupationfinal<-merge(labels,pupationyvalue)
####################################################################################################
# Time to pupation plot
####################################################################################################
# Plot of data
(pupation_plot <- ggplot(sus_dev_data, aes(time_point, days_to_pupation)) +
Alex_Theme +
geom_boxplot(fill = "grey80", outlier.size = 0.75) +
geom_text(data = pupationfinal, aes(x = time_point, y = days_to_pupation,
label = Letters),vjust=-2,hjust=.5, size = 4) +
#ggtitle(expression(atop("Days to pupation"))) +
labs(y = 'Days to pupation', x = 'Weeks post-hatch') +
scale_y_continuous(limits = c(0, 200)) +
scale_x_discrete(labels=c("3" = "13", "8" = "18",
"12" = "22")) +
geom_label_repel(aes(x = 1, y = 9),
label = '1')
)
Here's a shorter example to demonstrate what is going on. Essentially, your labels are beng recycled to be the same length as the data.
df = data.frame(x=1:5, y=1:5)
ggplot(df, aes(x,y, color=x)) +
geom_point() +
geom_label_repel(aes(x = 1, y = 1), label = '1')
You can override this by providing new data for the ggrepel
ggplot(df, aes(x,y, color=x)) +
geom_point() +
geom_label_repel(data = data.frame(x=1, y=1), label = '1')
Based on your data, you have 3 outliers (one in each group), you can manually identify them by applying the classic definition of outliers by John Tukey (Upper: Q3+1.5*IQR and Lower: Q1-1.5*IQR) (but you are free to set your own rules to define an outlier). You can use the function quantile and IQR to get those points.
Here, I incorporated them in a sequence of pipe using dplyr package:
library(tidyverse)
Outliers <- sus_dev_data %>% group_by(time_point) %>%
mutate(Out_up = ifelse(days_to_pupation > quantile(days_to_pupation,0.75)+1.5*IQR(days_to_pupation), "Out","In"))%>%
mutate(Out_Down = ifelse(days_to_pupation < quantile(days_to_pupation,0.25)-1.5*IQR(days_to_pupation), "Out","In")) %>%
filter(Out_up == "Out" | Out_Down == "Out")
# A tibble: 3 x 4
# Groups: time_point [3]
time_point days_to_pupation Out_up Out_Down
<fct> <int> <chr> <chr>
1 3 9 In Out
2 8 122 Out In
3 12 60 Out In
As mentioned by #dww, you need to pass a new dataframe to geom_label_repel if you want your outliers to be single labeled. So, here we use the dataframe Outliers to feed the geom_label_repel function:
library(ggplot2)
library(ggrepel)
ggplot(sus_dev_data, aes(time_point, days_to_pupation)) +
#Alex_Theme +
geom_boxplot(fill = "grey80", outlier.size = 0.75) +
geom_text(data = pupationfinal, aes(x = time_point, y = days_to_pupation,
label = Letters),vjust=-2,hjust=.5, size = 4) +
#ggtitle(expression(atop("Days to pupation"))) +
labs(y = 'Days to pupation', x = 'Weeks post-hatch') +
scale_y_continuous(limits = c(0, 200)) +
scale_x_discrete(labels=c("3" = "13", "8" = "18",
"12" = "22")) +
geom_label_repel(inherit.aes = FALSE,
data = Outliers,
aes(x = time_point, y = days_to_pupation, label = "Out"))
And you get the following graph:
I hope it helps you to figure it how to label all your outliers.
I need to include age adjustment in the geom_smooth line I am adding to my ggscatter plot.
my data looks like~
table link
structure(list(Time = c(0L, 0L, 0L, 0L, 6L, 12L, 18L, 18L, 0L,
12L, 18L, 6L), group = structure(c(1L, 1L, 2L, 2L, 1L, 3L, 3L,
3L, 3L, 4L, 4L, 1L), .Label = c("A", "B", "C", "D"), class = "factor"),
Age = c(77, 70.2, 69.9, 65.7, 66.2, 66.7, 67.2, 67.7, 66.8,
67.8, 68.3, 68.8), Average = c(96L, 90L, 94L, 94L, 96L, 96L,
92L, 120L, 114L, 109L, 113L, 103L)), row.names = c(NA, 12L
), class = "data.frame")
What I currently have (the 'Average" value have dependency in age..):
ggscatter(dtable, "Time","Average",conf.int = TRUE)+theme_bw()+
geom_smooth(aes(group=1),method='lm')+facet_wrap(~groups)
What I would like to have is something like:
ggscatter(dtable, "Time","Average",conf.int = TRUE)+theme_bw()+
geom_smooth(aes(group=1),method='lm', adjust= ~age)+facet_wrap(~groups)
With adjustment per each group mean age
Any suggestions?
Here is I think what you are after.
First, we need to fit the more complicated model because ggplot does not have a functionality for multivariable models (yet)
fit <- lm(Average ~ Time + group + Age, data = tdata)
Then we can use some functionality from the broom package to add the predictions and associated standard errors. With these in hand we can manually build the plot using the geom_line and geom_ribbon geoms
library(broom)
tdata %>%
bind_cols(augment(fit)) %>%
ggplot(aes(Time, Average))+
geom_point()+
geom_line(aes(x = Time, y = .fitted), size = 2, color = "blue")+
geom_ribbon(aes(ymin = .fitted + .se.fit*2, ymax = .fitted - .se.fit*2), alpha = .2)+
facet_wrap(~group)+
theme_bw()
Additionally, if you wanted to look at pooled vs non-pooled estimates
fit_no_pool <- lm(Average ~ Time + group + Age, data = tdata)
fit_complete_pool <- lm(Average ~ Time + Age, data = tdata)
library(broom)
tdata %>%
bind_cols(augment(fit_no_pool) %>% setNames(sprintf("no_pool%s", names(.)))) %>%
bind_cols(augment(fit_complete_pool) %>% setNames(sprintf("pool%s", names(.)))) %>%
ggplot(aes(Time, Average))+
geom_point()+
# Non-Pooled Estimates
geom_line(aes(x = Time, y = no_pool.fitted, color = "blue"), size = 2)+
geom_ribbon(aes(ymin = no_pool.fitted + no_pool.se.fit*2,
ymax = no_pool.fitted - no_pool.se.fit*2), alpha = .2)+
# Pooled Estimates
geom_line(aes(x = Time, y = pool.fitted, color = "orange"), size = 2)+
geom_ribbon(aes(ymin = pool.fitted + pool.se.fit*2,
ymax = pool.fitted - pool.se.fit*2), alpha = .2)+
facet_wrap(~group)+
scale_color_manual(name = "Regression",
labels = c("Pooled", "Non-Pooled"),
values = c("blue", "orange"))+
theme_bw()
One way to go is to run your model with Age as an additional predictor in your model. then use predict to get the predicted value with CIs. Append to your data then use ggplot to plot. I know you want to facet by group, so it might be worth putting it into your model as well. Just a thought. The steps would be the same.
df <- structure(list(Time = c(0L, 0L, 0L, 0L, 6L, 12L, 18L, 18L, 0L,
12L, 18L, 6L), group = structure(c(1L, 1L, 2L, 2L, 1L, 3L, 3L,
3L, 3L, 4L, 4L, 1L), .Label = c("A", "B", "C", "D"), class = "factor"),
Age = c(77, 70.2, 69.9, 65.7, 66.2, 66.7, 67.2, 67.7, 66.8,
67.8, 68.3, 68.8), Average = c(96L, 90L, 94L, 94L, 96L, 96L,
92L, 120L, 114L, 109L, 113L, 103L)), row.names = c(NA, 12L
), class = "data.frame")
#model adjusted for age
mod <- lm(Average ~ Time + Age, data = df)
#get prediction with CIS
premod <- predict(mod, interval = "predict")
#append to data
df2 <- cbind(df,premod)
#add prediction to ggplot with scatter plot
ggplot(df2) +
geom_point(aes(x=Time,y=Average)) +
geom_line(aes(x=Time, y = fit)) +
geom_ribbon(aes(x = Time,ymin = lwr, ymax = upr), alpha = .1)+
facet_wrap(~group)+
theme_bw()
I would simply like to increase the font size of the title for a gganimate object. I used the following code but it didnt change the size of the title. I changed the title font using theme.
Libraries
library(ggplot2)
library(gganimate)
library(ggpubr)
Example Data
structure(list(subject = c(1L, 1L, 1L, 2L, 2L, 2L, 3L, 3L, 3L
), treatment = c("a", "a", "a", "b", "b", "b", "a", "a", "a"),
time = c(1L, 2L, 3L, 1L, 2L, 3L, 1L, 2L, 3L), outcome1 = c(80L,
75L, 74L, 90L, 81L, 76L, 90L, 89L, 87L), outcome2 = c(15L,
14L, 12L, 16L, 15L, 15L, 17L, 14L, 12L)), class = "data.frame", row.names = c(NA,
-9L))
Example Code
ggplot(dat2, aes(x=treatment, y=outcome1, fill=treatment)) +
geom_violin() +
guides(fill = FALSE) +
scale_fill_manual(values=c("#00AFBB", "#FC4E07")) +
stat_compare_means(aes(label = ..p.format..), paired = FALSE, label.x.npc = 0.5) +
theme(plot.title = element_text(size = 20, face = "bold")) +
labs(title = 'Week: {frame_time}', x = 'Diet', y = 'Outcome1 (mm)') +
transition_time(time) +
ease_aes('linear')
animate(p1, duration = 12, fps = 1)
Thanks for reading!
I an answered my own question. Never mind, theme(plot.title = element_text(size = 20, face = "bold")) is working! Made a mistake earlier in printing the graph.
I'm unsure why none of my data points show up on the map.
Store_ID visits CRIND_CC ISCC EBITDAR top_bottom Latitude Longitude
(int) (int) (int) (int) (dbl) (chr) (fctr) (fctr)
1 92 348 14819 39013 76449.15 top 41.731373 -93.58184
2 2035 289 15584 35961 72454.42 top 41.589428 -93.80785
3 50 266 14117 27262 49775.02 top 41.559017 -93.77287
4 156 266 7797 25095 28645.95 top 41.6143 -93.834404
5 66 234 8314 18718 46325.12 top 41.6002 -93.779236
6 207 18 2159 17999 20097.99 bottom 41.636208 -93.531876
7 59 23 10547 28806 52168.07 bottom 41.56153 -93.88083
8 101 23 1469 11611 7325.45 bottom 41.20982 -93.84298
9 130 26 2670 13561 14348.98 bottom 41.614517 -93.65789
10 130 26 2670 13561 14348.98 bottom 41.6145172 -93.65789
11 24 27 17916 41721 69991.10 bottom 41.597134 -93.49263
> dput(droplevels(top_bottom))
structure(list(Store_ID = c(92L, 2035L, 50L, 156L, 66L, 207L,
59L, 101L, 130L, 130L, 24L), visits = c(348L, 289L, 266L, 266L,
234L, 18L, 23L, 23L, 26L, 26L, 27L), CRIND_CC = c(14819L, 15584L,
14117L, 7797L, 8314L, 2159L, 10547L, 1469L, 2670L, 2670L, 17916L
), ISCC = c(39013L, 35961L, 27262L, 25095L, 18718L, 17999L, 28806L,
11611L, 13561L, 13561L, 41721L), EBITDAR = c(76449.15, 72454.42,
49775.02, 28645.95, 46325.12, 20097.99, 52168.07, 7325.45, 14348.98,
14348.98, 69991.1), top_bottom = c("top", "top", "top", "top",
"top", "bottom", "bottom", "bottom", "bottom", "bottom", "bottom"
), Latitude = structure(c(11L, 4L, 2L, 7L, 6L, 10L, 3L, 1L, 8L,
9L, 5L), .Label = c("41.20982", "41.559017", "41.56153", "41.589428",
"41.597134", "41.6002", "41.6143", "41.614517", "41.6145172",
"41.636208", "41.731373"), class = "factor"), Longitude = structure(c(3L,
7L, 5L, 8L, 6L, 2L, 10L, 9L, 4L, 4L, 1L), .Label = c("-93.49263",
"-93.531876", "-93.58184", "-93.65789", "-93.77287", "-93.779236",
"-93.80785", "-93.834404", "-93.84298", "-93.88083"), class = "factor")), row.names = c(NA,
-11L), .Names = c("Store_ID", "visits", "CRIND_CC", "ISCC", "EBITDAR",
"top_bottom", "Latitude", "Longitude"), class = c("tbl_df", "tbl",
"data.frame"))
Creating the plot:
map <- qmap('Des Moines') +
geom_point(data = top_bottom, aes(x = as.numeric(Longitude),
y = as.numeric(Latitude)), colour = top_bottom, size = 3)
I get the warning message:
Removed 11 rows containing missing values (geom_point).
However, this works without the use of ggmap():
ggplot(top_bottom) +
geom_point(aes(x = as.numeric(Longitude), y = as.numeric(Latitude)),
colour = top_bottom, size = 3)
How do I get the points to overlay on ggmap??
You are using as.numeric() with a factor. As seen here that gives you a level number for the factor (not the number represented). Unsurprisingly, all those levels are points not on the canvas displayed for "Des Moines".
Use as.numeric(as.character(Latitude)) and as.numeric(as.character(Longitude)), as ugly as it seems.
Seeing the sample data, it seems that there is one data point which does not stay in the map area.
library(dplyr)
library(ggplot2)
library(ggmap)
### You can find lon/lat for bbox using your ggmap object.
### For instance, des1 <- ggmap(mymap1)
### str(des1)
### You could use bb2bbox() in the ggmap package to find lon/lat.
filter(top_bottom,
between(Latitude, 41.27057, 41.92782),
between(Longitude, -94.04787, -93.16897)) -> inside
setdiff(top_bottom, inside)
# Store_ID visits CRIND_CC ISCC EBITDAR top_bottom Latitude Longitude
#1 101 23 1469 11611 7325.45 bottom 41.20982 -93.84298
Since you used qmap() without specifying zoom, I do not know what zoom level you had. Let's play around a bit. In the first case, there is one data point missing; Removed 1 rows containing missing values (geom_point).
mymap1 <- get_map('Des Moines', zoom = 10)
ggmap(mymap1) +
geom_point(data = top_bottom, aes(x = as.numeric(Longitude),
y = as.numeric(Latitude)), colour = top_bottom, size = 3)
mymap2 <- get_map('Des Moines', zoom = 9)
ggmap(mymap2) +
geom_point(data = top_bottom, aes(x = as.numeric(Longitude),
y = as.numeric(Latitude)), colour = top_bottom, size = 3)
So the key thing, I think, is that you want to make sure you choose the right zoom level for your data set. For that, you may want to specify zoom in qmap(). I hope this will help you.
DATA
top_bottom <- structure(list(Store_ID = c(92L, 2035L, 50L, 156L, 66L, 207L,
59L, 101L, 130L, 130L, 24L), visits = c(348L, 289L, 266L, 266L,
234L, 18L, 23L, 23L, 26L, 26L, 27L), CRIND_CC = c(14819L, 15584L,
14117L, 7797L, 8314L, 2159L, 10547L, 1469L, 2670L, 2670L, 17916L
), ISCC = c(39013L, 35961L, 27262L, 25095L, 18718L, 17999L, 28806L,
11611L, 13561L, 13561L, 41721L), EBITDAR = c(76449.15, 72454.42,
49775.02, 28645.95, 46325.12, 20097.99, 52168.07, 7325.45, 14348.98,
14348.98, 69991.1), top_bottom = structure(c(2L, 2L, 2L, 2L,
2L, 1L, 1L, 1L, 1L, 1L, 1L), .Label = c("bottom", "top"), class = "factor"),
Latitude = c(41.731373, 41.589428, 41.559017, 41.6143, 41.6002,
41.636208, 41.56153, 41.20982, 41.614517, 41.6145172, 41.597134
), Longitude = c(-93.58184, -93.80785, -93.77287, -93.834404,
-93.779236, -93.531876, -93.88083, -93.84298, -93.65789,
-93.65789, -93.49263)), .Names = c("Store_ID", "visits",
"CRIND_CC", "ISCC", "EBITDAR", "top_bottom", "Latitude", "Longitude"
), class = "data.frame", row.names = c("1", "2", "3", "4", "5",
"6", "7", "8", "9", "10", "11"))