R 在字符串中查找特定字符串并总结

问题描述 投票:0回答:1

我想要总结调查数据中的 3 列,以便我可以正确地对它们进行分类。这 3 列是职位、行业和change_since_ai。

对于职位名称,我想将任何包含单词“CEO”(大写或小写)的单元格替换为 CEO。

最初,我有 31 个首席执行官的话,有了这个代码,我现在有 87 个。

gsub("ceo|CEO|owner|Ceo|Owner|executive|CEO |CEo|CE0|CEO/CEO|\\ceo|\\CEO", "CEO",aiprm$job_title)

但我仍然缺少这些要转换的:

首席执行官/创意总监、首席执行官兼制作人、首席执行官/首席执行官、首席执行官/设计师、首席执行官/运营商、首席执行官/SEO顾问。

关于如何转换这些内容有什么想法吗?

还有 1 个额外栏目,行业。我想转换为左边的单词,右边的任何单词。

行业
营销##营销-广告-广告
人工智能## IA-人工智能
金融##金融-银行-金融-
自由职业者 ## 自由职业者 - 自由职业者 - 远程 -
信息技术 ## IT - it - It。

数据如下:

https://drive.google.com/file/d/1_ywESP2cYat7y42VpzmPl-Gv6HYTQmFX/view?usp=sharing

这是前 200 行:

