Displaying 20 results from an estimated 20000 matches similar to: "removing characters from a string"
2005 Apr 13
3
terminate R program when trying to access out-of-bounds array element?
I want R to stop running a script (after printing an
error message) when an array subscript larger than the
length of the array is used, for example
x = c(1)
print(x[2])
rather than printing NA, since trying to access such
an element may indicate an error in my program. Is
there a way to get this behavior in R? Explicit
testing with the is.na() function everywhere does not
seem like a good
2007 Apr 11
3
Fortran coding standards
I have some comments on the Fortran code in the
fseries package in file 4A-GarchModelling.f ,
especially the subroutine GARCHFIT and function
DSNORM.
I appended the code to the end of an earlier message,
but it was rejected by some rule. Let me first say
that I am grateful that packages for financial
econometrics exist in R.
Fortran 77 had PARAMETERs, and PARAMETERs equal to
99999 and 200 should
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,
2005 Apr 11
2
static analysis tools for R code?
An R script will terminate when one tries to use an
undefined variable, with a message such as
Error in print(x) : Object "x" not found
This run-time error might occur after the script has
already been running for some time. In some cases it
would be nice to get such warnings before the script
is run, just as a syntax error caused by a missing
parenthesis is caught.
Are there any
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
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 Apr 13
1
Why is 1 a double?
Based on examples in R books and the syntax of other
programming languages, I expected that
n <- 10
assigns the integer 10 to n, but typeof(n) is actually
a double. The subscripting expression x[1] is valid,
but sprintf("\n %d",1) is not, giving the error
Error in sprintf("\n %d", 1) : use format %f, %e or %g
for numeric objects
One must use instead sprintf("\n
2005 Nov 27
4
gsub syntax
Hello
I know that R's string functions are not as extensive as those of Unix but
I need to do some text handling totally within an R environment because
the target is a Windows system which will not have the corresponding shell
utilities, sed, awk etc.
Can anyone explain the following gsub phenomenon to me:
>
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"
>
2011 Sep 29
2
String manipulation with regexpr, got to be a better way
Help-Rs,
I'm doing some string manipulation in a file where I converted a string date in mm/dd/yyyy format and returned the date yyyy.
I've used regexpr (hat tip to Gabor G for a very nice earlier post on this function) in steps (I've un-nested the code and provided it and an example of what I did below. My question is: is there a more efficient way to do this. Specifically is
2005 Oct 31
6
getting last 2 charcters of a string, other "text" functions?
I wish to obtain the right-most n characters of a character string? What is the appropriate function?
---------------------------------
[[alternative HTML version deleted]]
2012 Feb 08
4
"unsparse" a vector
Suppose I have a vector of strings:
c("A1B2","A3C4","B5","C6A7B8")
[1] "A1B2" "A3C4" "B5" "C6A7B8"
where each string is a sequence of <column><value> pairs
(fixed width, in this example both value and name are 1 character, in
reality the column name is 6 chars and value is 2 digits).
I need to
2012 Mar 04
1
quantmod getOptionChain Not Work
Dear R Helpers,
I am still having trouble with the getOptionChain command in quantmod. I
have the latest version of quantmod, etc. so I was under the impression
that the problem was solved with updates to the package.
If someone could let me know what I need to install in order to make this
work, I would really appreciate it.
My error message as session info are shown below. Thanks a bunch.
2010 Mar 04
2
Removing colon from numerical data
Basic question, looked through the forum and documentation but didnt see a
solution.
So consider
O<-c(1:20)
D<-c("1:","2:","3:","4:","5:","6:","7:","8:","9:","10:","11:","12:","13:","14:","15:","16:",
2007 May 16
5
drop a letter
hello,
how can I do to drop C from this character "C325" ?
_____________________________________________________________________________
[[alternative HTML version deleted]]
1998 Apr 12
3
R-beta: S Compatibility (again)
While I think total compatibility is not possible or even very
important I have become aware recently of some fairly low level
incompatibilities that have rather serious consequences for
interchange between systems. Some of these are possibly well
known, but I put them on on record here just in case. (I do not
expect any action on these, of course, but people may want to
note them, and correct
1998 Apr 12
3
R-beta: S Compatibility (again)
While I think total compatibility is not possible or even very
important I have become aware recently of some fairly low level
incompatibilities that have rather serious consequences for
interchange between systems. Some of these are possibly well
known, but I put them on on record here just in case. (I do not
expect any action on these, of course, but people may want to
note them, and correct
2010 Dec 26
4
Parsing a Simple Chemical Formula
Hello R Folks...
I've been looking around the 'net and I see many complex solutions in
various languages to this question, but I have a pretty simple need
(and I'm not much good at regex). I want to use a chemical formula as
a function argument. The formula would be in "Hill order" which is to
list C, then H, then all other elements in alphabetical order. My
2008 Dec 03
3
Strplit code
Dear R-users,
The strsplit function does not exist in S-plus and I would like to use it. How
could I reproduce the function in Splus or access to its source code?
Thank you in advance,
Sebastien
2010 Feb 08
2
the hat ^ in regular expression
Un texte encapsul? et encod? dans un jeu de caract?res inconnu a ?t? nettoy?...
Nom : non disponible
URL : <https://stat.ethz.ch/pipermail/r-help/attachments/20100208/52a6d080/attachment.pl>