You can also do it without external packages if you wish:
data <- rbind(c(6,16,25), c(1,4,7), c(NA, 1,2), c(NA, NA, 1))
# set some names (not necessary- helps understand the code):
rownames(data) <- 1:4
colnames(data) <- LETTERS[1:3]
data
A B C
1 6 16 25
2 1 4 7
3 NA 1 2
4 NA NA 1
# convert to data.frame:
d <- as.data.frame.table(data)
d
Var1 Var2 Freq
1 1 A 6
2 2 A 1
3 3 A NA
4 4 A NA
5 1 B 16
6 2 B 4
7 3 B 1
8 4 B NA
9 1 C 25
10 2 C 7
11 3 C 2
12 4 C 1
ggplot(d, aes(x = Var1, y = Freq, group = Var2, colour = Var2)) +
geom_point() +
geom_line(aes(lty = Var2)) +
scale_y_log10(breaks = c(1,2,5,10,25))

as.data.frame(data)in your above code?as.data.frame(data)because it seemed not to work only with a matrix, but probably it is not usefullas.data.frame(data)to any variable (in particulardata). So if you did this in your code it is doing effectively nothing. Might not have worked due to some other reason that vanished later.