Hi,
May be this helps:
set.seed(14)
dat1 <- data.frame(shell_ID=
sample(c("0208A_47_33","0208A_47_34","0912C_13_3","1400C_2_48"),20,replace=TRUE),stringsAsFactors=FALSE)
dat2 <- dat1
ord1 <-
order(as.numeric(gsub("[[:alpha:]]+.*","",dat1$shell_ID)),as.numeric(gsub(".*\\_","",dat1$shell_ID))
)
om: r-help-boun...@r-project.org [mailto:r-help-boun...@r-project.org] On
> Behalf
> Of William Dunlap
> Sent: Friday, October 11, 2013 9:51 AM
> To: arun; Steven Ranney; r-help@r-project.org
> Subject: Re: [R] Create sequential vector for values in another column
>
> At this poin
Original Message-
> From: r-help-boun...@r-project.org [mailto:r-help-boun...@r-project.org] On
> Behalf
> Of arun
> Sent: Friday, October 11, 2013 6:43 AM
> To: Steven Ranney; r-help@r-project.org
> Subject: Re: [R] Create sequential vector for values in another col
On 11-10-2013, at 15:26, Steven Ranney wrote:
> Hello all -
>
> I have an example column in a dataFrame
>
> id.name
> 123.45
> 123.45
> 123.45
> 123.45
> 234.56
> 234.56
> 234.56
> 234.56
> 234.56
> 234.56
> 234.56
> 345.67
> 345.67
> 345.67
> 456.78
> 456.78
> 456.78
> 456.78
> 456.78
> 456.7
lto:r-help-bounces@r-
> project.org] On Behalf Of Steven Ranney
> Sent: Friday, October 11, 2013 3:26 PM
> To: r-help@r-project.org
> Subject: [R] Create sequential vector for values in another column
>
> Hello all -
>
> I have an example column in a dataFrame
>
Also,
it might be faster to use ?data.table()
library(data.table)
dt1<- data.table(dat1,key='id.name')
dt1[,x:=seq(.N),by='id.name']
A.K.
On , arun wrote:
Hi,
Try:
dat1<-
structure(list(id.name = c(123.45, 123.45, 123.45, 123.45, 234.56,
234.56, 234.56, 234.56, 234.56, 234.56, 234.56, 345
Hello all -
I have an example column in a dataFrame
id.name
123.45
123.45
123.45
123.45
234.56
234.56
234.56
234.56
234.56
234.56
234.56
345.67
345.67
345.67
456.78
456.78
456.78
456.78
456.78
456.78
456.78
456.78
456.78
...
[truncated]
And I'd like to create a second vector of sequential values
7 matches
Mail list logo