R: Count the Occurrence of words in list to create benchmark

I have list that consist of words:

$text $text[[1]] [1] "qlikview" "gpa" "access" "gpa" "access" "access" "qlikview" "gpa" "access" [10] "gpa" $text[[2]] [1] "report" "qlikview" "gpa" "access" "qlikview" "gpa" "access" "qlikview" "gpa" [10] "access"` $text[[3]] [1] "qlikview" "gpa" "access" "gpa" "access" "access" "qlikview" "gpa" "access" [10] "gpa" $text[[4]] [1] "qlikview" "gpa" "access" "gpa" "access" "access" "qlikview" "gpa" "access" [10] "gpa" $text[[5]] [1] "report" "qlikview" "gpa" "access" "access" "gpa" "access" "qlikview" "gpa" [10] "access" "access" "gpa" "qlikview" "gpa" "access" "qlikview" "gpa" "access"

I need to count the number of words occurring in each row of list and plot. I have tried with various ways, but effective only within sentence. Please refer this. Could somebody who has worked on such could help!

edit

dput(O) O <- structure(list(text = list(c("report", "gpa", "access", "access", "access", "gpa", "access", "gpa", "access"), c("report", "report", "access", "report", "report", "data", "report", "report"), c("report", "qlikview", "gpa", "access", "access", "qlikview", "gpa", "access", "access", "qlikview", "gpa", "access", "access", "qlikview", "gpa", "access"), character(0), c("gpa", "gpa", "gpa", "gpa", "gpa", "gpa", "gpa", "gpa", "gpa", "gpa", "gpa", "gpa"), c("report", "qlikview", "gpa", "access", "access", "qlikview", "gpa", "access", "qlikview", "gpa", "access", "access", "gpa", "qlikview", "gpa", "access"), c("report", "data", "data"), c("report", "report", "report", "data", "report", "report"))), .Names = "text")

-------------Problems Reply------------

Try

library(qdapTools)
res <- mtabulate(O$text)
dim(res)
#[1] 244 8

head(res,3)
# access adhoc data gpa maturity pfi qlikview report
#1 4 0 0 4 0 0 2 0
#2 3 0 0 3 0 0 3 1
#3 4 0 0 4 0 0 2 0

Based on the new dput output (on a small subset)

res1 <- mtabulate(O$text)
head(res1,3)
# access data gpa qlikview report
#1 5 0 3 0 1
#2 1 1 0 0 6
#3 7 0 4 4 1

Category:r Views:0 Time:2018-02-13
Tags:

Related post

  • How can I count the occurrences of a list item in Python? 2010-04-08

    Given an item, how can I count its occurrences in a list in Python? --------------Solutions------------- >>> [1, 2, 3, 4, 1, 4, 1].count(1) 3 If you are using Python 2.7 or 3 and you want number of occurrences for each element: >>>

  • Counting the occurrence of a sub-graph in a graph 2010-11-12

    I have a 3 dimensional dataset that describes the gene interactions which can be formulated as a graph. The sample of dataset is: a + b b + c c - f b - d a + c f + g g + h f + h '+' indicates that a gene on the left side positively regulates the gene

  • What's the fastest way to count the number of words in a string in Perl? 2011-05-19

    I have a few functions that I'm running over a million times on various texts, which means small improvements in these functions translate to big gains overall. Currently, I've noticed that all of my functions which involve word counts take drastical

  • How to count the number of words in a paragraph and exclude some words (from file)? 2011-09-09

    I've just started to learn Python so my question might be a bit silly. I'm trying to create a program that would: - import a text file (got it) - count the total number of words (got it), - count the number of words in a specific paragraph, starting

  • How to use Scanner in java to count the number of words seperate by "," from a input .txt file? 2012-01-12

    My input file look like this: 1,2,3,4,5,6 3,4,5,6,7,8 5,6,7,8,9,9 1,2,3,4,5,6 I want to count the number of word in a column and the number of rows so that I can know the array size and put them into a 2D array. How can I get the number of column and

  • Count the number of words in a string in R? 2012-01-19

    Is there a function to count the number of words in a string? for example str1 <- "How many words are in this sentence" to return a result of 7 Thanks. --------------Solutions------------- Use the regular expression symbol \\W to match non-word ch

  • Counting the occurrence of each number in prime factors of an integer 2012-04-12

    I want to count the number of each prime factor of an integer. For an example 18=2^1*3^2. I want to get all exponent part of each prime number. For number 18, it is 1+2=3. Below is the program which generates all the prime factors of an integer. Scan

  • How to count the occurrence of even number? 2012-06-28

    There is a list of numbers under A column, Does anyone have any suggestions on How to count the occurrence of even/odd number? Thank everyone very much for any suggestions --------------Solutions------------- Hi, Odd =SUMPRODUCT((MOD(A1:A100,2)<

  • How to remove duplicate values from an array in PHP and count the occurrence? 2009-08-05

    How to remove duplicate values from an array in PHP and count the occurrence of every element? I have this array foo bar foo I want the result to be in array like this value freq ---- ---- foo 2 bar 1 Thanks --------------Solutions------------- so si

  • How can i count the number of words between two words? 2010-07-21

    How can i count the number of words between two words? $txt = "tükörfúrógép banana orange lime, tükörfúrógép cherry árvíztűrő orange lyon cat lime mac tükörfúrógép cat orange lime cat árvíztűrő tükörfúrógép banana orange lime orange lime cat árvíztűr

  • count the occurrences of a specific character in the input 2010-11-01

    Possible Duplicate: How do I count the number of occurrences of a char in a String? I am looking to count the occurrences of a specific character, for example "i" that occurs in the input. Example, from standard input: Lorem ipsum dolor sit amet, con

  • Count the number of words in NSString 2011-03-03

    I'm trying to implement a word count function for my app that uses UITextView. There's a space between two words in English, so it's really easy to count the number of words in an English sentence. The problem occurs with Chinese and Japanese word co

  • How do I count the number of words in a string that have 3,4,5 or 6 characters in Javascript? 2011-04-26

    I have been given a task... "count the number of words in the string "tx_val" that have 3,4,5 or 6 characters show these four counts on a single line separated by commas" I have been trying multiple different loop statements but I cannot seem to get

  • count the number of words in a xml node using xsl 2011-05-31

    Here is the sample xml document. <root> <node> count the number of words </node> </root> For this example I want to count the number of words in the node "" in xslt. The output like be Number of words:: 5 Any idea for this? Yo

  • Counting the number of words using C from a text file 2011-12-09

    Hey I have been trying to count the number of words in my text file, to load up a bunch of words for a Hangman game, from C but I am hitting a brick wall. This piece of code I am using is supposed I am using this piece of code; FILE *infile; FILE *in

  • Counting the occurrences of a string in a cell array of strings in Matlab 2012-02-21

    I have two cell arrays of strings of varying lengths, d={'nerve','body','muscle','bone'} and e={'body','body','muscle'}. I have to compare these two arrays and count the occurrences of each string in e in d. The expected result should be a vector, co

  • Counting the number of words in a text area 2012-04-09

    Hello everyone my first question on stack overflow import javax.swing.*; import java.util.*; import java.awt.event.*; public class TI extends JFrame implements ActionListener { static int count=0; String ct; JTextField word; JTextArea tohide; public

  • How can I count the occurrences of a string within a file using bash? 2011-07-19

    Just take this code as an example. Pretending it is an HTML/text file, if I would like to know the total number of times that echo appears, how can I do it using bash? new_user() { echo "Preparing to add a new user..." sleep 2 adduser # run the addus

  • Count the occurrence of a string in an input file 2012-01-23

    There is a shell script which is supposed to process an incoming text file. This text file contains strings split on multiple lines, and each string is present more than once. The shell script needs to read this text file and output the String and co

  • Count the occurrences of items in ArrayList 2010-04-15

    I have a java.util.ArrayList<Item> and an Item object. Now, I want to obtain the number of times the Item is stored in the arraylist. I know that I can do arrayList.contains() check but it returns true, irrespective of whether it contains one o

  • im counting the number of characters in a file but i want to count the number of words that are less than 5 and 6 or greater 2010-05-05

    i want to do this: reads the words in the file one at a time. (Use a string to do this) Counts three things: how many single-character words are in the file, how many short (2 to 5 characters) words are in the file, and how many long (6 or more chara

  • How to count the occurrences of a string inside TEXT datatype in SQL Server 2005 2010-09-23

    There is a column of datatype TEXT in my table. Now, I need to find the number of occurrences of a string in that TEXT field. I have already created a Full-text index on that table. But I don't know how to proceed further. I already found ways to cou

  • Elegant ways to count the frequency of words in a file 2011-02-03

    What are the elegant and effective ways to count the frequency of each "english" word in a file? --------------Solutions------------- First of all, I define letter_only std::locale so as to ignore punctuations coming from the stream, and to read only

  • how to count the number of words in a line in perl? 2011-05-08

    I know I could write my own while loop along with regex to count the words in a line. But, I am processing like 1000 lines and I dont want to run this loop each and every time. So, I was wondering is there any way to count the words in the line in pe

Copyright (C) dskims.com, All Rights Reserved.

processed in 0.188 (s). 11 q(s)