Open julianstanley opened 4 years ago
Hi Julian,
I've just made a small modification of the gfpop R function to take in account your problem. Adding mygraph$state1 <- as.character(mygraph$state1) mygraph$state2 <- as.character(mygraph$state2) mygraph$type <- as.character(mygraph$type) into this function enforces the right type and you don't have to use the stringAsFactors option anymore. Thank you for noticing this message error. Are you ok with this solution?
Vincent
Hey Vincent,
Perfect! My previous example runs perfectly now:
> iso_graph <- gfpop::graph(penalty = 15, type = "isotonic")
> data <- gfpop::dataGenerator(50, changepoints = c(1), parameters = c(1))
> gfpop::gfpop(data = data, mygraph = iso_graph, type = "mean")$changepoints
[1] 50
>
> write.csv(iso_graph, "graphtest.csv", row.names = FALSE)
> iso_graph_import <- gfpop::graph(read.csv("graphtest.csv"))
> gfpop::gfpop(data = data, mygraph = iso_graph_import, type = "mean")$changepoints
[1] 50
I'll write a quick test for this and pull request if that's okay?
That's okay, thanks!
Today I imported a .csv file specifying a constraint graph and passed it through
gfpop::graph()
. I tried to use that graph to run gfpop, but got an error that was a bit confusing:Error in x[[jj]][iseq] <- vjj : replacement has length zero
The problem is that, when I import a graph from file, I need to set
stringsAsFactors
to false. I saw the same problem and solution withread.csv
anddata.table::fread
.I worked through that issue here in gfpop-gui and @tdhock suggested posting here.
Example: