statistikat / x12

The R package x12
http://statistikat.github.io/x12
17 stars 2 forks source link

Error in file(con, "r") : cannot open the connection #16

Closed Jeeva-Ganesan closed 6 years ago

Jeeva-Ganesan commented 6 years ago

Hi, I am trying to run sessional adjustment here using x12 package. I downloaded x12 arima source package from http://gretl.sourceforge.net/index.html. And placed it in my instance.

Here is my snippet pointing to that package,

sa_out <- function(x){ t <- ts(x,start=2007,frequency=12) x12out <- x12work(t, x12path="/home/rstudio/x12arima/x12a", transform.function="log", x11.type="sa",x11.samode = 'multi') x12out$d11 }

And here is the error i am getting, `

sa_list_uptill <- sa_out(Li_pivot) sh: 1: /Applications/x12arima/x12a: not found Error in file(con, "r") : cannot open the connection In addition: Warning message: In file(con, "r") : Show Traceback

Rerun with Debug Error in file(con, "r") : cannot open the connection

source('./R/custom_functions.R')

x <- by(Li_pviot,Li_pviot$Source,FUN=function(x) x)

sa_list_uptill <- sa_out(Li_pivot) sh: 1: /home/rstudio/x12arima/x12a: not found Error in file(con, "r") : cannot open the connection In addition: Warning message: In file(con, "r") : Error in file(con, "r") : cannot open the connection 8.file(con, "r") 7.readLines(con = paste(file, ".", "err", sep = ""), n = -1) 6.readx12Out(file, freq_series = frequency(tso), start_series = start_series, end_series = end_series, tblnames = tblnames, Rtblnames = Rtblnames, transform = transform, slidingspans = slidingspans, history = history, x11regress = x11regress, outlier = outlier, showWarnings = showWarnings, ... 5.x12work(t, x12path = "/home/rstudio/x12arima/x12a", transform.function = "log", x11.type = "sa", x11.samode = y) at custom_functions.R#16 4.FUN(X[[i]], ...) 3.lapply(x[, c(3:ncol(x))], seasonal_adjustment, y = "mult") 2.do.call(cbind, lapply(x[, c(3:ncol(x))], seasonal_adjustment, y = "mult")) at custom_functions.R#26 1.sa_out(Li_pivot) `

I checked the file and it is present in the right location. How do I debug this? Any idea why it is happening.

Here is the sessioninfo,

`> sessionInfo() R version 3.4.2 (2017-09-28) Platform: x86_64-pc-linux-gnu (64-bit) Running under: Ubuntu 16.04.3 LTS

Matrix products: default BLAS: /usr/lib/libblas/libblas.so.3.6.0 LAPACK: /usr/lib/lapack/liblapack.so.3.6.0

locale: [1] LC_CTYPE=en_US.UTF-8 LC_NUMERIC=C LC_TIME=en_US.UTF-8 LC_COLLATE=en_US.UTF-8
[5] LC_MONETARY=en_US.UTF-8 LC_MESSAGES=en_US.UTF-8 LC_PAPER=en_US.UTF-8 LC_NAME=en_US.UTF-8
[9] LC_ADDRESS=en_US.UTF-8 LC_TELEPHONE=en_US.UTF-8 LC_MEASUREMENT=en_US.UTF-8 LC_IDENTIFICATION=en_US.UTF-8

attached base packages: [1] stats graphics grDevices utils datasets methods base

other attached packages: [1] rvest_0.3.2 xml2_1.1.1 jsonlite_1.5 curl_3.0 tidyr_0.7.2 stringr_1.2.0
[7] RJDBC_0.2-5 rJava_0.9-9 ggthemes_3.4.0 scales_0.5.0 lubridate_1.7.1 ggrepel_0.7.0
[13] ggplot2_2.2.1 x12_1.8.0 x13binary_1.1.39-1 xts_0.10-0 zoo_1.8-0 dplyr_0.7.4
[19] plyr_1.8.4 janitor_0.3.0 reshape2_1.4.2 openxlsx_4.0.17 readxl_1.0.0 RMySQL_0.10.13
[25] DBI_0.7

loaded via a namespace (and not attached): [1] Rcpp_0.12.13 cellranger_1.1.0 compiler_3.4.2 bindr_0.1 tools_3.4.2 tibble_1.3.4 gtable_0.2.0
[8] lattice_0.20-35 pkgconfig_2.0.1 rlang_0.1.4 parallel_3.4.2 bindrcpp_0.2 httr_1.3.1 grid_3.4.2
[15] glue_1.2.0 R6_2.2.2 XML_3.98-1.9 selectr_0.3-1 purrr_0.2.4 magrittr_1.5 assertthat_0.2.0 [22] colorspace_1.3-2 stringi_1.1.5 lazyeval_0.2.1 munsell_0.4.3
`

alexkowa commented 6 years ago

I am not sure about that error, but I see you have also the x13binary package installed, you can use the binary included in this package, you get the path by: x13p <- x13binary::x13path() files <- list.files(x13p) path <- file.path(x13p,files[head(grep("x13as",files),1)]) then it should work to do something like x12work(t, x12path=path)

However it is recommended to use the function x12() instead of x12work() .