-
-
Couldn't load subscription status.
- Fork 51
Description
Hi Yihui :)
EDIT: 2018-FEB-19: I did a hack who tries to fit the desired width, and works for many cases. Reference: #71.
I'm using formatR inside bookdown and I found an issue when creating the PDF. The maximum width doesn't work for the code (but it does for comments!)
Easily reproducible at formatR, copy the following lines (using minimum line width=56)
Input:
# Keeping all columns except the ones present in 'vars_to_remove' vector
heart_disease_2=select(heart_disease, -one_of(vars_to_remove))
aasd = select(daa, -one_of(holas), -one_of(holas), -one_of(holas))
Output:
# Keeping all columns except the ones present in
# 'vars_to_remove' vector
heart_disease_2 = select(heart_disease, -one_of(vars_to_remove))
aasd = select(daa, -one_of(holas), -one_of(holas), -one_of(holas))
Width line 3: 64
Width line 3: 66
So it didn't re adjust the with for the code.
Afer doing several test, I tracked the problem to what it seem its origin: base::deparse function.
Testing from your code:
text="# Keeping all columns except the ones present in 'vars_to_remove' vector
heart_disease_2 = select(heart_disease, -one_of(vars_to_remove))
aasd = select(daa, -one_of(holas), -one_of(holas), -one_of(holas))"
exprs = parse_only(text)
base::deparse(exprs, width)
[1] "expression(heart_disease_2 = select(heart_disease, -one_of(vars_to_remove)), "
[2] " aasd = select(daa, -one_of(holas), -one_of(holas), -one_of(holas)))"
If I try lower width, let's say 40, it adjust the 3rd line but the max len is 50...
I would have like to fix it myself, but I'm lack of ideas to debug deparse function... Any ideas?
Related to this case: https://stackoverflow.com/questions/20778635/formatr-width-cutoff-issue
Thanks!