Re: [R] Splitting vector elements

2014-05-21 Thread Luca Cerone
Thanks Arun, I agree using read.table is probably easier :) 2014-05-21 12:08 GMT+02:00 arun : > > > Hi Katherine, > > #or you can use: > read.table(text=dat,sep="",header=FALSE,stringsAsFactors=FALSE) > # V1 V2 > #1 ABC 1 > #2 ABC 2 > #3 ABC 3 > #4 DEF 10 > #5 DEF 20 > A.K. > > > On Wednesday

Re: [R] Splitting vector elements

2014-05-21 Thread arun
Hi Katherine, #or you can use: read.table(text=dat,sep="",header=FALSE,stringsAsFactors=FALSE) #   V1 V2 #1 ABC  1 #2 ABC  2 #3 ABC  3 #4 DEF 10 #5 DEF 20 A.K. On Wednesday, May 21, 2014 5:38 AM, Luca Cerone wrote: Hi Katherin, the following code does the trick: x <- strsplit(dat," ") df <-

Re: [R] Splitting vector elements

2014-05-21 Thread Luca Cerone
Hi Katherin, the following code does the trick: x <- strsplit(dat," ") df <- data.frame(p1=sapply(x, function(x) x[1]), p2 = sapply(x, function(x) x[2])) Hope it helps, Luca 2014-05-21 11:29 GMT+02:00 Katherine Gobin : > Dear R forum > > I have a vector as > > dat = c("ABC 1", "ABC 2", "ABC 3",

[R] Splitting vector elements

2014-05-21 Thread Katherine Gobin
Dear R forum I have a vector as  dat = c("ABC 1", "ABC 2", "ABC 3", "DEF 10", "DEF 20") > dat [1] "ABC 1"  "ABC 2"  "ABC 3"  "DEF 10" "DEF 20" I need to split the names into two parts say    p1      p2  ABC    1  ABC    2  ABC    3  DEF     10  DEF     20 Kindly guide Katherine [[al

Re: [R] Splitting vector

2013-04-18 Thread arun
Hi, Try: vec1<- "mue#d/sjbijk@ruepvnvbnceiicrpgxkgcyl@keduhqvqi/ubudvxopddpfddgitrynzshzdcwgneyffrkpbxwilwqngrsals#geqmtkcpkp/qecgdfa#uag" library(seqinr)  res<-lapply(0:4,function(i) lapply(2:5,function(j) splitseq(s2c(gsub("[#@/]","",vec1)),word=j,frame=i))) #or library(stringr) res1<-lapply

[R] splitting vector into equal sets

2009-04-16 Thread utkarshsinghal
Hi R, I have explored R archives a lot but couldn't find an efficient way of doing the following: I want to split a vector into sets of equal sizes. Is there any inbuilt function of doing so with the option of specifying how to treat the remaining observations. For example: suppose I want to