Related
I have a cleaned data set with 26 nodes. I am placing these 26 nodes in an undirected network graph using tidygraph, where I use the centrality_degree() function to calculate the centrality degree. However, when I graph the resulting network, my highest possible centrality degree is 40, which should not be possible. When I change the graph to directed, this is corrected.
I somewhat confused, as other methods I have used in the past, where I manually calculated the centrality degree, I have never once come across this issue.
Is this regular behaviour, or am I doing something wrong?
Reproducible example:
library(tidygraph)
library(ggraph)
library(tidyverse)
nodes <- structure(list(id = 1:26, label = c("a", "b", "c", "d", "e",
"f", "g", "h", "i", "j", "k", "l", "m", "n", "o", "p", "q", "r",
"s", "t", "u", "v", "w", "x", "y", "z")), row.names = c(NA, -26L
), class = "data.frame")
edges <- structure(list(from = c(21L, 21L, 21L, 21L, 21L, 21L, 21L, 21L,
21L, 21L, 21L, 11L, 11L, 11L, 11L, 11L, 11L, 11L, 11L, 11L, 11L,
11L, 11L, 11L, 11L, 11L, 11L, 11L, 11L, 11L, 1L, 1L, 1L, 1L,
1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 12L, 12L,
12L, 12L, 12L, 12L, 12L, 12L, 12L, 12L, 12L, 12L, 12L, 12L, 12L,
12L, 12L, 13L, 13L, 13L, 13L, 13L, 13L, 13L, 13L, 13L, 13L, 13L,
13L, 13L, 13L, 13L, 13L, 13L, 13L, 3L, 3L, 3L, 3L, 3L, 3L, 3L,
3L, 3L, 3L, 3L, 3L, 3L, 3L, 3L, 3L, 3L, 3L, 3L, 3L, 3L, 18L,
18L, 18L, 18L, 18L, 18L, 18L, 16L, 16L, 16L, 16L, 16L, 16L, 16L,
16L, 16L, 16L, 16L, 16L, 16L, 16L, 16L, 16L, 16L, 16L, 16L, 24L,
24L, 24L, 24L, 24L, 24L, 24L, 24L, 24L, 24L, 24L, 24L, 24L, 24L,
24L, 24L, 24L, 24L, 24L, 5L, 5L, 5L, 5L, 5L, 5L, 5L, 5L, 5L,
5L, 5L, 5L, 5L, 5L, 5L, 5L, 7L, 7L, 7L, 7L, 7L, 7L, 7L, 7L, 7L,
7L, 7L, 7L, 7L, 7L, 7L, 7L, 7L, 7L, 7L, 7L, 14L, 14L, 14L, 14L,
14L, 14L, 14L, 14L, 14L, 14L, 14L, 14L, 14L, 14L, 14L, 4L, 4L,
4L, 4L, 4L, 4L, 4L, 4L, 4L, 4L, 4L, 4L, 4L, 4L, 4L, 4L, 4L, 4L,
4L, 4L, 4L, 4L, 10L, 10L, 10L, 10L, 10L, 10L, 10L, 10L, 10L,
10L, 10L, 10L, 10L, 10L, 10L, 10L, 10L, 10L, 10L, 10L, 10L, 10L,
6L, 6L, 6L, 6L, 6L, 6L, 6L, 6L, 6L, 6L, 6L, 6L, 6L, 6L, 6L, 6L,
6L, 6L, 6L, 6L, 25L, 25L, 25L, 25L, 25L, 25L, 25L, 25L, 25L,
25L, 25L, 25L, 9L, 9L, 9L, 9L, 9L, 9L, 9L, 9L, 9L, 9L, 9L, 9L,
9L, 9L, 9L, 22L, 22L, 22L, 22L, 22L, 22L, 22L, 22L, 22L, 22L,
22L, 22L, 22L, 22L, 22L, 22L, 22L, 22L, 22L, 22L, 15L, 15L, 15L,
15L, 15L, 15L, 15L, 15L, 15L, 15L, 15L, 15L, 15L, 15L, 15L, 15L,
15L, 2L, 2L, 2L, 2L, 2L, 2L, 2L, 2L, 2L, 2L, 2L, 2L, 2L, 2L,
2L, 2L, 2L, 2L, 2L, 2L, 2L, 20L, 20L, 20L, 20L, 20L, 20L, 20L,
20L, 20L, 20L, 20L, 20L, 8L, 8L, 8L, 8L, 8L, 8L, 8L, 8L, 8L,
8L, 8L, 8L, 8L, 8L, 8L, 8L, 8L, 8L, 17L, 17L, 17L, 17L, 17L),
to = c(1L, 12L, 3L, 16L, 24L, 4L, 10L, 6L, 22L, 2L, 8L, 1L,
12L, 13L, 3L, 18L, 16L, 24L, 5L, 7L, 14L, 4L, 10L, 6L, 9L,
22L, 15L, 2L, 20L, 8L, 21L, 12L, 13L, 3L, 16L, 24L, 5L, 7L,
14L, 4L, 10L, 6L, 22L, 15L, 2L, 8L, 17L, 21L, 1L, 13L, 3L,
16L, 5L, 7L, 14L, 10L, 6L, 9L, 22L, 15L, 2L, 20L, 8L, 17L,
21L, 1L, 3L, 18L, 16L, 5L, 7L, 14L, 4L, 10L, 6L, 25L, 9L,
22L, 15L, 20L, 8L, 17L, 21L, 11L, 1L, 12L, 13L, 18L, 16L,
24L, 5L, 7L, 14L, 4L, 10L, 6L, 25L, 9L, 22L, 15L, 20L, 8L,
17L, 1L, 3L, 10L, 6L, 22L, 20L, 8L, 21L, 11L, 1L, 13L, 3L,
18L, 24L, 7L, 4L, 10L, 6L, 25L, 9L, 22L, 15L, 2L, 20L, 8L,
17L, 21L, 11L, 1L, 12L, 13L, 18L, 16L, 5L, 7L, 14L, 10L,
6L, 25L, 9L, 22L, 15L, 20L, 8L, 17L, 1L, 3L, 18L, 16L, 7L,
14L, 4L, 10L, 6L, 9L, 22L, 15L, 2L, 20L, 8L, 17L, 21L, 11L,
1L, 12L, 13L, 3L, 18L, 16L, 24L, 14L, 4L, 10L, 6L, 25L, 9L,
22L, 15L, 2L, 20L, 8L, 11L, 1L, 3L, 18L, 16L, 7L, 10L, 6L,
9L, 22L, 15L, 2L, 20L, 8L, 17L, 21L, 11L, 1L, 12L, 13L, 3L,
18L, 16L, 24L, 5L, 7L, 14L, 10L, 6L, 25L, 9L, 22L, 15L, 2L,
20L, 8L, 17L, 21L, 11L, 1L, 12L, 13L, 3L, 18L, 16L, 24L,
5L, 7L, 14L, 4L, 6L, 25L, 9L, 22L, 15L, 2L, 20L, 8L, 17L,
21L, 11L, 1L, 12L, 13L, 3L, 18L, 24L, 5L, 7L, 14L, 4L, 10L,
25L, 9L, 22L, 15L, 2L, 20L, 8L, 21L, 1L, 13L, 3L, 18L, 5L,
10L, 6L, 22L, 2L, 20L, 8L, 21L, 1L, 13L, 3L, 18L, 16L, 24L,
4L, 10L, 6L, 22L, 15L, 2L, 20L, 8L, 11L, 1L, 12L, 13L, 3L,
16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L, 1L,
15L, 4L, 7L, 3L, 1L, 4L, 12L, 8L, 1L, 9L, 32L, 3L, 7L, 5L,
35L, 1L, 1L, 3L, 1L, 6L, 4L, 4L, 12L, 2L, 5L, 4L, 2L, 2L,
9L, 1L, 2L, 3L, 4L, 9L, 13L, 2L, 1L, 25L, 25L, 10L, 14L,
10L, 4L, 59L, 4L, 5L, 21L, 19L, 1L, 8L, 27L, 3L, 5L, 8L,
8L, 11L, 12L, 111L, 5L, 50L, 45L, 15L, 32L, 10L, 49L, 109L,
1L, 8L, 28L, 39L, 53L, 13L, 48L, 5L, 13L, 2L, 20L, 3L, 3L,
27L, 10L, 8L, 1L, 58L, 1L, 7L, 32L, 13L, 21L, 110L, 1L, 17L,
27L, 124L, 1L, 1L, 1L, 2L, 3L, 1L, 1L, 2L, 7L, 1L, 1L, 1L,
2L, 2L, 1L, 5L, 2L, 2L, 2L, 1L, 3L, 3L, 14L, 2L, 2L, 4L,
1L, 3L, 14L, 5L, 8L, 44L, 16L, 14L, 4L, 12L, 4L, 19L, 41L,
47L, 2L, 1L, 11L, 24L, 2L, 18L, 1L, 7L, 5L, 1L, 7L, 3L, 27L,
3L, 15L, 7L, 54L, 1L, 4L, 17L, 5L, 6L, 27L, 1L, 1L, 2L, 3L,
4L, 10L, 56L, 3L, 25L, 25L, 7L, 16L, 5L, 29L, 59L, 3L, 3L,
20L, 17L, 5L, 31L, 3L, 6L, 1L, 4L, 7L, 1L, 3L, 1L, 6L, 5L,
13L, 1L, 2L, 9L, 1L, 15L, 2L, 1L, 16L, 4L, 4L, 3L, 1L, 6L,
17L, 10L, 1L, 13L, 63L, 11L, 12L, 1L, 5L, 1L, 2L, 3L)), row.names = c(NA,
-383L), class = c("tbl_df", "tbl", "data.frame"))
routes_tidy <- tbl_graph(nodes=nodes, edges=edges, directed=FALSE) %>% mutate(neighbors = centrality_degree())
# Filtering out 3 nodes out of the graph as they have no connections and zoom the figure way out
ggraph(routes_tidy, layout="graphopt") +
geom_node_point(aes(size=neighbors, filter=(label!="z" & label!="s" & label!="w"))) +
geom_edge_link(aes(width=weight, alpha=weight)) +
scale_edge_width(range=c(0.2, 2)) +
geom_node_text(aes(label=label, fontface="bold", size=neighbors, filter=(label!="z" & label!="s" & label!="w")), repel=TRUE) +
labs(edge_width="N") +
theme_graph()
I'm new to the whole tidygraph thing, stumbled over this question, got confused, and figured it'd be a nice way to get to know stuff. So, I don't know if it's a bug or a feature, but the behaviour is triggered because you have doubled edges:
# Given your edges
edges %>%
filter((from == 1 & to == 2) | from == 2 & to == 1)
# A tibble: 2 x 3
from to weight
<int> <int> <int>
1 1 2 11
2 2 1 3
And those count as 2 connections in the calculation of the degree centrality. One way to remove those double edges is to convert the network to a simple network:
routes_simple <-
routes_tidy %>%
morph(to_simple) %>%
crystallise() %>%
pull(graph) %>%
getElement(1) %>%
activate(nodes) %>%
mutate(neighbors = centrality_degree())
Now the maximum degree is 22 (and the heighest possible, presumably, 25).
I m looking to calculate cumulative returns based on column values for each quarter grouped by investors. I tried using Return.cumulative but didn't get any success.
I appreciate if someone can help me with some easy way to calculate cumulative return in R?
structure(list(Quarter = structure(c(1L, 2L, 3L, 4L, 5L, 6L,
7L, 8L, 9L, 10L, 11L, 12L, 13L, 14L, 15L, 16L, 17L, 18L, 19L,
20L, 1L, 2L, 3L, 4L, 5L, 6L, 7L, 8L, 9L, 10L, 11L, 12L, 13L,
14L, 15L, 16L, 17L, 18L, 19L, 20L, 1L, 2L, 3L, 4L, 5L, 6L, 7L,
8L, 9L, 10L, 11L, 12L, 13L, 14L, 15L, 16L, 17L, 18L, 19L, 20L,
1L, 2L, 3L, 4L, 5L, 6L, 7L, 8L, 9L, 10L, 11L, 12L, 13L, 14L,
15L, 16L, 17L, 18L, 19L, 20L, 1L, 2L, 3L, 4L, 5L, 6L, 7L, 8L,
9L, 10L, 11L, 12L, 13L, 14L, 15L, 16L, 17L, 18L, 19L, 20L, 1L,
2L, 3L, 4L, 5L, 6L, 7L, 8L, 9L, 10L, 11L, 12L, 13L, 14L, 15L,
16L, 17L, 18L, 19L, 20L), .Label = c("2012Q1", "2012Q2", "2012Q3",
"2012Q4", "2013Q1", "2013Q2", "2013Q3", "2013Q4", "2014Q1", "2014Q2",
"2014Q3", "2014Q4", "2015Q1", "2015Q2", "2015Q3", "2015Q4", "2016Q1",
"2016Q2", "2016Q3", "2016Q4"), class = "factor"), Total_Return = c(0.040561972,
0.012692509, 0.053079761, 0.048656856, 0.037110412, 0.041422455,
0.052373109, 0.049826591, 0.053255331, 0.050956964, 0.038683073,
0.018446161, 0.039546641, 0.057108385, 0.020790648, 0.020743042,
0.015486459, 0.001202289, 0.066082963, 0.036178889, 0.037096464,
0.003068485, 0.026307213, 0.052918456, 0.019292362, 0.058390755,
0.040255949, 0.020420614, 0.024955646, 0.051180526, 0.04598829,
0.012425778, 0.036190369, 0.079480322, 0.00574259, 0.026401296,
0.018309495, 0.004887553, 0.05935355, 0.051702238, 0.080892981,
0.07076032, 0.088251171, 0.045903253, 0.029692483, 0.058297815,
0.065338687, 0.071947108, 0.074878083, 0.03989637, -0.031255434,
0.029883299, 0.008148657, 0.078836907, 0.030064965, 0.048887451,
0.034827005, -0.065304898, 0.136766281, 0.019039148, 0.075818622,
0.037509338, 0.060238115, 0.03877549, 0.027433037, 0.033627931,
0.053488836, 0.024999278, 0.016037836, 0.011863841, -0.02610323,
0.046568702, 0.021033516, 0.052322078, 0.038724408, 0.023703685,
0.013482776, 0.018159864, 0.01098064, 0.014761168, 0.010590211,
0.001237805, 0.097323777, 0.088712748, 0.034759189, 0.022507656,
0.036512294, 0.048105471, 0.030822456, 0.07172102, 0.029038233,
0.032163273, 0.015176988, 0.041039802, -0.006245358, 0.049354849,
0.00318641, 0.012988646, 0.053365281, 0.03352103, 0.030454118,
-0.011862117, 0.015271336, 0.036371973, 0.045939313, 0.047864175,
0.053764664, 0.055199293, 0.072631781, 0.063949369, 0.09113885,
0.012533175, 0.049910727, 0.055676551, 0.008841404, 0.01962578,
0.015040302, 0.020496695, 0.054345313, 0.052533934), Investor = structure(c(1L,
1L, 1L, 1L, 1L, 1L, 1L, 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, 2L,
2L, 2L, 2L, 2L, 2L, 2L, 2L, 5L, 5L, 5L, 5L, 5L, 5L, 5L, 5L, 5L,
5L, 5L, 5L, 5L, 5L, 5L, 5L, 5L, 5L, 5L, 5L, 6L, 6L, 6L, 6L, 6L,
6L, 6L, 6L, 6L, 6L, 6L, 6L, 6L, 6L, 6L, 6L, 6L, 6L, 6L, 6L, 3L,
3L, 3L, 3L, 3L, 3L, 3L, 3L, 3L, 3L, 3L, 3L, 3L, 3L, 3L, 3L, 3L,
3L, 3L, 3L, 4L, 4L, 4L, 4L, 4L, 4L, 4L, 4L, 4L, 4L, 4L, 4L, 4L,
4L, 4L, 4L, 4L, 4L, 4L, 4L), .Label = c("Active", "Total", "America",
"Africa", "China", "Europe"), class = "factor"), Date = structure(c(6L,
11L, 16L, 1L, 7L, 12L, 17L, 2L, 8L, 13L, 18L, 3L, 9L, 14L, 19L,
4L, 10L, 15L, 20L, 5L, 6L, 11L, 16L, 1L, 7L, 12L, 17L, 2L, 8L,
13L, 18L, 3L, 9L, 14L, 19L, 4L, 10L, 15L, 20L, 5L, 6L, 11L, 16L,
1L, 7L, 12L, 17L, 2L, 8L, 13L, 18L, 3L, 9L, 14L, 19L, 4L, 10L,
15L, 20L, 5L, 6L, 11L, 16L, 1L, 7L, 12L, 17L, 2L, 8L, 13L, 18L,
3L, 9L, 14L, 19L, 4L, 10L, 15L, 20L, 5L, 6L, 11L, 16L, 1L, 7L,
12L, 17L, 2L, 8L, 13L, 18L, 3L, 9L, 14L, 19L, 4L, 10L, 15L, 20L,
5L, 6L, 11L, 16L, 1L, 7L, 12L, 17L, 2L, 8L, 13L, 18L, 3L, 9L,
14L, 19L, 4L, 10L, 15L, 20L, 5L), .Label = c("12/1/2012", "12/1/2013",
"12/1/2014", "12/1/2015", "12/1/2016", "3/1/2012", "3/1/2013",
"3/1/2014", "3/1/2015", "3/1/2016", "6/1/2012", "6/1/2013", "6/1/2014",
"6/1/2015", "6/1/2016", "9/1/2012", "9/1/2013", "9/1/2014", "9/1/2015",
"9/1/2016"), class = "factor")), class = "data.frame", row.names = c(NA,
-120L))
library(tidyverse)
df %>%
arrange(Investor, Date) %>%
group_by(Investor) %>%
mutate(return_coef = 1 + Total_Return,
return_coef_cuml = cumprod(return_coef),
return_cuml = return_coef_cuml - 1) %>%
ungroup()
# A tibble: 120 x 7
# Groups: Investor [6]
Quarter Total_Return Investor Date return_coef return_coef_cuml return_cuml
<fct> <dbl> <fct> <fct> <dbl> <dbl> <dbl>
1 2012Q4 0.0487 Active 12/1/2012 1.05 1.05 0.0487
2 2013Q4 0.0498 Active 12/1/2013 1.05 1.10 0.101
3 2014Q4 0.0184 Active 12/1/2014 1.02 1.12 0.121
4 2015Q4 0.0207 Active 12/1/2015 1.02 1.14 0.144
5 2016Q4 0.0362 Active 12/1/2016 1.04 1.19 0.186
6 2012Q1 0.0406 Active 3/1/2012 1.04 1.23 0.234
7 2013Q1 0.0371 Active 3/1/2013 1.04 1.28 0.280
8 2014Q1 0.0533 Active 3/1/2014 1.05 1.35 0.348
9 2015Q1 0.0395 Active 3/1/2015 1.04 1.40 0.401
10 2016Q1 0.0155 Active 3/1/2016 1.02 1.42 0.423
I am having a dataframe of 2 variables
structure(list(X1 = structure(c(17L, 27L, 6L, 1L, 28L, 1L, 1L,4L, 17L, 28L, 28L, 12L, 21L, 28L, 28L, 8L, 28L, 1L, 1L, 10L, 4L, 21L, 30L, 1L, 8L, 28L, 1L, 1L, 1L, 1L, 8L, 1L, 17L, 1L, 1L, 28L, 8L, 23L, 15L, 23L, 25L, 13L, 8L, 4L, 28L, 10L, 1L, 30L, 13L, 4L, 1L, 1L, 17L, 13L, 13L, 8L, 4L, 4L, 4L, 28L, 28L, 13L,1L, 4L, 28L, 1L, 1L, 1L, 1L, 1L, 12L, 2L, 6L, 1L, 8L, 1L, 21L, 1L, 21L, 1L, 30L,13L, 25L, 17L, 1L, 28L, 13L, 1L, 1L, 1L, 1L,8L, 30L, 25L, 28L, 4L, 1L, 13L, 17L, 4L,1L, 1L, 28L, 1L, 1L, 8L, 1L, 8L, 1L, 13L, 1L, 1L, 1L, 4L, 6L, 1L, 1L, 30L,1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 6L, 6L, 1L, 15L, 21L, 10L, 21L, 1L, 10L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 28L, 28L, 1L, 30L, 15L, 25L, 6L, 17L, 25L, 15L, 8L, 18L, 22L, 14L, 22L, 28L, 30L, 3L, 30L, 14L, 18L, 22L, 24L, 10L, 26L, 26L, 18L, 26L, 30L, 29L, 18L, 14L, 9L, 9L, 16L, 16L, 29L, 18L, 16L, 27L, 24L, 14L, 26L, 5L, 22L, 28L, 22L, 11L, 9L, 26L, 30L, 18L, 28L, 16L, 26L, 7L, 30L, 7L, 28L, 5L, 18L, 9L, 26L, 24L, 27L, 16L, 16L, 14L, 26L, 29L, 5L, 22L, 24L, 26L, 18L, 27L, 9L, 18L, 11L, 14L, 18L, 22L, 29L, 26L, 22L, 26L, 20L, 24L, 14L, 7L, 16L, 24L, 26L, 29L, 24L, 24L, 24L, 20L, 20L, 24L, 11L, 20L, 29L, 16L, 18L, 24L, 24L, 7L, 24L, 18L, 11L, 11L, 24L, 24L, 7L, 11L, 18L, 24L, 24L, 16L, 29L, 7L, 30L, 24L, 22L, 24L, 18L, 26L, 9L, 9L, 24L, 29L, 9L, 24L, 30L, 11L, 24L, 16L, 26L, 26L, 26L, 30L, 26L, 16L, 26L, 24L, 29L, 20L, 24L, 14L, 9L, 7L, 29L, 29L, 15L, 6L, 15L, 2L, 6L, 6L, 3L, 2L, 17L, 30L, 27L, 23L, 2L, 15L, 8L, 13L, 21L, 28L, 23L, 25L, 1L, 25L, 19L, 27L, 23L, 15L, 19L, 19L, 23L, 2L, 27L, 27L, 15L, 2L, 2L, 3L, 23L, 2L, 23L, 6L, 2L, 15L, 13L,1L, 1L, 13L, 28L, 1L, 1L, 28L, 21L, 1L, 28L, 4L, 1L, 17L, 17L, 13L, 21L, 1L, 1L, 1L, 17L, 1L, 1L, 17L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 13L, 1L, 1L, 1L, 1L, 8L,25L, 1L, 28L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 8L, 4L, 1L, 25L, 28L, 13L, 1L, 1L, 28L, 1L, 4L, 1L, 1L, 8L, 1L, 8L, 13L, 4L, 28L, 21L, 28L, 28L, 28L, 28L, 28L, 8L, 1L, 1L, 1L, 1L, 13L, 21L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 28L, 4L, 1L, 17L, 17L, 28L, 1L, 13L, 8L, 17L, 1L, 13L, 13L, 8L, 4L, 1L, 17L, 25L, 1L, 1L, 8L, 8L, 1L, 4L, 17L, 21L),
.Label = c("<8", ">1024", "1024", "11", "11.000000000000007", "128", "128.00000000000009", "16", "16.000000000000007", "181", "181.00000000000006", "22", "23", "23.000000000000011", "256", "256.00000000000017", "32", "32.000000000000014", "362", "362.00000000000017", "45", "45.000000000000014", "512", "512.00000000000045", "64", "64.000000000000028", "724", "8", "8.0000000000000018", "90"),
class = "factor"),
X2 = structure(c(7L, 2L, 2L, 8L, 18L, 4L, 13L, 18L, 8L, 13L, 8L, 18L, 12L, 13L, 18L, 16L, 7L, 5L, 1L, 16L, 18L, 18L, 18L, 12L, 7L, 1L, 4L, 4L, 2L,16L, 12L, 12L, 2L, 2L, 13L, 13L, 18L, 2L, 16L, 2L, 16L, 16L, 2L, 12L, 16L, 2L, 12L,2L, 2L, 16L, 16L, 2L, 2L, 2L, 2L, 2L, 7L, 18L, 18L, 18L, 13L, 18L, 13L, 18L, 9L, 13L, 8L, 4L, 1L, 13L, 8L, 2L, 16L, 12L, 7L, 7L, 18L, 18L, 18L, 12L, 16L, 7L, 16L, 7L, 12L, 12L, 16L, 12L, 13L, 13L, 12L, 16L, 12L, 12L, 7L, 7L, 13L,16L, 7L, 18L, 16L, 13L, 18L, 4L, 12L, 7L, 4L, 18L, 18L, 18L, 9L, 17L, 13L, 7L, 12L, 7L, 18L, 12L, 18L, 13L, 9L, 1L, 18L, 1L, 13L, 13L, 13L, 1L, 1L, 13L, 12L, 4L, 1L,1L, 4L, 12L, 9L, 1L, 1L, 1L, 2L, 12L, 9L, 2L, 18L, 2L, 18L, 7L, 12L, 1L, 9L, 9L, 7L, 18L, 9L, 18L, 1L, 12L, 13L, 12L, 16L, 7L, 12L, 7L, 16L, 2L, 12L,7L, 16L, 12L, 16L, 2L, 12L, 2L, 15L, 7L, 7L, 2L, 7L, 3L, 12L, 16L, 1L, 17L, 2L, 18L, 5L, 7L, 1L, 16L, 7L, 10L, 1L, 12L, 18L, 16L, 16L, 13L, 12L, 7L, 2L, 1L, 9L, 18L, 12L, 13L, 2L, 2L, 12L, 2L, 2L, 2L, 16L, 2L, 1L, 18L, 12L, 7L, 2L, 2L, 12L, 7L, 12L, 4L, 2L, 18L, 13L, 2L, 16L, 7L, 2L, 2L, 12L, 2L, 14L, 12L, 12L, 16L, 1L, 2L, 4L, 2L, 2L, 2L, 17L, 2L, 2L, 2L, 18L, 16L, 2L, 2L, 2L, 2L, 2L, 2L, 3L, 12L, 2L, 2L, 1L, 2L, 12L, 18L, 2L, 15L, 16L, 16L, 2L, 2L, 2L, 2L, 11L, 12L, 14L, 2L, 2L, 2L, 2L, 2L, 2L, 2L, 2L, 2L, 2L, 2L, 16L, 16L, 12L, 2L, 12L, 2L, 2L, 2L, 12L, 2L,16L, 2L, 12L, 14L, 7L, 2L, 4L, 14L, 2L, 16L, 15L, 7L, 16L, 18L, 2L, 16L, 2L, 2L, 12L, 12L, 2L, 2L, 4L, 2L, 2L, 2L, 16L, 2L, 12L,18L, 3L, 16L, 2L, 2L, 13L, 2L, 2L, 2L, 2L, 2L, 2L, 2L, 2L, 2L, 2L, 2L, 2L, 2L, 2L, 2L, 2L, 2L, 16L, 16L, 2L, 2L, 4L, 4L, 11L, 13L, 4L, 4L, 8L, 4L, 13L, 1L, 4L, 1L, 1L, 2L, 2L, 11L, 18L, 8L, 8L, 4L, 7L, 8L, 4L, 8L, 4L, 4L, 8L, 8L, 1L, 4L, 8L, 4L, 13L, 1L, 6L, 1L, 17L, 2L, 2L, 8L, 18L, 8L, 8L, 4L, 7L, 8L, 17L, 8L, 4L, 1L, 4L, 13L, 1L, 2L, 4L, 16L, 13L, 4L, 4L, 17L, 4L, 7L, 4L, 4L, 1L, 1L, 4L, 1L, 17L, 8L, 1L, 8L, 1L, 4L, 1L, 8L, 8L, 8L, 1L, 13L, 16L, 16L, 17L, 8L, 13L, 1L, 4L, 7L, 1L, 1L, 4L, 4L, 8L, 6L, 4L, 1L, 12L, 13L, 8L, 4L, 4L, 18L, 2L, 4L, 8L, 13L, 17L,13L, 18L, 7L, 16L, 7L, 1L, 13L, 8L, 13L, 4L, 1L, 7L),
.Label = c("<8", ">1024", "1024", "11", "128", "16", "181", "22", "23", "256", "32", "362", "45", "512", "64", "724", "8", "90"), class = "factor")),
.Names = c("X1", "X2"),
row.names = c(NA, -471L),
class = "data.frame")
I have 2 questions
1) Each one is having some greater than values and some with less than values. i want to remove the > and < characters from data frame and retain only the number in the dataframe. I can do it in excel but i want to learn the code for learning it in R.
2) I want to reduce the number of decimals to integer/whole number as some are having more number of decimals.
It may be a small question, but i am struggling to do this. i highly appreciate for this help.
You can use dplyr::mutate_all and stringr::str_replace_all.
Decimals are directly approximated by as.numeric since it is ~10^(-13)magnitude.
your_df <- structure(list(X1 = structure(c(17L, 27L, 6L, 1L, 28L, 1L, 1L,4L, 17L, 28L, 28L, 12L, 21L, 28L, 28L, 8L, 28L, 1L, 1L, 10L, 4L, 21L, 30L, 1L, 8L, 28L, 1L, 1L, 1L, 1L, 8L, 1L, 17L, 1L, 1L, 28L, 8L, 23L, 15L, 23L, 25L, 13L, 8L, 4L, 28L, 10L, 1L, 30L, 13L, 4L, 1L, 1L, 17L, 13L, 13L, 8L, 4L, 4L, 4L, 28L, 28L, 13L,1L, 4L, 28L, 1L, 1L, 1L, 1L, 1L, 12L, 2L, 6L, 1L, 8L, 1L, 21L, 1L, 21L, 1L, 30L,13L, 25L, 17L, 1L, 28L, 13L, 1L, 1L, 1L, 1L,8L, 30L, 25L, 28L, 4L, 1L, 13L, 17L, 4L,1L, 1L, 28L, 1L, 1L, 8L, 1L, 8L, 1L, 13L, 1L, 1L, 1L, 4L, 6L, 1L, 1L, 30L,1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 6L, 6L, 1L, 15L, 21L, 10L, 21L, 1L, 10L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 28L, 28L, 1L, 30L, 15L, 25L, 6L, 17L, 25L, 15L, 8L, 18L, 22L, 14L, 22L, 28L, 30L, 3L, 30L, 14L, 18L, 22L, 24L, 10L, 26L, 26L, 18L, 26L, 30L, 29L, 18L, 14L, 9L, 9L, 16L, 16L, 29L, 18L, 16L, 27L, 24L, 14L, 26L, 5L, 22L, 28L, 22L, 11L, 9L, 26L, 30L, 18L, 28L, 16L, 26L, 7L, 30L, 7L, 28L, 5L, 18L, 9L, 26L, 24L, 27L, 16L, 16L, 14L, 26L, 29L, 5L, 22L, 24L, 26L, 18L, 27L, 9L, 18L, 11L, 14L, 18L, 22L, 29L, 26L, 22L, 26L, 20L, 24L, 14L, 7L, 16L, 24L, 26L, 29L, 24L, 24L, 24L, 20L, 20L, 24L, 11L, 20L, 29L, 16L, 18L, 24L, 24L, 7L, 24L, 18L, 11L, 11L, 24L, 24L, 7L, 11L, 18L, 24L, 24L, 16L, 29L, 7L, 30L, 24L, 22L, 24L, 18L, 26L, 9L, 9L, 24L, 29L, 9L, 24L, 30L, 11L, 24L, 16L, 26L, 26L, 26L, 30L, 26L, 16L, 26L, 24L, 29L, 20L, 24L, 14L, 9L, 7L, 29L, 29L, 15L, 6L, 15L, 2L, 6L, 6L, 3L, 2L, 17L, 30L, 27L, 23L, 2L, 15L, 8L, 13L, 21L, 28L, 23L, 25L, 1L, 25L, 19L, 27L, 23L, 15L, 19L, 19L, 23L, 2L, 27L, 27L, 15L, 2L, 2L, 3L, 23L, 2L, 23L, 6L, 2L, 15L, 13L,1L, 1L, 13L, 28L, 1L, 1L, 28L, 21L, 1L, 28L, 4L, 1L, 17L, 17L, 13L, 21L, 1L, 1L, 1L, 17L, 1L, 1L, 17L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 13L, 1L, 1L, 1L, 1L, 8L,25L, 1L, 28L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 8L, 4L, 1L, 25L, 28L, 13L, 1L, 1L, 28L, 1L, 4L, 1L, 1L, 8L, 1L, 8L, 13L, 4L, 28L, 21L, 28L, 28L, 28L, 28L, 28L, 8L, 1L, 1L, 1L, 1L, 13L, 21L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 28L, 4L, 1L, 17L, 17L, 28L, 1L, 13L, 8L, 17L, 1L, 13L, 13L, 8L, 4L, 1L, 17L, 25L, 1L, 1L, 8L, 8L, 1L, 4L, 17L, 21L), .Label = c("<8", ">1024", "1024", "11", "11.000000000000007", "128", "128.00000000000009", "16", "16.000000000000007", "181", "181.00000000000006", "22", "23", "23.000000000000011", "256", "256.00000000000017", "32", "32.000000000000014", "362", "362.00000000000017", "45", "45.000000000000014", "512", "512.00000000000045", "64", "64.000000000000028", "724", "8", "8.0000000000000018", "90"), class = "factor"), X2 = structure(c(7L, 2L, 2L, 8L, 18L, 4L, 13L, 18L, 8L, 13L, 8L, 18L, 12L, 13L, 18L, 16L, 7L, 5L, 1L, 16L, 18L, 18L, 18L, 12L, 7L, 1L, 4L, 4L, 2L,16L, 12L, 12L, 2L, 2L, 13L, 13L, 18L, 2L, 16L, 2L, 16L, 16L, 2L, 12L, 16L, 2L, 12L,2L, 2L, 16L, 16L, 2L, 2L, 2L, 2L, 2L, 7L, 18L, 18L, 18L, 13L, 18L, 13L, 18L, 9L, 13L, 8L, 4L, 1L, 13L, 8L, 2L, 16L, 12L, 7L, 7L, 18L, 18L, 18L, 12L, 16L, 7L, 16L, 7L, 12L, 12L, 16L, 12L, 13L, 13L, 12L, 16L, 12L, 12L, 7L, 7L, 13L,16L, 7L, 18L, 16L, 13L, 18L, 4L, 12L, 7L, 4L, 18L, 18L, 18L, 9L, 17L, 13L, 7L, 12L, 7L, 18L, 12L, 18L, 13L, 9L, 1L, 18L, 1L, 13L, 13L, 13L, 1L, 1L, 13L, 12L, 4L, 1L,1L, 4L, 12L, 9L, 1L, 1L, 1L, 2L, 12L, 9L, 2L, 18L, 2L, 18L, 7L, 12L, 1L, 9L, 9L, 7L, 18L, 9L, 18L, 1L, 12L, 13L,
12L, 16L, 7L, 12L, 7L, 16L, 2L, 12L,7L, 16L, 12L, 16L, 2L, 12L, 2L, 15L, 7L, 7L, 2L, 7L, 3L, 12L, 16L, 1L, 17L, 2L, 18L, 5L, 7L, 1L, 16L, 7L, 10L, 1L, 12L, 18L, 16L, 16L, 13L, 12L, 7L, 2L, 1L, 9L, 18L, 12L, 13L, 2L, 2L, 12L, 2L, 2L, 2L, 16L, 2L, 1L, 18L, 12L, 7L, 2L, 2L, 12L, 7L, 12L, 4L, 2L, 18L, 13L, 2L, 16L, 7L, 2L, 2L, 12L, 2L, 14L, 12L, 12L, 16L, 1L, 2L, 4L, 2L, 2L, 2L, 17L, 2L, 2L, 2L, 18L, 16L, 2L, 2L, 2L, 2L, 2L, 2L, 3L, 12L, 2L, 2L, 1L, 2L, 12L, 18L, 2L, 15L, 16L, 16L, 2L, 2L, 2L, 2L, 11L, 12L, 14L, 2L, 2L, 2L, 2L, 2L, 2L, 2L, 2L, 2L, 2L, 2L, 16L, 16L, 12L, 2L, 12L, 2L, 2L, 2L, 12L, 2L,16L, 2L, 12L, 14L, 7L, 2L, 4L, 14L, 2L, 16L, 15L, 7L, 16L, 18L, 2L, 16L, 2L, 2L, 12L, 12L, 2L, 2L, 4L, 2L, 2L, 2L, 16L, 2L, 12L,18L, 3L, 16L, 2L, 2L, 13L, 2L, 2L, 2L, 2L, 2L, 2L, 2L, 2L, 2L, 2L, 2L, 2L, 2L, 2L, 2L, 2L, 2L, 16L, 16L, 2L, 2L, 4L, 4L, 11L, 13L, 4L, 4L, 8L, 4L, 13L, 1L, 4L, 1L, 1L, 2L, 2L, 11L, 18L, 8L, 8L, 4L, 7L, 8L, 4L, 8L, 4L, 4L, 8L, 8L, 1L, 4L, 8L, 4L, 13L, 1L, 6L, 1L, 17L, 2L, 2L, 8L, 18L, 8L, 8L, 4L, 7L, 8L, 17L, 8L, 4L, 1L, 4L, 13L, 1L, 2L, 4L, 16L, 13L, 4L, 4L, 17L, 4L, 7L, 4L, 4L, 1L, 1L, 4L, 1L, 17L, 8L, 1L, 8L, 1L, 4L, 1L, 8L, 8L, 8L, 1L, 13L, 16L, 16L, 17L, 8L, 13L, 1L, 4L, 7L, 1L, 1L, 4L, 4L, 8L, 6L, 4L, 1L, 12L, 13L, 8L, 4L, 4L, 18L, 2L, 4L, 8L, 13L, 17L,13L, 18L, 7L, 16L, 7L, 1L, 13L, 8L, 13L, 4L, 1L, 7L),
.Label = c("<8", ">1024", "1024", "11", "128", "16", "181", "22", "23", "256", "32", "362", "45", "512", "64", "724", "8", "90"), class = "factor")), .Names = c("X1", "X2"), row.names = c(NA, -471L), class = "data.frame")
library(dplyr)
library(stringr)
mutate_all(your_df, function(x) as.numeric(str_replace_all(x, pattern = "<|>", replacement = "")))
#> X1 X2
#> 1 32 181
#> 2 724 1024
#> 3 128 1024
#> 4 8 22
#> 5 8 90
#> 6 8 11
#> 7 8 45
#> 8 11 90
#> 9 32 22
#> 10 8 45
#> 11 8 22
#> 12 22 90
#> 13 45 362
You can do this with base R:
my_df <- as.data.frame(sapply(my_df, gsub, pattern = "<|>", replacement = ""))
my_df <- as.data.frame(sapply(my_df, as.numeric))
my_df
# X1 X2
# 1 8 23
# 2 8 90
# 3 8 8
# 4 8 362
# 5 8 45
# 6 90 362
# 7 256 724
# 8 64 181
# 9 128 362
# 10 32 181
# 11 64 724
# 12 256 1024
# 13 16 362
# 14 32.000000000000014 181
# 15 45.000000000000014 724
# 16 23.000000000000011 362
# 17 45.000000000000014 724
# 18 8 1024
# 19 90 362
# 20 1024 1024
# 21 90 64
# 22 23.000000000000011 181
# 23 32.000000000000014 181
# 24 45.000000000000014 1024
# 25 512.00000000000045 181
If you only want to round the decimals, but keep the < and > signs you can do the following (without perfoming the steps above):
sapply(my_df,
function(x) paste0(gsub(x, pattern = "\\d|\\.", replacement = ""),
round(as.numeric(gsub(x, pattern = "<|>", replacement = "")))))
# X1 X2
# [1,] "<8" "23"
# [2,] "<8" "90"
# [3,] "8" "<8"
# [4,] "8" "362"
# [5,] "<8" "45"
# [6,] "90" "362"
# [7,] "256" "724"
# [8,] "64" "181"
# [9,] "128" "362"
# [10,] "32" "181"
# [11,] "64" "724"
# [12,] "256" ">1024"
# [13,] "16" "362"
# [14,] "32" "181"
# [15,] "45" "724"
# [16,] "23" "362"
# [17,] "45" "724"
# [18,] "8" ">1024"
# [19,] "90" "362"
# [20,] "1024" ">1024"
# [21,] "90" "64"
# [22,] "23" "181"
# [23,] "32" "181"
# [24,] "45" ">1024"
# [25,] "512" "181"
How it works
sapply takes the data.frame and applys the function specified after the comma to each column of the data.frame. gsub substitute the pattern with the replacement in x (a column of the data.frame). There I used regular expression, so \\d means all digits (0-9) and \\. the dot and | combines them with a OR logic.
stringr-solution
There's a shorter solution with stringr:
library(stringr)
sapply(my_df,
function(x) str_c(str_extract(x, "[<>]?"),
round(as.numeric(str_extract(x, "\\d+")))))
Here the pattern we want to have are extracted and then combined again after rounding the decimals.
Data
my_df <-
structure(list(X1 = structure(c(1L, 1L, 28L, 28L, 1L, 30L, 15L,
25L, 6L, 17L, 25L, 15L, 8L, 18L,
22L, 14L, 22L, 28L, 30L, 3L, 30L,
14L, 18L, 22L, 24L),
.Label = c("<8", ">1024", "1024", "11",
"11.000000000000007", "128",
"128.00000000000009", "16",
"16.000000000000007", "181",
"181.00000000000006", "22",
"23", "23.000000000000011",
"256", "256.00000000000017",
"32", "32.000000000000014",
"362", "362.00000000000017",
"45", "45.000000000000014",
"512", "512.00000000000045",
"64", "64.000000000000028",
"724", "8",
"8.0000000000000018", "90"),
class = "factor"),
X2 = structure(c(9L, 18L, 1L, 12L, 13L, 12L, 16L, 7L,
12L, 7L, 16L, 2L, 12L, 7L, 16L, 12L,
16L, 2L, 12L, 2L, 15L, 7L, 7L, 2L, 7L),
.Label = c("<8", ">1024", "1024", "11",
"128", "16", "181", "22", "23",
"256", "32", "362", "45", "512",
"64", "724", "8", "90"),
class = "factor")),
.Names = c("X1", "X2"),
row.names = c(NA, -25L),
class = "data.frame")
# X1 X2
# 1 <8 23
# 2 <8 90
# 3 8 <8
# 4 8 362
# 5 <8 45
# 6 90 362
# 7 256 724
# 8 64 181
# 9 128 362
# 10 32 181
# 11 64 724
# 12 256 >1024
# 13 16 362
# 14 32.000000000000014 181
# 15 45.000000000000014 724
# 16 23.000000000000011 362
# 17 45.000000000000014 724
# 18 8 >1024
# 19 90 362
# 20 1024 >1024
# 21 90 64
# 22 23.000000000000011 181
# 23 32.000000000000014 181
# 24 45.000000000000014 >1024
# 25 512.00000000000045 181
i've this data frame:
date sessions Fuentes
1 2014-12-01 197 Directo
2 2014-12-01 1 Referencias
3 2014-12-01 7 Social Media
4 2014-12-01 13 SEO
5 2014-12-01 1 Email
6 2014-12-01 1 Referencias
This is the data after using dput():
structure(list(date = structure(c(1L, 1L, 1L, 1L, 1L, 1L, 1L,
1L, 1L, 1L, 1L, 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9L, 9L, 9L, 9L, 9L, 9L, 9L, 9L, 9L, 9L, 9L, 9L,
9L, 9L, 9L, 9L, 9L, 9L, 9L, 9L, 9L, 9L, 9L, 9L, 9L, 9L, 9L, 9L,
9L, 9L, 9L, 9L, 9L, 9L, 9L, 9L, 9L, 9L, 9L, 9L, 9L, 9L, 9L, 9L,
9L, 9L, 9L, 9L, 9L, 9L, 9L, 9L, 9L, 9L, 9L, 9L, 9L, 9L, 10L,
10L, 10L, 10L, 10L, 10L, 10L, 10L, 10L, 10L, 10L, 10L, 10L, 10L,
10L, 10L, 10L, 10L, 10L, 10L, 10L, 10L, 10L, 10L, 10L, 10L, 10L,
10L, 10L, 10L, 10L, 10L, 10L, 10L, 10L, 10L, 10L, 10L, 10L, 10L,
10L, 10L, 10L, 10L, 10L, 10L, 10L, 10L, 10L, 10L, 10L, 10L, 10L,
10L, 10L, 10L, 10L, 10L, 10L, 10L, 10L, 10L, 10L, 10L, 10L, 10L,
10L, 10L, 10L, 10L, 10L, 10L, 10L, 10L, 10L, 10L, 10L, 10L, 10L,
10L, 10L, 11L, 11L, 11L, 11L, 11L, 11L, 11L, 11L, 11L, 11L, 11L,
11L, 11L, 11L, 11L, 11L, 11L, 11L, 11L, 11L, 11L, 11L, 11L, 11L,
11L, 11L, 11L, 11L, 11L, 11L, 11L, 11L, 11L, 11L, 11L, 11L, 11L,
11L, 11L, 11L, 11L, 11L, 11L, 11L, 11L, 11L, 11L, 11L, 11L, 11L,
11L, 11L, 11L, 11L, 11L, 11L, 11L, 11L, 12L, 12L, 12L, 12L, 12L,
12L, 12L, 12L, 12L, 12L, 12L, 12L, 12L, 12L, 12L, 12L, 12L, 12L,
12L, 12L, 12L, 12L, 12L, 12L, 12L, 12L, 12L, 12L, 12L, 12L, 12L,
12L, 12L, 12L, 12L, 12L, 12L, 12L, 12L, 12L, 12L, 12L, 12L, 12L,
12L, 12L, 12L, 12L, 12L, 12L, 12L, 12L, 12L, 12L, 12L, 12L, 12L,
12L, 12L, 12L, 12L, 12L, 12L, 12L, 12L, 12L, 13L, 13L, 13L, 13L,
13L, 13L, 13L, 13L, 13L, 13L, 13L, 13L, 13L, 13L, 13L, 13L, 13L,
13L, 13L, 13L, 13L, 13L, 13L, 13L, 13L, 13L, 13L, 13L, 13L, 13L,
13L, 13L, 13L, 13L, 13L, 13L, 13L, 13L, 13L, 13L, 13L, 13L, 13L,
13L, 13L, 13L, 13L, 13L, 13L, 14L, 14L, 14L, 14L, 14L, 14L, 14L,
14L, 14L, 14L, 14L, 14L, 14L, 14L, 14L, 14L, 14L, 14L, 14L, 14L,
14L, 14L, 14L, 14L, 14L, 14L, 14L, 14L, 14L, 14L, 14L, 14L, 14L,
14L, 14L, 14L, 14L, 14L, 14L, 14L, 14L, 14L, 14L, 14L, 14L, 14L,
14L, 14L, 14L, 14L, 14L, 14L, 14L, 14L, 14L, 14L, 14L, 14L, 14L,
14L, 14L, 14L, 14L, 14L, 14L, 14L, 14L, 14L, 14L, 14L, 14L, 14L,
15L, 15L, 15L, 15L, 15L, 15L, 15L, 15L, 15L, 15L, 15L, 15L, 15L,
15L, 15L, 15L, 15L, 15L, 15L, 15L, 15L, 15L, 15L, 15L, 15L, 15L,
15L, 15L, 15L, 15L, 15L, 15L, 15L, 15L, 15L, 15L, 15L, 15L, 15L,
15L, 15L, 15L, 15L, 15L, 15L, 15L, 15L, 15L, 15L, 15L, 15L, 15L,
15L, 15L, 15L, 16L, 16L, 16L, 16L, 16L, 16L, 16L, 16L, 16L, 16L,
16L, 16L, 16L, 16L, 16L, 16L, 16L, 16L, 16L, 16L, 16L, 16L, 16L,
16L, 16L, 16L, 16L, 16L, 16L, 16L, 16L, 16L, 16L, 16L, 16L, 16L,
16L, 16L, 16L, 16L, 16L, 16L, 16L, 16L, 16L, 16L, 16L, 16L, 16L,
16L, 16L, 16L, 16L, 16L, 17L, 17L, 17L, 17L, 17L, 17L, 17L, 17L,
17L, 17L, 17L, 17L, 17L, 17L, 17L, 17L, 17L, 17L, 17L, 17L, 17L,
17L, 17L, 17L, 17L, 17L, 17L, 17L, 17L, 17L, 17L, 17L, 17L, 17L,
17L, 17L, 17L, 17L, 17L, 17L, 17L, 17L, 17L, 17L, 17L, 17L, 17L,
17L, 17L, 17L, 17L, 17L, 17L, 17L, 17L, 17L, 17L, 17L, 17L, 17L,
17L, 17L, 17L, 17L, 17L, 17L, 17L, 17L, 17L, 17L, 17L, 17L, 17L,
17L, 17L, 17L, 17L, 18L, 18L, 18L, 18L, 18L, 18L, 18L, 18L, 18L,
18L, 18L, 18L, 18L, 18L, 18L, 18L, 18L, 18L, 18L, 18L, 18L, 18L,
18L, 18L, 18L, 18L, 18L, 18L, 18L, 18L, 18L, 18L, 18L, 18L, 18L,
18L, 18L, 18L, 18L, 18L, 18L, 18L, 18L, 18L, 18L, 18L, 19L, 19L,
19L, 19L, 19L, 19L, 19L, 19L, 19L, 19L, 19L, 19L, 19L, 19L, 19L,
19L, 19L, 19L, 19L, 19L, 19L, 19L, 19L, 19L, 19L, 19L, 19L, 19L,
19L, 19L, 19L, 19L, 19L, 19L, 19L, 19L, 19L, 19L, 19L, 19L, 19L,
19L, 19L, 19L, 20L, 20L, 20L, 20L, 20L, 20L, 20L, 20L, 20L, 20L,
20L, 20L, 20L, 20L, 20L, 20L, 20L, 20L, 20L, 20L, 20L, 20L, 20L,
20L, 20L, 20L, 20L, 20L, 20L, 20L, 20L, 20L, 20L, 20L, 20L, 20L,
20L, 20L, 20L, 20L, 20L, 20L, 20L, 20L, 20L, 20L, 20L, 20L, 20L,
20L, 20L, 20L, 20L, 21L, 21L, 21L, 21L, 21L, 21L, 21L, 21L, 21L,
21L, 21L, 21L, 21L, 21L, 21L, 21L, 21L, 21L, 21L, 21L, 21L, 21L,
21L, 21L, 21L, 21L, 21L, 21L, 21L, 21L, 21L, 21L, 21L, 21L, 21L,
21L, 21L, 21L, 21L, 21L, 21L, 21L, 21L, 21L, 21L, 21L, 21L, 21L,
21L, 21L, 21L, 21L, 21L, 21L, 21L, 21L, 22L, 22L, 22L, 22L, 22L,
22L, 22L, 22L, 22L, 22L, 22L, 22L, 22L, 22L, 22L, 22L, 22L, 22L,
22L, 22L, 22L, 22L, 22L, 22L, 22L, 22L, 22L, 22L, 22L, 22L, 22L,
22L, 22L, 22L, 22L, 22L, 22L, 22L, 22L, 22L, 22L, 22L, 22L, 22L,
22L, 22L, 22L, 22L, 22L, 22L, 22L, 22L, 23L, 23L, 23L, 23L, 23L,
23L, 23L, 23L, 23L, 23L, 23L, 23L, 23L, 23L, 23L, 23L, 23L, 23L,
23L, 23L, 23L, 23L, 23L, 23L, 23L, 23L, 23L, 23L, 23L, 23L, 23L,
23L, 23L, 23L, 23L, 23L, 23L, 23L, 23L, 23L, 24L, 24L, 24L, 24L,
24L, 24L, 24L, 24L, 24L, 24L, 24L, 24L, 24L, 24L, 24L, 24L, 24L,
24L, 24L, 24L, 24L, 24L, 24L, 24L, 24L, 24L, 24L, 24L, 24L, 24L,
24L, 24L, 24L, 24L, 24L, 25L, 25L, 25L, 25L, 25L, 25L, 25L, 25L,
25L, 25L, 25L, 25L, 25L, 25L, 25L, 25L, 25L, 25L, 25L, 25L, 25L,
25L, 25L, 25L, 25L, 25L, 25L, 25L, 25L, 25L, 25L, 25L, 25L, 25L,
25L, 25L, 26L, 26L, 26L, 26L, 26L, 26L, 26L, 26L, 26L, 26L, 26L,
26L, 26L, 26L, 26L, 26L, 26L, 26L, 26L, 26L, 26L, 26L, 26L, 26L,
26L, 26L, 26L, 26L, 26L, 26L, 26L, 26L, 26L, 26L, 26L, 26L, 26L,
26L, 26L, 26L, 26L, 26L, 26L, 26L, 26L, 26L, 26L, 26L, 26L, 26L,
26L, 26L, 26L, 26L, 26L, 26L, 26L, 26L, 26L, 27L, 27L, 27L, 27L,
27L, 27L, 27L, 27L, 27L, 27L, 27L, 27L, 27L, 27L, 27L, 27L, 27L,
27L, 27L, 27L, 27L, 27L, 27L, 27L, 27L, 27L, 27L, 27L, 27L, 27L,
27L, 27L, 27L, 27L, 27L, 27L, 27L, 27L, 27L, 27L, 27L, 27L, 27L,
27L, 27L, 27L, 27L, 27L, 28L, 28L, 28L, 28L, 28L, 28L, 28L, 28L,
28L, 28L, 28L, 28L, 28L, 28L, 28L, 28L, 28L, 28L, 28L, 28L, 28L,
28L, 28L, 28L, 28L, 28L, 28L, 28L, 28L, 28L, 28L, 28L, 28L, 28L,
28L, 28L, 28L, 28L, 28L, 28L, 28L, 28L, 28L, 28L, 28L, 29L, 29L,
29L, 29L, 29L, 29L, 29L, 29L, 29L, 29L, 29L, 29L, 29L, 29L, 29L,
29L, 29L, 29L, 29L, 29L, 29L, 29L, 29L, 29L, 29L, 29L, 29L, 29L,
29L, 29L, 29L, 29L, 29L, 29L, 29L, 29L, 29L, 29L, 29L, 29L, 29L,
29L, 30L, 30L, 30L, 30L, 30L, 30L, 30L, 30L, 30L, 30L, 30L, 30L,
30L, 30L, 30L, 30L, 30L, 30L, 30L, 30L, 30L, 30L, 30L, 30L, 30L,
30L, 30L, 30L, 30L, 30L, 30L, 30L, 30L, 30L, 30L, 30L, 30L, 30L,
30L, 30L, 30L, 30L, 30L, 30L, 31L, 31L, 31L, 31L, 31L, 31L, 31L,
31L, 31L, 31L, 31L, 31L, 31L, 31L, 31L, 31L, 31L, 31L, 31L, 31L,
31L, 31L, 31L, 31L, 31L, 31L, 31L, 31L, 31L, 31L, 31L), .Label = c("2014-12-01",
"2014-12-02", "2014-12-03", "2014-12-04", "2014-12-05", "2014-12-06",
"2014-12-07", "2014-12-08", "2014-12-09", "2014-12-10", "2014-12-11",
"2014-12-12", "2014-12-13", "2014-12-14", "2014-12-15", "2014-12-16",
"2014-12-17", "2014-12-18", "2014-12-19", "2014-12-20", "2014-12-21",
"2014-12-22", "2014-12-23", "2014-12-24", "2014-12-25", "2014-12-26",
"2014-12-27", "2014-12-28", "2014-12-29", "2014-12-30", "2014-12-31"
), class = "factor"), sessions = c(197L, 1L, 7L, 13L, 1L, 1L,
10L, 1L, 3L, 3L, 5L,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6L, 5L, 5L, 5L, 5L, 6L, 5L, 5L, 5L,
5L, 4L, 5L, 2L, 5L, 5L, 5L, 5L, 6L, 3L, 5L, 4L, 4L, 6L, 4L, 5L,
5L, 5L, 7L, 6L, 5L, 5L, 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")), .Names = c("date",
"sessions", "Fuentes"), class = "data.frame", row.names = c(NA,
-1724L))
In a Shiny App, want to plot bars for Fuentes, acording to a data range specified by the user. I use daterangeInput in my ui.R, but cannot get it to plot what I need.
My ui.R
library(shiny)
# Define the overall UI
shinyUI(
# Use a fluid Bootstrap layout
fluidPage(
# Give the page a title
br(),
br(),
titlePanel("Visitas por fuente"),
# Generate a row with a sidebar
sidebarLayout(
# Define the sidebar with one input
sidebarPanel(
dateRangeInput("dates", label = h3("Date range"),
start = "2014-12-01", end = "2014-12-31")
),
# Create a spot for the barplot
mainPanel(
plotOutput("VisitasFuente")
)
)
)
)
My server.R ### Edited - Now can plot, but labels appeare as a blur from botton to top.
library(ggplot2)
library(dplyr)
require(scales)
Visitas_Por_Fuente <- read.csv("D:\\RCoursera\\Movistar- App-2\\Visitas_Por_Fuente_Dic.csv")
labels = c("Directo", "Email", "Referencias", "SEO", "Social Media")
Visitas_Por_Fuente$date <- as.Date(Visitas_Por_Fuente$date)
shinyServer(
function(input, output) {
output$VisitasFuente <- renderPlot({
# Filter the data based on user selection month
date_seq <- seq(input$dates[1], input$dates[2], by = "day")
#VisitasData <- filter(Visitas_Por_Fuente, date >= input$dates[1],
# date <= input$dates[2])
VisitasData <- filter(Visitas_Por_Fuente, date %in% date_seq & Fuentes %in% labels)
# Bar graph using ggplot2 library
ggplot(VisitasData, aes(factor(Fuentes), sessions, fill = Fuentes)) +
geom_bar(stat="identity", position = "dodge") +
geom_text(aes(label = comma(sessions)), position=position_dodge(width=0.9), vjust=-0.25) +
scale_fill_manual(breaks = c("0", "1", "3", "6", "9"),
labels = c("Directo", "Email", "References",
"SEO", "Social Media"),
values = c("#E69F00", "#56B4E9", "#009E73",
"#F0E442", "#0072B2"))
})
})
This was fixied by loading the corresponded packages
Thanks to #goodtimeslim, i've made the recomendations you gave me. But now i get:
Error in match(x, table, nomatch = 0L) :
'match' requires vector arguments
What could it be? Thanks again.
#
Okay, first thing, you need to tell R that Visitas_Por_Fuente$date is a date, with Visitas_Por_Fuente$date <- as.Date(Visitas_Por_Fuente$date) .
You can do this right after you import your data at the beginning.
Now you want to create a range of dates, in your server file, using the date inputs, like so:
date_seq <- seq(input$dates[1], input$dates[2], by = "day")
Now you just need to change your filter, so that the date is in that sequence, like so:
VisitasData <- filter(Visitas_Por_Fuente, date %in% date_seq)
Now I admit that doesn't solve everything, I was getting some weird errors with your ggplot code, but this will solve the subsetting issue.
This issue with your ggplot is that your data has 7 variables, but you're only giving it information for 5. If you just want those 5 variables, then at the top (right after you import your data), write this:
labels = c("Directo", "Email", "References", "SEO", "Social Media")
and then, for your plot, get rid of the scale_manual line and replace it with:
scale_x_discrete(limit = labels)
That'll force those 5 on there, and at the moment, it'll do it in whatever color R wants. I'll let you figure out the rest if you want to change it.
Let me know if this is clear enough or if you just want the whole server.r code.
edit: Okay, I fixed it. You had an error in your code, you have "References", but in your data, it's "Referencias". So now, assuming you still want those five variables only, and not all 7, do this: change labels (at the top) like so:
labels = c("Directo", "Email", "Referencias", "SEO", "Social Media")
Change your filter like so:
VisitasData <- filter(Visitas_Por_Fuente, date %in% date_seq & Fuentes %in% labels)
Then you can get rid of that scale_x_discrete line I had, and put your line back in. It should all work now. (Except edit your labels in the manual_scale part to reflect the proper "Referencias".
edit 2: Here's the full server.r that runs just fine on my computer. I've made some slight changes for consistency/clarity, but otherwise it's mostly the same.
library(ggplot2)
Visitas_Por_Fuente <- read.csv("visitas.csv") ## put your path here
labelsF = c("Directo", "Email", "Referencias", "SEO", "Social Media")
Visitas_Por_Fuente$date <- as.Date(Visitas_Por_Fuente$date)
shinyServer(
function(input, output) {
output$VisitasFuente <- renderPlot({
# Filter the data based on user selection month
date_seq <- seq(input$dates[1], input$dates[2], by = "day")
#VisitasData <- filter(Visitas_Por_Fuente, date >= input$dates[1],
# date <= input$dates[2])
VisitasData <- filter(Visitas_Por_Fuente, date %in% date_seq & Fuentes %in% labelsF)
# Bar graph using ggplot2 library
ggplot(VisitasData, aes(factor(Fuentes), sessions, fill = Fuentes)) +
geom_bar(stat="identity", position = "dodge") +
scale_fill_manual(breaks = c("0", "1", "3", "6", "9"),
labels = labelsF,
values = c("#E69F00", "#56B4E9", "#009E73",
"#F0E442", "#0072B2"))
})
})
Have data for everyday of dicember 2014. want to plot a barchart according to the selection of dates:
Original data:
structure(list(date = 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, 2L, 2L, 2L,
2L, 2L, 2L, 2L, 2L, 2L, 2L, 2L, 2L, 2L, 2L, 2L, 2L, 2L, 2L, 2L,
2L, 2L, 2L, 2L, 2L, 2L, 2L, 2L, 2L, 2L, 2L, 2L, 2L, 2L, 2L, 2L,
2L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, 10L, 10L, 10L, 10L, 10L, 10L, 10L, 10L,
10L, 10L, 10L, 10L, 10L, 10L, 10L, 10L, 10L, 10L, 10L, 10L, 10L,
10L, 10L, 10L, 10L, 10L, 10L, 10L, 10L, 10L, 10L, 10L, 10L, 10L,
10L, 10L, 10L, 10L, 10L, 10L, 10L, 10L, 10L, 10L, 10L, 10L, 10L,
10L, 10L, 10L, 10L, 10L, 10L, 10L, 10L, 10L, 10L, 10L, 10L, 10L,
10L, 10L, 11L, 11L, 11L, 11L, 11L, 11L, 11L, 11L, 11L, 11L, 11L,
11L, 11L, 11L, 11L, 11L, 11L, 11L, 11L, 11L, 11L, 11L, 11L, 11L,
11L, 11L, 11L, 11L, 11L, 11L, 11L, 11L, 11L, 11L, 11L, 11L, 11L,
11L, 11L, 11L, 11L, 11L, 11L, 11L, 11L, 11L, 11L, 11L, 11L, 11L,
11L, 11L, 11L, 11L, 11L, 11L, 11L, 11L, 12L, 12L, 12L, 12L, 12L,
12L, 12L, 12L, 12L, 12L, 12L, 12L, 12L, 12L, 12L, 12L, 12L, 12L,
12L, 12L, 12L, 12L, 12L, 12L, 12L, 12L, 12L, 12L, 12L, 12L, 12L,
12L, 12L, 12L, 12L, 12L, 12L, 12L, 12L, 12L, 12L, 12L, 12L, 12L,
12L, 12L, 12L, 12L, 12L, 12L, 12L, 12L, 12L, 12L, 12L, 12L, 12L,
12L, 12L, 12L, 12L, 12L, 12L, 12L, 12L, 12L, 13L, 13L, 13L, 13L,
13L, 13L, 13L, 13L, 13L, 13L, 13L, 13L, 13L, 13L, 13L, 13L, 13L,
13L, 13L, 13L, 13L, 13L, 13L, 13L, 13L, 13L, 13L, 13L, 13L, 13L,
13L, 13L, 13L, 13L, 13L, 13L, 13L, 13L, 13L, 13L, 13L, 13L, 13L,
13L, 13L, 13L, 13L, 13L, 13L, 14L, 14L, 14L, 14L, 14L, 14L, 14L,
14L, 14L, 14L, 14L, 14L, 14L, 14L, 14L, 14L, 14L, 14L, 14L, 14L,
14L, 14L, 14L, 14L, 14L, 14L, 14L, 14L, 14L, 14L, 14L, 14L, 14L,
14L, 14L, 14L, 14L, 14L, 14L, 14L, 14L, 14L, 14L, 14L, 14L, 14L,
14L, 14L, 14L, 14L, 14L, 14L, 14L, 14L, 14L, 14L, 14L, 14L, 14L,
14L, 14L, 14L, 14L, 14L, 14L, 14L, 14L, 14L, 14L, 14L, 14L, 14L,
15L, 15L, 15L, 15L, 15L, 15L, 15L, 15L, 15L, 15L, 15L, 15L, 15L,
15L, 15L, 15L, 15L, 15L, 15L, 15L, 15L, 15L, 15L, 15L, 15L, 15L,
15L, 15L, 15L, 15L, 15L, 15L, 15L, 15L, 15L, 15L, 15L, 15L, 15L,
15L, 15L, 15L, 15L, 15L, 15L, 15L, 15L, 15L, 15L, 15L, 15L, 15L,
15L, 15L, 15L, 16L, 16L, 16L, 16L, 16L, 16L, 16L, 16L, 16L, 16L,
16L, 16L, 16L, 16L, 16L, 16L, 16L, 16L, 16L, 16L, 16L, 16L, 16L,
16L, 16L, 16L, 16L, 16L, 16L, 16L, 16L, 16L, 16L, 16L, 16L, 16L,
16L, 16L, 16L, 16L, 16L, 16L, 16L, 16L, 16L, 16L, 16L, 16L, 16L,
16L, 16L, 16L, 16L, 16L, 17L, 17L, 17L, 17L, 17L, 17L, 17L, 17L,
17L, 17L, 17L, 17L, 17L, 17L, 17L, 17L, 17L, 17L, 17L, 17L, 17L,
17L, 17L, 17L, 17L, 17L, 17L, 17L, 17L, 17L, 17L, 17L, 17L, 17L,
17L, 17L, 17L, 17L, 17L, 17L, 17L, 17L, 17L, 17L, 17L, 17L, 17L,
17L, 17L, 17L, 17L, 17L, 17L, 17L, 17L, 17L, 17L, 17L, 17L, 17L,
17L, 17L, 17L, 17L, 17L, 17L, 17L, 17L, 17L, 17L, 17L, 17L, 17L,
17L, 17L, 17L, 17L, 18L, 18L, 18L, 18L, 18L, 18L, 18L, 18L, 18L,
18L, 18L, 18L, 18L, 18L, 18L, 18L, 18L, 18L, 18L, 18L, 18L, 18L,
18L, 18L, 18L, 18L, 18L, 18L, 18L, 18L, 18L, 18L, 18L, 18L, 18L,
18L, 18L, 18L, 18L, 18L, 18L, 18L, 18L, 18L, 18L, 18L, 19L, 19L,
19L, 19L, 19L, 19L, 19L, 19L, 19L, 19L, 19L, 19L, 19L, 19L, 19L,
19L, 19L, 19L, 19L, 19L, 19L, 19L, 19L, 19L, 19L, 19L, 19L, 19L,
19L, 19L, 19L, 19L, 19L, 19L, 19L, 19L, 19L, 19L, 19L, 19L, 19L,
19L, 19L, 19L, 20L, 20L, 20L, 20L, 20L, 20L, 20L, 20L, 20L, 20L,
20L, 20L, 20L, 20L, 20L, 20L, 20L, 20L, 20L, 20L, 20L, 20L, 20L,
20L, 20L, 20L, 20L, 20L, 20L, 20L, 20L, 20L, 20L, 20L, 20L, 20L,
20L, 20L, 20L, 20L, 20L, 20L, 20L, 20L, 20L, 20L, 20L, 20L, 20L,
20L, 20L, 20L, 20L, 21L, 21L, 21L, 21L, 21L, 21L, 21L, 21L, 21L,
21L, 21L, 21L, 21L, 21L, 21L, 21L, 21L, 21L, 21L, 21L, 21L, 21L,
21L, 21L, 21L, 21L, 21L, 21L, 21L, 21L, 21L, 21L, 21L, 21L, 21L,
21L, 21L, 21L, 21L, 21L, 21L, 21L, 21L, 21L, 21L, 21L, 21L, 21L,
21L, 21L, 21L, 21L, 21L, 21L, 21L, 21L, 22L, 22L, 22L, 22L, 22L,
22L, 22L, 22L, 22L, 22L, 22L, 22L, 22L, 22L, 22L, 22L, 22L, 22L,
22L, 22L, 22L, 22L, 22L, 22L, 22L, 22L, 22L, 22L, 22L, 22L, 22L,
22L, 22L, 22L, 22L, 22L, 22L, 22L, 22L, 22L, 22L, 22L, 22L, 22L,
22L, 22L, 22L, 22L, 22L, 22L, 22L, 22L, 23L, 23L, 23L, 23L, 23L,
23L, 23L, 23L, 23L, 23L, 23L, 23L, 23L, 23L, 23L, 23L, 23L, 23L,
23L, 23L, 23L, 23L, 23L, 23L, 23L, 23L, 23L, 23L, 23L, 23L, 23L,
23L, 23L, 23L, 23L, 23L, 23L, 23L, 23L, 23L, 24L, 24L, 24L, 24L,
24L, 24L, 24L, 24L, 24L, 24L, 24L, 24L, 24L, 24L, 24L, 24L, 24L,
24L, 24L, 24L, 24L, 24L, 24L, 24L, 24L, 24L, 24L, 24L, 24L, 24L,
24L, 24L, 24L, 24L, 24L, 25L, 25L, 25L, 25L, 25L, 25L, 25L, 25L,
25L, 25L, 25L, 25L, 25L, 25L, 25L, 25L, 25L, 25L, 25L, 25L, 25L,
25L, 25L, 25L, 25L, 25L, 25L, 25L, 25L, 25L, 25L, 25L, 25L, 25L,
25L, 25L, 26L, 26L, 26L, 26L, 26L, 26L, 26L, 26L, 26L, 26L, 26L,
26L, 26L, 26L, 26L, 26L, 26L, 26L, 26L, 26L, 26L, 26L, 26L, 26L,
26L, 26L, 26L, 26L, 26L, 26L, 26L, 26L, 26L, 26L, 26L, 26L, 26L,
26L, 26L, 26L, 26L, 26L, 26L, 26L, 26L, 26L, 26L, 26L, 26L, 26L,
26L, 26L, 26L, 26L, 26L, 26L, 26L, 26L, 26L, 27L, 27L, 27L, 27L,
27L, 27L, 27L, 27L, 27L, 27L, 27L, 27L, 27L, 27L, 27L, 27L, 27L,
27L, 27L, 27L, 27L, 27L, 27L, 27L, 27L, 27L, 27L, 27L, 27L, 27L,
27L, 27L, 27L, 27L, 27L, 27L, 27L, 27L, 27L, 27L, 27L, 27L, 27L,
27L, 27L, 27L, 27L, 27L, 28L, 28L, 28L, 28L, 28L, 28L, 28L, 28L,
28L, 28L, 28L, 28L, 28L, 28L, 28L, 28L, 28L, 28L, 28L, 28L, 28L,
28L, 28L, 28L, 28L, 28L, 28L, 28L, 28L, 28L, 28L, 28L, 28L, 28L,
28L, 28L, 28L, 28L, 28L, 28L, 28L, 28L, 28L, 28L, 28L, 29L, 29L,
29L, 29L, 29L, 29L, 29L, 29L, 29L, 29L, 29L, 29L, 29L, 29L, 29L,
29L, 29L, 29L, 29L, 29L, 29L, 29L, 29L, 29L, 29L, 29L, 29L, 29L,
29L, 29L, 29L, 29L, 29L, 29L, 29L, 29L, 29L, 29L, 29L, 29L, 29L,
29L, 30L, 30L, 30L, 30L, 30L, 30L, 30L, 30L, 30L, 30L, 30L, 30L,
30L, 30L, 30L, 30L, 30L, 30L, 30L, 30L, 30L, 30L, 30L, 30L, 30L,
30L, 30L, 30L, 30L, 30L, 30L, 30L, 30L, 30L, 30L, 30L, 30L, 30L,
30L, 30L, 30L, 30L, 30L, 30L, 31L, 31L, 31L, 31L, 31L, 31L, 31L,
31L, 31L, 31L, 31L, 31L, 31L, 31L, 31L, 31L, 31L, 31L, 31L, 31L,
31L, 31L, 31L, 31L, 31L, 31L, 31L, 31L, 31L, 31L, 31L), .Label = c("2014-12-01",
"2014-12-02", "2014-12-03", "2014-12-04", "2014-12-05", "2014-12-06",
"2014-12-07", "2014-12-08", "2014-12-09", "2014-12-10", "2014-12-11",
"2014-12-12", "2014-12-13", "2014-12-14", "2014-12-15", "2014-12-16",
"2014-12-17", "2014-12-18", "2014-12-19", "2014-12-20", "2014-12-21",
"2014-12-22", "2014-12-23", "2014-12-24", "2014-12-25", "2014-12-26",
"2014-12-27", "2014-12-28", "2014-12-29", "2014-12-30", "2014-12-31"
), 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, 1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, 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")), .Names = c("date",
"sessions", "Fuentes"), class = "data.frame", row.names = c(NA,
-1724L))
My data after the summarise function:
Fuentes sessions
1 Adwords 71
2 Campa�as 280
3 Directo 11610
4 Email 437
5 Referencias 13143
6 SEO 39837
7 Social Media 5981
Howcome my shiny code does not print right my plot?
1) when used within Shiny, the label appears like blured:
do a summarise before plotting (see code below):
server.R file:
library(ggplot2)
library(dplyr)
require(scales)
Visitas_Por_Fuente <- read.csv("D:\\RCoursera\\Movistar-App-2\\Visitas_Por_Fuente_Dic.csv")
labelsF = c("Directo", "Email", "Referencias", "SEO", "Social Media", "Campañas", "Adwords")
Visitas_Por_Fuente$date <- as.Date(Visitas_Por_Fuente$date)
shinyServer(
function(input, output) {
output$VisitasFuente <- renderPlot({
# Filter the data based on user selection month
date_seq <- seq(input$dates[1], input$dates[2], by = "day")
VisitasData <- filter(Visitas_Por_Fuente, date %in% date_seq & Fuentes %in% labelsF)
VisitasData %>% group_by(Fuentes) %>%
summarise(sessions = sum(sessions))
ggplot(VisitasData, aes(factor(Fuentes), sessions, fill = Fuentes)) +
geom_bar(stat="identity", position = "dodge") +
geom_text(aes(label = comma(sessions)), position=position_dodge(width=0.9), vjust=-0.25) +
scale_fill_manual(breaks = c("0", "1", "3", "6", "9", "12", "15"),
labels = labelsF,
values = c("#E69F00", "#56B4E9", "#009E73",
"#F0E442", "#0072B2", "#A082F8", "#F072A2"))
})
})
2) Then i use the same code, but not within shiny, just ggplot2 code:
ggplot(VisitasData, aes(factor(Fuentes), sessions, fill = Fuentes)) +
geom_bar(stat="identity", position = "dodge") +
geom_text(aes(label = comma(sessions)), position=position_dodge(width=0.9), vjust=-0.25) +
scale_fill_manual(breaks = c("0", "1", "3", "6", "9", "12", "15"),
labels = labelsF,
values = c("#E69F00", "#56B4E9", "#009E73",
"#F0E442", "#0072B2", "#A082F8", "#F072A2"))
And get what i need:
I also tried, using a reactive function (as recommended in comments), but got:
Error : ggplot2 doesn't know how to deal with data of class reactive
Googled that and found:
http://stackoverflow.com/questions/27771691/many-error-signs-when-running-ggplot-in-render-plot-shiny-in-general
But now,prints a blank sheet:
This is my code with the reactive function:
function(input, output) {
dataSeq <- reactive({
date_seq <- seq(input$dates[1], input$dates[2], by = "day")
})
VisitasData <- reactive({
VisitasData <- filter(Visitas_Por_Fuente, date %in% dataSeq & Fuentes %in% labelsF)
VisitasData %>% group_by(Fuentes) %>%
summarise(sessions = sum(sessions))
})
output$VisitasFuente <- renderPlot({
# Bar graph using ggplot2 library
ggplot(ggplot(selectedData(VisitasData), aes(factor(VisitasData$Fuentes), VisitasData$sessions,
fill = Fuentes)) +
geom_bar(stat="identity", position = "dodge") +
geom_text(aes(label = comma(sessions)), position=position_dodge(width=0.9), vjust=-0.25) +
scale_fill_manual(breaks = c("0", "1", "3", "6", "9", "12", "15"),
labels = labelsF,
values = c("#E69F00", "#56B4E9", "#009E73",
"#F0E442", "#0072B2", "#A082F8", "#F072A2"))
})
})
Assuming you want those numbers that showed up in your first call
Fuentes sessions
1 Adwords 71
2 Campa�as 280
3 Directo 11610
4 Email 437
5 Referencias 13143
6 SEO 39837
7 Social Media 5981
You just made a little mistake here:
VisitasData %>% group_by(Fuentes) %>%
summarise(sessions = sum(sessions))
You made a new dataframe, but you didn't assign it to anything. What you want is:
VisitasData <- VisitasData %>% group_by(Fuentes) %>%
summarise(sessions = sum(sessions))
Then you don't need to do a reactive thing, just used the code you did when you first posted it above.
library(ggplot2)
library(dplyr)
require(scales)
Visitas_Por_Fuente <- read.csv("D:\\RCoursera\\Movistar-App-2\\Visitas_Por_Fuente_Dic.csv")
labelsF = c("Directo", "Email", "Referencias", "SEO", "Social Media", "Campañas", "Adwords")
Visitas_Por_Fuente$date <- as.Date(Visitas_Por_Fuente$date)
shinyServer(
function(input, output) {
output$VisitasFuente <- renderPlot({
# Filter the data based on user selection month
date_seq <- seq(input$dates[1], input$dates[2], by = "day")
VisitasData <- filter(Visitas_Por_Fuente, date %in% date_seq & Fuentes %in% labelsF)
VisitasData <- VisitasData %>% group_by(Fuentes) %>%
summarise(sessions = sum(sessions))
# Bar graph using ggplot2 library
ggplot(VisitasData, aes(factor(Fuentes), sessions, fill = Fuentes)) +
geom_bar(stat="identity", position = "dodge") +
geom_text(aes(label = comma(sessions)), position=position_dodge(width=0.9), vjust=-0.25) +
scale_fill_manual(breaks = c("0", "1", "3", "6", "9", "12", "15"),
labels = labelsF,
values = c("#E69F00", "#56B4E9", "#009E73",
"#F0E442", "#0072B2", "#A082F8", "#F072A2"))
})
})
Is this what you intended?