I am creating a graph from a data frame which contains factors. graph_from_data_frame() converts them to characters with these lines: (I saw on an old post by Gábor on StackOverflow)

newval <- d[, i]
if (class(newval) == "factor") {
  newval <- as.character(newval)
attrs[[names(d)[i]]] <- newval

So I wrote a new function gfdf with these lines commented out (following Gábor’s suggestion)

newval <- d[, i]
#if (class(newval) == "factor") {
 #newval <- as.character(newval)
attrs[[names(d)[i]]] <- newval

But the conversion still seems to be happening.

> g=gfdf(zEdges,vertices=zNodes)
> is.factor(zNodes$CLEAN.GENDER)
[1] TRUE
> is.factor(V(g)$CLEAN.GENDER)

But curiously:

> head(zNodes$CLEAN.GENDER)
[1] H H H H H H
Levels:  H M x
> head(V(g)$CLEAN.GENDER)
[1] 2 2 2 2 2 2

V(g)$CLEAN.GENDER has become numeric

It would be very convenient to keep these things as factors.
What am I missing?

igraph.version() is 1.2.4

Robin Cowan