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

Issues with tibbles and `backCalc()` #34

Closed
droglenc opened this issue Dec 21, 2018 · 3 comments
Closed

Issues with tibbles and `backCalc()` #34

droglenc opened this issue Dec 21, 2018 · 3 comments
Assignees
Labels
bug

Comments

@droglenc
Copy link
Owner

@droglenc droglenc commented Dec 21, 2018

backCalc() fails when the data is a tibble because the following lines return a one-column data.frame on tibbles but a vector on regular data.frames. This can be corrected by converting the tibble to a data.frame with as.data.frame() but I need to find a more robust answer. Another possible solution, but I need to research this more, is to add drop=TRUE to the following lines in backCalc().

regLcap <- regdat[,rlang::quo_name(rlang::enquo(lencap))]
Lcap <- dat[,rlang::quo_name(rlang::enquo(lencap))]
@droglenc droglenc added the bug label Dec 21, 2018
@droglenc droglenc self-assigned this Dec 21, 2018
@droglenc
Copy link
Owner Author

@droglenc droglenc commented Apr 13, 2019

See this ...

library(tibble)

( dft <- tibble(id=1:10,x=rnorm(10)) )
( df <- as.data.frame(dft) )

dft[,"x"]
df[,"x"]
df[,"x",drop=FALSE]
dft[,"x",drop=FALSE]
df[,"x",drop=TRUE]
dft[,"x",drop=TRUE]

@droglenc
Copy link
Owner Author

@droglenc droglenc commented Apr 13, 2019

Use this is a test (seems to work properly for versions >0.2.0

data(SMBassWB2,package="RFishBC")
data(SMBassWB1,package="RFishBC")

smb1 <- inner_join(SMBassWB1,SMBassWB2,by="id") %>%
  arrange(id)
smb2 <- as_tibble(smb1)
str(smb1)
str(smb2)

smb1_FL <- backCalc(smb1,lencap,BCM="FRALE",inFormat="wide",digits=0)
smb2_FL <- backCalc(smb2,lencap,BCM="FRALE",inFormat="wide",digits=0)
str(smb1_FL)
str(smb2_FL)
@droglenc
Copy link
Owner Author

@droglenc droglenc commented Apr 13, 2019

Is fixed in versions >0.2.0

@droglenc droglenc closed this Apr 13, 2019
droglenc added a commit that referenced this issue Apr 13, 2019
@droglenc droglenc mentioned this issue Apr 13, 2019
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Linked pull requests

Successfully merging a pull request may close this issue.

None yet
1 participant
You can’t perform that action at this time.