Related
I have a data like this
df<- structure(list(14, FALSE, c(1, 2, 3, 4, 5, 7, 8, 9, 10, 11, 12,
13, 6), c(0, 0, 0, 0, 0, 6, 6, 6, 6, 6, 6, 6, 0), c(0, 1, 2,
3, 4, 12, 5, 6, 7, 8, 9, 10, 11), c(0, 1, 2, 3, 4, 12, 5, 6,
7, 8, 9, 10, 11), c(0, 0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11,
12, 13), c(0, 6, 6, 6, 6, 6, 6, 13, 13, 13, 13, 13, 13, 13, 13
), list(c(1, 0, 1), structure(list(), names = character(0)),
list(name = c("Bestman", "Tera1", "Tera2", "Tera3", "Tera4",
"Tera5", "Tetra", "Brownie1", "Brownie2", "Brownie3", "Brownie4",
"Brownie5", "Brownie6", "Brownie7")), list()), <environment>), class = "igraph")
I can plot it like this
plot(df)
if I want to remove the label , I can do this
plot(df,vertex.label=NA)
but it removes it for all and I want to keep the core
I want to be able to plot it with ggplot , removing the label on each node but leave the main core label on , remove the line around the circles
Your dput is not directly reproducible (igraphs contain an environment which isn't included in a dput). The graph I can recover has two linked central nodes, each with several child nodes.
We can draw graphs with plentiful customization options using the tidygraph and ggraph packages:
library(ggraph)
library(tidygraph)
library(extrafont)
as_tbl_graph(g) %>%
activate(nodes) %>%
mutate(type = ifelse(name %in% c("Bestman", "Tetra"), "root", "branch")) %>%
mutate(group = ifelse(name == "Bestman" | grepl("Tera", name),
"Bestman", "Tera")) %>%
ggraph(layout = "igraph", algorithm = "nicely") +
geom_edge_link(width = 2, alpha = 0.1) +
geom_node_circle(aes(r = ifelse(type == "root", 0.4, 0.1), fill = group),
color = NA) +
geom_node_text(aes(label = ifelse(type == "root", name, "")), size = 5,
color = "gray40", family = "Roboto Condensed", fontface = 2) +
theme_graph() +
coord_equal() +
scale_fill_brewer(palette = "Pastel2", guide = "none")
Data
network_data <- list(nodes = structure(list(id = c(0, 1, 2, 3, 4, 5, 6, 7, 8,
9, 10, 11, 12, 13, 14), label = c("2892056", "2894543", "2894544",
"2894545", "2894546", "2894547", "2894548", "2894549", "2894550",
"2894551", "2894552", "2894553", "2894554", "2894555", "2894556"
)), row.names = c(NA, -15L), class = "data.frame"), links = structure(list(
from = c(3, 5, 7, 13, 13, 7, 3, 5, 0, 0, 5, 2, 7, 6, 13,
11, 0, 3, 2, 7, 13, 3, 0, 0, 5, 3, 13, 4, 0, 14, 13, 7, 2,
3, 5, 0, 12), to = c(0, 0, 0, 0, 2, 2, 2, 2, 2, 3, 3, 3,
3, 3, 3, 4, 5, 5, 5, 5, 5, 6, 6, 7, 7, 7, 7, 11, 12, 12,
12, 13, 13, 13, 13, 13, 14), weight = c(1, 2, 2, 1, 2, 1,
1, 1, 2, 1, 1, 1, 1, 2, 1, 1, 2, 1, 2, 1, 2, 2, 2, 1, 1,
2, 1, 2, 1, 1, 2, 2, 2, 1, 2, 1, 1)), row.names = c(NA, -37L
), class = "data.frame"))
I have this list of nodes and links for building a network. Rather than plotting the network, I want to get the network characteristics such as isolates, reciprocity, etc.
Here's the rest of the code that I'm using to obtain these characteristics:
network_data$nodes <- network_data$nodes %>% select(id, label)
network_data$links <- network_data$links %>% rename(from = source, to = target)
print(network_data$nodes)
print(network_data$links)
SNA <- tidygraph::tbl_graph(
nodes = network_data$nodes,
edges = network_data$links,
directed = T
)
The last line is where it errors out.
Error in (function (edges, n = max(edges), directed = TRUE) :
At structure_generators.c:86 : Invalid (negative) vertex id, Invalid vertex id
I googled the issue and seems like it's pretty prevalent, but none of the methods suggested worked for me. What's different in my data that it's still generating the error, and how can I resolve this error?
I have a question for you please :
My data :
Nb_obs <- as.vector(c( 2, 0, 6, 2, 7, 1, 8, 0, 2, 1, 1, 3, 11, 5, 9, 6, 4, 0, 7, 9))
Nb_obst <- as.vector(c(31, 35, 35, 35, 39, 39, 39, 39, 39, 41, 41, 42, 43, 43, 45, 45, 47, 48, 51, 51))
inf20 <- as.vector(c(2, 2, 2, 2, 3, 3, 3, 3, 3, 3, 3, 3, 3, 4, 3, 4, 4, 3, 5, 4))
sup20 <- as.vector(c(3, 4, 4, 4, 5, 4, 4, 5, 4, 4, 5, 5, 5, 6, 5, 6, 6, 5, 7, 6))
inf40 <- as.vector(c(1, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 3, 2, 3, 3, 3, 4, 3))
sup40 <- as.vector(c(4, 5, 5, 5, 6, 5, 5, 6, 5, 5, 6, 6, 6, 7, 6, 7, 7, 7, 9, 7))
inf60 <- as.vector(c(1, 1, 1, 1, 2, 1, 1, 1, 1, 1, 1, 1, 2, 2, 2, 2, 2, 2, 3, 2))
sup60 <- as.vector(c(5, 6, 6, 6, 8, 7, 7, 7, 7, 7, 7, 7, 8, 9, 8, 9, 9, 9, 11, 9))
inf90 <- as.vector(c(0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 0, 0, 1, 0, 1, 1))
sup90 <- as.vector(c(10, 11, 11, 11, 15, 13, 13, 14, 12, 13, 13, 13, 14, 17, 15, 17, 17, 16, 21, 18))
data <- cbind.data.frame(Nb_obs, Nb_obst, inf20, sup20, inf40, sup40, inf60 , sup60, inf90 , sup90)
My plot :
plot(data$Nb_obst, data$Nb_obs, type = "n", xlab = "Number obst", ylab = "number obs", ylim = c(0, 25))
lines(data$Nb_obst, data$inf20, col = "dark red")
lines(data$Nb_obst, data$sup20, col = "dark red")
lines(data$Nb_obst, data$inf40, col = "red")
lines(data$Nb_obst, data$sup40, col = "red")
lines(data$Nb_obst, data$inf60, col = "dark orange")
lines(data$Nb_obst, data$sup60, col = "dark orange")
lines(data$Nb_obst, data$inf90, col = "yellow")
lines(data$Nb_obst, data$sup90, col = "yellow")
My question :
There are two things I'd like to do (and so I think it could be done by ggplot):
In the idea of the graph at the top, the "inf" and "sup" are limits of my model in the IC 20%, then 40%, then 60%, and finally 90%. I would first like to smooth each curve, and then I would like to color the surface between two curves of the same IC, for example that the surface between "data$inf90" and "data$sup90" is yellow, the area between "data$inf60" and "data$60" is orange, etc. And I would like to superimpose each of these colored surfaces + put the good legend please.
Thanks for your help !
Cool question since I had to give myself a crash course in using LOESS for ribbons!
First thing I'm doing is getting the data into a long shape, since that's what ggplot will expect, and since your data has some characteristics that are kind of hidden within values. For example, if you gather into a long shape and have, say a column key, with a value of "inf20" and another of "sup20", those hold more information than you currently have access to, i.e. the measure type is either "inf" or "sup", and the level is 20. You can extract that information out of that column to get columns of measure types ("inf" or "sup") and levels (20, 40, 60, or 90), then map aesthetics onto those variables.
So here I'm getting the data into a long shape, then using spread to make columns of inf and sup, because those will become ymin and ymax for the ribbons. I made level a factor and reversed its levels, because I wanted to change the order of the ribbons being drawn such that the narrow one would come up last and be drawn on top.
library(tidyverse)
data_long <- data %>%
as_tibble() %>%
gather(key = key, value = value, -Nb_obs, -Nb_obst) %>%
mutate(measure = str_extract(key, "\\D+")) %>%
mutate(level = str_extract(key, "\\d+")) %>%
select(-key) %>%
group_by(level, measure) %>%
mutate(row = row_number()) %>%
spread(key = measure, value = value) %>%
ungroup() %>%
mutate(level = as.factor(level) %>% fct_rev())
head(data_long)
#> # A tibble: 6 x 6
#> Nb_obs Nb_obst level row inf sup
#> <dbl> <dbl> <fct> <int> <dbl> <dbl>
#> 1 0 35 20 2 2 4
#> 2 0 35 40 2 2 5
#> 3 0 35 60 2 1 6
#> 4 0 35 90 2 0 11
#> 5 0 39 20 8 3 5
#> 6 0 39 40 8 2 6
ggplot(data_long, aes(x = Nb_obst, ymin = inf, ymax = sup, fill = level)) +
geom_ribbon(alpha = 0.6) +
scale_fill_manual(values = c("20" = "darkred", "40" = "red",
"60" = "darkorange", "90" = "yellow")) +
theme_light()
But it still has the issue of being jagged, so for each level I predicted smoothed values of both inf and sup versus Nb_obst using loess. group_by and do yield a nested data frame, and unnest pulls it back out into a workable form. Feel free to adjust the span parameter, as well as other loess.control parameters that I know very little about.
data_smooth <- data_long %>%
group_by(level) %>%
do(Nb_obst = .$Nb_obst,
inf_smooth = predict(loess(.$inf ~ .$Nb_obst, span = 0.35), .$Nb_obst),
sup_smooth = predict(loess(.$sup ~ .$Nb_obst, span = 0.35), .$Nb_obst)) %>%
unnest()
head(data_smooth)
#> # A tibble: 6 x 4
#> level Nb_obst inf_smooth sup_smooth
#> <fct> <dbl> <dbl> <dbl>
#> 1 90 35 0 11.
#> 2 90 39 0 13.4
#> 3 90 48 0.526 16.7
#> 4 90 39 0 13.4
#> 5 90 41 0 13
#> 6 90 41 0 13
ggplot(data_smooth, aes(x = Nb_obst, ymin = inf_smooth, ymax = sup_smooth, fill = level)) +
geom_ribbon(alpha = 0.6) +
scale_fill_manual(values = c("20" = "darkred", "40" = "red",
"60" = "darkorange", "90" = "yellow")) +
theme_light()
Created on 2018-05-26 by the reprex package (v0.2.0).
This produces the plot with shaded areas using base R graphics.
The trick is to pair the x values with the y values.
plot(data$Nb_obst, data$Nb_obs, type = "n", xlab = "Number obst", ylab = "number obs", ylim = c(0, 25))
lines(data$Nb_obst, data$inf20, col = "dark red")
lines(data$Nb_obst, data$sup20, col = "dark red")
lines(data$Nb_obst, data$inf40, col = "red")
lines(data$Nb_obst, data$sup40, col = "red")
lines(data$Nb_obst, data$inf60, col = "dark orange")
lines(data$Nb_obst, data$sup60, col = "dark orange")
lines(data$Nb_obst, data$inf90, col = "yellow")
lines(data$Nb_obst, data$sup90, col = "yellow")
with(data, polygon(c(Nb_obst, rev(Nb_obst)), c(inf90, rev(sup90)), col = "yellow"))
with(data, polygon(c(Nb_obst, rev(Nb_obst)), c(inf60, rev(sup60)), col = "dark orange"))
with(data, polygon(c(Nb_obst, rev(Nb_obst)), c(inf40, rev(sup40)), col = "red"))
with(data, polygon(c(Nb_obst, rev(Nb_obst)), c(inf20, rev(sup20)), col = "dark red"))
The code for a ggplot graph is a bit longer. There is a function geom_ribbon perfect for this.
g <- ggplot(data)
g + geom_ribbon(aes(x = Nb_obst, ymin = sup60, ymax = sup90), fill = "yellow") +
geom_ribbon(aes(x = Nb_obst, ymin = sup40, ymax = sup60), fill = "dark orange") +
geom_ribbon(aes(x = Nb_obst, ymin = sup20, ymax = sup40), fill = "red") +
geom_ribbon(aes(x = Nb_obst, ymin = inf20, ymax = sup20), fill = "dark red") +
geom_ribbon(aes(x = Nb_obst, ymin = inf40, ymax = inf20), fill = "red") +
geom_ribbon(aes(x = Nb_obst, ymin = inf60, ymax = inf40), fill = "dark orange") +
geom_ribbon(aes(x = Nb_obst, ymin = inf90, ymax = inf60), fill = "yellow")
Data.
I will redo your dataset, simplifying its creation. You don't need as.vector and if you are creating a data.frame there is no need for the data.frame method of cbind, data.frame(.) is enough.
Nb_obs <- c( 2, 0, 6, 2, 7, 1, 8, 0, 2, 1, 1, 3, 11, 5, 9, 6, 4, 0, 7, 9)
Nb_obst <- c(31, 35, 35, 35, 39, 39, 39, 39, 39, 41, 41, 42, 43, 43, 45, 45, 47, 48, 51, 51)
inf20 <- c(2, 2, 2, 2, 3, 3, 3, 3, 3, 3, 3, 3, 3, 4, 3, 4, 4, 3, 5, 4)
sup20 <- c(3, 4, 4, 4, 5, 4, 4, 5, 4, 4, 5, 5, 5, 6, 5, 6, 6, 5, 7, 6)
inf40 <- c(1, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 3, 2, 3, 3, 3, 4, 3)
sup40 <- c(4, 5, 5, 5, 6, 5, 5, 6, 5, 5, 6, 6, 6, 7, 6, 7, 7, 7, 9, 7)
inf60 <- c(1, 1, 1, 1, 2, 1, 1, 1, 1, 1, 1, 1, 2, 2, 2, 2, 2, 2, 3, 2)
sup60 <- c(5, 6, 6, 6, 8, 7, 7, 7, 7, 7, 7, 7, 8, 9, 8, 9, 9, 9, 11, 9)
inf90 <- c(0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 0, 0, 1, 0, 1, 1)
sup90 <- c(10, 11, 11, 11, 15, 13, 13, 14, 12, 13, 13, 13, 14, 17, 15, 17, 17, 16, 21, 18)
data <- data.frame(Nb_obs, Nb_obst, inf20, sup20, inf40, sup40, inf60 , sup60, inf90 , sup90)
I have data that looks like:
year mean.streak
1958 2.142857
1959 3.066667
1960 2.166667
1961 2.190476
The code for my plot with localized regression looks like:
ggplot(aes(x = year, y = mean.streak, color = year), data = streaks)+
geom_point(color = 'black')+
geom_smooth(method = 'loess')
and outputs:
I'd like to capture the somewhat sinusoidal pattern of the data by passing a smooth line through all of the data points, rather than the typical jagged geom_line. I tried polynomial interpolation by writing:
ggplot(df)+
geom_point(aes(x = year, y = mean.streak, colour = year), size = 3) +
stat_smooth(aes(x = year, y = mean.streak), method = "lm",
formula = y ~ poly(x, 57), se = FALSE)
Taken from this thread. But I get the error:
Warning message:
Computation failed in `stat_smooth()`:
'degree' must be less than number of unique points
seemingly because there are too many datapoints, as this answer seems to indicate.
Is there a way to pass a smooth line through all the data with 59 data points?
Full data is:
structure(list(year = 1958:2016, mean.streak = c(2.14285714285714,
3.06666666666667, 2.16666666666667, 2.19047619047619, 2.35, 2.42857142857143,
2.28571428571429, 1.92592592592593, 1.69230769230769, 2.61111111111111,
3, 2.94117647058824, 2.2, 2.5, 2.13636363636364, 1.76923076923077,
1.36111111111111, 1.41176470588235, 1.76, 2, 2.63157894736842,
2.08695652173913, 2.86666666666667, 2.125, 3, 3.125, 2.57894736842105,
1.84, 1.46666666666667, 1.7037037037037, 1.625, 1.67741935483871,
1.84, 1.6, 3, 3.11111111111111, 3.66666666666667, 4.18181818181818,
2.85714285714286, 3.66666666666667, 2.66666666666667, 2.92857142857143,
3.1875, 2.76923076923077, 5.375, 5.18181818181818, 4.08333333333333,
6.85714285714286, 2.77777777777778, 2.76470588235294, 3.15384615384615,
3.83333333333333, 3.06666666666667, 3.07692307692308, 4.41666666666667,
4.9, 5.22222222222222, 5, 5.27272727272727), median.streak = c(1,
3, 1.5, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 1, 2, 1, 1, 1, 1, 2,
2, 3, 2, 2, 2.5, 2, 2, 1, 1, 1, 1, 1, 1, 1.5, 2, 4, 4, 1, 3,
2, 2.5, 2, 2, 5.5, 4, 2.5, 9, 2, 2, 2, 1.5, 2, 3, 2.5, 4.5, 4,
5, 4), max.streak = c(6, 6, 9, 7, 5, 5, 7, 4, 3, 7, 9, 7, 6,
6, 6, 4, 3, 4, 4, 10, 8, 6, 6, 5, 10, 8, 5, 6, 3, 4, 4, 4, 4,
5, 8, 8, 11, 8, 8, 11, 10, 5, 12, 7, 10, 12, 12, 10, 7, 10, 10,
14, 9, 7, 9, 12, 10, 14, 12), mean.std = c(-0.73762950487994,
-0.480997734887942, -0.517355702126398, -0.387678832192802, -0.315808940316265,
-0.455313725347534, -0.520453518496716, -0.598412265824216, -0.523171795723798,
-0.62285788065637, -0.54170040191883, -0.590289727314622, -0.468222025966258,
-0.639180735884434, -0.656427002478427, -0.565745564840106, -0.473399411312895,
-0.564475310127763, -0.493531273810312, -0.543209721496256, -0.640240670332106,
-0.510337503791441, -0.596096374402028, -0.504696265560619, -0.620412635042488,
-0.497008319856979, -0.546623513153538, -0.613345407826292, -0.564945850817486,
-0.581770706442245, -0.5709080560492, -0.627986564445679, -0.680973485641403,
-0.548092447365696, -0.554620596559388, -0.483847268000936, -0.67619820292833,
-0.613245144944101, -0.509832316970819, -0.302654541906113, -0.623276311320811,
-0.431421947082012, -0.525548788393688, -0.244995094473986, -0.412444188256097,
-0.112114155982405, -0.299486359079708, -0.300201791042539, -0.240281366191648,
-0.359719754440627, -0.511417389357902, -0.474906675611613, -0.312106332395495,
-0.449137693833681, -0.526248555772371, -0.56052848268042, -0.390017880007091,
-0.537267264953157, -0.444528236868953)), class = c("tbl_df",
"tbl", "data.frame"), .Names = c("year", "mean.streak", "median.streak",
"max.streak", "mean.std"), row.names = c(NA, -59L))
Adjust the span:
ggplot(aes(x = year, y = mean.streak, color = year), data = streaks)+
geom_point(color = 'black')+
stat_smooth(method = 'loess', span = 0.3)
Or use a spline:
library(splines)
ggplot(aes(x = year, y = mean.streak, color = year), data = streaks)+
geom_point(color = 'black')+
stat_smooth(method = 'lm', formula = y ~ ns(x, 10))
Generally, you don't want to fit an extremely high-degree polynomial. Such fits look awful. It would be much better to fit an actual time series model to your data:
library(forecast)
library(zoo)
ggplot(aes(x = year, y = mean.streak, color = year), data = streaks)+
geom_point(color = 'black')+
geom_line(data = data.frame(year = sort(streaks$year),
mean.streak = fitted(auto.arima(zoo(streaks$mean.streak,
order.by = streaks$year)))),
show.legend = FALSE)
I try to plot this visual with ggplot2:
ggplot(Trump_df, aes(x=freq.dif, y=Spacing)) +
geom_text(aes(size=TrumpT.txt, label=row.names(Trump_df),
colour=freq.dif), alpha=0.7, family="Arial") +
geom_text(data=Kasich_df, aes(x=freq.dif, y=Spacing,
label=row.names(Kasich_df), size=KasichT.txt, color=freq.dif),
alpha=0.7, family="Arial") +
geom_text(data=both_df, aes(x=freq.dif, y=Spacing,
label=row.names(both_df), size=TrumpT.txt, color=freq.dif),
alpha=0.7, family="Arial") +
scale_size(range=c(3,11)) +
scale_colour_gradient(low="red3", high="blue3", guide="none") +
scale_x_continuous(breaks=c(min(Kasich_df$freq.dif), 0, max(Trump_df$freq.dif)),
labels=c("Twitted More by Kasich","Twitted Equally","Twitted More by Trump")) +
scale_y_continuous(breaks=c(0), labels=c("")) +
labs(title="Conway's Word Cloud, Tweets (Trump -vs- Kasich)", x="", y="", size="Word Frequency") +
theme_bw() +
theme(panel.grid.major.y = element_line(),
panel.grid.minor.x = element_line(),
plot.title = element_text(family="Arial", size=18)
But get a plot with the axis labels stacked:
Here are my data frames:
dput(df)
>dput(df)
structure(list(TrumpT.txt = c(25, 34, 8, 3, 11, 4, 3, 4, 4, 16,
4, 8, 21, 16, 3, 21, 3, 10, 9, 11, 4, 6, 3, 4, 3, 6, 4, 3, 5,
55), KasichT.txt = c(6, 5, 3, 4, 3, 4, 6, 3, 4, 7, 29, 3, 3,
5, 4, 4, 3, 6, 22, 3, 3, 4, 3, 3, 3, 6, 5, 4, 6, 4), freq.dif = c(19,
29, 5, -1, 8, 0, -3, 1, 0, 9, -25, 5, 18, 11, -1, 17, 0, 4, -13,
8, 1, 2, 0, 1, 0, 0, -1, -1, -1, 51)), .Names = c("TrumpT.txt",
"KasichT.txt", "freq.dif"), row.names = c("america", "amp", "back",
"best", "can", "candidate", "check", "day", "done", "gopdebate",
"john", "join", "just", "make", "nation", "new", "next", "now",
"ohio", "one", "see", "state", "talk", "tax", "thanks", "time",
"today", "voting", "watch", "will"), class = "data.frame")
dput(df$freq.dif)
>dput(df$freq.dif)
c(19, 29, 5, -1, 8, 0, -3, 1, 0, 9, -25, 5, 18, 11, -1, 17, 0,
4, -13, 8, 1, 2, 0, 1, 0, 0, -1, -1, -1, 51)
dput(Trump_df)
>dput(Trump_df)
structure(list(TrumpT.txt = c(3, 3, 4, 3, 9, 4, 3, 5), KasichT.txt = c(4,
6, 29, 4, 22, 5, 4, 6), freq.dif = c(-1, -3, -25, -1, -13, -1,
-1, -1), Spacing = c(-0.4, 0.0249155652709305, -0.184168514423072,
-0.2, 0.0361329583451152, 0, 0.2, 0.4)), .Names = c("TrumpT.txt",
"KasichT.txt", "freq.dif", "Spacing"), row.names = c("best",
"check", "john", "nation", "ohio", "today", "voting", "watch"
), class = "data.frame")
dput(Kasich_df)
>dput(Kasich_df)
structure(list(TrumpT.txt = c(25, 34, 8, 11, 4, 16, 8, 21, 16,
21, 10, 11, 4, 6, 4, 55), KasichT.txt = c(6, 5, 3, 3, 3, 7, 3,
3, 5, 4, 6, 3, 3, 4, 3, 4), freq.dif = c(19, 29, 5, 8, 1, 9,
5, 18, 11, 17, 4, 8, 1, 2, 1, 51), Spacing = c(-0.171893353201449,
0.113299035839736, -0.5, -0.5, -0.333333333333333, 0.0629540653899312,
0.5, -0.161544232908636, 0.166435130592436, 0.193869082257152,
0.0795861765742302, 0.5, 0, -0.139369543548673, 0.333333333333333,
0.117351376824081)), .Names = c("TrumpT.txt", "KasichT.txt",
"freq.dif", "Spacing"), row.names = c("america", "amp", "back",
"can", "day", "gopdebate", "join", "just", "make", "new", "now",
"one", "see", "state", "tax", "will"), class = "data.frame")
dput(both_df)
>dput(both_df)
structure(list(TrumpT.txt = c(4, 4, 3, 3, 3, 6), KasichT.txt = c(4,
4, 3, 3, 3, 6), freq.dif = c(0, 0, 0, 0, 0, 0), Spacing = c(-0.833333333333333,
-0.5, -0.166666666666667, 0.166666666666667, 0.5, 0.833333333333333)), .Names = c("TrumpT.txt", "KasichT.txt", "freq.dif", "Spacing"),
row.names = c("candidate", "done", "next", "talk", "thanks",
"time"), class = "data.frame")
I would like to have "Twitted More by Kasich" on the far left, "Twitted Equally" in the middle, and "Twitted More by Trump" on the far right. I have tried messing with the scale, but what I'm doing doesn't seem to work. I'd appreciate any help.