Displaying 20 results from an estimated 7000 matches similar to: "substring from behind"
1999 Aug 03
3
RW 0.64.2 substring() string truncation?
Hi,
(First, apology for my earlier incorrectly addressed "subscribe"
post.)
Can somebody tell me what exactly is going on below. Basically, I am
running into some kind of "string truncation" problem when I try
to get a substring starting past the 8192nd character (see sample
session below). There doesn't appear to be any problem creating the
string, and nchar()
2014 May 19
3
substring if value starts with a character
Hello togehter,
i have a litte problem to convert a data.frame. My data.frame looks like
this one
A
1 R5000
2 R4800
3 R4700
4 3500
5 3800
I need now a command, which outputs all the numbers, without the character
in front.
The solution look like this one:
A
1 5000
2 4800
3 4700
4 3500
5 3800
Thanks.
Best regards. Mat
--
View this message in context:
2011 Jul 07
1
Substring a column vector
How to substring the following vector (in data frame b)
>b
a
11
12
1234
1245
124567
126786
145769
such that:
a1??? a2
1???? 1
1???? 2
12??? 23
12??? 34
124?? 567
126???787
145???769 ?
I tried logical commands with substr() did not work out.
2008 Oct 29
6
substring/strsplit question
Dear R People:
Here is a toy example:
> x <- c("2E","5W","12H")
> substr(x,2,2)
[1] "E" "W" "2"
>
Sometimes x has 3 elements, sometimes 2. I want to extract the last
element, and then extract the other 1 or 2 elements.
How can I do this, please?
TIA,
Sincerely,
Erin
--
Erin Hodgess
Associate Professor
Department of
2006 Aug 29
3
Substring and strsplit
Dear R People:
I am trying to split a character vector into a set of individual
letters:
Ideal:
x3 <- c("dog")
"d" "o" "g"
I tried the following:
> strsplit(x3)
Error in strsplit(x3) : argument "split" is missing, with no default
> strsplit(x3,1)
[[1]]
[1] "dog"
I know that this is incredibly simple, but what am I doing
2010 Jun 04
2
Argument recycling in substring()
Hi,
According to its man page substring() "expands (its) arguments
cyclically to the length of the longest _provided_ none are of
zero length".
So, as expected, I get an error here:
> substring("abcd", first=2L, last=integer(0))
Error in substring("abcd", first = 2L, last = integer(0)) :
invalid substring argument(s)
But I don't get one here:
2019 Feb 22
1
Bug: time complexity of substring is quadratic as string size and number of substrings increases
On 2/20/19 7:55 PM, Toby Hocking wrote:
> Update: I have observed that stringi::stri_sub is linear time complexity,
> and it computes the same thing as base::substring. figure
> https://github.com/tdhock/namedCapture-article/blob/master/figure-substring-bug.png
> source:
> https://github.com/tdhock/namedCapture-article/blob/master/figure-substring-bug.R
>
> To me this is a
2019 Feb 20
2
Bug: time complexity of substring is quadratic as string size and number of substrings increases
Hi all, (and especially hi to Tomas Kalibera who accepted my patch sent
yesterday)
I believe that I have found another bug, this time in the substring
function. The use case that I am concerned with is when there is a single
(character scalar) text/subject, and many substrings to extract. For example
substring("AAAA", 1:4, 1:4)
or more generally,
N=1000
2013 Dec 13
1
substring() and propagation of names
Hi,
In R < 3.0.0, we used to get:
> substring(c(A="abcdefghij", B="123456789"), 2, 6:2)
A B A B A
"bcdef" "2345" "bcd" "23" "b"
But in R >= 3.0.0, we get:
> substring(c(A="abcdefghij", B="123456789"), 2, 6:2)
[1] "bcdef"
2010 Jul 19
1
Help with replacing a substring in a string
Dear R Users,
I am trying to replace a substring in a string with something else.
For example:
if we have "abc.degg.hijk"
I would like to replace all the "." with a SPACE to become
"abc degg hijk"
I have tried the replace.substring.wild function in the Hmisc package but get this error:
> replace.substring.wild("abc.degg.hijk","*.*","
2012 Jul 12
6
read.table with numeric row names
I have a text file like this
2.5 3.6 7.1 7.9
100 3 4 2 3
200 3.1 4 3 3
300 2.2 3.3 2 4
I used "r <- read.table("a.txt", header=T)"
The row names becomes X2.5, X3.6... What I need is the row names are
numeric, so I can use the row names as numbers on x-axis for plotting. e.g.
"plot(colMeans(r)~names(r))",
2008 May 29
2
how to use substring match as condition?
Hi,
How can I use a substring match as a condition in a subset command?
Sth like this:
subset(input, field1=="blah1" & field2=="blah2") # but now with substring
match in field2
subset(input, field1=="blah1" & field3 *substringmatch* "blah3")
I've tried with gsub, but it won't work:
subset(input, field1=="blah1" &
2011 Feb 03
2
substring and paste character with a for loop
Hello R users,
I have a little problem with a for loop.
Below there is an simple example of my problem.
I want to delet the commas in the character string. Fore this reason I
create a for loop to unpick the string and rebuild him without the commas.
The problem is, that "paste" does not work in the loop as I expected.
text <- "aaa,bbb,ccc,ddd"
characterseq <-
2012 Oct 23
3
frequency
Hello,
I have a data as follow:
ID Visit
xa1
xa2
yb1
yc23
yb33
I want to look at frequency of visit for ID and create a new column as response .
For example my response would be 2 for x and 3 for y.
I think I need to write a loop, but I don't know how.
I really appreciate your help.
Thanks a lot.
Best,Farnoosh Sheikhi
[[alternative HTML version deleted]]
2009 Jul 20
1
locate substring in the string it belong to
Hi R users,
I am trying generate the indices for locating a in the string it come from.
Given the length of the string, it will take too long using the combn() for
further comparison. I am wondering if R has any built-in function for this
purpose.
To make it concrete:
this.substring="cc"
this.string="ccc"
start.location=1,2
end.location=2,3
Thanks in advance,
Kevin
2020 Jun 26
2
Error in substring: invalid multibyte string
Hi all,
I'm getting the following error from substring:
> substr("<I>Jens Oehlschl\xe4gel-Akiyoshi", 1, 100)
Error in substr("<I>Jens Oehlschl\xe4gel-Akiyoshi", 1, 100) :
invalid multibyte string at '<e4>gel-A<6b>iyoshi'
Is that normal / intended? I've tried setting the Encoding/locale to
Latin-1/UTF-8 but that does not help. nchar
2006 Nov 14
1
greatest common substring
Dear R-members,
Suppose I have a vector with the following strings:
V = c("Welfare_Group_1024",
"Welfare_Group_1536",
"Welfare_Group_160")
I want to 'automatically generate a nice y-axis label for this data.
A good candidate is something close to "Welfare Group".
Is there an easy way to compute something close to the greatest
common
2020 Jun 27
1
Error in substring: invalid multibyte string
Thanks for the quick response Ivan. readLines with encoding='latin1' works
for me (on Ubuntu).
However I was more concerned with the inconsistency in results between
substr and regexpr. I was expecting that if one of them errors because of
an unknown encoding then the other should as well. Even better, if regexpr
works, why shouldn't substr work as well?
Incidentally the analogous
2009 Mar 21
1
Subsetting data where the condition is that the value of some column contains some substring
I have some data that looks like this:
> dataP
input output corpusFreq pvolOT pvolRatioOT
1 give(my sister, the old book) P 47.0 56016 0.1543651
5 donate(her, the book) P 48.7 68928 0.1899471
9 give(my sister, the book) P 73.4 80136 0.2208333
13 donate(my sister, the old book) P
how to count the total number of (INCLUDING overlapping) occurrences of a substring within a string?
2009 Dec 20
1
how to count the total number of (INCLUDING overlapping) occurrences of a substring within a string?
Last one for you guys:
The command:
length(gregexpr('cus','hocus pocus')[[1]])
[1] 2
returns the number of times the substring 'cus' appears in 'hocus pocus'
(which is two)
It's returning the number of **disjoint** matches. So:
length(gregexpr('aa','aaa')[[1]])
[1] 1
returns 1.
**What I want to do:**
I'm looking for a way to count