similar to: the integer of a given location

Displaying 20 results from an estimated 10000 matches similar to: "the integer of a given location"

2009 Dec 19
3
integer(0) and NA do not equal FALSE
Hi, A noobie question: I'm simply trying to run a conditional statement that evaluates if a substring is found within a larger string. I find that if it IS found, my function returns TRUE (great!), but if not, the condition does not evaluate to FALSE. ex): if( grep("hi", "hop", fixed = TRUE) ) print('yes, your substring is in your string') else
2007 Dec 13
2
use ggplot in a function to which a column name is given
Hi everyone, Hi ggplot users in particular, ggplot makes it very easy to plot things given their names when you use it interactively (and therefore can provide the names of the columns). qplot(x,foo,data=A) where A has columns (x,y,foo,bar) for example but I would like to use this from inside a function to which the name of the column is given. I cannot find an elegant way to make this
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,
2018 Jan 21
3
substr gives empty output
Dear all, I have a string, let's say "testing", and I would like to extract in sequence each letter (character) from it. But when I use substr() I only properly get the first character, the rest is empty (""). What am I getting wrong? For example, I have this code: >>> x <- "testing" k <- nchar(x) for (i in 1:k) { y <- substr(x, i, 1)
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 May 22
4
grep, gsub, sub have problems with NA values (PR#3078)
In a string context, grep, gsub, sub are improperly treating NA (missing) as the string "NA", and returning unexpected results > grep("A", c(NA,"NA")) [1] 1 2 # expected: # [1] 2 > gsub("A", "X", c(NA,"NA")) [1] "NX" "NX" # expected # [1] NA "NX" > sub("A", "X",
2007 Jan 25
1
Substring error
Hi, Do anybody know when and why the below error we get? Error in substr(x, as.integer(start), as.integer(stop)) : invalid substring argument(s) in substr() Thanks in advance, Shubha [[alternative HTML version deleted]]
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
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
2008 Oct 20
2
Extracting variables with a given prefix in the parent environment
hi, get.vars.name.prefix<-function(prefix){ result<-list() len<-nchar(prefix) var.names<-ls(name=1,pattern=prefix) #name=1 probably wrong option print(var.names) for(i in 1:length(var.names)){ name<-var.names[i] field<-substr(name,len+1,nchar(name)) result[[field]]<-get(name) } result } for example x.1<-1 x.2<-2 get.vars.name.prefix("x.") should
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,
2003 Nov 07
3
Q. About String indexing
Hi all - this is a very basic question: how does one index substrings of a character string, for example get the 2nd through 5th characters of the string "testing", in the R language? Indexing with square brackets seems only to work for vectors, lists, etc., and although I've found plenty of functions for concatenating strings, running substitutions with regexps and the like, I seem
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
2009 Dec 01
1
explanation for left-side behaviour
Hi there, I'm pretty sure that it's written down somewhere but I cannot find it so far. The little example shows different approaches to replace a substring. Only the last one works. I think it has something to do with the fact that "substr" is used on the left side. Can anybody refer to an explanation for this behaviour? Thanks a lot in advance! Antje values <-
2005 Jun 22
6
Is it possible to get the first letter of a word?
Hi, I would to get the first letter of a word like: > title_cat TitleCat 1 Training I would like T from Training! Thnaks a lot for your help Sabine --------------------------------- T侀l侀chargez le ici ! [[alternative HTML version deleted]]
2009 Sep 28
1
model.matrix troubles with AlgDesign
Dear DevelopeRs, in continuing with my suite of packages on experimental design, I am stuck with an issue that appears to be related to package AlgDesign - I have tried to get it solved by Bob Wheeler, but he seems to be stuck as well. Whenever AlgDesign is loaded, some of my code does not work any more. For example, in a fresh R session: require(DoE.base) fac.design(nlevels=c(2,6,2))
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
2011 Nov 15
1
Problem with substr
Hi, everyone When I ran this cript, There is Error in substring(tmp.subject, tmp.end[ex] + 1, tmp.start[ex + 1] - 1) : invalid substring argument(s) Could someone figure out what the problem is? for(i in 1:length(genebody[,1])){ tmp.id<-as.vector(genebody[i,1]) # get gene id tmp.subject<-as.vector(genebody[i,2]) # get gene sequence
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",
2004 Mar 12
5
grep
Hi, I want to use the first digit of the elements of a vector. I've tried grep but didn't work. Any help is welcome. Thanks EJ > grep("^[0-9]",as.character(runif(100,0,2))) [1] 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 [19] 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 [37] 37 38 39 40 41 42 43 44 45