caught segfault error in R

前端 未结 3 406
有刺的猬
有刺的猬 2020-11-29 21:54

I am getting a caught segfault error every time I try to run any plotting functions from the ggplot2 package (1.0.0). I have tried this with

相关标签:
3条回答
  • 2020-11-29 22:21

    This is not an answer to this question but it might be useful for someone. I had segfaults when I did pdf to create a PDF graphics device and then used plot. This happened with R 2.15.3, 3.2.4, and one or two other versions, running on Scientific Linux release 6.7. I tried many different things, but the only ways I could get it to work were (a) using png or tiff instead of pdf, or (b) saving large .RData files and then using a completely separate R program to create the graphics.

    0 讨论(0)
  • 2020-11-29 22:23

    This is not an answer to this question but it might be helpful for someone. (Inspired by user1310503. Thanks!)

    I am working on a data.frame df with three cols: col1, col2, col3. Initially,

    df =data.frame(col1=character(),col2=numeric(),col3=numeric(),stringsAsFactors = F)
    

    In the process, rbind is used for many times, like:

    aList<-list(col1="aaa", col2 = "123", col3 = "234")
    dfNew <- as.data.frame(aList)
    df <- rbind(df, dfNew)
    

    At last, df is written to file via data.table::fwrite

    data.table::fwrite(x = df, file = fileDF, append = FALSE, row.names = F, quote = F, showProgress = T)
    

    df has 5973 rows and 3 cols. The "caught segfault" always occurs:

    address 0x1, cause 'memory not mapped'. 
    

    The solution to this problem is:

    aList<-list(col1=as.character("aaa"), col2 = as.numeric("123"), col3 = as.numeric("234"))
    dfNew <- as.data.frame(aList)
    dfNew$col1 <- as.characer(dfNew$col1)
    dfNew$col2 <- as.numeric(dfNew$col2)
    dfNew$col3 <- as.numeric(dfNew$col3)
    df <- rbind(df, dfNew)
    

    Then this problem is solved. Possible reason is that the classes of cols are different.

    0 讨论(0)
  • 2020-11-29 22:32

    In case anyone else has this problem or similar in the future, I sent a bug report to the package maintainer and he recommended uninstalling all installed packages and starting over. I took his advice and it worked!

    I followed advice from this posting: http://r.789695.n4.nabble.com/Reset-R-s-library-to-base-packages-only-remove-all-installed-contributed-packages-td3596151.html

    ip <- installed.packages()
    pkgs.to.remove <- ip[!(ip[,"Priority"] %in% c("base", "recommended")), 1]
    sapply(pkgs.to.remove, remove.packages)
    
    0 讨论(0)
提交回复
热议问题