Skip to content

Commit

Permalink
improve as.code of formula
Browse files Browse the repository at this point in the history
  • Loading branch information
grlloyd committed Jan 31, 2024
1 parent aa5922c commit edb4541
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 3 deletions.
2 changes: 1 addition & 1 deletion R/struct_class.R
Original file line number Diff line number Diff line change
Expand Up @@ -736,7 +736,7 @@ setMethod(f = 'as.code',
str=paste0(str,P[p], ' = ', val)

} else if (is(val,'formula')) {
str=paste0(str,P[p], ' = ',capture.output(print(val)))
str=paste0(str,P[p], ' = ',deparse1(val))
} else if (is.null(val)) {
str=paste0(str,P[p], ' = ','NULL')
} else {
Expand Down
7 changes: 5 additions & 2 deletions R/zzz.R
Original file line number Diff line number Diff line change
Expand Up @@ -184,9 +184,12 @@ stringify_params = function(M,P,type='param',val=NULL) {
} else if (is(val,'character')) {
d=paste0(d,'\\code{"',val,'"}.')
} else if (is.function(val) | is.call(val)) {
d=paste0(d,'\\code{',gsub('}','\\}',
paste0(trimws(deparse(val)),collapse='')),'}.')
d=paste0(d,
'\\code{',gsub('}','\\}',
paste0(trimws(deparse1(val)),collapse='')),'}.')
#d=paste0(d,'\\code{some_function()}.')
} else if (is(val,'formula')) {
d = paste0('\\code{',deparse1(val),'}.')
} else {

d=paste0(d,'\\code{',val,'}.\\cr')
Expand Down

0 comments on commit edb4541

Please sign in to comment.