FAQ Database Discussion Community


number of occurrences by lines R

r,find-occurrences
I have this array: [1] 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 2 1 [38] 1 1 1 1 1 1 1...

Finding multiple occurrences of pairs in CSV file

python,list,python-2.7,csv,find-occurrences
I'm trying to write a Python script that will search through a CSV file and identify the number of occurrences when two items appear next to each other. For example, let's say the CSV looks like the following: red,green,blue,red,yellow,green,yellow,red,green,purple,blue,yellow,red,blue,blue,green,purple,red,blue,blue,red,green And I'd like to find the number of times when "red,green"...

Keep the second occurrence in a column in R

r,conditional,subset,find-occurrences
I have quite a simple dataset: ID Value Time 1 censored 1 1 censored 2 1 uncensored 3 1 uncensored 4 1 censored 5 1 censored 6 2 censored 1 2 uncensored 2 2 uncensored 3 2 uncensored 4 2 censored 5 I want to keep the first uncensored occurrence,...

How can you determine the number of occurrences of a keyword in a web page?

php,string,webpage,find-occurrences
I'm trying to figure out how search for the number of occurrence for a keyword on a php webpage. Not a string but count the occurrences and then post the number, for how many times a certain number appears on the page. Are there any functions for this. The only...

Print 10 most frequently occurring words of a text that including and excluding stopwords

python,nltk,word-frequency,find-occurrences
I got the question from here with my changes. I have following code: from nltk.corpus import stopwords >>> def content_text(text): stopwords = nltk.corpus.stopwords.words('english') content = [w for w in text if w.lower() in stopwords] return content How can I print the 10 most frequently occurring words of a text that...

Finding occurrences of specific word line by line from text file

c,find-occurrences
I'm trying to read out my text file line by line FILE *infile; char line[1000]; infile = fopen("file.txt","r"); while(fgets(line,1000,infile) != NULL) { //.... } fclose(infile); And then I need to find a specific word, for example "the", and need to see how many time it occurs and what lines it...