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