df <- structure(list(...1 = c(1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 
13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25, 26, 27, 28, 
29, 30, 31, 32, 33, 34, 35, 36, 37, 38, 39, 40, 41, 42, 43, 44, 
45, 46, 47, 48, 49, 50, 51, 52, 53, 54, 55, 56, 57, 58, 59, 60, 
61, 62, 63, 64, 65, 66, 67, 68, 69, 70, 71, 72, 73, 74, 75, 76, 
77, 78, 79, 80, 81, 82, 83, 84, 85, 86, 87, 88, 89, 90, 91, 92, 
93, 94, 95, 96, 97, 98, 99, 100, 101, 102, 103, 104, 105, 106, 
107, 108, 109, 110, 111, 112, 113, 114, 115, 116, 117, 118, 119, 
120, 121, 122, 123, 124, 125, 126, 127, 128, 129, 130, 131, 132, 
133, 134, 135, 136, 137, 138, 139, 140, 141, 142, 143, 144, 145, 
146, 147, 148, 149, 150, 151, 152, 153, 154, 155, 156, 157, 158, 
159, 160, 161, 162, 163, 164, 165, 166, 167, 168, 169, 170, 171, 
172, 173, 174, 175, 176, 177, 178, 179, 180, 181, 182, 183, 184, 
185, 186, 187, 188, 189, 190, 191, 192, 193, 194, 195, 196, 197, 
198, 199, 200), job_title = c("Marketing Director", "Digital Content Manager", 
"Owner", "Content Principal", "Chief Consultant", "Managing Director", 
"Senior SEO Analyst", "Senior SEO Specialist", "Head of Content", 
"content manager", "CEO", "Head of SEO", "Owner/SEO Consultant", 
"Snr Manager, SEO + Talent", "Head of Web and Digital Communications", 
"VP of SEO & Content", "SEO consultant", "SEO Specialist", "SEO Director", 
"Owner", "Team Director, SEO", "SEO Outreach Specialist", "SEO Professional", 
"Owner", "CEO", "Chief Discoverability Officer (formerly Managing Director, Discoverability)", 
"CRO", "Founder and SEO", "SEO Manager", "Global Seo Lead", "Sr SEO Analyst (consultant)", 
"Director of Product", "Digital Content Manager", "SEO Specialist", 
"SEO Consultant", "COO", "Senior SEO Manager", "Sep specialist", 
"SEO account director", "CTO", "Assistente de comunicação", 
"COO", "Senior SEO Analyst", "Head of Digital", "Owner", "CTO Co-Founder", 
"Director of Spa Opperations", "Founder", "Director", "management", 
"Freelancer", "PhD", "Manager", "Sales", "Filmmaker", "Evil Scientist (COO, CTO)", 
"Gas Engineer", "pro arif", "Sales", "Content & SEO", "CEO", 
"Global Medical L&D Manager", "Owner", "Outreach Committee Chair, Board Member", 
"COMMUNITY MANAGER", "Broker / Owner", "Founder & CEO", "Owner", 
"Broker Associate", "Owner/Designer", "Sales Director", "Manager", 
"SEO", "Administrator", "Founder", "IT Manager", "営業", "CEO", 
"Dhdhdh", "CEO", "President & Chief Brand Strategist", "Principal", 
"MD", "ADMINISTRADOR", "Owner", "Company Representative", "owner", 
"owner", "Social worker", "Digital Performance Specialist", "Owner / Creative Director", 
"負責人", "Vice President", "Copywriter", "Academic Writer", 
"Fotógrafo e gestor de Tráfego", "Content creator and instructor", 
"Founder", "Consultant", "Editor Website", "no have a job.", 
"Infrastructure Tech", "Developer", "Founder", "Markerter", "Owner", 
"Ceo", "CEO", "Mr.", "Growth Marketer", "Owner", "Real Estate Consultant", 
"Design Strategist", "Founder", "self-employed", "Freelance Senior Digital Creative", 
"CEO", "SEO", "Virtual Assistant", "Bubu", "CEO", "CEO", "Gerenet", 
"Owner", "CEO", "VP", "Marketing Director", "Marketing manager", 
"CEO", "Product Manager | Business Analyst", "Digital Project Manager", 
"Data enginner", "Senior Technology Specialist", "MD", "External moderator", 
"owner", "Owner", "Head, Digital & Social Media", "助理", "Executive Director", 
"Ceo", "Software engineer", "AI Development & Social Community", 
"Senior SEO Manager", "Founder", "Brand Manager", "Communication & Marketing Manager", 
"Manager", "Translating job", "Designer", "Director & Team Lead, Content", 
"neuro-harmonizer-in-chief", "SEO", "Content writer", "LAWYER", 
"No Company", "Director", "cv medicine", "Self Employed", "Founder", 
".", "Director", "Secretary", "CEO", "Vediographer", "Unemplloef", 
"Key Manager", "AGM - Marketing", "QC Microbiologist", "Digital Ads Specialist", 
"FreeLance", "Concept Artist", "CEO", "Director", "IT", "Founder", 
"ceo", "Owner", "Copywriter", "Content Coordinator", "Manager realtions with parteners", 
"Administrative assistant", "Owner", "Graphic Designer", "Academic writer", 
"員工", "Owner", "Software engineer", "Freelancer", "Founder", 
"Trader", "ceo", "Freelancer", "Owner", "Digital Marketer", "Consultant", 
"Cloud Consultant", "Technical support engineer", "IT", "marketar"
), industry = c("Sporting Goods", "Marketing and Advertising", 
"Software", "Tech", "Business technology services", "Marketing", 
"SEO", "Automotive", "Marketing", "entertainment", "Advertising", 
"Digital Marketing", "Marketing", "SEO", "Online publishing", 
"private equity / finance", "SEO", "Sports Data", "eLearning", 
"Marketing", "B2B Tech Marketing", "Healthcare", "Real Estate", 
"Higher Education", "Marketing Agency", "Full-service ad agency", 
"B2B SaaS", "Marketing", "Agency", "Healthcare", "Marketing", 
"Media", "Marketing", "Biohazard Cleanup", "SEO", "Media/Publishing", 
"CMS", "Seo", "Agency", "Regenerative Agriculture and Food Transformation", 
"Automotive", "Marketing", "internet marketing", "Agency", "Marketing Social Media", 
"marketing", "Fashion and Beauty", "Marketing agency", "I don’t know what am I doing", 
"education", "Marketing consulting", "AI research in health", 
"Digital Success", "Marketing", "Tv and film", "Rewards Programs", 
"Construction", "tile", "Real Estate", "Education", "Education", 
"Pharmaceutical", "Consulting", "Government", "Ai / MEDIA", "Real Estate", 
"AI Consulting", "Gardening publisher", "Real Estate", "Advertising/Motion Design", 
"Design", "Computer", "Digital", "E-Commerce", "Digital Agency", 
"IT", "建設業", "ZK ART criations", "Fhhdfhj", "Marketing", 
"Casino", "Marketing", "IT", "COMERCIAL Y FABRICACION DE EQUIPOS", 
"Supply, logistics and contracting", "Online sales", "service", 
"service", "Behavior health", "Auto", "Photography marketing", 
"餐飲", "Engineering for civil work, roads, railways, hydraulic, etc.", 
"IT", "Writing and Translation", "Audio Visual", "Content Writing", 
"Coaching and Training", "Education", "Indonesia", "no have a job.", 
"Data center", "Real Estate IT Department", "Technology", "IT", 
"Retail sales", "Digital marketing", "Web Design", "Wellness", 
"Marketing & Advertising", "Construction", "Real estate", "Design Consulting", 
"Technology", "Content Creation", "Design", "Marketing & Advertisement", 
"Digital Marketing", "Online Freelancer", "Pirate", "Trainings", 
"Healthcare", "Telecomunicações", "Retailer Electronics Product", 
"consultation", "Building Materials Distribution", "Education", 
"Affiliate", "IT-Services", "Fintech", "Bituminous Waterproofing", 
"البرمجة", "Telecommunication", "Medical equipment", "Academic", 
"branding", "SEO", "Financial Services", "服務業", "NGO", 
"Media", "nutikas tootmine", "Artificial Intelligence", "Assistive Technologies", 
"Ecommerce & SaaS", "Garden Furniture", "Communication", "Technology", 
"Ma Computers system ltd", "Ai Business Intelligence", "Marketing", 
"med", "E-Commerce", "Digital marketing", "ANTON DE LA CALLE ABOGADOS", 
"IT", "eCommerce", "ROC", "Graphic Design", "Digital Marketing", 
"IT", "Supply", "Publishing", "BRANDING AND PRINTING", "Vediography", 
"net", "Digital Marketing", "Retail Software", "Beauty and Personal care", 
"Import", "Copywriting", "Virtual Reality Software Company", 
"Civil Engineering", "SEO", "Hospital", "Marketing", "software", 
"Digital MLM", "Marketing", "Education", "Creditation", "Construction, transportation,operations and management", 
"Web Design", "Advertising", "Education", "工程師", "Real estate sales", 
"IT", "Blogging", "Consultancy", "Stockmarket", "marketing digital", 
"Data work", "Security Equipment Installer", "CBD", "Digital Marketing", 
"Hybrid Cloud", "IT consulting", "Charity", "paid advertising"
), change_since_ai = c("Yes, we've cut back on using external contractors.", 
"Much more efficient and creative", "No", "Haven't", "Quality, innovation, and productivity of work has increased.", 
"Leaning in, using in workflows, discovering ways to accelerate output, always collaboration, never wholesale use. Essentially using as an assistant", 
"We've rolled out new service offerings around generative AI as well as incorporating it into some of our tasks", 
"We already had a data science and AI team for some years.", 
"Created a community of interest: Our Telegram chat, where everyone shares their experiences. \r\n Regular mastermind sessions for knowledge exchange;\r\n Maintain a database of trials and errors;\r\n Involve the team in regular testing of new startups in the field.", 
"they haven't", "They have not changed", "They haven’t yet but this is something that will be evolving in the next few months.", 
"No", "Our SEO and content teams were able to provide AI as a low / no cost solution to some SaaS clients looking to scale quickly, that weren't able to afford content writers. Because of this, our content team has focused more of their role on editing AI and less on giving feedback to writers. It's put a hold on our hiring of new content specialists who handle content workflows and manage those writers.", 
"Not changed.", "No, but how we're using contractors or other team members for work is changing", 
"not at all", "No, they haven't.", "I wouldn't say our teams have changed; some individuals have adopted generative AI for their own workflows but nothing at an institutional or team level.", 
"Generative AI has improved my efficiency by handling some of the mind-numbing parts of marketing research and data analysis.", 
"they haven't yet, still taking shape", "We haven't incorporated generative AI.", 
"More efficient but it take times to understand the process for AI generation", 
"We've been able to incorporate more automation of tasks and data gathering.", 
"they haven't", "There is a big move to upskill - and honestly, it's refreshing. It harkens back to the early days of search when algorithm changes were big enough to be worth talking about because it's a pretty seismic and exciting shift. Young talent is hungry and excited to learn again, the chance to talk about something new is reinvigorating, it's exciting to get weird in search again. That's not a tangible thing necessarily - but we're definitely using it, talking about it, augmenting and enhancing our work in practical ways.", 
"Yes. We've been able to streamline content 'repurposing' , saving time, allowing focussing on more relevant research.", 
"I am a one man business, so there are a lot of things that got easier by adding Generative AI to the regular processes.", 
"There hasn't been any significant changes yet but it certainly has sped up some of our tasks.", 
"They don’t have changed we use the tool as inspiration", "They haven't", 
NA, "Our teams hasn't changed, but we've outsourced a lot less work to freelancers than we have in previous years.", 
"We have been able to streamline processes and optimize our workflow so much more efficiently and quickly.", 
"The workflow has changed", "The writing teams have stayed the same, we are still using 100% human writers for the majority of our content, but we are testing out some AI use cases in other parts of our workflows (socials for example).", 
"We've not reduced or expanded, but we're testing improvements to our editorial capacity, content repurposing and distribution strategies", 
"I use AI for creating a base of content to work with. It allows me to create templated content much faster. And then we can spend more of our clients time improving and adding value rather than writing the basic content first. There are lots of other ways we’re working on!!", 
"Some of the tasks have become semi automated but no change to teams", 
"I am using it mostly but it has allowed me to synthesize information and bring information to my team in a timely and comprehensive manner", 
"I can't awnser this", "Improved productivity", "Seam teams, using AI for pre-existing tasks", 
"we have changed processes, but have always made sure humans are guiding and directing everything.", 
"No", "not", "No one knows I use it to streamline processes", 
"Hire less writers", "Yes, some aspects it facilitate a lot, our fear is people who is already using it with intentions of control, maximize power full of egocentric ideas", 
"no. the change here is slowly.", "Yes. I implement blogging much more with AI and do not need to hire out a blogger.", 
"As we have already developed health solutions using AI; Everyone is very interested in using the news of AI Generative.", 
"Still Learning", "no", "No teams", "WOrking less hours, getting more done", 
"N/A", NA, "They have not", "No", "More efficient.", "Haven’t", 
"n/a", "Not really getting into it", "More efficient and creative", 
"Some of the dialogue has been beneficial with overall connection with our ideal clients. Need more localized content.", 
"More creative", "No.", "Not changed", "no", "No", NA, "Bien", 
"good", "I am solopreneur", NA, "今はまだ得には変わらない", 
NA, "Fnfjfj", "quicker", "They haven’t", "We are able to creat content much quicker so it can be edited and made final.", 
"No", "NO", "N/A", "Work faster", "it helps us outline a project", 
NA, "Not using it for work", "More efficient in terms of work that heavily relies on writing.", 
"No.", NA, "Ever since AIPRM support for the chat and text production.", 
"nothing much, but probably deliver faster.", "Increased Productivity", 
"I don't have", "More productive", "Haven’t changed teams but we are training in use of generative AI.", 
"The scope has broaden a lot since I have been able to use ChatGPT to generate code that enables me to find solutions that in the past the lack of a consistent knowledge in programming stopped me.", 
NA, "no have", "Not yet, bc we see the future but can't quite reach it, and I can feel the need to help create something no one has ever seen before.", 
"yes write article", "Not at all", "Smartness and Workflow is increased", 
"no", "No", "Productivity gains are seen mainly in document creation.", 
"No", "No change", "They havent", "No changes", "Just getting to know this new tool at our disposal.", 
NA, "They have not changed in size, but has enabled us to increase productivity/research/ideas.", 
"iʼm writing lot more text myself now, no more stock photography", 
"Faster copy production and quality control.", "More Productive", 
"For me, individually I gain confidence with my works.", "No", 
NA, "Excited about the Thruput", "Mais agéis", "No Change, I use AI to get knowledge of Personal Information.", 
"no impact", "Limited", "less time wasted with brainstorming for content creation, faster translation process to French,", 
"More effective", "No", "No teams have not integrated AI in the workflows yet. Some use it here and there.", 
"No change", "Nope", "Yes", "Better performance in less time", 
"Efficiency", "AI give me more optimal time. I get focus in forgoten by myself more relevant, as well, sales, promoting and listen to my audience.", 
"No", "They haven't incorporated AI into their work yet.", "none", 
"Made different in work environment.", "No change", "Greatly improved the team's efficiency, the level of code writing standards, the quality of code writing, and the efficiency of completing tasks. All have been significantly enhanced.", 
"No team yet.", NA, "Fewer people are required", "None", "Nothing change in that way", 
"Haven't", NA, "We are a startup", "We are more of an editorial function rather that just a production unit", 
"pple got replaced with AI", "haven't", "No", NA, "No idea", 
"No", "1, communication, 2, efficacy of problem -solving 3, efficacy of decision- making", 
NA, "Changed the process of content production", "No", NA, "Mind blowing", 
"NOT YET", NA, NA, "No", "Haven't changed", "No", "No", "Working faster", 
"No", "A Lot!", "Everything is much faster and more effeciently executed.", 
"A lot", NA, "more free time", "Nil", "More efficiency", "We all use it, it's helped with creating new content", 
NA, "Yes", "Yes", "Our team has become more effective delivery jobs in a timely manner.", 
"Yes", NA, "Haven't changed", "nothing changed, just working way faster", 
"We are just of us, and it has help u to certain extent", "They are all focused on GPT development", 
"gradual Process", NA, "No", "I'm the only one that uses it for creating quotes and emails.", 
"I dont have a team", "The time being taken by the team has reduced", 
"I am using tools like ChatGPT, bard for my own use and for my own learning purpose", 
"It's didn't change", NA, "They did not change")), row.names = c(NA, 
-200L), class = c("tbl_df", "tbl", "data.frame"))

谢谢!

r string replace grepl
1个回答
0
投票

如果您想用 CEO 替换

整个
值,我认为您不想在这里使用 gsub - 它只会替换 CEO 部分 - 例如:

gsub("ceo", "CEO", "ceo and Owner")

将返回“CEO 和所有者”而不是“CEO”。

您可能希望在此处使用

grep
来定义具有 CEO、经理等变体的值的索引,然后将其替换为 CEO。您还将受益于
ignore.case
,它忽略模式的大写/小写,因此您可以避免考虑每个排列 (
ceo|Ceo|cEo|...
)

ceo_ix <- grep("ceo|owner|executive", aiprm$job_title, 
               ignore.case = TRUE)

aiprm$job_title[ceo_ix] <- "CEO"

如果您只是想更正 eco、cEo 等的大写并替换“owner”和“executive”等单词,您确实可以使用

gsub
:

gsub("ceo|owner|executive", "CEO", aiprm$job_title, ignore.case = TRUE)
© www.soinside.com 2019 - 2024. All rights reserved.