# Convert .px file format into CSV
# load library
if (!require(pxR)) install.packages('pxR')
#> Loading required package: pxR
#> Warning in library(package, lib.loc = lib.loc, character.only = TRUE,
#> logical.return = TRUE, : there is no package called 'pxR'
#> Installing package into 'C:/Users/hdsda/Documents/R/win-library/4.0'
#> (as 'lib' is unspecified)
#> also installing the dependency 'RJSONIO'
#> package 'RJSONIO' successfully unpacked and MD5 sums checked
#> package 'pxR' successfully unpacked and MD5 sums checked
#>
#> The downloaded binary packages are in
#> C:\Users\hdsda\AppData\Local\Temp\RtmpWKrlxt\downloaded_packages
library(pxR)
#> Warning: package 'pxR' was built under R version 4.0.3
#> Loading required package: stringr
#> Loading required package: reshape2
#> Loading required package: RJSONIO
#> Warning: package 'RJSONIO' was built under R version 4.0.3
#> Loading required package: plyr
# Object into Data
my.px.object <- read.px("http://www.cso.ie/px/pxeirestat/pssn/prtb/homepagefiles/RIA02.px")
#> Warning in file(con, "r"): cannot open URL 'http://www.cso.ie/px/pxeirestat/
#> pssn/prtb/homepagefiles/RIA02.px': HTTP status was '403 Forbidden'
#> Error in file(con, "r"): cannot open the connection
my.px.data <- as.data.frame( my.px.object )
#> Error in as.data.frame(my.px.object): object 'my.px.object' not found
#
devtools::use_data(my.px.data)
#> Error: 'use_data' is not an exported object from 'namespace:devtools'
# Write Table
write.table(my.px.data, file = "", append = FALSE, quote = TRUE, sep = " ",
eol = "\n", na = "NA", dec = ".", row.names = TRUE,
col.names = TRUE, qmethod = c("escape", "double"),
fileEncoding = "")
#> Error in is.data.frame(x): object 'my.px.data' not found
# convert to csv file
write.csv(my.px.data, file = "ria02.csv")
#> Error in is.data.frame(x): object 'my.px.data' not found
Created on 2020-11-26 by the reprex package (v0.3.0)