简体   繁体   中英

How to set column width in kable()?

I have a data table I want to display for HTML report. Her is a dummy table

BelQ= structure(list(Source = "Kalender 2019", `Sourse of Questions` = "The survey instruments were part of a larger survey that included other motivational constructs. The development and validation of these surveys is reported in prior work [18–22,59]. ",     Results = "PCA analysis reveals that for both genders, sense of belonging and identity were not separate from the Expectancy Value Theory constructs. Instead, sense of belonging was closely tied to self-efficacy, which was therefore labeled as “self-efficacy or belonging” component or factor. ", Questions = "Sense of Belonging or Self-efficacy (not separated in a paper):<br>1. Sometimes I worry that I do not belong in this physics class<br>2. I feel like I can be myself in this class<br>3. I am able to help my classmates with physics in the laboratory or in recitation<br>4. I understand concepts I have studied in physics<br>5. If I wanted to, I could be good at physics research<br>6. ",     Reference = "Kalender, Z. Y., Marshman, E., Schunn, C. D., Nokes-Malach, T. J., & Singh, C. (2019). Gendered patterns in the construction of physics identity from motivational factors. Physical Review Physics Education Research, 15(2), [020119](https://journals.aps.org/prper/abstract/10.1103/PhysRevPhysEducRes.15.020119)"), row.names = c(NA, -1L), class = c("tbl_df", "tbl", "data.frame"))

when I try to produce a table I am not able to change teh widths of teh columns and I get teh error Error in UseMethod("nodeset_apply") : no applicable method for 'nodeset_apply' applied to an object of class "NULL"

BelQ  %>%
  kable(format = "html",escape = FALSE) %>%   kable_styling() %>% 
  scroll_box(width = "100%", height = "500px") %>% 
  kable_styling(full_width = F) %>%
  column_spec(1, width = "18em")

My code chunk has {r results="asis" }

Not sure why but scroll_box should go to the end and width_min to be used

BelQ  %>%
  kable(format = "html",escape = FALSE) %>%   
  kable_styling(full_width = F) %>% 
  column_spec(1, width_min = "18em")%>%
  scroll_box(width = "100%", height = "500px") 

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM