plot qlrdf in a ggplo2 2 plot qlrdf <- as.data.frame(qlr$fstats) qlrdf <- qlrdf %>% mutate(index = c(1:1730), stats = x) qlrdf$x <- null in r

To plot qlrdf using ggplot2, first, we need to ensure that qlrdf contains the necessary columns for plotting.

main.r
# Assign data to the qlrdf variable
qlrdf <- as.data.frame(qlr$fstats)
# Add a new column to create a sequence of numbers
qlrdf$index <- seq.int(nrow(qlrdf))
# Rename the stats column to values
names(qlrdf)[3] <- "values"
222 chars
7 lines

The values column qlrdf$values contains the actual f-statistics that can be plotted. We can then use ggplot2 to create a scatter plot.

main.r
# Plot the values against the index
library(ggplot2)
ggplot(qlrdf, aes(x=index, y=values)) + geom_point() + ylab("F-Statistics")
129 chars
4 lines

This will create a scatter plot with the F-statistics on the y-axis and the index on the x-axis.

Note that in the original code provided, qlrdf$x was set to null, so we had to generate an index column to use as the x-axis variable.

gistlibby LogSnag