Displaying 20 results from an estimated 8000 matches similar to: "selecting characters from a line of text"
2005 Apr 12
8
removing characters from a string
Is there a simple way in R to remove all characters
from a string other than those in a specified set? For
example, I want to keep only the digits 0-9 in a
string.
In general, I have found the string handling abilities
of R a bit limited. (Of course it's great for stats in
general). Is there a good reference on this? Or should
R programmers dump their output to a text file and use
something
2011 Dec 04
2
Extract last 3 characters from numeric vector
Hi all,
I have a numeric vector with 1 decimal place, and I'd like to extract
the last 3 characters, including the decimal point. The vector ranges
from 0 to 20.
x <- round(runif(100)*20, digits=1)
Some of numbers have 3 characters, and some have 4. I've read up on
the substr() function but that extracts characters based on exact
positions. How can I extract just the last 3
2010 Apr 30
2
drop last character in a names'vector
Hi, i have a vector filled with names:
[1] Alvaro Adela ...
[25] Beatriz Berta ...
...
[100000] ...
I would like to drop last character in every name.
I use the next program:
for (i in 1:100000) {
? ? ? ? ? ? ? ? ? ? ? ? ? largo <- nchar(names[i]-1)
? ? ? ? ? ? ? ? ? ? ? ? ? names[i] <- substring (names[i],1,largo]
? ? ? ? ? ? ? ? ? ? ? ? ?}
Is another and faster way of do it?
Thanks,
2007 Aug 02
4
Finding multiple characters in the same string
Hi
I have this problem where I need to find if there is any numbers in a
string, this is no problem if theres only one number per string. I would
then simply use the regexpr() funtion togheter with the substring function
to extract the number. But regexpr only picks one number per string either
from the beginning or the end, but not multiple. Can this be done? And how
for example
My string <-
2011 Jan 05
2
vector of character with unequal width
Dear R users,
The best in this new year 2011.
I am dealing with a character vector (xx) whose nchar are not the same.
Ex.
nchar(xx)
[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 1 1
[38] 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 3 3 3 3 3 4 4 4 4 4 4 4 4
[75] 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 ....... 9
I need xx to be nchar = 9
My
2008 Mar 31
10
Problems with *_path() and *_url() helpers when using Publisher
Hello,
I am running into issues using *_path() and *_url() helpers the
Facebooker Publisher framework. I encounter the following error when
using these helpers while *inside of a partial*:
undefined method `default_url_options'' for ActionView::Base:Class
I''ve seen a few other people speak about this issue, yet I haven''t
seen any resolution on the mailing list yet.
2006 Jun 04
1
text bubble (rectangle)?
Dear R wizards: sorry to bug everyone twice in one day.
I would like to annotate my graph by putting text strings into
rectangle boxes with a little cartoon-like bubble with a lid pointing
to a specific location. I can draw some sort of bubble-with-lid using
the R primitives. (has anyone done something like this already?)
the problem where I am stuck is that the width of the rectangle must
2013 Jan 30
2
substring from behind
Hello together,
i have a question for "substring".
I know i can filter a number like this one:
bill$No<-substring(bill$Customer,2,4)
in this case i get the 2nd, 3rd and 4th number of my Customer ID.
But how can i do this, if i want the 2nd, 3rd and 4th number of a column.
Like this one.
I have: Mercedes_02352
Audi_03555
and now i want to filter this data.frame to
235
355
can you
2005 Jun 22
10
How to read an excel data into R?
Hi all,
Does anybody know the easiest way to import excel data into R? I copied
and pasted the excel data into a txt file, and tried read.table, but R
reported that
Error in read.table("data_support.txt", sep = " ", header = T) :
more columns than column names
Thanks!
Ling
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()
2003 Jul 21
1
Inconsistent handling of character NA?
[R 1.7.1 on Windows XP Pro]
Since R allows missing values for character variables, why
are NA's not propagated by character manipulation functions?
For example:
> temp <- c("a", NA)
> temp
[1] "a" NA
> is.na(temp)
[1] FALSE TRUE
> paste(temp[1], temp[2])
[1] "a NA"
> substr(temp, 1, 1)
[1] "a" "N"
>
2010 Jan 12
5
Drop last numeral
Hello all,
Frustrated and i know you can help
I need to drop the last numeral of each of my values in my data set. So for
the following i have tried the ?substring but since i have to specify the
length, but because my data are of varying lengths it doenst work so well
Data<-c("1131", "1132", "1731" ,"1732" ,"1821" ,"1822",
2010 Jun 29
2
Help with dates and characters
Dear R Experts,
I have a vector of dates in character format like this:
date
"2000-01-01"
"2000-01-23"
"2001-03-12"
...
...
...
"2009-12-31"
I would like to delete the last part of the character string (i.e. the
"day" part), so the vector looks like this:
date
"2000-01"
"2000-01"
"2001-03"
...
...
...
2001 Feb 14
2
assignment function
Hi,
I am trying to create the assignment function:
"substring<-" <- function(text, first, last=100000, sub) {
if(is.character(first)) {
if(!missing(last)) stop('wrong # arguments')
return(sedit(text, first, sub))
}
lf <- length(first)
if(length(text)==1 && lf > 1) {
if(missing(last)) last <- nchar(text)
last <- rep(last,
2011 Apr 26
6
Tell the difference between characters
Dear all,
I just want to determine if the characters in a character string are the
same or not. For example,
temp <- c("aa", "aA", "ab")
How do I determine the first one have the two same ?a?, and the second and
third have the different characters? Thanks in advance.
Lisa
--
View this message in context:
2005 Oct 28
3
splitting a character field in R
Dear R users,
I have a dataframe with one character field, and I would like to create two
new fields (columns) in my dataset, by spliting the existing character
field into two using an existing substring.
... something that in SAS I could solve e.g. combining substr(which I am
aware exist in R) and "index" for determining the position of the pattern
within the string.
e.g. if my
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 <-
2002 Oct 23
3
How to pipe debugmsg to a file?
Is there a wine option to send the log output to a file?
I'm doing the following:
wineconsole --debugmsg +all program_name parm1 parm2 parm3 > /mylog.txt
mylog.txt is not receiving a copy of the millions, nay billions!, of
messages output.
I'm using Redhat 7.3 and the 10/07/2002 RPMs.
- Bill
2009 Mar 04
5
Sinitra 0.9.1 Webrat 0.4.2 Cuc problem
Have created sample sinatra cucumber app as suggested on wiki. Tried both
env.rb configurations from there and aslaks git repo. With this combination
of gems I get the following error doing basic cuc tests
When I visit ''/foo'' #
features/step_definitions/general.rb:1
PATH_INFO must start with / (Rack::Lint::LintError)
2007 Oct 12
7
puppet (Timeout::Error) HELP???
Can anyone help me with this error I am having. I am using puppet on
Debian Etch, version 0.20.1-1 from apt works OK, but due to one or two
problems we want to use the version from testing, 0.23.2-10, but the
puppetd just fails upon startup spitting this out:
Starting puppet configuration management
tool/usr/lib/ruby/1.8/timeout.rb:54:in `open'': execution expired
(Timeout::Error)