guide_imp <- function(x, y, pid, method = 'new', ...)  {
  data = data.frame(x, y)

  gdir = paste0("tmp", pid)
  setdir = paste0("mkdir -p ", gdir)
  system(setdir)
  

  role = rep('n', NCOL(x))
  role[sapply(x, class) %in% c('factor')] = 'c'
  role = c(role, 'd')
  header = paste0('data.csv\nNA\n2')
  
  if (method == 'new') {
    guide = ';../../GUIDE/guide360'
  } else {
    guide = ';../../GUIDE/guide360'
  }

  write.csv(data, file = paste0(gdir, '/data.csv'), row.names = FALSE)
  write(header, file = paste0(gdir, '/data.dsc'))
  write.table(cbind(1:NCOL(data), colnames(data), role), 
              file = paste0(gdir, '/data.dsc'),
              append = TRUE, quote = FALSE, row.names = FALSE, col.names = FALSE)
  if (class(y) == 'factor') {
    system(paste0("cd ", gdir, guide, " < ../../GUIDE/imp_c.in > log.txt"), ignore.stdout = T, ignore.stderr = T)
  } else {
    system(paste0("cd ", gdir, guide, " < ../../GUIDE/imp.in > log.txt"), ignore.stdout = T, ignore.stderr = T)
  }
  
  
  tmpImp = read.table(paste0(gdir, '/imp.txt'), header=TRUE)
  system(paste0("rm -rf ", gdir))
  
  tmpScore = tmpImp$Score
  names(tmpScore) = tmpImp$Variable
  tmpRank = imp_measure(tmpScore)
  names(tmpRank) = tmpImp$Variable
 
  list(errRank = tmpRank[xvars], 
       imp = imp_scale(tmpScore[xvars]),
       oimp = tmpScore[xvars],
       gimp = tmpImp)
}
