df<-read.table("barplot and reshape.txt", h=T)
df
## Cat Si No
## 1 Repitencia 20 9
## 2 Profeinfluye 23 6
## 3 Compromiso 22 7
## 4 Cargaacademica 19 10
## 5 Motivacion 20 9
## 6 Interes 16 13
## 7 Evaluacion 19 10
## 8 Recreacion 20 9
## 9 Dormir 17 12
library(reshape)
df1 <- melt( df, id.vars = "Cat", variable_name = "Respuesta")
df1
## Cat Respuesta value
## 1 Repitencia Si 20
## 2 Profeinfluye Si 23
## 3 Compromiso Si 22
## 4 Cargaacademica Si 19
## 5 Motivacion Si 20
## 6 Interes Si 16
## 7 Evaluacion Si 19
## 8 Recreacion Si 20
## 9 Dormir Si 17
## 10 Repitencia No 9
## 11 Profeinfluye No 6
## 12 Compromiso No 7
## 13 Cargaacademica No 10
## 14 Motivacion No 9
## 15 Interes No 13
## 16 Evaluacion No 10
## 17 Recreacion No 9
## 18 Dormir No 12
library(ggplot2)
## Warning: package 'ggplot2' was built under R version 3.2.4
ggplot(df1, aes(Cat, value, fill=Respuesta)) +
geom_bar(stat="identity", , position="dodge")

require(reshape)
df <- data.frame(time = 1:10,
a = cumsum(rnorm(10)),
b = cumsum(rnorm(10)),
c = cumsum(rnorm(10)))
df <- melt(df , id.vars = "time")
df
## time variable value
## 1 1 a 1.0224365
## 2 2 a 2.9207643
## 3 3 a 3.9383836
## 4 4 a 5.6602195
## 5 5 a 5.6505254
## 6 6 a 3.8293188
## 7 7 a 3.5492310
## 8 8 a 4.2189888
## 9 9 a 3.7503896
## 10 10 a 4.5278357
## 11 1 b -1.3741381
## 12 2 b -1.5844968
## 13 3 b -0.1783970
## 14 4 b 0.6927895
## 15 5 b -1.1293673
## 16 6 b -1.0193718
## 17 7 b -0.1321568
## 18 8 b 0.3526214
## 19 9 b 0.7050583
## 20 10 b 1.0581158
## 21 1 c 0.2743089
## 22 2 c -0.4633104
## 23 3 c 0.8550178
## 24 4 c -0.8449925
## 25 5 c -0.5760820
## 26 6 c -1.3804431
## 27 7 c -1.2591637
## 28 8 c -1.9719931
## 29 9 c -2.0740805
## 30 10 c -1.2304945
ggplot(df, aes(time,value)) + geom_line(aes(colour = variable))

Clasico de barras
df3 <- data.frame(dose=c("D0.5", "D1", "D2"),
len=c(4.2, 10, 29.5))
head(df3)
## dose len
## 1 D0.5 4.2
## 2 D1 10.0
## 3 D2 29.5
ggplot(data=df3, aes(x=dose, y=len)) +geom_bar(stat="identity")
