Thank you,
So my mistake was my data was a factor and not character,for strsplit
Thanks so much
-Original Message-
From: Rui Barradas [mailto:ruipbarra...@sapo.pt]
Sent: 08 July 2013 15:55
To: Pancho Mulongeni
Cc: r-help@r-project.org
Subject: Re: [R] Splitting coordinates into two
Hello,
Try the following
x <- structure(...)
sp <- strsplit(as.character(x), ",")
G1 <- sapply(sp, `[`, 1)
G2 <- sapply(sp, `[`, 2)
Hope this helps,
Rui Barradas
Em 08-07-2013 14:49, Pancho Mulongeni escreveu:
Hi users,
I have a simple vector of five coordinates in form of ('lat1,
long1'
`,1)
G2<-sapply(strsplit(as.character(vec1),","),`[`,2)
G1
#[1] "-22.576608" "-24.621739" "-26.567955" "-22.832516" "-21.980459"
A.K.
- Original Message -
From: Pancho Mulongeni
To: "r-help@r-project.org"
Cc:
Sent: Mon
Hi users,
I have a simple vector of five coordinates in form of ('lat1,
long1','lat2,long2',...,'latn,longn')
And I would like to create two vectors, one just with the first coordinate
G1<-c('lat1,'lat2',..,'latn')
G2<-c('long1,'long2',...,'longn')
I am trying to apply strsplit(x=g,split=',') on
4 matches
Mail list logo