search for: strsplit

Displaying 20 results from an estimated 1234 matches for "strsplit".

2011 Dec 21
1
Gps fraction of degrees function
Dear all,   I have the following written example > coords <- "51°30'48.58\"N" > > as.integer(strsplit(coords, "°")[[1]][1]) [1] 51 > as.integer(strsplit(strsplit(coords, "°")[[1]][2], "'")[[1]][1]) [1] 30 > as.numeric(strsplit(strsplit(strsplit(coords, "°")[[1]][2], "'")[[1]][2], "\"")[[1]][1]) [1] 48.58 > strsplit(st...
2012 Jan 25
4
help to slip a file name using "strsplit" function
Dear Researchers, I have several files as this example: Myfile_MyArea1_sample1.txt i wish to split in "Myfile", "MyArea1", "sample1", and "txt", becasue i need to use "sample1" label. I try to use "strsplit" but I am able just to split as "Myfile_MyArea1_sample1" and "txt" OR "Myfile", "MyArea1", "sample1.txt" using strsplit(as.character("Myfile_MyArea1_sample1.txt"), ".", fixed = TRUE) strsplit(as.character("Myfile_MyAr...
2011 Feb 04
3
lapply, strsplit, and list elements
Hi there, I have a problem about lapply, strsplit, and accessing list elements, which I don't understand or cannot solve: I have e.g. a character vector with three elements: x = c("349/077,349/074,349/100,349/117", "340/384.2,340/513,367/139,455/128,D13/168", "600/437,128/903,128/904") The t...
2012 Apr 11
1
strsplit help
Dear all, I want to use string split to parse column names, however, I am having some errors that I don't understand. I see a problem when I try to rbind the output from strsplit. please let me know if I'm missing something obvious, thanks, alison here are my commands: >strsplit<-strsplit(as.character(Rumino_Reps_agreeWalign$geneid),"\\.") > Rumino_Reps_agreeWalignTR<-transform(Rumino_Reps_agreeWalign,taxid=do.call(rbind, strsplit)) Warning...
2010 Jul 08
2
strsplit("dia ma", "\\b") splits characterwise
\b is word boundary. But, unexpectedly, strsplit("dia ma", "\\b") splits character by character. > strsplit("dia ma", "\\b") [[1]] [1] "d" "i" "a" " " "m" "a" > strsplit("dia ma", "\\b", perl=TRUE) [[1]] [1] "d&quot...
2006 Apr 17
1
strsplit does not return correct value when spliting "" (PR#8777)
Full_Name: Charles Dupont Version: 2.2.0 OS: linux Submission from: (NULL) (160.129.129.136) when strsplit("", " ") returns character(0) where as strsplit("a", " ") returns "a". these return values are not constiant with each other. Charles Dupont
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 wrong? Either Windows or Linux 2.3.1 Thanks in advance! Sincerely, Erin Hodgess Associate Professor Depart...
2008 Oct 15
3
Removing characters and periods from character strings
...factor(Hab)3", "factor(Hab)4", "factor(Hab)5","factor(Hab)7", "factor(Log)1", "Hunt", "Pop", "s(PrimRd).1", "s(PrimRd).2", "Unlog", "Xcoord", "Ycoord") vars=as.character(as.vector(strsplit(pick,"1"))) vars=unique(as.character(as.vector(strsplit(vars,"2")))) vars=unique(as.character(as.vector(strsplit(vars,"3")))) vars=unique(as.character(as.vector(strsplit(vars,"4")))) vars=unique(as.character(as.vector(strsplit(vars,"5&quo...
2009 Sep 17
2
Why strsplit can be used with matrix but not data.frame?
Hi, As show in the code below, strsplit can be applied to a matrix but not a data.frame. I don't understand why R is designed in this way. Can somebody help me understand it? How to split all the strings in x$y? x=data.frame(x=1:10,y=rep("abc",10)) strsplit(x$y,'b') #Error in strsplit(x$y, "b") : non-char...
2006 Apr 04
1
extending strsplit(): supply pattern to keep, not to split by
strsplit() is a convenient way to get a list of items from a string when you have a regular expression for what is not an item. E.g., > strsplit("1.2, 34, 1.7e-2", split="[ ,] *") [[1]]: [1] "1.2" "34" "1.7e-2" However, sometimes is it...
2012 Nov 08
3
strsplit with invalid regular expression
Hi all, > diff_operator <- "\\(" > strsplit(cond, diff_operator) [[1]] [1] "andsin" "log_angle_1_4)" > diff_operator <- "\\sin(" > strsplit(cond, diff_operator) Error in strsplit(cond, diff_operator) : invalid regular expression '\sin(', reason 'Missing ')'' When I a...
2005 Oct 28
1
Error in ?strsplit
Hi all, Came across an error in ?strsplit in the details section: Details: Arguments 'x' and 'split' will be coerced to character, so you will see uses with 'split = NULL' to mean 'split = character(0)', including in the examples below. I caught myself trying to use strsplit() on a factor...
2007 Oct 22
3
strsplit
Hello R Gurus: I would like to take a character string and split at the $ sign. I thought that strsplit would do it, but here are the results: > vv [1] "whine$ts1" > vv [1] "whine$ts1" > strsplit(vv,"$") [[1]] [1] "whine$ts1" Does anyone have any suggestions, please? Thanks, Edna Bell
2012 Jan 12
3
strsplit() does not split on "."?
Any ideas what is wrong? > strsplit("a.b", ".") # generates empty strings with split="." [[1]] [1] "" "" "" > strsplit("a b", " ") # seems to work fine with split=" ", and other characters... [[1]] [1] "a" "b" > >...
2012 Feb 11
2
obtaining a true/false vector with combination of strsplit, length, unlist,
...der=T) closeAllConnections() I'm having a hard time coming up with the R code that would produce a TRUE/FALSE vector based on whether or not the first column of the data.frame "edm" has a length of 2 or 3? To show what I mean going row-by-row, I could do the following: > length(strsplit(as.character(edm$WELLID),"_")[[1]])==3 [1] FALSE > length(strsplit(as.character(edm$WELLID),"_")[[2]])==3 [1] FALSE > length(strsplit(as.character(edm$WELLID),"_")[[3]])==3 [1] TRUE > length(strsplit(as.character(edm$WELLID),"_")[[4]])==3 [1] TRUE &g...
2007 Dec 03
3
strsplit on comma, with a trailing comma in input
I have a comma-separated data file in which trailing commas sometimes occur. I am using strsplit to extract the data from this file, and it seems great except in cases with trailing comma characters. The example below illustrates. What I'd like is to get a fourth element in the answer, being an empty string just like the second element. Is there a way I can express my patter (or perhaps...
2011 Aug 03
2
strsplit and forward slash '/'
Hi All, is there a way of using strsplit with a forward slash '/' as the splitting point? For data such as: 1 T/T C/C 16/33 2 T/T C/C 33/36 3 T/T C/C 16/34 4 T/T C/C 16/31 5 C/C C/C 28/29 6 T/T C/C 16/34 strsplit(my.data[1,1], "/") # and any variation thereof Erro...
2012 Mar 22
2
Strsplit with a separator of ||
Hi, I tried to use strsplit for separating a string with || like strsplit(string,"\\||") but it returned each single character was separated. For example: strsplit("a||bc","\\||") [[1]] [1] "a" "" "" "b" "c" where I want the result to be...
2019 Dec 18
2
A weird behaviour of strsplit?
Hi all, In the help of strsplit one can read split character vector (or object which can be coerced to such) containing regular expression<http://127.0.0.1:39783/help/library/base/help/regular%20expression>(s) (unless fixed = TRUE) to use for splitting. If empty matches occur, in particular if split has length 0, x is sp...
2011 Feb 07
2
Confused
Hi Im confused by one thing, and if someone can explain it I would be a happy > rev(strsplit("hej",NULL)) [[1]] [1] "h" "e" "j" > lapply(strsplit("hej",NULL),rev) [[1]] [1] "j" "e" "h" Why dossent the first one work? What is it in R that "fails" so to say that you need to use lapply for it to get...