This is not as complicated as it seems. Factors in R are ordered in the object. If you use levels() to look at the contents of the factor the order corresponds to the factor index (i.e., first class is 1, second 2, ect...). Because of this you can deal with the character component of a factor indirectly and never have to muck with the actual attribute value.
Here is a worked example of what you are wanting.
Add the required packages and an example SpatialPixelsDataFrame
require(sp)
require(raster)
data(meuse.grid)
sgdf <- SpatialPixelsDataFrame(points=meuse.grid[c("x", "y")], data=meuse.grid)
Here we make the soil attribute into a character factor. We can examine the resulting factor using levels(), nlevels() or str(). The order of the factor dictates the resulting position index.
levels(sgdf@data$soil) <- c("type1","type2","type3")
levels(sgdf@data$soil)
str(sgdf@data)
Now we can coerce the SpatialPixelsDataFrame into a raster object and by passing a function to rasterToPolygons convert a single class into a polygon. Since we know that the first factor level corresponds with "type 1" we can index the value in our function.
If you print the resulting object "r" you will see that the attributes are maintained along with the factor index value, which in turn, corresponds to the values in the raster.
Note; the argument "layer=6" in the raster function corresponds to the column in the SpatialPixelsDataFrame's @data slot.
( r <- raster(sgdf, layer=6) )
r.poly <- rasterToPolygons(r, fun=function(x) {x == 1}, dissolve=TRUE )
class(r.poly)
Now, let's plot the results (raster with the "type1" polygon overlay).
plot(r)
plot(r.poly, col="red", add=TRUE)