I have a tibble
, df
:
> df
# A tibble: 4 x 5
profile Sepal.Length Sepal.Width Petal.Length Petal.Width
<chr> <dbl> <dbl> <dbl> <dbl>
1 Profile 1 -1.011 0.850 -1.301 -1.251
2 Profile 2 0.542 -0.389 0.662 0.673
3 Profile 3 -0.376 -0.967 0.115 0.038
4 Profile 4 1.502 0.158 1.277 1.239
When I use `tidyr::gather(), as follows:
tidyr::gather(df, var, val, -profile)
The following error is returned:
Warning message: attributes are not identical across measure variables; they will be dropped
I did some searching (and checked to see whether df
has any attributes that might be causing the issue), but can't understand why this warning is being printed.
df <- structure(list(profile = c("Profile 1", "Profile 2", "Profile 3",
"Profile 4"), Sepal.Length = structure(c(-1.011, 0.542, -0.376,
1.502), .Dim = c(150L, 1L), "`scaled:center`" = 5.84333333333333, "`scaled:scale`" = 0.828066127977863),
Sepal.Width = structure(c(0.85, -0.389, -0.967, 0.158), .Dim = c(150L,
1L), "`scaled:center`" = 3.05733333333333, "`scaled:scale`" = 0.435866284936698),
Petal.Length = structure(c(-1.301, 0.662, 0.115, 1.277), .Dim = c(150L,
1L), "`scaled:center`" = 3.758, "`scaled:scale`" = 1.76529823325947),
Petal.Width = structure(c(-1.251, 0.673, 0.038, 1.239), .Dim = c(150L,
1L), "`scaled:center`" = 1.19933333333333, "`scaled:scale`" = 0.762237668960347)), class = c("tbl_df",
"tbl", "data.frame"), row.names = c(NA, -4L), .Names = c("profile",
"Sepal.Length", "Sepal.Width", "Petal.Length", "Petal.Width"))
EDIT:
When I print df
, it looks fine:
> df
# A tibble: 2 x 5
profile Sepal.Length Sepal.Width Petal.Length Petal.Width
<chr> <dbl> <dbl> <dbl> <dbl>
1 Profile 1 -1.011 0.850 -1.301 -1.251
2 Profile 2 0.506 -0.425 0.650 0.625
However, when I run dput(df)
, and then run the code that it output (the same code as above), the error identified by @neilfws is returned.