R package development - how to deal with requiring a specific version of an imported package

Hello -

Currently working on building an R shiny application as an R package which for now is available for install via github and thus can be installed using devtools (devtools::install_github). However, my question is when a new user installs devtools, tibble version 3.0.4 gets installed, yet this version of tibble gives an error with my application and my application requires tibble version 2.1.3.

I see when making my description file and I use
usethis::use_package("tibble", min_version="2.1.3)
The output from the above command in the Description file is so:
tibble (>= 2.1.3), which reads that the application can use a version of tibble that is not acceptable.

I am curious about the best way to deal with this within my package.
One potential work around is to tell new users after downloading to use this command
devtools::install_version("tibble", version = "2.1.3")
but I would like an way to not have to request a new user who downloads the application to do this.

Any thoughts -

If I put myself in the shoes of an r user that wanted to run your app, I would think its best if you made your program compatible with versions of tibble after 2.1.3.

1 Like

Yes, I agree with your statement @ nirgrahamuk but the error I get when using the two different versions is:

Warning: Error in : Assigned data values must be compatible with existing data.
i Error occurred for column 2013C-3134_fastx5.
x Can't convert double to character.

and I have been unsuccessful at dealing with this error.
So I guess a secondary/alternative questions would be - Any thoughts on dealing with this error.

Id be happy to investigate and see what can be done, others on the forum may also.

To help us help you, could you please prepare a reproducible example (reprex) illustrating your issue? Please have a look at this guide, to see how to create one:

1 Like

Okay - here is a minimal reprex

#honestly this seems a bit bananas to me that I need to do lines 5-14de to get a matrix that matches to what I would read in
testing_genetic <- matrix(c(1, "-", 0.2, 0.5, 0.1, 0, "-", 0.3, 0.9, 0.8, 0.2, 0.2, "-", 0.5, "-", 0.7), nrow = 4, dimnames = list(c("A","B","C","D"), c("A","B","C","D")))
testing_genetic <- as.data.frame(testing_genetic)
testing_genetic <- droplevels(testing_genetic)
testing_genetic <- data.frame(lapply(testing_genetic, as.character), stringsAsFactors=FALSE)
testing_genetic <- tibble::rownames_to_column(testing_genetic, var=".")  
#rename this column to make a matrix with both 
testing_genetic[1,1] <- "A"
testing_genetic[2,1] <- "B"
testing_genetic[3,1] <- "C"
testing_genetic[4,1] <- "D"

#additional manipulation of genetic distance matrix for ultimately getting the mean number of SNPs 
testing_genetic  <- testing_genetic %>%
  dplyr::rename( label = 1) %>% #rename columnn 1 to label for joining of data sets later
  stats::na.omit()%>% #remove na
  tidyr::pivot_longer(-label)%>%  #convert to a three column data frame 
  .[which(.$label != .$name),]  #remove self comparisons for this table - necessary for snp mean/median calculation.

testing_genetic <-  testing_genetic%>%
     replace(., .=="-", 0) #replace - with zero in the file; if zeros already infile, still works

When the above code is run I get the error -
"Error: Assigned data values must be compatible with existing data.
i Error occurred for column value.
x Can't convert double to character."

Let me know if this is not an acceptable minimum reprex

you can use


testing_genetic <-  testing_genetic%>%
  mutate(value=ifelse(value=="-", 0,value)) #replace - with zero in the file

Very cool! Thank you :grinning:

1 Like

This topic was automatically closed 7 days after the last reply. New replies are no longer allowed.

If you have a query related to it or one of the replies, start a new topic and refer back with a link.