RStudio: Trouble uploading an Excel file. "No package called 'pkgconfig'

I was able to import an excel spreadsheet into RStudio and work on it while at work, so I decided to email myself the same spreadsheet and work on it at home as well. When I downloaded the excel file and tried to import it into the RStudio environment at home, I get this error message:

"Is this a valid Excel file? there is no package called 'pkgconfig'"

I've tried a fresh install of R and RStudio, simply installing pkgconfig, and updating as many packages as possible and I still receive this error message.

I also tried converting the Excel file to a .csv where I received a similar error message, "there is no package called 'pkgconfig'".

In trying this code:

library(readxl)

FinancialSpreadsheet <- read_excel("FinancialSpreadsheet.xlsx")

I receive:

Error in loadNamespace(j <- i[[1L]], c(lib.loc, .libPaths()), versionCheck = vI[[j]]) : there is no package called ‘pkgconfig’

I feel I am possibly overlooking something obvious because I am fairly new to this language and software. Thank you for any help.

2 Answers

This actually just answered my question! Apparently R was storing packages in a different place than where it was looking to pull those packages from.

  • Part of the problem was pkgconfig was not installed
  • also, with windows, the current directory often changes and should never be relied on. You can use an if statement combined with something like file.exists(fileNamePath) to perform a test.
  • read_excel requires parameters to be set up path should point to a file-name-path

example

.... #install up required packages
install.packages("pkgconfig")
install.packages("Rcpp")
install.packages("readxl") #load up required packages
library(pkgconfig)
library(Rcpp)
library(readxl) #load up an excel spreadsheet into a variable object called datasets
filePath <- "C:/.../extdata/evaluation/"
fileName <- 'GPW Detailed Tables March 2019 - STP.xlsx'
fileNamePath <- paste0(filePath, fileName) #TEST FILE is where you think it is
file.exists(fileNamePath)
#read_excel(datasets)
#FinancialSpreadsheet <- read_excel("FinancialSpreadsheet.xlsx")
#return data into a tibble Data Frame
datasets <- read_xlsx(path = fileNamePath, sheet = '1a', range = "D18:L26")
#return data result to the terminal screen
read_excel(path = fileNamePath, sheet = '1a', range = "D18:L26")
....

example O/P using a spreadsheet on my box

....
> fileNamePath <- paste0(filePath, fileName)
> file.exists(fileNamePath)
[1] TRUE
> datasets <- read_xlsx(path = fileNamePath,
+ sheet = '1a',
+ range = "D18:L26")
New names:
* `` -> ...2
* `` -> ...3
>
> read_excel(path = fileNamePath,
+ sheet = '1a',
+ range = "D18:L26")
New names:
* `` -> ...2
* `` -> ...3
# A tibble: 8 x 9 `Lancashire and South C~ ...2 ...3 `1263` `689` `255` `8` `185` `145` <chr> <lgl> <chr> <dbl> <dbl> <dbl> <chr> <dbl> <dbl>
1 00Q NA NHS Blackburn wit~ 110 65 19 - 11 16
2 00R NA NHS Blackpool CCG 97 56 16 1 17 8
3 00X NA NHS Chorley and S~ 125 59 33 1 18 14
4 01A NA NHS East Lancashi~ 313 153 61 2 41 63
5 01E NA NHS Greater Prest~ 148 68 35 2 32 13
6 01K NA NHS Morecambe Bay~ 279 176 60 2 34 8
7 02G NA NHS West Lancashi~ 72 42 10 - 8 13
8 02M NA NHS Fylde and Wyr~ 130 71 23 - 24 13
>
....

Your Answer

Sign up or log in

Sign up using Google Sign up using Facebook Sign up using Email and Password

Post as a guest

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

You Might Also Like