Athomas hat geschrieben: ↑Di Okt 23, 2018 12:11 pm
Code: Alles auswählen
library(data.table)
DT <- fread("D:/R/R Forum/Boxplots/Beispieldaten.txt", dec=",")
DT[ , ID:=.I]
DT.long <- melt(DT, id="ID", variable.name="Messung", variable.factor = FALSE)
DT.long[ , ":="(Art = substr(Messung, 1, nchar(Messung) - 2),
Version = substr(Messung, nchar(Messung), nchar(Messung)))]
DT.2 <- dcast(DT.long, ID + Art ~ Version)
library(ggplot2)
Grafik <- ggplot(DT.2) +
theme_bw() +
geom_point(aes(k,n)) +
facet_wrap(Art ~.)
print(Grafik)
BITTE
Wow danke!
habe den code straight übernommen... und bekomme folgende Meldung:
Code: Alles auswählen
> library(data.table)
> DT <- fread("C:/beispieldata.txt", dec=",")
> DT[ , ID:=.I]
> DT.long <- melt(DT, id="ID", variable.name="Messung", variable.factor = FALSE)
[b]Warning message:[/b]
In melt.data.table(DT, id = "ID", variable.name = "Messung", variable.factor = FALSE) :
'measure.vars' [id, Median_rr_k, Median_rr_n, ...] are not all of the same type. By order of hierarchy, the molten data value column will be of type 'double'. All measure variables not of type 'double' will be coerced too. Check DETAILS in ?melt.data.table for more on coercion.
> DT.long[ , ":="(Art = substr(Messung, 1, nchar(Messung) - 2),
+ Version = substr(Messung, nchar(Messung), nchar(Messung)))]
> DT.2 <- dcast(DT.long, ID + Art ~ Version)
>
> library(ggplot2)
> Grafik <- ggplot(DT.2) +
+ theme_bw() +
+ geom_point(aes(k,n)) +
+ facet_wrap(Art ~.)
> print(Grafik)
[b]Error in FUN(X[[i]], ...) : object 'k' not found[/b]
DT versteh ich...
DT.long: was passiert da? sollte ich die struktur noch verstehen, wenn ich mir das environment (RStudio) ansehe?
DT.2: HÄ?
Frage nur nach, weil ich gerne verstehn möchte, womit ich arbeite und weil ich ja längerfristig selbst mehr zusammenbringen möchte