38971/r-programming-regexpr-error
Here's my code:
> x <- c("ABCDE CDEFG FGHIJ") > x [1] "ABCDE CDEFG FGHIJ" > regexpr("D", x) [1] 4 attr(,"match.length") [1] 1
The problem is regexpr only gives back the first occurrence of D, how do I get it to return all occurrences of D?
The below code will help:
gregexpr("D", x) # [[1]] # [1] 4 8 # attr(,"match.length") # [1] 1 1 # attr(,"useBytes") # [1] TRUE
share
Yes, Just like @Maverik said, It happens ...READ MORE
This is caused by using an object-oriented ...READ MORE
This error is likely to occur when ...READ MORE
Hi. Instead of breaking the line add it ...READ MORE
Format your code this way: myfunction <- function() ...READ MORE
You're using a factor: fert <- factor(c(50,20,10,10,20,50)) levels(fert) #[1] ...READ MORE
The basket.sorted() has less than 5 rules. Refer ...READ MORE
Try this: ggplot(dfc, aes(x=x, y=y, colour=f, fill=f, ymin=y-se, ...READ MORE
Alright, you can either use gsub to match the ...READ MORE
You need to install the following packages: install.packages(c('RO ...READ MORE
OR
At least 1 upper-case and 1 lower-case letter
Minimum 8 characters and Maximum 50 characters
Already have an account? Sign in.