我试图在两个不同的对象中找到字符数据类型的重叠(在本例中为dataframes),并在R中返回重叠的百分比。
我的数据看起来就像
dput(lyrics_acousticness_upcoming0.01_frequency[1:100,])
structure(list(tolower.lyrics_acousticness_upcoming0.01. = structure(1:100, .Label = c(" late",
" miss it", " yeah", "1", "100", "1発打ったこのビートを鳴らしてよ",
"3x", "40", "5", "6", "9", "999", "a", "à", "aah", "aaliyah",
"about", "above", "account", "act", "actavis", "actin", "acting",
"acto", "acura", "add", "addicts", "adding", "admit", "afraid",
"after", "afterlife", "again", "against", "age", "ago", "ah",
"ahead", "ai", "aim", "ain", "air", "airin", "al", "album", "alguien",
"algún", "alive", "all", "almost", "alone", "along", "already",
"alright", "always", "am", "amazing", "amends", "âmes", "amor",
"an", "and", "and care", "and every morning", "and neither",
"and nobody", "and on", "and you shoulda too", "ange",
"angry", "another", "any", "anybody", "anyhow", "anymore", "anyone",
"anything", "apologized", "apparel", "arc", "are", "aren", "arenas",
"armes", "around", "arrest", "as", "ask", "asked", "askin", "at",
"atlanta", "attached", "attention", "attitude", "aussi", "austin",
"autres", "avenir", "aventura", "avenue", "away", "aww", "ayy",
"b", "baby", "babylon", "back", "backflips", "backwards", "backwoods",
"bad", "badder", "badge", "ball", "balloon", "band", "bandit",
"bank", "banks", "based", "basement", "bay", "bbk", "be", "be cool",
"beach", "beast", "beat", "beautiful", "beauty", "because", "becky",
"bed", "been", "beens", "bees", "before", "behind", "being",
"believe", "believed", "belong", "below", "bench", "bendin",
"bent", "best", "bet", "better", "big", "bigger", "billin", "billion",
"biscayne", "bitch", "bitches", "bitter", "black", "blade", "blame",
"blamin", "blatt", "blend", "bling", "block", "blossom", "blue",
"blunt", "bo", "boardin", "boat", "body", "bogey", "bone", "born",
"both", "bothers", "bottles", "bottom", "boucle", "bought", "bounce",
"bound", "bout", "bowtie", "boy", "boys", "bracelet", "brain",
"brand", "breads", "break", "breed", "bridge", "briefcase", "brim",
"bring", "britain", "britney", "broke", "buckle", "building",
"built", "bullshit", "bunny", "buried", "burning", "bus", "business",
"bust", "busy", "but", "butt", "buy", "by", "bye", "c", "cada",
"cadillacs", "cafe", "call", "callin", "came", "can", "cannot",
"cap", "capaces", "cards", "care", "carpet", "carried", "cars",
"cartier", "cash", "cashin", "catch", "catfish", "cathedral",
"cause", "cause i", "ce", "ceiling", "celebratin", "cell",
"certains", "cette", "chain", "champagne", "changed", "changes",
"cheapskate", "check", "chercher", "chest", "chill", "choice",
"choose", "chubbs", "ciel", "cielo", "city", "claimed", "class",
"cleansing", "clear", "clearly", "clearport", "clock", "close",
"closed", "closer", "clothes", "cloud", "clouds", "clubbin",
"coals", "cobblestone", "coeur", "coke", "cold", "collect", "college",
"come", "comfort", "comfortable", "coming", "comma", "comme",
"common", "condo", "control", "cool", "corner", "cosign", "could",
"couldn", "count", "countin", "country", "couple", "coups", "courtside",
"cover", "cozy", "crack", "crackhead", "crave", "crazy", "create",
"credit", "crest", "crew", "crib", "crime", "crossed", "crown",
"cure", "cursive", "cut", "cuz", "cuz in", "d", "dabble", "dame",
"damn", "damnation", "damned", "damon", "dance", "dangerous",
"dar", "dare", "darling", "dawg", "dawn", "day", "days", "de",
"dead", "deal", "dealing", "deals", "death", "debatin", "decide",
"decision", "decisions", "decorating", "deep", "deepest", "defend",
"definitely", "dem", "denzel", "des", "deserve", "desire", "destruction",
"detest", "devil", "di", "diamonds", "did", "didn", "die", "died",
"diet", "different", "difícil", "diggin", "direct", "dirty",
"dirtyin", "dis", "disait", "distance", "ditches", "divide",
"do", "dodging", "does", "doesn", "dog", "dogs", "doin", "doing",
"dois", "dolled", "dolly", "dominatin", "don", "done", "donuts",
"door", "doorknob", "dormais", "dormir", "dosed", "double", "doubt",
"down", "downplayin", "drake", "drama", "dre", "dream", "dreams",
"drink", "drive", "driven", "driving", "drizzy", "drop", "drove",
"drowned", "drug", "drum", "dry", "dubplate", "dude", "due",
"dug", "dumb", "dying", "dеfend", "e", "each", "early", "eastside",
"easy", "eat", "eating", "economy", "ed", "edge", "eh", "either",
"el", "else", "em", "embassy", "emotion", "en", "end", "endlessly",
"ends", "enemies", "energizer", "enfuir", "enough", "entends",
"entero", "entourage", "envolent", "es", "escape", "especially",
"espère", "est", "eternal", "eternity", "eux", "even", "ever",
"every", "everybody", "everyday", "everyone", "everything", "everywhere",
"evil", "exactly", "excited", "execute", "expect", "expecting",
"exposed", "exposеd", "extra", "eye", "eyes", "f", "face", "fact",
"fade", "failure", "fair", "fait", "faith", "fake", "fall", "fam",
"fame", "famous", "fantasies", "fast", "fate", "fault", "fausses",
"faut", "favorite", "fear", "fears", "features", "fed", "feel",
"feel straight", "feeling", "feelings", "feet", "fela", "fell",
"felt", "feu", "feus", "fight", "fighting", "final", "finally",
"find", "fine", "fines", "finger", "fingertips", "finna", "firm",
"first", "fish", "fit", "five", "fix", "fixate", "fl", "flame",
"flashy", "flatline", "flex", "float", "floor", "floors", "flow",
"fly", "flyin", "flying", "fo", "fooled", "for", "for myself",
"forced", "fore", "forever", "forget", "fort", "found", "fout",
"fragrance", "frankenstein", "franny", "frère", "fresh", "friday",
"friend", "friendly", "friends", "from", "front", "fuck", "fucked",
"fuckin", "fucking", "fucks", "full", "funny", "furs", "further",
"future", "g", "gala", "gallon", "game", "gang", "gangstas",
"gangster", "gasoline", "gave", "get", "gets", "gettin", "getting",
"gibbo", "gig", "gimme", "gimmе", "girl", "girls", "give", "given",
"glass", "glasses", "glowin", "go", "god", "goddamn", "goes",
"goin", "going", "gold", "gon", "gone", "gonna", "good", "got",
"gotta", "gotten", "gotti", "graduated", "grammy", "grams", "grandeza",
"grandir", "grave", "gravel", "greatest", "greatness", "greaze",
"green", "grew", "grind", "grippin", "grips", "groovy", "guarantee",
"guardin", "guest", "guidance", "guide", "gun", "guy", "guys",
"ha", "had", "hair", "hall", "halloween", "hand", "hands", "hang",
"hangin", "happened", "happiness", "hard", "harder", "has", "hate",
"hates", "haunted", "have", "have some love", "havin", "hawks",
"he", "head", "headlines", "hear", "heard", "hearin", "heart",
"heat", "heaven", "heavenly", "hectic", "hell", "hello", "help",
"hen", "henn", "hennessy", "her", "here", "hey", "hi", "hide",
"high", "higher", "him", "himself", "his", "hit", "hits", "ho",
"hoes", "hold", "holiday", "holler", "holy", "home", "homies",
"honey", "hood", "hookers", "hope", "hot", "hotel", "hotline",
"house", "how", "howard", "huh", "hundred", "hundreds", "hurt",
"hustlin", "hype", "i", "i have smaller", "i try", "i wanted to go",
"ice", "icy", "if", "il", "ill", "ils", "imagine", "immortal",
"important", "in", "inhibitions", "innocent", "inside", "inspirin",
"into", "invested", "invitation", "invited", "involved", "ironic",
"is", "islands", "isn", "it", "italians", "its", "j", "jacket",
"jail", "jang", "jealousy", "jeans", "jeez", "jet", "jeu", "jheeze",
"job", "jokes", "joking", "julie", "just", "karaoke", "keep",
"keep on", "keeping", "keepsake", "kettle", "keychain", "kid",
"kiddin", "kill", "kind", "kinda", "king", "kiss", "knew", "know",
"know i", "knowing", "known", "knows", "kobe", "kush", "kuti",
"l", "la", "là", "labels", "lady", "land", "lang", "language",
"larmes", "last", "late", "lately", "lay", "le", "lead", "leads",
"leaf", "learned", "learning", "least", "leather", "leave", "leavin",
"leaving", "left", "legacy", "legal", "lens", "les", "less",
"lessons", "let", "lettre", "lie", "lies", "life", "lifestyle",
"light", "like", "line", "linea", "lis", "list", "listen", "liter",
"little", "live", "lived", "livin", "living", "ll", "lo", "lonely",
"long", "look", "looking", "looks", "lord", "lose", "lost", "lot",
"lotta", "louis", "love", "loved", "loves", "low", "loyalty",
"luke", "luna", "luther", "lyin", "m", "m2", "m6", "ma", "mac",
"machine", "mack", "mad", "made", "madness", "magazine", "magdalene",
"maint", "major", "make", "makes", "makin", "making", "male",
"male friends", "malibu", "mall", "mally", "mama", "man", "mannie",
"mansions", "many", "margherita", "mark", "marry", "martin",
"martyr", "más", "mascot", "matrix", "matter", "matters", "maybe",
"me", "mean", "mean i", "meant", "medical", "medicine", "melt",
"mêmes", "memphis", "men", "menti", "mention", "menu", "met",
"metal", "mi", "miami", "miedo", "miette", "might", "mil", "mile",
"miles", "million", "millions", "mind", "mine", "mines", "minute",
"mirror", "miss", "missed", "missions", "missus", "mistake",
"mistakes", "mixed", "mixtape", "mj", "mm", "mmm", "mo", "moi",
"moment", "monday", "monde", "money", "monster", "months", "montre",
"moon", "more", "most", "mostrarle", "motel", "motherfucker",
"motherfuckers", "motherfuckin", "motion", "motor", "motto",
"mountain", "mouth", "move", "moved", "moves", "movie", "movin",
"mr", "much", "muddy", "multiplying", "must", "my", "my heart",
"myself", "n", "na", "nadie", "nan", "nant", "nasty", "naturally",
"ne", "need", "needed", "needle", "needs", "negative", "neither",
"nerve", "nerves", "nervous", "never", "nevermind", "new", "news",
"next", "nice", "nicki", "nigga", "niggas", "night", "nights",
"niko", "nine", "nir", "no", "nobody", "noddin", "noise", "none",
"normal", "not", "nother", "nothin", "nothing", "nous", "now",
"nuit", "number", "nеrve", "o", "of", "off", "oh", "ojos", "okay",
"old", "older", "on", "once", "one", "online", "only", "ooh",
"open", "opened", "opi", "opinion", "opposite", "or", "orleans",
"ot", "other", "oti", "ouais", "our", "out", "outs", "outta",
"over", "overrated", "overseas", "ovo", "owe", "own", "p", "paddle",
"pages", "paid", "pain", "panoramic", "papa", "paparazzi", "papers",
"para", "pardon", "park", "part", "partir", "parton", "party",
"pas", "pass", "passion", "passport", "past", "patek", "patience",
"patron", "pay", "peace", "peach", "peaks", "peel", "pen", "pendus",
"people", "pepperoni", "percocet", "perderme", "perdus", "persian",
"person", "personified", "pete", "phone", "photo", "piece", "pimp",
"pimpin", "pink", "pippen", "pissed", "place", "places", "plan",
"planeta", "planner", "plans", "plat", "platinum", "play", "players",
"playground", "playin", "plus", "po", "pocket", "point", "poison",
"pole", "police", "politician", "pool", "pop", "por", "posing",
"poster", "posеd", "pour", "powers", "prada", "pray", "preaching",
"precious", "prefer", "president", "presidential", "pretend",
"pretty", "price", "pride", "prime", "prison", "probably", "problem",
"problems", "profile", "promis", "proof", "protest", "proud",
"prove", "psychic", "puerta", "puisque", "pull", "purpose", "pushin",
"pushing", "pussy", "pussyholes", "put", "puttin", "qu", "qualification",
"quand", "que", "quick", "quit", "quitte", "quizá", "r", "race",
"rain", "ralentit", "ran", "rap", "rapper", "rappin", "ras",
"rate", "rather", "razor", "re", "reached", "reaction", "read",
"ready", "real", "realest", "reality", "realize", "really", "reason",
"record", "records", "red", "referring", "refuse to", "regarde",
"relay", "religion", "remake", "remember", "reply", "reputation",
"researchin", "reservations", "respect", "rest", "restera", "restraint",
"retirement", "rev", "revenge", "rhythm", "rich", "riddim", "ride",
"ridge", "riding", "right", "ring", "rips", "risk", "road", "rock",
"rockin", "roll", "rolled", "rollie", "rolling", "romance", "room",
"rough", "round", "row", "rr", "rubber", "rugs", "ruin", "run",
"runnin", "running", "runs", "rush", "rushing", "s", "sad", "safe",
"sag", "said", "saigne", "sailed", "sake", "salad", "salir",
"same", "santa", "satan", "save", "saviour", "saw", "say", "sayin",
"saying", "says", "scared", "scene", "scènes", "scottie", "scratch",
"sea", "seat", "secret", "secrets", "security", "see", "seem",
"seen", "self", "send", "sense", "sensе", "separa", "service",
"seven", "seventeen", "sex", "shame", "share", "she", "sheet",
"shelter", "sheriff", "shh", "shine", "shing", "ship", "shirt",
"shit", "shocking", "shoes", "shorty", "shots", "should", "shoulda",
"shouldn", "shout", "shovel", "show", "shower", "showin", "showing",
"showtime", "shut", "si", "side", "sides", "sign", "signals",
"silence", "simple", "since", "singin", "singing", "single",
"sit", "sittin", "sitting", "six", "skeet", "sleep", "slice",
"slow", "smaller", "smart", "smoke", "snowin", "snug", "so",
"social", "solid", "solo", "some", "somebody", "someday", "someone",
"something", "sometimes", "somewhere", "son", "sont", "soon",
"soul", "sound", "sound different", "south", "space", "spaceship",
"spanish", "speak", "special", "speed", "spell", "spend", "spit",
"spotlight", "spray", "squad", "stacks", "stand", "star", "start",
"started", "starting", "state", "statement", "stay", "stick",
"still", "stones", "stop", "stories", "story", "straddling",
"straight", "street", "streets", "strength", "stressed", "stripper",
"strong", "stuck", "study", "stunna", "stunt", "stupid", "style",
"such", "sugar", "suicide", "summer", "sunshine", "supermodel",
"suppose", "supposed", "sur", "sure", "surely", "sûrement",
"surface", "surprised", "surrounded", "survived", "suzuki", "swag",
"swam", "swear", "sweepstakes", "sweet", "sweetest", "swervin",
"switch", "switches", "switchin", "symptom", "t", "t say what",
"tag", "tailor", "take", "taken", "takes", "takin", "taking",
"taliban", "talk", "talkin", "talking", "talks", "tall", "taller",
"tanto", "taping", "taught", "te", "tea", "team", "tech", "tell",
"tellin", "telling", "tells", "temps", "tengo", "tenir", "tennessee",
"tenue", "testimony", "text", "texts", "than", "thang", "that",
"the", "them", "then", "there", "these", "they", "thing", "things",
"think", "thinkin", "thinking", "thirsty", "thirty", "this",
"those", "thou", "though", "thought", "thoughts", "thread", "three",
"through", "throwin", "thе", "ti", "ticket", "tied", "tiempo",
"ties", "tight", "til", "till", "time", "times", "timin", "ting",
"tints", "tit", "tits", "to", "toast", "today", "todos", "together",
"toi", "told", "tongue", "tonight", "too", "toodles", "took",
"top", "tore", "toronto", "tote", "touch", "touched", "touching",
"tough", "toujours", "tour", "tout", "town", "tracin", "traitors",
"trampoline", "trauma", "travel", "treadmill", "treat", "tree",
"tried", "trigger", "trillion", "trip", "trippin", "trop", "trophy",
"trouble", "troubled", "true", "trust", "truth", "try", "try to be cool",
"trying", "tryna", "tu", "tune", "tunechi", "tunnel", "turn",
"turnin", "turns", "turnt", "tus", "twenty", "twisted", "two",
"tyme", "type", "ugk", "uh", "uhh", "umbrella", "umpire", "un",
"una", "unbearable", "uncle", "under", "underground", "understand",
"undiscovered", "unless", "unlucky", "unreal", "unruly", "until",
"up", "upside", "uptown", "us", "used", "values", "vas", "vayan",
"ve", "venue", "venus", "verme", "very", "veut", "vez", "viens",
"view", "views", "villain", "vision", "voodoo", "voulais", "waist",
"wait", "walk", "walking", "wall", "walls", "wanna", "want",
"want to", "want to know", "wanted", "wants", "warm", "was",
"wasn", "waste", "wasted", "watch", "watched", "water", "way",
"wayans", "ways", "we", "weak", "weakness", "weapon", "wear",
"wearing", "wedding", "weed", "weekend", "well", "went", "were",
"wet", "what", "whatever", "when", "whenever", "where", "where my",
"whereabouts", "which", "whip", "whippin", "whitney", "who",
"whoever", "whole", "why", "wife", "wildin", "will", "williams",
"win", "wind", "wine", "wings", "winnin", "wise", "wish", "wished",
"wishing", "with", "with a", "without", "woman", "women", "won",
"wonder", "wonderin", "wondering", "woo", "wood", "woodgrain",
"word", "work", "workin", "working", "world", "worry", "worse",
"worth", "would", "wouldn", "wow", "wrist", "wrong", "wrote",
"wе", "xanax", "y", "ya", "yachts", "yale", "yeah", "year",
"years", "yes", "yesterday", "ymca", "ymcmb", "yo", "yolo", "york",
"you", "young", "youngest", "your", "yours", "yourself", "zone",
"ぁあ", "あなたの言葉は この鼻を伸ばす", "あの子の顔 探しても見当たらない",
"あれほど生きてきたけど全ては夢みたい", "あれもこれも",
"あれもこれも魅力的でも私は君がいい", "あんたに聴かすだけだから",
"カッコの悪い 恋の歌", "ここに", "このくらいがちょうどいいかなって",
"さぁ", "さながら", "さよならがあんたに捧ぐ愛の言葉",
"さよならべいべ", "そのエロい体を貸してくれ",
"その一瞬の隙を運命は 見逃してくれない",
"それでいいでしょ", "そんなことはどうでもいいからって",
"だいたいこんなもん", "だいたいそんなもん",
"だから涙は見せずに さよならべいべ", "だから笑って手を振る さよならべいべ",
"だけどそれが分かって本当に良かった", "ちょっと待ったって",
"ついハイになって", "で", "でも何もかもが不快だね",
"どうかしそうやこの胸は", "どこにいたの 探してたよ",
"どこまでも どこまでも", "どっかいっちゃって",
"どれほど朽ち果てようと最後にゃ笑いたい",
"なんとかしてや", "の歌詞", "はみ出したったモノを隠す場所もない",
"まぁいいかな", "まぁいいから", "まやかしの宝 見せかけの光",
"もう二度と犯さない", "もう行く時間か 最後までカッコ悪いわしじゃったな",
"わしかてずっと一緒におりたかったわ", "世間は許しちゃくれやせんよ",
"今日も愉快だね", "伝えた日", "何か分かったようで 何も分かってなくて",
"何のために戦おうとも動機は愛がいい", "何もかも 捨ててくよ",
"余裕のない 愛の言葉", "優しかった いつも支えてくれた 信じてた",
"先天的だ過敏なこの衝動", "別れはみんないつか通る道じゃんか",
"刺さった枯れ木に注いだ火", "前に進むことしか出来ん道じゃから",
"叶えたい想像に", "君とならば さらり さらり",
"君とならばさらり さらり", "塞いだ目", "大炎上大炎上大炎上大炎上大炎上",
"常にここに ここに", "引き返せなくて", "当たり前なんてない",
"恥ずかしいカン違い", "息せき切ってきたの",
"意地はっても すぐに崩れるし", "手を抜いて",
"振られるくらいが僕らしいんだもん", "携帯越しの タッグファイト",
"支えたいと君に", "散々だな後悔はないけど",
"新しい扉を叩き割った", "新しい日々は探さずとも常に ここに",
"新しい日々も 拙い過去も 全てがきらり",
"明け行く夕日の中を今夜も昼下がり さらり",
"時には途方に暮れてただ風に吹かれて ゆらり",
"時間てこんな 冷たかったかな", "来んと思った 時はすぐに来た",
"気付けば", "気恥ずかしいから 置き手紙だけで許してな",
"永遠に きらり", "泣いとる時間もないようになるけどな 今",
"瀬戸際の見栄が この首を絞める", "無くしてしまったものを振り返って ほろり",
"煩わしいから 何にも包まずにおくわ", "珍回答だ僕は気にしないけど",
"理不尽がお決まりの世界だもん", "生きてきたけど全ては夢みたい",
"着色の言葉 無味無臭の心", "私だって 私だって",
"空気の読めぬ 恋の歌", "紛らわしいから まっすぐな言葉にするわ",
"自分で一人 生きてきたって 果たしたって",
"自分にも周りの人にもバレないように", "自分にも周りの人にもバレないように利を振って",
"自分のモンなんてない", "自己満たちが踊る世界だもん",
"色々見てきたけれどこの瞳は永遠に きらり",
"荒れ狂う 季節の中も 群衆の中も", "荒れ狂う季節の中を二人は一人きり さらり",
"藤井風", "行き先は決めたの", "行き違って 行き違って",
"裸のまま透明な服を着た王様だ", "裸足だって 裸足だって",
"見栄はっても すぐに剥がれるし", "誰も知らない ミッドナイト",
"誰も見とらんから少しくらいええかな", "調子のっちゃって",
"調子のんないで", "迷わずに行きたいけど保証はしないよ",
"連れてって 連れてって", "風に乗って 風に乗って",
"飾りのない 愛の言葉", "魅力的でも私は君がいい"
), class = "factor"), Freq = c(1L, 2L, 4L, 2L, 4L, 2L, 1L, 2L,
2L, 4L, 1L, 2L, 670L, 1L, 4L, 6L, 87L, 1L, 22L, 28L, 2L, 2L,
3L, 2L, 12L, 3L, 1L, 15L, 6L, 4L, 3L, 2L, 20L, 1L, 5L, 8L, 38L,
16L, 2L, 2L, 90L, 68L, 2L, 2L, 1L, 2L, 2L, 14L, 220L, 6L, 43L,
14L, 14L, 1L, 53L, 91L, 10L, 2L, 4L, 2L, 12L, 577L, 1L, 1L, 1L,
1L, 1L, 1L, 2L, 4L, 5L, 7L, 9L, 4L, 18L, 8L, 12L, 2L, 5L, 4L,
78L, 2L, 2L, 4L, 32L, 1L, 38L, 39L, 13L, 6L, 54L, 4L, 2L, 6L,
5L, 2L, 1L, 1L, 1L, 3L)), row.names = c(NA, 100L), class = "data.frame")
dput(sad_words[1:100,])
structure(list(word = c("abandon", "abandoned", "abandonment",
"abduction", "abortion", "abortive", "abscess", "absence", "absent",
"absentee", "abuse", "abysmal", "abyss", "accident", "accursed",
"ache", "aching", "adder", "adrift", "adultery", "adverse", "adversity",
"afflict", "affliction", "affront", "aftermath", "aggravating",
"agony", "ail", "ailing", "alcoholism", "alienated", "alienation",
"anathema", "anchorage", "anguish", "animosity", "annihilated",
"annihilation", "annulment", "anthrax", "antisocial", "anxiety",
"apathetic", "apathy", "apologize", "appendicitis", "arid", "arraignment",
"arsenic", "art", "ashamed", "ashes", "assailant", "assassin",
"assassination", "atherosclerosis", "atrocity", "atrophy", "attacking",
"attenuation", "austere", "autopsy", "avalanche", "awful", "backwater",
"bacteria", "bad", "badly", "bang", "banish", "banished", "banishment",
"bankrupt", "bankruptcy", "banshee", "barren", "bastard", "battered",
"battled", "beating", "beg", "beggar", "belittle", "bereaved",
"bereavement", "betray", "betrayal", "bier", "bigoted", "bitch",
"bitterly", "bitterness", "blackness", "bleak", "bleeding", "blemish",
"blight", "blighted", "blindly"), sadness = c(TRUE, TRUE, TRUE,
TRUE, TRUE, TRUE, TRUE, TRUE, TRUE, TRUE, TRUE, TRUE, TRUE, TRUE,
TRUE, TRUE, TRUE, TRUE, TRUE, TRUE, TRUE, TRUE, TRUE, TRUE, TRUE,
TRUE, TRUE, TRUE, TRUE, TRUE, TRUE, TRUE, TRUE, TRUE, TRUE, TRUE,
TRUE, TRUE, TRUE, TRUE, TRUE, TRUE, TRUE, TRUE, TRUE, TRUE, TRUE,
TRUE, TRUE, TRUE, TRUE, TRUE, TRUE, TRUE, TRUE, TRUE, TRUE, TRUE,
TRUE, TRUE, TRUE, TRUE, TRUE, TRUE, TRUE, TRUE, TRUE, TRUE, TRUE,
TRUE, TRUE, TRUE, TRUE, TRUE, TRUE, TRUE, TRUE, TRUE, TRUE, TRUE,
TRUE, TRUE, TRUE, TRUE, TRUE, TRUE, TRUE, TRUE, TRUE, TRUE, TRUE,
TRUE, TRUE, TRUE, TRUE, TRUE, TRUE, TRUE, TRUE, TRUE)), row.names = c(NA,
-100L), class = c("tbl_df", "tbl", "data.frame"))在这里,必须检查来自tolower.lyrics_acousticness_upcoming0.01. dataframe的lyrics_acousticness_upcoming0.01_frequency列条目是否与来自sad_words dataframe的word列中的重叠内容,而在lyrics_acousticness_upcoming0.01_frequency dataframe中的所有单词中,所需的是重叠内容的百分比。
欢迎所有建议。
发布于 2022-11-04 15:25:43
首先,我建议始终放置一个小的输入数据集,使其易于复制。这就是你要找的百分比吗?
overlapped = lyrics_acousticness_upcoming0.01_frequency %>%
select(tolower.lyrics_acousticness_upcoming0.01.) %>%
unique() %>%
rename(word = "tolower.lyrics_acousticness_upcoming0.01.") %>%
inner_join(sad_words %>% select(word) %>% unique())
total_words_lyrics_acousticness_upcoming0.01_frequency =
lyrics_acousticness_upcoming0.01_frequency %>%
select(all_word) %>%
unique() %>%
tally()
total_words_matching = overlapped %>%
select(word) %>%
unique() %>%
tally()
pct = total_words_matching$n %>%
unique()
total_words_lyrics_acousticness_upcoming0.01_frequency$n %>%
unique()我假定all_word是您的专栏文章之一,您提到了“在lyrics_acousticness_upcoming0.01_frequency数据文件中的所有单词中”。
发布于 2022-11-07 18:43:05
您可以使用mean(x %in% y)从另一个向量中获取元素的比例。对于您的数据,这将是:
mean(lyrics_acousticness_upcoming0.01_frequency$tolower.lyrics_acousticness_upcoming0.01. %in% sad_words$word)
# 0第一个数据文件中的单词None出现在第二个数据帧中,因此%为0。
如果我们编出一个确实有一些重叠的例子:
set.seed(13)
data(words, package = "stringr")
df1 <- data.frame(x = sample(words, 500))
df2 <- data.frame(y = sample(words, 500))
mean(df1$x %in% df2$y)
# 0.482df1$x中约48%的单词出现在df2$y中。
https://stackoverflow.com/questions/74282121
复制相似问题