Re: [R] Splitting and arranging in ascending order

2015-06-04 Thread Amelia Marsh
Dear Sir, Thanks for your guidance and sinecerly apologize for late reply from my end. Regards Amelia On Wednesday, 3 June 2015 10:38 PM, Rui Barradas wrote: Hello, Try the following. tmp <- strsplit(as.character(my_dat$instrument), "_") tmp <- t(as.data.frame(tmp)) tmp <- data.frame(inst

Re: [R] Splitting and arranging in ascending order

2015-06-03 Thread PIKAL Petr
7 For ordering use ?order or ?sort. Changing column ?names is also trivial. Cheers Petr > -Original Message- > From: R-help [mailto:r-help-boun...@r-project.org] On Behalf Of Amelia > Marsh > Sent: Wednesday, June 03, 2015 11:09 AM > To: r-help@r-project.org > Su

Re: [R] Splitting and arranging in ascending order

2015-06-03 Thread Rui Barradas
Hello, Try the following. tmp <- strsplit(as.character(my_dat$instrument), "_") tmp <- t(as.data.frame(tmp)) tmp <- data.frame(instrument = tmp[,1], sr_no = as.integer(tmp[, 2]), my_dat$mtm_value) result <- tmp[order(tmp[, 1], tmp[, 2]), ] rm(tmp) rownames(result) <- NULL result Hope this

[R] Splitting and arranging in ascending order

2015-06-03 Thread Amelia Marsh
Dear R forum I have a data (actually its a big data and I am only giving part of my interest) as my_dat = data.frame(instrument = c("EQ_0", "EQ_1", "EQ_10", "EQ_100", "EQ_2", "EQ_20", "IRS_0", "IRS_1", "IRS_10", "IRS_100", "IRS_2", "IRS_20"), mtm_value = c(23, 63, 8, 44, 68, 11, 83, 56, 73, 92