How to calculate the number of occurrence of a given character in each row of a column of strings?count number of numbers (not digits) in a stringHow to count the number of a specific digit in each cell in Routput computation in R using shinyCount number of short strings in a long string in RCount Occurrences of Character “?” in rR - count number of items in a piped listSearch for a specific number of characters in a stringHow to find the observations that have more than one underscore?How to find number 1s in 101 in RHow to find multiple underscore in the same string?How to replace all occurrences of a string in JavaScriptHow do I remove all non alphanumeric characters from a string except dash?How to count string occurrence in string?How to drop rows of Pandas DataFrame whose value in certain columns is NaNCount number of ocorrences with regexJava String Matching the RegexFind specific strings, count their frequency in a given text, and report it as a proportion of the number of wordsCalculate the number of occurrence of a given character in each row of a data frame?Extract pattern that occurs multiple times within stringHow to extract index columns and rows in R?
Can a Knock spell open the door to Mordenkainen's Magnificent Mansion?
Walter Rudin's mathematical analysis: theorem 2.43. Why proof can't work under the perfect set is uncountable.
Capacitor electron flow
How do I prevent inappropriate ads from appearing in my game?
categorizing a variable turns it from insignificant to significant
What is this high flying aircraft over Pennsylvania?
What is the period/term used describe Giuseppe Arcimboldo's style of painting?
What is the meaning of "You've never met a graph you didn't like?"
Not hide and seek
I keep switching characters, how do I stop?
Reasons for having MCU pin-states default to pull-up/down out of reset
Is there any common country to visit for persons holding UK and Schengen visas?
Can Gdal.Translate() return an object instead of writing a file?
Should I warn a new PhD Student?
What is the tangent at a sharp point on a curve?
Why does a 97 / 92 key piano exist by Bosendorfer?
C++ lambda syntax
Make a Bowl of Alphabet Soup
Is there a distance limit for minecart tracks?
Why would five hundred and five same as one?
How can a new country break out from a developed country without war?
Why is "la Gestapo" feminine?
Why doesn't Gödel's incompleteness theorem apply to false statements?
New Order #2: Turn My Way
How to calculate the number of occurrence of a given character in each row of a column of strings?
count number of numbers (not digits) in a stringHow to count the number of a specific digit in each cell in Routput computation in R using shinyCount number of short strings in a long string in RCount Occurrences of Character “?” in rR - count number of items in a piped listSearch for a specific number of characters in a stringHow to find the observations that have more than one underscore?How to find number 1s in 101 in RHow to find multiple underscore in the same string?How to replace all occurrences of a string in JavaScriptHow do I remove all non alphanumeric characters from a string except dash?How to count string occurrence in string?How to drop rows of Pandas DataFrame whose value in certain columns is NaNCount number of ocorrences with regexJava String Matching the RegexFind specific strings, count their frequency in a given text, and report it as a proportion of the number of wordsCalculate the number of occurrence of a given character in each row of a data frame?Extract pattern that occurs multiple times within stringHow to extract index columns and rows in R?
I have a data.frame in which certain variables contain a text string. I wish to count the number of occurrences of a given character in each individual string.
Example:
q.data<-data.frame(number=1:3, string=c("greatgreat", "magic", "not"))
I wish to create a new column for q.data with the number of occurence of "a" in string (ie. c(2,1,0)).
The only convoluted approach I have managed is:
string.counter<-function(strings, pattern)
counts<-NULL
for(i in 1:length(strings))
counts[i]<-length(attr(gregexpr(pattern,strings[i])[[1]], "match.length")[attr(gregexpr(pattern,strings[i])[[1]], "match.length")>0])
return(counts)
string.counter(strings=q.data$string, pattern="a")
number string number.of.a
1 1 greatgreat 2
2 2 magic 1
3 3 not 0
regex r dataframe
add a comment |
I have a data.frame in which certain variables contain a text string. I wish to count the number of occurrences of a given character in each individual string.
Example:
q.data<-data.frame(number=1:3, string=c("greatgreat", "magic", "not"))
I wish to create a new column for q.data with the number of occurence of "a" in string (ie. c(2,1,0)).
The only convoluted approach I have managed is:
string.counter<-function(strings, pattern)
counts<-NULL
for(i in 1:length(strings))
counts[i]<-length(attr(gregexpr(pattern,strings[i])[[1]], "match.length")[attr(gregexpr(pattern,strings[i])[[1]], "match.length")>0])
return(counts)
string.counter(strings=q.data$string, pattern="a")
number string number.of.a
1 1 greatgreat 2
2 2 magic 1
3 3 not 0
regex r dataframe
add a comment |
I have a data.frame in which certain variables contain a text string. I wish to count the number of occurrences of a given character in each individual string.
Example:
q.data<-data.frame(number=1:3, string=c("greatgreat", "magic", "not"))
I wish to create a new column for q.data with the number of occurence of "a" in string (ie. c(2,1,0)).
The only convoluted approach I have managed is:
string.counter<-function(strings, pattern)
counts<-NULL
for(i in 1:length(strings))
counts[i]<-length(attr(gregexpr(pattern,strings[i])[[1]], "match.length")[attr(gregexpr(pattern,strings[i])[[1]], "match.length")>0])
return(counts)
string.counter(strings=q.data$string, pattern="a")
number string number.of.a
1 1 greatgreat 2
2 2 magic 1
3 3 not 0
regex r dataframe
I have a data.frame in which certain variables contain a text string. I wish to count the number of occurrences of a given character in each individual string.
Example:
q.data<-data.frame(number=1:3, string=c("greatgreat", "magic", "not"))
I wish to create a new column for q.data with the number of occurence of "a" in string (ie. c(2,1,0)).
The only convoluted approach I have managed is:
string.counter<-function(strings, pattern)
counts<-NULL
for(i in 1:length(strings))
counts[i]<-length(attr(gregexpr(pattern,strings[i])[[1]], "match.length")[attr(gregexpr(pattern,strings[i])[[1]], "match.length")>0])
return(counts)
string.counter(strings=q.data$string, pattern="a")
number string number.of.a
1 1 greatgreat 2
2 2 magic 1
3 3 not 0
regex r dataframe
regex r dataframe
edited Sep 14 '12 at 15:26
Etienne Low-Décarie
asked Sep 14 '12 at 15:17
Etienne Low-DécarieEtienne Low-Décarie
6,265145182
6,265145182
add a comment |
add a comment |
11 Answers
11
active
oldest
votes
The stringr package provides the str_count
function which seems to do what you're interested in
# Load your example data
q.data<-data.frame(number=1:3, string=c("greatgreat", "magic", "not"), stringsAsFactors = F)
library(stringr)
# Count the number of 'a's in each element of string
q.data$number.of.a <- str_count(q.data$string, "a")
q.data
# number string number.of.a
#1 1 greatgreat 2
#2 2 magic 1
#3 3 not 0
1
Yours was much faster although it does need an as.character() around the main argument to succeed with the problem posed.
– 42-
Sep 14 '12 at 20:09
1
@DWin - That's true but I avoided that issue by addingstringsAsFactors = FALSE
when defining the data frame.
– Dason
Sep 14 '12 at 20:10
Sorry I was unclear. I was actually responding to tim riffe and telling him that his function threw an error with the problem posed. He may have used your redefinition of the problem but he didn't say so.
– 42-
Sep 14 '12 at 20:14
yeah, I also did,stringsAsFactors=TRUE
on my comp, but didn't mention this
– tim riffe
Sep 14 '12 at 20:31
Searching for a string in a factor will work i.e. str_count(d$factor_column,'A') but not vice-versa
– Nitro
Sep 27 '17 at 19:24
|
show 1 more comment
If you don't want to leave base R, here's a fairly succinct and expressive possibility:
x <- q.data$string
lengths(regmatches(x, gregexpr("a", x)))
# [1] 2 1 0
2
OK -- maybe that will only feel expressive once you've used theregmatches
andgregexpr
together a few times, but that combo is powerful enough that I thought it deserved a plug.
– Josh O'Brien
Sep 14 '12 at 15:48
+1 for regmatches, I was not aware of the function.
– Roman Luštrik
Sep 14 '12 at 16:06
regmatches
is relatively new. It was introduced in 2.14.
– Dason
Sep 15 '12 at 17:49
I don't think you need the regmatches bit. The function gregexpr returns a list with the indices of the matched occurrences for each element of x.
– savagent
Aug 26 '14 at 3:27
1
Sorry, I forgot about the -1. It only works if each line has at least one match, sapply(gregexpr("g", q.data$string), length).
– savagent
Aug 26 '14 at 4:42
|
show 3 more comments
nchar(as.character(q.data$string)) -nchar( gsub("a", "", q.data$string))
[1] 2 1 0
Notice that I coerce the factor variable to character, before passing to nchar. The regex functions appear to do that internally.
Here's benchmark results (with a scaled up size of the test to 3000 rows)
q.data<-q.data[rep(1:NROW(q.data), 1000),]
str(q.data)
'data.frame': 3000 obs. of 3 variables:
$ number : int 1 2 3 1 2 3 1 2 3 1 ...
$ string : Factor w/ 3 levels "greatgreat","magic",..: 1 2 3 1 2 3 1 2 3 1 ...
$ number.of.a: int 2 1 0 2 1 0 2 1 0 2 ...
benchmark( Dason = q.data$number.of.a <- str_count(as.character(q.data$string), "a") ,
Tim = resT <- sapply(as.character(q.data$string), function(x, letter = "a")
sum(unlist(strsplit(x, split = "")) == letter) ) ,
DWin = resW <- nchar(as.character(q.data$string)) -nchar( gsub("a", "", q.data$string)),
Josh = x <- sapply(regmatches(q.data$string, gregexpr("g",q.data$string )), length), replications=100)
#-----------------------
test replications elapsed relative user.self sys.self user.child sys.child
1 Dason 100 4.173 9.959427 2.985 1.204 0 0
3 DWin 100 0.419 1.000000 0.417 0.003 0 0
4 Josh 100 18.635 44.474940 17.883 0.827 0 0
2 Tim 100 3.705 8.842482 3.646 0.072 0 0
1
This is the fastest solution in the answers but is made ~30% faster on your benchmark by passing the optionalfixed=TRUE
togsub
. There are also cases wherefixed=TRUE
would be required (i.e., when the character you want to count could be interpreted as a regex assertion such as.
).
– C8H10N4O2
Jan 16 '18 at 16:15
add a comment |
sum(charToRaw("abc.d.aa") == charToRaw('.'))
is an good option.
add a comment |
I'm sure someone can do better, but this works:
sapply(as.character(q.data$string), function(x, letter = "a")
sum(unlist(strsplit(x, split = "")) == letter)
)
greatgreat magic not
2 1 0
or in a function:
countLetter <- function(charvec, letter)
sapply(charvec, function(x, letter)
sum(unlist(strsplit(x, split = "")) == letter)
, letter = letter)
countLetter(as.character(q.data$string),"a")
I seem to get an error with the first one ... and the second one... (was trying to benchmark all of these.)
– 42-
Sep 14 '12 at 20:04
Useas.character()
– 42-
Sep 14 '12 at 20:10
edited to reflect this, thx
– tim riffe
Sep 14 '12 at 20:31
add a comment |
I count characters same way as Amarjeet. However I prefer to do it in a single line.
HowManySpaces<-nchar(DF$string)-nchar(gsub(" ","",DF$string)) # count spaces in DF$string
add a comment |
The easiest and the cleanest way IMHO is :
q.data$number.of.a <- lengths(gregexpr('a', q.data$string))
# number string number.of.a`
#1 1 greatgreat 2`
#2 2 magic 1`
#3 3 not 0`
add a comment |
You could just use string division
require(roperators)
my_strings <- c('apple', banana', 'pear', 'melon')
my_strings %s/% 'a'
Which will give you 1, 3, 1, 0. You can also use string division with regular expressions and whole words.
add a comment |
The stringi
package provides the functions stri_count
and stri_count_fixed
which are very fast.
stringi::stri_count(q.data$string, fixed = "a")
# [1] 2 1 0
benchmark
Compared to the fastest approach from @42-'s answer and to the equivalent function from the stringr
package for a vector with 30.000 elements.
library(microbenchmark)
benchmark <- microbenchmark(
stringi = stringi::stri_count(test.data$string, fixed = "a"),
baseR = nchar(test.data$string) - nchar(gsub("a", "", test.data$string, fixed = TRUE)),
stringr = str_count(test.data$string, "a")
)
autoplot(benchmark)
data
q.data <- data.frame(number=1:3, string=c("greatgreat", "magic", "not"), stringsAsFactors = FALSE)
test.data <- q.data[rep(1:NROW(q.data), 10000),]
add a comment |
The question below has been moved here, but it seems this page doesn't directly answer to Farah El's question.
How to find number 1s in 101 in R
So, I'll write an answer here, just in case.
library(magrittr)
n %>% # n is a number you'd like to inspect
as.character() %>%
str_count(pattern = "1")
https://stackoverflow.com/users/8931457/farah-el
add a comment |
s <- "aababacababaaathhhhhslsls jsjsjjsaa ghhaalll"
p <- "a"
s2 <- gsub(p,"",s)
numOcc <- nchar(s) - nchar(s2)
May not be the efficient one but solve my purpose.
2
This is exactly same as this answer.
– zx8754
Apr 6 '16 at 11:29
add a comment |
Your Answer
StackExchange.ifUsing("editor", function ()
StackExchange.using("externalEditor", function ()
StackExchange.using("snippets", function ()
StackExchange.snippets.init();
);
);
, "code-snippets");
StackExchange.ready(function()
var channelOptions =
tags: "".split(" "),
id: "1"
;
initTagRenderer("".split(" "), "".split(" "), channelOptions);
StackExchange.using("externalEditor", function()
// Have to fire editor after snippets, if snippets enabled
if (StackExchange.settings.snippets.snippetsEnabled)
StackExchange.using("snippets", function()
createEditor();
);
else
createEditor();
);
function createEditor()
StackExchange.prepareEditor(
heartbeatType: 'answer',
autoActivateHeartbeat: false,
convertImagesToLinks: true,
noModals: true,
showLowRepImageUploadWarning: true,
reputationToPostImages: 10,
bindNavPrevention: true,
postfix: "",
imageUploader:
brandingHtml: "Powered by u003ca class="icon-imgur-white" href="https://imgur.com/"u003eu003c/au003e",
contentPolicyHtml: "User contributions licensed under u003ca href="https://creativecommons.org/licenses/by-sa/3.0/"u003ecc by-sa 3.0 with attribution requiredu003c/au003e u003ca href="https://stackoverflow.com/legal/content-policy"u003e(content policy)u003c/au003e",
allowUrls: true
,
onDemand: true,
discardSelector: ".discard-answer"
,immediatelyShowMarkdownHelp:true
);
);
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
StackExchange.ready(
function ()
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f12427385%2fhow-to-calculate-the-number-of-occurrence-of-a-given-character-in-each-row-of-a%23new-answer', 'question_page');
);
Post as a guest
Required, but never shown
11 Answers
11
active
oldest
votes
11 Answers
11
active
oldest
votes
active
oldest
votes
active
oldest
votes
The stringr package provides the str_count
function which seems to do what you're interested in
# Load your example data
q.data<-data.frame(number=1:3, string=c("greatgreat", "magic", "not"), stringsAsFactors = F)
library(stringr)
# Count the number of 'a's in each element of string
q.data$number.of.a <- str_count(q.data$string, "a")
q.data
# number string number.of.a
#1 1 greatgreat 2
#2 2 magic 1
#3 3 not 0
1
Yours was much faster although it does need an as.character() around the main argument to succeed with the problem posed.
– 42-
Sep 14 '12 at 20:09
1
@DWin - That's true but I avoided that issue by addingstringsAsFactors = FALSE
when defining the data frame.
– Dason
Sep 14 '12 at 20:10
Sorry I was unclear. I was actually responding to tim riffe and telling him that his function threw an error with the problem posed. He may have used your redefinition of the problem but he didn't say so.
– 42-
Sep 14 '12 at 20:14
yeah, I also did,stringsAsFactors=TRUE
on my comp, but didn't mention this
– tim riffe
Sep 14 '12 at 20:31
Searching for a string in a factor will work i.e. str_count(d$factor_column,'A') but not vice-versa
– Nitro
Sep 27 '17 at 19:24
|
show 1 more comment
The stringr package provides the str_count
function which seems to do what you're interested in
# Load your example data
q.data<-data.frame(number=1:3, string=c("greatgreat", "magic", "not"), stringsAsFactors = F)
library(stringr)
# Count the number of 'a's in each element of string
q.data$number.of.a <- str_count(q.data$string, "a")
q.data
# number string number.of.a
#1 1 greatgreat 2
#2 2 magic 1
#3 3 not 0
1
Yours was much faster although it does need an as.character() around the main argument to succeed with the problem posed.
– 42-
Sep 14 '12 at 20:09
1
@DWin - That's true but I avoided that issue by addingstringsAsFactors = FALSE
when defining the data frame.
– Dason
Sep 14 '12 at 20:10
Sorry I was unclear. I was actually responding to tim riffe and telling him that his function threw an error with the problem posed. He may have used your redefinition of the problem but he didn't say so.
– 42-
Sep 14 '12 at 20:14
yeah, I also did,stringsAsFactors=TRUE
on my comp, but didn't mention this
– tim riffe
Sep 14 '12 at 20:31
Searching for a string in a factor will work i.e. str_count(d$factor_column,'A') but not vice-versa
– Nitro
Sep 27 '17 at 19:24
|
show 1 more comment
The stringr package provides the str_count
function which seems to do what you're interested in
# Load your example data
q.data<-data.frame(number=1:3, string=c("greatgreat", "magic", "not"), stringsAsFactors = F)
library(stringr)
# Count the number of 'a's in each element of string
q.data$number.of.a <- str_count(q.data$string, "a")
q.data
# number string number.of.a
#1 1 greatgreat 2
#2 2 magic 1
#3 3 not 0
The stringr package provides the str_count
function which seems to do what you're interested in
# Load your example data
q.data<-data.frame(number=1:3, string=c("greatgreat", "magic", "not"), stringsAsFactors = F)
library(stringr)
# Count the number of 'a's in each element of string
q.data$number.of.a <- str_count(q.data$string, "a")
q.data
# number string number.of.a
#1 1 greatgreat 2
#2 2 magic 1
#3 3 not 0
answered Sep 14 '12 at 15:25
DasonDason
45.8k797128
45.8k797128
1
Yours was much faster although it does need an as.character() around the main argument to succeed with the problem posed.
– 42-
Sep 14 '12 at 20:09
1
@DWin - That's true but I avoided that issue by addingstringsAsFactors = FALSE
when defining the data frame.
– Dason
Sep 14 '12 at 20:10
Sorry I was unclear. I was actually responding to tim riffe and telling him that his function threw an error with the problem posed. He may have used your redefinition of the problem but he didn't say so.
– 42-
Sep 14 '12 at 20:14
yeah, I also did,stringsAsFactors=TRUE
on my comp, but didn't mention this
– tim riffe
Sep 14 '12 at 20:31
Searching for a string in a factor will work i.e. str_count(d$factor_column,'A') but not vice-versa
– Nitro
Sep 27 '17 at 19:24
|
show 1 more comment
1
Yours was much faster although it does need an as.character() around the main argument to succeed with the problem posed.
– 42-
Sep 14 '12 at 20:09
1
@DWin - That's true but I avoided that issue by addingstringsAsFactors = FALSE
when defining the data frame.
– Dason
Sep 14 '12 at 20:10
Sorry I was unclear. I was actually responding to tim riffe and telling him that his function threw an error with the problem posed. He may have used your redefinition of the problem but he didn't say so.
– 42-
Sep 14 '12 at 20:14
yeah, I also did,stringsAsFactors=TRUE
on my comp, but didn't mention this
– tim riffe
Sep 14 '12 at 20:31
Searching for a string in a factor will work i.e. str_count(d$factor_column,'A') but not vice-versa
– Nitro
Sep 27 '17 at 19:24
1
1
Yours was much faster although it does need an as.character() around the main argument to succeed with the problem posed.
– 42-
Sep 14 '12 at 20:09
Yours was much faster although it does need an as.character() around the main argument to succeed with the problem posed.
– 42-
Sep 14 '12 at 20:09
1
1
@DWin - That's true but I avoided that issue by adding
stringsAsFactors = FALSE
when defining the data frame.– Dason
Sep 14 '12 at 20:10
@DWin - That's true but I avoided that issue by adding
stringsAsFactors = FALSE
when defining the data frame.– Dason
Sep 14 '12 at 20:10
Sorry I was unclear. I was actually responding to tim riffe and telling him that his function threw an error with the problem posed. He may have used your redefinition of the problem but he didn't say so.
– 42-
Sep 14 '12 at 20:14
Sorry I was unclear. I was actually responding to tim riffe and telling him that his function threw an error with the problem posed. He may have used your redefinition of the problem but he didn't say so.
– 42-
Sep 14 '12 at 20:14
yeah, I also did,
stringsAsFactors=TRUE
on my comp, but didn't mention this– tim riffe
Sep 14 '12 at 20:31
yeah, I also did,
stringsAsFactors=TRUE
on my comp, but didn't mention this– tim riffe
Sep 14 '12 at 20:31
Searching for a string in a factor will work i.e. str_count(d$factor_column,'A') but not vice-versa
– Nitro
Sep 27 '17 at 19:24
Searching for a string in a factor will work i.e. str_count(d$factor_column,'A') but not vice-versa
– Nitro
Sep 27 '17 at 19:24
|
show 1 more comment
If you don't want to leave base R, here's a fairly succinct and expressive possibility:
x <- q.data$string
lengths(regmatches(x, gregexpr("a", x)))
# [1] 2 1 0
2
OK -- maybe that will only feel expressive once you've used theregmatches
andgregexpr
together a few times, but that combo is powerful enough that I thought it deserved a plug.
– Josh O'Brien
Sep 14 '12 at 15:48
+1 for regmatches, I was not aware of the function.
– Roman Luštrik
Sep 14 '12 at 16:06
regmatches
is relatively new. It was introduced in 2.14.
– Dason
Sep 15 '12 at 17:49
I don't think you need the regmatches bit. The function gregexpr returns a list with the indices of the matched occurrences for each element of x.
– savagent
Aug 26 '14 at 3:27
1
Sorry, I forgot about the -1. It only works if each line has at least one match, sapply(gregexpr("g", q.data$string), length).
– savagent
Aug 26 '14 at 4:42
|
show 3 more comments
If you don't want to leave base R, here's a fairly succinct and expressive possibility:
x <- q.data$string
lengths(regmatches(x, gregexpr("a", x)))
# [1] 2 1 0
2
OK -- maybe that will only feel expressive once you've used theregmatches
andgregexpr
together a few times, but that combo is powerful enough that I thought it deserved a plug.
– Josh O'Brien
Sep 14 '12 at 15:48
+1 for regmatches, I was not aware of the function.
– Roman Luštrik
Sep 14 '12 at 16:06
regmatches
is relatively new. It was introduced in 2.14.
– Dason
Sep 15 '12 at 17:49
I don't think you need the regmatches bit. The function gregexpr returns a list with the indices of the matched occurrences for each element of x.
– savagent
Aug 26 '14 at 3:27
1
Sorry, I forgot about the -1. It only works if each line has at least one match, sapply(gregexpr("g", q.data$string), length).
– savagent
Aug 26 '14 at 4:42
|
show 3 more comments
If you don't want to leave base R, here's a fairly succinct and expressive possibility:
x <- q.data$string
lengths(regmatches(x, gregexpr("a", x)))
# [1] 2 1 0
If you don't want to leave base R, here's a fairly succinct and expressive possibility:
x <- q.data$string
lengths(regmatches(x, gregexpr("a", x)))
# [1] 2 1 0
edited Feb 27 at 11:55
zx8754
30.3k764101
30.3k764101
answered Sep 14 '12 at 15:44
Josh O'BrienJosh O'Brien
129k18279388
129k18279388
2
OK -- maybe that will only feel expressive once you've used theregmatches
andgregexpr
together a few times, but that combo is powerful enough that I thought it deserved a plug.
– Josh O'Brien
Sep 14 '12 at 15:48
+1 for regmatches, I was not aware of the function.
– Roman Luštrik
Sep 14 '12 at 16:06
regmatches
is relatively new. It was introduced in 2.14.
– Dason
Sep 15 '12 at 17:49
I don't think you need the regmatches bit. The function gregexpr returns a list with the indices of the matched occurrences for each element of x.
– savagent
Aug 26 '14 at 3:27
1
Sorry, I forgot about the -1. It only works if each line has at least one match, sapply(gregexpr("g", q.data$string), length).
– savagent
Aug 26 '14 at 4:42
|
show 3 more comments
2
OK -- maybe that will only feel expressive once you've used theregmatches
andgregexpr
together a few times, but that combo is powerful enough that I thought it deserved a plug.
– Josh O'Brien
Sep 14 '12 at 15:48
+1 for regmatches, I was not aware of the function.
– Roman Luštrik
Sep 14 '12 at 16:06
regmatches
is relatively new. It was introduced in 2.14.
– Dason
Sep 15 '12 at 17:49
I don't think you need the regmatches bit. The function gregexpr returns a list with the indices of the matched occurrences for each element of x.
– savagent
Aug 26 '14 at 3:27
1
Sorry, I forgot about the -1. It only works if each line has at least one match, sapply(gregexpr("g", q.data$string), length).
– savagent
Aug 26 '14 at 4:42
2
2
OK -- maybe that will only feel expressive once you've used the
regmatches
and gregexpr
together a few times, but that combo is powerful enough that I thought it deserved a plug.– Josh O'Brien
Sep 14 '12 at 15:48
OK -- maybe that will only feel expressive once you've used the
regmatches
and gregexpr
together a few times, but that combo is powerful enough that I thought it deserved a plug.– Josh O'Brien
Sep 14 '12 at 15:48
+1 for regmatches, I was not aware of the function.
– Roman Luštrik
Sep 14 '12 at 16:06
+1 for regmatches, I was not aware of the function.
– Roman Luštrik
Sep 14 '12 at 16:06
regmatches
is relatively new. It was introduced in 2.14.– Dason
Sep 15 '12 at 17:49
regmatches
is relatively new. It was introduced in 2.14.– Dason
Sep 15 '12 at 17:49
I don't think you need the regmatches bit. The function gregexpr returns a list with the indices of the matched occurrences for each element of x.
– savagent
Aug 26 '14 at 3:27
I don't think you need the regmatches bit. The function gregexpr returns a list with the indices of the matched occurrences for each element of x.
– savagent
Aug 26 '14 at 3:27
1
1
Sorry, I forgot about the -1. It only works if each line has at least one match, sapply(gregexpr("g", q.data$string), length).
– savagent
Aug 26 '14 at 4:42
Sorry, I forgot about the -1. It only works if each line has at least one match, sapply(gregexpr("g", q.data$string), length).
– savagent
Aug 26 '14 at 4:42
|
show 3 more comments
nchar(as.character(q.data$string)) -nchar( gsub("a", "", q.data$string))
[1] 2 1 0
Notice that I coerce the factor variable to character, before passing to nchar. The regex functions appear to do that internally.
Here's benchmark results (with a scaled up size of the test to 3000 rows)
q.data<-q.data[rep(1:NROW(q.data), 1000),]
str(q.data)
'data.frame': 3000 obs. of 3 variables:
$ number : int 1 2 3 1 2 3 1 2 3 1 ...
$ string : Factor w/ 3 levels "greatgreat","magic",..: 1 2 3 1 2 3 1 2 3 1 ...
$ number.of.a: int 2 1 0 2 1 0 2 1 0 2 ...
benchmark( Dason = q.data$number.of.a <- str_count(as.character(q.data$string), "a") ,
Tim = resT <- sapply(as.character(q.data$string), function(x, letter = "a")
sum(unlist(strsplit(x, split = "")) == letter) ) ,
DWin = resW <- nchar(as.character(q.data$string)) -nchar( gsub("a", "", q.data$string)),
Josh = x <- sapply(regmatches(q.data$string, gregexpr("g",q.data$string )), length), replications=100)
#-----------------------
test replications elapsed relative user.self sys.self user.child sys.child
1 Dason 100 4.173 9.959427 2.985 1.204 0 0
3 DWin 100 0.419 1.000000 0.417 0.003 0 0
4 Josh 100 18.635 44.474940 17.883 0.827 0 0
2 Tim 100 3.705 8.842482 3.646 0.072 0 0
1
This is the fastest solution in the answers but is made ~30% faster on your benchmark by passing the optionalfixed=TRUE
togsub
. There are also cases wherefixed=TRUE
would be required (i.e., when the character you want to count could be interpreted as a regex assertion such as.
).
– C8H10N4O2
Jan 16 '18 at 16:15
add a comment |
nchar(as.character(q.data$string)) -nchar( gsub("a", "", q.data$string))
[1] 2 1 0
Notice that I coerce the factor variable to character, before passing to nchar. The regex functions appear to do that internally.
Here's benchmark results (with a scaled up size of the test to 3000 rows)
q.data<-q.data[rep(1:NROW(q.data), 1000),]
str(q.data)
'data.frame': 3000 obs. of 3 variables:
$ number : int 1 2 3 1 2 3 1 2 3 1 ...
$ string : Factor w/ 3 levels "greatgreat","magic",..: 1 2 3 1 2 3 1 2 3 1 ...
$ number.of.a: int 2 1 0 2 1 0 2 1 0 2 ...
benchmark( Dason = q.data$number.of.a <- str_count(as.character(q.data$string), "a") ,
Tim = resT <- sapply(as.character(q.data$string), function(x, letter = "a")
sum(unlist(strsplit(x, split = "")) == letter) ) ,
DWin = resW <- nchar(as.character(q.data$string)) -nchar( gsub("a", "", q.data$string)),
Josh = x <- sapply(regmatches(q.data$string, gregexpr("g",q.data$string )), length), replications=100)
#-----------------------
test replications elapsed relative user.self sys.self user.child sys.child
1 Dason 100 4.173 9.959427 2.985 1.204 0 0
3 DWin 100 0.419 1.000000 0.417 0.003 0 0
4 Josh 100 18.635 44.474940 17.883 0.827 0 0
2 Tim 100 3.705 8.842482 3.646 0.072 0 0
1
This is the fastest solution in the answers but is made ~30% faster on your benchmark by passing the optionalfixed=TRUE
togsub
. There are also cases wherefixed=TRUE
would be required (i.e., when the character you want to count could be interpreted as a regex assertion such as.
).
– C8H10N4O2
Jan 16 '18 at 16:15
add a comment |
nchar(as.character(q.data$string)) -nchar( gsub("a", "", q.data$string))
[1] 2 1 0
Notice that I coerce the factor variable to character, before passing to nchar. The regex functions appear to do that internally.
Here's benchmark results (with a scaled up size of the test to 3000 rows)
q.data<-q.data[rep(1:NROW(q.data), 1000),]
str(q.data)
'data.frame': 3000 obs. of 3 variables:
$ number : int 1 2 3 1 2 3 1 2 3 1 ...
$ string : Factor w/ 3 levels "greatgreat","magic",..: 1 2 3 1 2 3 1 2 3 1 ...
$ number.of.a: int 2 1 0 2 1 0 2 1 0 2 ...
benchmark( Dason = q.data$number.of.a <- str_count(as.character(q.data$string), "a") ,
Tim = resT <- sapply(as.character(q.data$string), function(x, letter = "a")
sum(unlist(strsplit(x, split = "")) == letter) ) ,
DWin = resW <- nchar(as.character(q.data$string)) -nchar( gsub("a", "", q.data$string)),
Josh = x <- sapply(regmatches(q.data$string, gregexpr("g",q.data$string )), length), replications=100)
#-----------------------
test replications elapsed relative user.self sys.self user.child sys.child
1 Dason 100 4.173 9.959427 2.985 1.204 0 0
3 DWin 100 0.419 1.000000 0.417 0.003 0 0
4 Josh 100 18.635 44.474940 17.883 0.827 0 0
2 Tim 100 3.705 8.842482 3.646 0.072 0 0
nchar(as.character(q.data$string)) -nchar( gsub("a", "", q.data$string))
[1] 2 1 0
Notice that I coerce the factor variable to character, before passing to nchar. The regex functions appear to do that internally.
Here's benchmark results (with a scaled up size of the test to 3000 rows)
q.data<-q.data[rep(1:NROW(q.data), 1000),]
str(q.data)
'data.frame': 3000 obs. of 3 variables:
$ number : int 1 2 3 1 2 3 1 2 3 1 ...
$ string : Factor w/ 3 levels "greatgreat","magic",..: 1 2 3 1 2 3 1 2 3 1 ...
$ number.of.a: int 2 1 0 2 1 0 2 1 0 2 ...
benchmark( Dason = q.data$number.of.a <- str_count(as.character(q.data$string), "a") ,
Tim = resT <- sapply(as.character(q.data$string), function(x, letter = "a")
sum(unlist(strsplit(x, split = "")) == letter) ) ,
DWin = resW <- nchar(as.character(q.data$string)) -nchar( gsub("a", "", q.data$string)),
Josh = x <- sapply(regmatches(q.data$string, gregexpr("g",q.data$string )), length), replications=100)
#-----------------------
test replications elapsed relative user.self sys.self user.child sys.child
1 Dason 100 4.173 9.959427 2.985 1.204 0 0
3 DWin 100 0.419 1.000000 0.417 0.003 0 0
4 Josh 100 18.635 44.474940 17.883 0.827 0 0
2 Tim 100 3.705 8.842482 3.646 0.072 0 0
edited Sep 14 '12 at 20:41
answered Sep 14 '12 at 19:23
42-42-
215k15263401
215k15263401
1
This is the fastest solution in the answers but is made ~30% faster on your benchmark by passing the optionalfixed=TRUE
togsub
. There are also cases wherefixed=TRUE
would be required (i.e., when the character you want to count could be interpreted as a regex assertion such as.
).
– C8H10N4O2
Jan 16 '18 at 16:15
add a comment |
1
This is the fastest solution in the answers but is made ~30% faster on your benchmark by passing the optionalfixed=TRUE
togsub
. There are also cases wherefixed=TRUE
would be required (i.e., when the character you want to count could be interpreted as a regex assertion such as.
).
– C8H10N4O2
Jan 16 '18 at 16:15
1
1
This is the fastest solution in the answers but is made ~30% faster on your benchmark by passing the optional
fixed=TRUE
to gsub
. There are also cases where fixed=TRUE
would be required (i.e., when the character you want to count could be interpreted as a regex assertion such as .
).– C8H10N4O2
Jan 16 '18 at 16:15
This is the fastest solution in the answers but is made ~30% faster on your benchmark by passing the optional
fixed=TRUE
to gsub
. There are also cases where fixed=TRUE
would be required (i.e., when the character you want to count could be interpreted as a regex assertion such as .
).– C8H10N4O2
Jan 16 '18 at 16:15
add a comment |
sum(charToRaw("abc.d.aa") == charToRaw('.'))
is an good option.
add a comment |
sum(charToRaw("abc.d.aa") == charToRaw('.'))
is an good option.
add a comment |
sum(charToRaw("abc.d.aa") == charToRaw('.'))
is an good option.
sum(charToRaw("abc.d.aa") == charToRaw('.'))
is an good option.
edited Jul 6 '16 at 16:24
Andy♦
31.3k21105163
31.3k21105163
answered Jul 6 '16 at 16:17
Zhang TaoZhang Tao
5111
5111
add a comment |
add a comment |
I'm sure someone can do better, but this works:
sapply(as.character(q.data$string), function(x, letter = "a")
sum(unlist(strsplit(x, split = "")) == letter)
)
greatgreat magic not
2 1 0
or in a function:
countLetter <- function(charvec, letter)
sapply(charvec, function(x, letter)
sum(unlist(strsplit(x, split = "")) == letter)
, letter = letter)
countLetter(as.character(q.data$string),"a")
I seem to get an error with the first one ... and the second one... (was trying to benchmark all of these.)
– 42-
Sep 14 '12 at 20:04
Useas.character()
– 42-
Sep 14 '12 at 20:10
edited to reflect this, thx
– tim riffe
Sep 14 '12 at 20:31
add a comment |
I'm sure someone can do better, but this works:
sapply(as.character(q.data$string), function(x, letter = "a")
sum(unlist(strsplit(x, split = "")) == letter)
)
greatgreat magic not
2 1 0
or in a function:
countLetter <- function(charvec, letter)
sapply(charvec, function(x, letter)
sum(unlist(strsplit(x, split = "")) == letter)
, letter = letter)
countLetter(as.character(q.data$string),"a")
I seem to get an error with the first one ... and the second one... (was trying to benchmark all of these.)
– 42-
Sep 14 '12 at 20:04
Useas.character()
– 42-
Sep 14 '12 at 20:10
edited to reflect this, thx
– tim riffe
Sep 14 '12 at 20:31
add a comment |
I'm sure someone can do better, but this works:
sapply(as.character(q.data$string), function(x, letter = "a")
sum(unlist(strsplit(x, split = "")) == letter)
)
greatgreat magic not
2 1 0
or in a function:
countLetter <- function(charvec, letter)
sapply(charvec, function(x, letter)
sum(unlist(strsplit(x, split = "")) == letter)
, letter = letter)
countLetter(as.character(q.data$string),"a")
I'm sure someone can do better, but this works:
sapply(as.character(q.data$string), function(x, letter = "a")
sum(unlist(strsplit(x, split = "")) == letter)
)
greatgreat magic not
2 1 0
or in a function:
countLetter <- function(charvec, letter)
sapply(charvec, function(x, letter)
sum(unlist(strsplit(x, split = "")) == letter)
, letter = letter)
countLetter(as.character(q.data$string),"a")
edited Sep 14 '12 at 20:31
answered Sep 14 '12 at 15:23
tim riffetim riffe
4,6881834
4,6881834
I seem to get an error with the first one ... and the second one... (was trying to benchmark all of these.)
– 42-
Sep 14 '12 at 20:04
Useas.character()
– 42-
Sep 14 '12 at 20:10
edited to reflect this, thx
– tim riffe
Sep 14 '12 at 20:31
add a comment |
I seem to get an error with the first one ... and the second one... (was trying to benchmark all of these.)
– 42-
Sep 14 '12 at 20:04
Useas.character()
– 42-
Sep 14 '12 at 20:10
edited to reflect this, thx
– tim riffe
Sep 14 '12 at 20:31
I seem to get an error with the first one ... and the second one... (was trying to benchmark all of these.)
– 42-
Sep 14 '12 at 20:04
I seem to get an error with the first one ... and the second one... (was trying to benchmark all of these.)
– 42-
Sep 14 '12 at 20:04
Use
as.character()
– 42-
Sep 14 '12 at 20:10
Use
as.character()
– 42-
Sep 14 '12 at 20:10
edited to reflect this, thx
– tim riffe
Sep 14 '12 at 20:31
edited to reflect this, thx
– tim riffe
Sep 14 '12 at 20:31
add a comment |
I count characters same way as Amarjeet. However I prefer to do it in a single line.
HowManySpaces<-nchar(DF$string)-nchar(gsub(" ","",DF$string)) # count spaces in DF$string
add a comment |
I count characters same way as Amarjeet. However I prefer to do it in a single line.
HowManySpaces<-nchar(DF$string)-nchar(gsub(" ","",DF$string)) # count spaces in DF$string
add a comment |
I count characters same way as Amarjeet. However I prefer to do it in a single line.
HowManySpaces<-nchar(DF$string)-nchar(gsub(" ","",DF$string)) # count spaces in DF$string
I count characters same way as Amarjeet. However I prefer to do it in a single line.
HowManySpaces<-nchar(DF$string)-nchar(gsub(" ","",DF$string)) # count spaces in DF$string
edited Nov 13 '17 at 12:29
answered Nov 13 '17 at 12:09
cineS.cineS.
62
62
add a comment |
add a comment |
The easiest and the cleanest way IMHO is :
q.data$number.of.a <- lengths(gregexpr('a', q.data$string))
# number string number.of.a`
#1 1 greatgreat 2`
#2 2 magic 1`
#3 3 not 0`
add a comment |
The easiest and the cleanest way IMHO is :
q.data$number.of.a <- lengths(gregexpr('a', q.data$string))
# number string number.of.a`
#1 1 greatgreat 2`
#2 2 magic 1`
#3 3 not 0`
add a comment |
The easiest and the cleanest way IMHO is :
q.data$number.of.a <- lengths(gregexpr('a', q.data$string))
# number string number.of.a`
#1 1 greatgreat 2`
#2 2 magic 1`
#3 3 not 0`
The easiest and the cleanest way IMHO is :
q.data$number.of.a <- lengths(gregexpr('a', q.data$string))
# number string number.of.a`
#1 1 greatgreat 2`
#2 2 magic 1`
#3 3 not 0`
answered Dec 26 '17 at 9:54
Giovanni CampagnoliGiovanni Campagnoli
264
264
add a comment |
add a comment |
You could just use string division
require(roperators)
my_strings <- c('apple', banana', 'pear', 'melon')
my_strings %s/% 'a'
Which will give you 1, 3, 1, 0. You can also use string division with regular expressions and whole words.
add a comment |
You could just use string division
require(roperators)
my_strings <- c('apple', banana', 'pear', 'melon')
my_strings %s/% 'a'
Which will give you 1, 3, 1, 0. You can also use string division with regular expressions and whole words.
add a comment |
You could just use string division
require(roperators)
my_strings <- c('apple', banana', 'pear', 'melon')
my_strings %s/% 'a'
Which will give you 1, 3, 1, 0. You can also use string division with regular expressions and whole words.
You could just use string division
require(roperators)
my_strings <- c('apple', banana', 'pear', 'melon')
my_strings %s/% 'a'
Which will give you 1, 3, 1, 0. You can also use string division with regular expressions and whole words.
answered Oct 3 '18 at 16:15
BenbobBenbob
312
312
add a comment |
add a comment |
The stringi
package provides the functions stri_count
and stri_count_fixed
which are very fast.
stringi::stri_count(q.data$string, fixed = "a")
# [1] 2 1 0
benchmark
Compared to the fastest approach from @42-'s answer and to the equivalent function from the stringr
package for a vector with 30.000 elements.
library(microbenchmark)
benchmark <- microbenchmark(
stringi = stringi::stri_count(test.data$string, fixed = "a"),
baseR = nchar(test.data$string) - nchar(gsub("a", "", test.data$string, fixed = TRUE)),
stringr = str_count(test.data$string, "a")
)
autoplot(benchmark)
data
q.data <- data.frame(number=1:3, string=c("greatgreat", "magic", "not"), stringsAsFactors = FALSE)
test.data <- q.data[rep(1:NROW(q.data), 10000),]
add a comment |
The stringi
package provides the functions stri_count
and stri_count_fixed
which are very fast.
stringi::stri_count(q.data$string, fixed = "a")
# [1] 2 1 0
benchmark
Compared to the fastest approach from @42-'s answer and to the equivalent function from the stringr
package for a vector with 30.000 elements.
library(microbenchmark)
benchmark <- microbenchmark(
stringi = stringi::stri_count(test.data$string, fixed = "a"),
baseR = nchar(test.data$string) - nchar(gsub("a", "", test.data$string, fixed = TRUE)),
stringr = str_count(test.data$string, "a")
)
autoplot(benchmark)
data
q.data <- data.frame(number=1:3, string=c("greatgreat", "magic", "not"), stringsAsFactors = FALSE)
test.data <- q.data[rep(1:NROW(q.data), 10000),]
add a comment |
The stringi
package provides the functions stri_count
and stri_count_fixed
which are very fast.
stringi::stri_count(q.data$string, fixed = "a")
# [1] 2 1 0
benchmark
Compared to the fastest approach from @42-'s answer and to the equivalent function from the stringr
package for a vector with 30.000 elements.
library(microbenchmark)
benchmark <- microbenchmark(
stringi = stringi::stri_count(test.data$string, fixed = "a"),
baseR = nchar(test.data$string) - nchar(gsub("a", "", test.data$string, fixed = TRUE)),
stringr = str_count(test.data$string, "a")
)
autoplot(benchmark)
data
q.data <- data.frame(number=1:3, string=c("greatgreat", "magic", "not"), stringsAsFactors = FALSE)
test.data <- q.data[rep(1:NROW(q.data), 10000),]
The stringi
package provides the functions stri_count
and stri_count_fixed
which are very fast.
stringi::stri_count(q.data$string, fixed = "a")
# [1] 2 1 0
benchmark
Compared to the fastest approach from @42-'s answer and to the equivalent function from the stringr
package for a vector with 30.000 elements.
library(microbenchmark)
benchmark <- microbenchmark(
stringi = stringi::stri_count(test.data$string, fixed = "a"),
baseR = nchar(test.data$string) - nchar(gsub("a", "", test.data$string, fixed = TRUE)),
stringr = str_count(test.data$string, "a")
)
autoplot(benchmark)
data
q.data <- data.frame(number=1:3, string=c("greatgreat", "magic", "not"), stringsAsFactors = FALSE)
test.data <- q.data[rep(1:NROW(q.data), 10000),]
edited Mar 7 at 20:35
answered Mar 7 at 20:27
markusmarkus
14.5k11336
14.5k11336
add a comment |
add a comment |
The question below has been moved here, but it seems this page doesn't directly answer to Farah El's question.
How to find number 1s in 101 in R
So, I'll write an answer here, just in case.
library(magrittr)
n %>% # n is a number you'd like to inspect
as.character() %>%
str_count(pattern = "1")
https://stackoverflow.com/users/8931457/farah-el
add a comment |
The question below has been moved here, but it seems this page doesn't directly answer to Farah El's question.
How to find number 1s in 101 in R
So, I'll write an answer here, just in case.
library(magrittr)
n %>% # n is a number you'd like to inspect
as.character() %>%
str_count(pattern = "1")
https://stackoverflow.com/users/8931457/farah-el
add a comment |
The question below has been moved here, but it seems this page doesn't directly answer to Farah El's question.
How to find number 1s in 101 in R
So, I'll write an answer here, just in case.
library(magrittr)
n %>% # n is a number you'd like to inspect
as.character() %>%
str_count(pattern = "1")
https://stackoverflow.com/users/8931457/farah-el
The question below has been moved here, but it seems this page doesn't directly answer to Farah El's question.
How to find number 1s in 101 in R
So, I'll write an answer here, just in case.
library(magrittr)
n %>% # n is a number you'd like to inspect
as.character() %>%
str_count(pattern = "1")
https://stackoverflow.com/users/8931457/farah-el
answered yesterday
YoshiakiYoshiaki
13
13
add a comment |
add a comment |
s <- "aababacababaaathhhhhslsls jsjsjjsaa ghhaalll"
p <- "a"
s2 <- gsub(p,"",s)
numOcc <- nchar(s) - nchar(s2)
May not be the efficient one but solve my purpose.
2
This is exactly same as this answer.
– zx8754
Apr 6 '16 at 11:29
add a comment |
s <- "aababacababaaathhhhhslsls jsjsjjsaa ghhaalll"
p <- "a"
s2 <- gsub(p,"",s)
numOcc <- nchar(s) - nchar(s2)
May not be the efficient one but solve my purpose.
2
This is exactly same as this answer.
– zx8754
Apr 6 '16 at 11:29
add a comment |
s <- "aababacababaaathhhhhslsls jsjsjjsaa ghhaalll"
p <- "a"
s2 <- gsub(p,"",s)
numOcc <- nchar(s) - nchar(s2)
May not be the efficient one but solve my purpose.
s <- "aababacababaaathhhhhslsls jsjsjjsaa ghhaalll"
p <- "a"
s2 <- gsub(p,"",s)
numOcc <- nchar(s) - nchar(s2)
May not be the efficient one but solve my purpose.
answered May 8 '15 at 6:00
AmarjeetAmarjeet
4761513
4761513
2
This is exactly same as this answer.
– zx8754
Apr 6 '16 at 11:29
add a comment |
2
This is exactly same as this answer.
– zx8754
Apr 6 '16 at 11:29
2
2
This is exactly same as this answer.
– zx8754
Apr 6 '16 at 11:29
This is exactly same as this answer.
– zx8754
Apr 6 '16 at 11:29
add a comment |
Thanks for contributing an answer to Stack Overflow!
- Please be sure to answer the question. Provide details and share your research!
But avoid …
- Asking for help, clarification, or responding to other answers.
- Making statements based on opinion; back them up with references or personal experience.
To learn more, see our tips on writing great answers.
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
StackExchange.ready(
function ()
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f12427385%2fhow-to-calculate-the-number-of-occurrence-of-a-given-character-in-each-row-of-a%23new-answer', 'question_page');
);
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown