Reputation: 173
What I want is:
m1 <- dbGetQuery(mydb, "select out,in from table where value > 1")
m2 <- dbGetQuery(mydb, "select out,in from table where value > 1.1")
m3 <- dbGetQuery(mydb, "select out,in from table where value > 1.2")
m4 <- dbGetQuery(mydb, "select out,in from table where value > 1.3")
.
.
.
m101 <- dbGetQuery(mydb, "select out,in from table where value > 10")
then
n1 <- degree(graph.data.frame(m))
n2 <- degree(graph.data.frame(m2)
.
.
.
I would like to simplify these codes with apply function but I have no clue :^(
Upvotes: 0
Views: 413
Reputation: 38500
Here is a for
loop solution that saves the results in a list:
# get list
myList <- list()
for(i in seq(1, 10, 0.1)) {
myList[[paste0("m",i)]]<- dbGetQuery(mydb,
paste("select out,in from table where value >", i))
}
You can then call the objects out of you list:
n1 <- degree(graph.data.frame(myList[["m1"]]))
and as above, you can put these results in a list. Named lists are a great way to store and organize many objects.
Upvotes: 1