Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Tibble error #1566

Closed
amaraftery opened this issue Aug 9, 2024 · 1 comment
Closed

Tibble error #1566

amaraftery opened this issue Aug 9, 2024 · 1 comment

Comments

@amaraftery
Copy link

I keep getting this error and tried various ways of fixing it without luck.
The x argument of as_tibble.matrix() must have unique column names if .name_repair is
omitted as of tibble 2.0.0.
ℹ Using compatibility .name_repair.
ℹ The deprecated feature was likely used in the tidyr package.
Please report the issue at https://github.com/tidyverse/tidyr/issues.
This warning is displayed once every 8 hours.
Call lifecycle::last_lifecycle_warnings() to see where this warning was generated.
Called from: FUN(X[[i]], ...)

#Fun
function (gdef, theme, gglayout)
{
if (inherits(gdef, "colorbar")) {
gdef$key <- gdef$key[!is.na(gdef$key$.value), ]
decor <- gdef$decor %||% gdef$bar
rng <- range(decor$value)
decor$value <- scales::rescale(decor$value, from = rng)
if (!"decor" %in% names(gdef)) {
gdef$key$.value <- scales::rescale(gdef$key$.value,
from = rng)
}
vals <- lapply(gglayout[c("xaxis", "yaxis")], function(ax) {
if (identical(ax$tickmode, "auto"))
ax$ticktext
else ax$tickvals
})
list(x = vals[[1]][[1]], y = vals[[2]][[1]], name = gdef$hash,
type = "scatter", mode = "markers", opacity = 0,
hoverinfo = "skip", showlegend = FALSE, marker = list(color = c(0,
1), colorscale = setNames(decor[c("value", "colour")],
NULL), colorbar = list(bgcolor = toRGB(theme$legend.background$fill),
bordercolor = toRGB(theme$legend.background$colour),
borderwidth = unitConvert(theme$legend.background[[linewidth_or_size(theme$legend.background)]],
"pixels", "width"), thickness = unitConvert(theme$legend.key.width,
"pixels", "width"), title = gdef$title, titlefont = text2font(gdef$title.theme %||%
theme$legend.title), tickmode = "array", ticktext = gdef$key$.label,
tickvals = gdef$key$.value, tickfont = text2font(gdef$label.theme %||%
theme$legend.text), ticklen = 2, len = 1/2)))
}
else {
NULL
}
}
#I think this function is causing the error

percX.withinY.argTest <- function(df, groupVar, xVar) {
keepGoing <- TRUE # Assume no problems initially.

Check if 'df' is a dataframe

if (!is.data.frame(df)) {
warning("The first argument must be a dataframe.")
keepGoing <- FALSE
} else if (nrow(df) == 0) {
warning("The dataframe has zero rows.")
keepGoing <- FALSE
}

Check if 'groupVar' and 'xVar' are character strings

if (!is.character(groupVar)) {
warning(sprintf(""%s" is not a character string. The second argument must be a character string name of a column in the dataframe.", groupVar))
keepGoing <- FALSE
}

if (!is.character(xVar)) {
warning(sprintf(""%s" is not a character string. The third argument must be a character string name of a column in the dataframe.", xVar))
keepGoing <- FALSE
}

Check if the dataframe contains the specified columns

if (keepGoing) {
dfHasGroupVar <- groupVar %in% names(df)
dfHasXVar <- xVar %in% names(df)

if (!dfHasGroupVar || !dfHasXVar) {
  missingVars <- c()
  if (!dfHasGroupVar) missingVars <- c(missingVars, groupVar)
  if (!dfHasXVar) missingVars <- c(missingVars, xVar)
  warning(sprintf("The following variables are not columns in the dataframe: %s", paste(missingVars, collapse = " and ")))
  keepGoing <- FALSE
}

}

return(keepGoing) # Return FALSE if any checks fail.
}

@DavisVaughan
Copy link
Member

Without a much more minimal reprex there is not much I can do to help here, sorry

If you've never heard of a reprex before, you might want to start by reading the tidyverse.org help page.

You can install reprex by running (you may already have it, though, if you have the tidyverse package installed):

install.packages("reprex")

Thanks

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants