Convert collection of html nodes into data frame

html_attrs_dfr(
  x,
  attrs = NULL,
  trim = FALSE,
  defaults = NA_character_,
  add_text = TRUE
)

Arguments

x

xml_nodeset object, containing text and attributes of interest

attrs

character vector of attribute names. If missing, all attributes will be used

trim

if TRUE, will trim leading and trailing spaces

defaults

character vector of default values to be passed to rvest::html_attr(). Recycled to match length of attrs

add_text

if TRUE, node content will be added as .text column (using rvest::html_text)

Value

data frame with one row per xml node, consisting of an html_text column with text and additional columns with attributes

Examples

# \donttest{ library(polite) library(rvest)
#> Loading required package: xml2
bow("https://en.wikipedia.org/wiki/List_of_cognitive_biases") %>% scrape() %>% html_nodes("tr td:nth-child(1) a") %>% html_attrs_dfr()
#> href #> 1 /wiki/Agent_detection #> 2 /wiki/Ambiguity_effect #> 3 /wiki/Anchoring #> 4 /wiki/Anthropocentric_thinking #> 5 /wiki/Anthropomorphism#Psychology_of_Anthropomorphism #> 6 /wiki/Attentional_bias #> 7 /wiki/Attribute_substitution #> 8 /wiki/Automation_bias #> 9 /wiki/Availability_heuristic #> 10 /wiki/Availability_cascade #> 11 /wiki/Backfire_effect #> 12 /wiki/Bandwagon_effect #> 13 /wiki/Base_rate_fallacy #> 14 /wiki/Belief_bias #> 15 /wiki/Ben_Franklin_effect #> 16 /wiki/Berkson%27s_paradox #> 17 /wiki/Bias_blind_spot #> 18 /wiki/Choice-supportive_bias #> 19 /wiki/Clustering_illusion #> 20 /wiki/Compassion_fade #> 21 /wiki/Confirmation_bias #> 22 /wiki/Congruence_bias #> 23 /wiki/Conjunction_fallacy #> 24 /wiki/Conservatism_(belief_revision) #> 25 /wiki/Continued_influence_effect #> 26 /wiki/Contrast_effect #> 27 /wiki/Curse_of_knowledge #> 28 /wiki/Declinism #> 29 /wiki/Decoy_effect #> 30 /wiki/Default_effect #> 31 /wiki/Denomination_effect #> 32 /wiki/Disposition_effect #> 33 /wiki/Distinction_bias #> 34 /wiki/Dunning%E2%80%93Kruger_effect #> 35 /wiki/Duration_neglect #> 36 /wiki/Empathy_gap #> 37 /wiki/End-of-history_illusion #> 38 /wiki/Endowment_effect #> 39 /wiki/Experimenter%27s_bias #> 40 /wiki/Expectation_bias #> 41 /wiki/Focusing_effect #> 42 /wiki/Forer_effect #> 43 /wiki/Barnum_effect #> 44 /wiki/Framing_effect_(psychology) #> 45 /wiki/Functional_fixedness #> 46 /wiki/Gambler%27s_fallacy #> 47 /wiki/Second-generation_gender_bias #> 48 /wiki/Groupthink #> 49 /wiki/Hard%E2%80%93easy_effect #> 50 /wiki/Hindsight_bias #> 51 /wiki/Hostile_attribution_bias #> 52 /wiki/Hot-hand_fallacy #> 53 /wiki/Hyperbolic_discounting #> 54 /wiki/IKEA_effect #> 55 /wiki/Illicit_transference #> 56 /wiki/Illusion_of_control #> 57 /wiki/Illusion_of_validity #> 58 /wiki/Illusory_correlation #> 59 /wiki/Illusory_truth_effect #> 60 /wiki/Impact_bias #> 61 /wiki/Implicit_association_test #> 62 /wiki/Information_bias_(psychology) #> 63 /wiki/Insensitivity_to_sample_size #> 64 /wiki/Escalation_of_commitment #> 65 /wiki/Law_of_the_instrument #> 66 /wiki/Less-is-better_effect #> 67 /wiki/Look-elsewhere_effect #> 68 /wiki/Loss_aversion #> 69 /wiki/Mere_exposure_effect #> 70 /wiki/Money_illusion #> 71 /wiki/Moral_credential #> 72 /wiki/Negativity_bias #> 73 /wiki/Neglect_of_probability #> 74 /wiki/Normalcy_bias #> 75 /wiki/Not_invented_here #> 76 /wiki/Observer-expectancy_effect #> 77 /wiki/Omission_bias #> 78 /wiki/Optimism_bias #> 79 /wiki/Ostrich_effect #> 80 /wiki/Outcome_bias #> 81 /wiki/Overconfidence_effect #> 82 /wiki/Pareidolia #> 83 /wiki/Pygmalion_effect #> 84 /wiki/Pessimism_bias #> 85 /wiki/Plan_continuation_bias #> 86 /wiki/Planning_fallacy #> 87 /wiki/Present_bias #> 88 /wiki/Plant_blindness #> 89 /wiki/Pro-innovation_bias #> 90 /wiki/Projection_bias #> 91 /wiki/Pseudocertainty_effect #> 92 /wiki/Reactance_(psychology) #> 93 /wiki/Reactive_devaluation #> 94 /wiki/Recency_illusion #> 95 /wiki/Restraint_bias #> 96 /wiki/Rhyme_as_reason_effect #> 97 /wiki/Risk_compensation #> 98 /wiki/Peltzman_effect #> 99 /wiki/Salience_bias #> 100 /wiki/Selection_bias #> 101 /wiki/Selective_perception #> 102 /wiki/Semmelweis_reflex #> 103 /wiki/Sexual_overperception_bias #> 104 /wiki/Sexual_underperception_bias #> 105 /wiki/Social_comparison_bias #> 106 /wiki/Social_desirability_bias #> 107 /wiki/Status_quo_bias #> 108 /wiki/Stereotyping #> 109 /wiki/Subadditivity_effect #> 110 /wiki/Subjective_validation #> 111 /wiki/Surrogation #> 112 /wiki/Survivorship_bias #> 113 /wiki/Time-saving_bias #> 114 /wiki/Third-person_effect #> 115 /wiki/Parkinson%27s_law_of_triviality #> 116 /wiki/Weber%E2%80%93Fechner_law #> 117 /wiki/Well_travelled_road_effect #> 118 /wiki/Women_are_wonderful_effect #> 119 /wiki/Zero-risk_bias #> 120 /wiki/Zero-sum_thinking #> 121 /wiki/Actor-observer_bias #> 122 /wiki/Authority_bias #> 123 /wiki/Cheerleader_effect #> 124 /wiki/Defensive_attribution_hypothesis #> 125 /wiki/Egocentric_bias #> 126 /wiki/Extrinsic_incentives_bias #> 127 /wiki/False_consensus_effect #> 128 /wiki/False_uniqueness_bias #> 129 /wiki/Fundamental_attribution_error #> 130 /wiki/Group_attribution_error #> 131 /wiki/Halo_effect #> 132 /wiki/Illusion_of_asymmetric_insight #> 133 /wiki/Illusion_of_external_agency #> 134 /wiki/Illusion_of_transparency #> 135 /wiki/Illusory_superiority #> 136 /wiki/Ingroup_bias #> 137 /wiki/Just-world_hypothesis #> 138 /wiki/Moral_luck #> 139 /wiki/Na%C3%AFve_cynicism #> 140 /wiki/Na%C3%AFve_realism_(psychology) #> 141 /wiki/Outgroup_homogeneity_bias #> 142 /wiki/Puritanical_bias #> 143 /wiki/Self-serving_bias #> 144 /wiki/Shared_information_bias #> 145 /wiki/System_justification #> 146 /wiki/Trait_ascription_bias #> 147 /wiki/Ultimate_attribution_error #> 148 /wiki/Worse-than-average_effect #> 149 /wiki/Bizarreness_effect #> 150 /wiki/Cue-dependent_forgetting #> 151 /wiki/Cross-race_effect #> 152 /wiki/Cryptomnesia #> 153 /wiki/Egocentric_bias #> 154 /wiki/Fading_affect_bias #> 155 /wiki/False_memory #> 156 /wiki/Generation_effect #> 157 /wiki/Google_effect #> 158 /wiki/Leveling_and_sharpening #> 159 /wiki/Levels-of-processing_effect #> 160 /wiki/Misinformation_effect #> 161 /wiki/Modality_effect #> 162 /wiki/State-dependent_memory #> 163 /wiki/Next-in-line_effect #> 164 /wiki/Part-list_cueing_effect #> 165 /wiki/Peak-end_rule #> 166 /wiki/Picture_superiority_effect #> 167 /wiki/Socioemotional_selectivity_theory #> 168 /wiki/Serial_position_effect #> 169 /wiki/Reminiscence_bump #> 170 /wiki/Self-reference_effect #> 171 /wiki/Misattribution_of_memory #> 172 /wiki/Spacing_effect #> 173 /wiki/Spotlight_effect #> 174 /wiki/Suggestibility#External #> 175 /wiki/Tachypsychia #> 176 /wiki/Telescoping_effect #> 177 /wiki/Testing_effect #> 178 /wiki/Tip_of_the_tongue #> 179 /wiki/Von_Restorff_effect #> 180 /wiki/Zeigarnik_effect #> 181 <NA> #> 182 /wiki/List_of_memory_biases #> title class #> 1 Agent detection <NA> #> 2 Ambiguity effect <NA> #> 3 Anchoring mw-redirect #> 4 Anthropocentric thinking mw-redirect #> 5 Anthropomorphism <NA> #> 6 Attentional bias <NA> #> 7 Attribute substitution <NA> #> 8 Automation bias <NA> #> 9 Availability heuristic <NA> #> 10 Availability cascade <NA> #> 11 Backfire effect mw-redirect #> 12 Bandwagon effect <NA> #> 13 Base rate fallacy <NA> #> 14 Belief bias <NA> #> 15 Ben Franklin effect <NA> #> 16 Berkson's paradox <NA> #> 17 Bias blind spot <NA> #> 18 Choice-supportive bias <NA> #> 19 Clustering illusion <NA> #> 20 Compassion fade <NA> #> 21 Confirmation bias <NA> #> 22 Congruence bias <NA> #> 23 Conjunction fallacy <NA> #> 24 Conservatism (belief revision) <NA> #> 25 Continued influence effect mw-redirect #> 26 Contrast effect <NA> #> 27 Curse of knowledge <NA> #> 28 Declinism <NA> #> 29 Decoy effect <NA> #> 30 Default effect <NA> #> 31 Denomination effect <NA> #> 32 Disposition effect <NA> #> 33 Distinction bias <NA> #> 34 Dunning–Kruger effect <NA> #> 35 Duration neglect <NA> #> 36 Empathy gap <NA> #> 37 End-of-history illusion <NA> #> 38 Endowment effect <NA> #> 39 Experimenter's bias mw-redirect #> 40 Expectation bias mw-redirect #> 41 Focusing effect mw-redirect #> 42 Forer effect mw-redirect #> 43 Barnum effect <NA> #> 44 Framing effect (psychology) <NA> #> 45 Functional fixedness <NA> #> 46 Gambler's fallacy <NA> #> 47 Second-generation gender bias <NA> #> 48 Groupthink <NA> #> 49 Hard–easy effect <NA> #> 50 Hindsight bias <NA> #> 51 Hostile attribution bias <NA> #> 52 Hot-hand fallacy mw-redirect #> 53 Hyperbolic discounting <NA> #> 54 IKEA effect <NA> #> 55 Illicit transference mw-redirect #> 56 Illusion of control <NA> #> 57 Illusion of validity <NA> #> 58 Illusory correlation <NA> #> 59 Illusory truth effect <NA> #> 60 Impact bias <NA> #> 61 Implicit association test mw-redirect #> 62 Information bias (psychology) <NA> #> 63 Insensitivity to sample size <NA> #> 64 Escalation of commitment <NA> #> 65 Law of the instrument <NA> #> 66 Less-is-better effect <NA> #> 67 Look-elsewhere effect <NA> #> 68 Loss aversion <NA> #> 69 Mere exposure effect mw-redirect #> 70 Money illusion <NA> #> 71 Moral credential mw-redirect #> 72 Negativity bias <NA> #> 73 Neglect of probability <NA> #> 74 Normalcy bias <NA> #> 75 Not invented here <NA> #> 76 Observer-expectancy effect <NA> #> 77 Omission bias <NA> #> 78 Optimism bias <NA> #> 79 Ostrich effect <NA> #> 80 Outcome bias <NA> #> 81 Overconfidence effect <NA> #> 82 Pareidolia <NA> #> 83 Pygmalion effect <NA> #> 84 Pessimism bias mw-redirect #> 85 Plan continuation bias mw-redirect #> 86 Planning fallacy <NA> #> 87 Present bias <NA> #> 88 Plant blindness <NA> #> 89 Pro-innovation bias <NA> #> 90 Projection bias mw-redirect #> 91 Pseudocertainty effect <NA> #> 92 Reactance (psychology) <NA> #> 93 Reactive devaluation <NA> #> 94 Recency illusion <NA> #> 95 Restraint bias <NA> #> 96 Rhyme as reason effect mw-redirect #> 97 Risk compensation <NA> #> 98 Peltzman effect mw-redirect #> 99 Salience bias mw-redirect #> 100 Selection bias <NA> #> 101 Selective perception <NA> #> 102 Semmelweis reflex <NA> #> 103 Sexual overperception bias mw-redirect #> 104 Sexual underperception bias mw-redirect #> 105 Social comparison bias <NA> #> 106 Social desirability bias <NA> #> 107 Status quo bias <NA> #> 108 Stereotyping mw-redirect #> 109 Subadditivity effect <NA> #> 110 Subjective validation <NA> #> 111 Surrogation <NA> #> 112 Survivorship bias <NA> #> 113 Time-saving bias <NA> #> 114 Third-person effect <NA> #> 115 Parkinson's law of triviality mw-redirect #> 116 Weber–Fechner law <NA> #> 117 Well travelled road effect <NA> #> 118 Women are wonderful effect mw-redirect #> 119 Zero-risk bias <NA> #> 120 Zero-sum thinking <NA> #> 121 Actor-observer bias mw-redirect #> 122 Authority bias <NA> #> 123 Cheerleader effect <NA> #> 124 Defensive attribution hypothesis <NA> #> 125 Egocentric bias <NA> #> 126 Extrinsic incentives bias <NA> #> 127 False consensus effect <NA> #> 128 False uniqueness bias mw-redirect #> 129 Fundamental attribution error <NA> #> 130 Group attribution error <NA> #> 131 Halo effect <NA> #> 132 Illusion of asymmetric insight <NA> #> 133 Illusion of external agency <NA> #> 134 Illusion of transparency <NA> #> 135 Illusory superiority <NA> #> 136 Ingroup bias mw-redirect #> 137 Just-world hypothesis <NA> #> 138 Moral luck <NA> #> 139 Naïve cynicism <NA> #> 140 Naïve realism (psychology) <NA> #> 141 Outgroup homogeneity bias mw-redirect #> 142 Puritanical bias <NA> #> 143 Self-serving bias <NA> #> 144 Shared information bias <NA> #> 145 System justification <NA> #> 146 Trait ascription bias <NA> #> 147 Ultimate attribution error <NA> #> 148 Worse-than-average effect <NA> #> 149 Bizarreness effect <NA> #> 150 Cue-dependent forgetting <NA> #> 151 Cross-race effect <NA> #> 152 Cryptomnesia <NA> #> 153 Egocentric bias <NA> #> 154 Fading affect bias <NA> #> 155 False memory <NA> #> 156 Generation effect <NA> #> 157 Google effect <NA> #> 158 Leveling and sharpening <NA> #> 159 Levels-of-processing effect mw-redirect #> 160 Misinformation effect <NA> #> 161 Modality effect <NA> #> 162 State-dependent memory <NA> #> 163 Next-in-line effect <NA> #> 164 Part-list cueing effect mw-redirect #> 165 Peak-end rule mw-redirect #> 166 Picture superiority effect <NA> #> 167 Socioemotional selectivity theory <NA> #> 168 Serial position effect mw-redirect #> 169 Reminiscence bump <NA> #> 170 Self-reference effect <NA> #> 171 Misattribution of memory <NA> #> 172 Spacing effect <NA> #> 173 Spotlight effect <NA> #> 174 Suggestibility <NA> #> 175 Tachypsychia mw-redirect #> 176 Telescoping effect <NA> #> 177 Testing effect <NA> #> 178 Tip of the tongue <NA> #> 179 Von Restorff effect <NA> #> 180 Zeigarnik effect <NA> #> 181 <NA> mw-selflink selflink #> 182 List of memory biases <NA> #> .text #> 1 Agent detection #> 2 Ambiguity effect #> 3 Anchoring #> 4 Anthropocentric thinking #> 5 Anthropomorphism #> 6 Attentional bias #> 7 Attribute substitution #> 8 Automation bias #> 9 Availability heuristic #> 10 Availability cascade #> 11 Backfire effect #> 12 Bandwagon effect #> 13 Base rate fallacy #> 14 Belief bias #> 15 Ben Franklin effect #> 16 Berkson's paradox #> 17 Bias blind spot #> 18 Choice-supportive bias #> 19 Clustering illusion #> 20 Compassion fade #> 21 Confirmation bias #> 22 Congruence bias #> 23 Conjunction fallacy #> 24 Conservatism (belief revision) #> 25 Continued influence effect #> 26 Contrast effect #> 27 Curse of knowledge #> 28 Declinism #> 29 Decoy effect #> 30 Default effect #> 31 Denomination effect #> 32 Disposition effect #> 33 Distinction bias #> 34 Dunning–Kruger effect #> 35 Duration neglect #> 36 Empathy gap #> 37 End-of-history illusion #> 38 Endowment effect #> 39 Experimenter's #> 40 expectation bias #> 41 Focusing effect #> 42 Forer effect #> 43 Barnum effect #> 44 Framing effect #> 45 Functional fixedness #> 46 Gambler's fallacy #> 47 Gender bias #> 48 Groupthink #> 49 Hard–easy effect #> 50 Hindsight bias #> 51 Hostile attribution bias #> 52 Hot-hand fallacy #> 53 Hyperbolic discounting #> 54 IKEA effect #> 55 Illicit transference #> 56 Illusion of control #> 57 Illusion of validity #> 58 Illusory correlation #> 59 Illusory truth effect #> 60 Impact bias #> 61 Implicit association #> 62 Information bias #> 63 Insensitivity to sample size #> 64 Irrational escalation or Escalation of commitment #> 65 Law of the instrument #> 66 Less-is-better effect #> 67 Look-elsewhere effect #> 68 Loss aversion #> 69 Mere exposure effect #> 70 Money illusion #> 71 Moral credential effect #> 72 Negativity bias #> 73 Neglect of probability #> 74 Normalcy bias #> 75 Not invented here #> 76 Observer-expectancy effect #> 77 Omission bias #> 78 Optimism bias #> 79 Ostrich effect #> 80 Outcome bias #> 81 Overconfidence effect #> 82 Pareidolia #> 83 Pygmalion effect #> 84 Pessimism bias #> 85 Plan continuation bias #> 86 Planning fallacy #> 87 Present bias #> 88 Plant blindness #> 89 Pro-innovation bias #> 90 Projection bias #> 91 Pseudocertainty effect #> 92 Reactance #> 93 Reactive devaluation #> 94 Recency illusion #> 95 Restraint bias #> 96 Rhyme as reason effect #> 97 Risk compensation #> 98 Peltzman effect #> 99 Salience bias #> 100 Selection bias #> 101 Selective perception #> 102 Semmelweis reflex #> 103 Sexual overperception bias #> 104 Sexual underperception bias #> 105 Social comparison bias #> 106 Social desirability bias #> 107 Status quo bias #> 108 Stereotyping #> 109 Subadditivity effect #> 110 Subjective validation #> 111 Surrogation #> 112 Survivorship bias #> 113 Time-saving bias #> 114 Third-person effect #> 115 Parkinson's law of triviality #> 116 Weber–Fechner law #> 117 Well travelled road effect #> 118 Women are wonderful effect #> 119 Zero-risk bias #> 120 Zero-sum bias #> 121 Actor-observer bias #> 122 Authority bias #> 123 Cheerleader effect #> 124 Defensive attribution hypothesis #> 125 Egocentric bias #> 126 Extrinsic incentives bias #> 127 False consensus effect #> 128 False uniqueness bias #> 129 Fundamental attribution error #> 130 Group attribution error #> 131 Halo effect #> 132 Illusion of asymmetric insight #> 133 Illusion of external agency #> 134 Illusion of transparency #> 135 Illusory superiority #> 136 Ingroup bias #> 137 Just-world hypothesis #> 138 Moral luck #> 139 Naïve cynicism #> 140 Naïve realism #> 141 Outgroup homogeneity bias #> 142 Puritanical bias #> 143 Self-serving bias #> 144 Shared information bias #> 145 System justification #> 146 Trait ascription bias #> 147 Ultimate attribution error #> 148 Worse-than-average effect #> 149 Bizarreness effect #> 150 Context effect #> 151 Cross-race effect #> 152 Cryptomnesia #> 153 Egocentric bias #> 154 Fading affect bias #> 155 False memory #> 156 Generation effect #> 157 Google effect #> 158 Leveling and sharpening #> 159 Levels-of-processing effect #> 160 Misinformation effect #> 161 Modality effect #> 162 Mood-congruent memory bias #> 163 Next-in-line effect #> 164 Part-list cueing effect #> 165 Peak-end rule #> 166 Picture superiority effect #> 167 Socioemotional selectivity theory #> 168 Serial position effect #> 169 Reminiscence bump #> 170 Self-relevance effect #> 171 Source confusion #> 172 Spacing effect #> 173 Spotlight effect #> 174 Suggestibility #> 175 Tachypsychia #> 176 Telescoping effect #> 177 Testing effect #> 178 Tip of the tongue #> 179 von Restorff effect #> 180 Zeigarnik effect #> 181 General #> 182 Memory
# }