Skip to content

$..<- behaves in an unexpected way #226

Open

Description

@GegznaV

Documentation says:

x$.. <- Sets the extra data (x@data without touching x$spc). The column names must match exactly in this case.

But $..<- behaves in an unexpected way. (See comment in code):

suppressPackageStartupMessages(library(hyperSpec))

flu$..
#>           filename    c
#> 1 rawdata/flu1.txt 0.05
#> 2 rawdata/flu2.txt 0.10
#> 3 rawdata/flu3.txt 0.15
#> 4 rawdata/flu4.txt 0.20
#> 5 rawdata/flu5.txt 0.25
#> 6 rawdata/flu6.txt 0.30
# I expect either a warning or an error here, 
# Or, better, that all data in @data (except column "spc") is replaced with the 
# the replacement data.
# 
# I do not expect that all columns get replaced with the same values 
# (but old column names will remain)
spc <- flu
spc$.. <- data.frame(a = 1:6)
spc$..
#>   filename c
#> 1        1 1
#> 2        2 2
#> 3        3 3
#> 4        4 4
#> 5        5 5
#> 6        6 6
# The warning here is not informative or even misleading.
# I'd prefer no warnings.
# 
# I expect correct replacement and not everything replaced with the same values 
# of the first column in the replacement dataset.
spc <- flu
spc$.. <- data.frame(c = 1:6, filename = letters[1:6])
#> Warning in x@label[i] <- label: number of items to replace is not a multiple of
#> replacement length
spc$..
#>   filename c
#> 1        1 1
#> 2        2 2
#> 3        3 3
#> 4        4 4
#> 5        5 5
#> 6        6 6

spc <- flu
spc$.. <- data.frame(filename = letters[1:6], c = 1:6)
#> Warning in x@label[i] <- label: number of items to replace is not a multiple of
#> replacement length
spc$..
#>   filename c
#> 1        a a
#> 2        b b
#> 3        c c
#> 4        d d
#> 5        e e
#> 6        f f

Created on 2020-07-26 by the reprex package (v0.3.0)

Activity

  1. added
    Type: bug 💣
    on Jul 26, 2020
  2. removed
    Type: bug 💣
    on Jul 27, 2020
  3. cbeleites commented on Jul 27, 2020

    @cbeleites
    Owner

    @GegznaV please do not use the label "bug" before there is confirmation that the issue is indeed a bug.

    I'll check this (but not sure whether this week) and if I can confirm this is not as it should be, I'll label it "bug" again

  4. GegznaV commented on Jul 27, 2020

    @GegznaV
    CollaboratorAuthor

    please do not use the label "bug" before there is confirmation

    OK.

  5. GegznaV commented on Jul 29, 2020

    @GegznaV
    CollaboratorAuthor

    Then I'll use a new tag possibly bug untill it is confirmed or dimissed.

  6. added
    Type: possibly bug ❓
    on Jul 29, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type: possibly bug ❓

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions