Posts by EGazzoli • 331 points
7 posts
-
5
votes2
answers85
viewsQ: Repeating the subtraction of groups in a data frame for all numerical variables
I have the following code: df <- data.frame(grp = rep(letters[1:3], each = 2), index = rep(1:2, times = 3), value = seq(10, 60, length.out = 6), value2 = seq(20, 70, length.out = 6), value3 =…
-
0
votes3
answers433
viewsA: geom_text positioning labels individually
Using together the excellent solutions received I arrived at the following code: mult = 2*(dat[dat$cod==rots[1], 3] > dat[dat$cod==rots[2], 3])-1 dat$pos=c(mult,mult*(-1))…
-
3
votes3
answers433
viewsQ: geom_text positioning labels individually
I’m making a chart similar to this one in the example, where I position the labels by group: I’m using the code: set.seed(1000) ano=factor(rep(1996:2016,2)) cod=c(rep("K1",21),rep("O1.3",21))…
-
3
votes1
answer387
viewsQ: Subtract rows from a group in a data frame by another group
Assuming the following example: set.seed(1234) df=data.frame(grupo=rep(c("A1","A1.2","C","D"), 3), ano=c(rep(2007,4),rep(2008,4),rep(2009,4)), valor1=sample.int(100,12), valor2=sample(20,12),…
-
3
votes1
answer89
viewsQ: Split data frame by the first line itself
I’m trying to create an index number from a data frame. I would like to divide each column by the first number without having to do the division column by column. Just as an example, df would be:…
-
5
votes1
answer452
viewsQ: bar graph ggplot 2 vectors side by side
Can anyone tell me if it is possible to make this chart with the bars side by side without using data frames or "melt"? v1=c(100,120,140) v2=c(125, 102,104) a=data.frame(year=factor(2003:2005))…
-
3
votes1
answer44
viewsQ: Filling lines with correct data in R, joining successive lines
I have a database with the second structure: a=as.data.frame(tribble( ~a, ~texto, ~x2007, ~x2008, "a","aa",0,0, 0,"--",12,13, "b","bb",1,2, "c","cc", 0, 0, 0,"dd", 0,0, 0,"ee",7,8)) The rows…