Re: [R] retaining characters in a csv file

2015-09-22 Thread Arunkumar Srinivasan
data.table's fread reads this as expected. Quoted strings aren't coerced. sapply(fread('5724550,"000202075214",2005.02.17,2005.02.17,"F"\n'), class) # V1 V2 V3 V4 V5 # "integer" "character" "character" "character" "character" Best, Arun. On Wed,

Re: [R] more complex by with data.table???

2015-06-21 Thread Arunkumar Srinivasan
Ramiro, `dt[, lapply(.SD, mean), by=name]` is the idiomatic way. I suggest reading through the new HTML vignettes at https://github.com/Rdatatable/data.table/wiki/Getting-started Ista, thanks for linking to the new vignette. On Wed, Jun 10, 2015 at 2:17 AM, Ista Zahn istaz...@gmail.com wrote:

Re: [R] data.frame: data-driven column selections that vary by row??

2015-04-01 Thread Arunkumar Srinivasan
David, In data.table v1.9.5 (current development version, which you can get from here: https://github.com/Rdatatable/data.table/wiki/Installation), new features were added to both `melt` and `cast` for data.tables. They both can handle multiple columns simultaneously. I think this would be of

Re: [R] DESeq vs DESeq2 different DEGs results

2014-05-09 Thread Arunkumar Srinivasan
You're on the wrong list. This is more appropriate on the bioconductor mailing list. On Mon, May 5, 2014 at 9:42 AM, Catalina Aguilar Hurtado cata...@gmail.comwrote: Hi, I want to compare DESeq vs DESeq2 and I am getting different number of DEGs which I will expect to be normal. However,

Re: [R] Reshape large Data Frame to new format

2014-04-30 Thread Arunkumar Srinivasan
Hi Dark, Sorry for the late response. Since you asked for a `data.table` solution as well, here's one: require(data.table) dt - as.data.table(rawData) dt[, GRP := (0:(.N-1L))%/%25L, by=PersonID] dt[, `:=`(var=codes, N = 1:.N), by=list(PersonID, GRP)] dcast.data.table(dt, PersonID+GRP ~ var+N,

Re: [R] creating table with sequences of numbers based on the table

2014-03-13 Thread Arunkumar Srinivasan
I think this'll be way simpler and also faster: ans - data.frame(pop = rep.int(tab$pop, tab$Freq), ind=sequence(tab$Freq)) Arun From: Dennis Murphy djmu...@gmail.com Reply: Dennis Murphy djmu...@gmail.com Date: March 13, 2014 at 9:57:20 PM To: arun smartpink...@yahoo.com Cc: R help

Re: [R] Assign numbers in R

2014-03-12 Thread Arunkumar Srinivasan
Here's another one: match(d, unique(d)). Arun From: Greg Snow 538...@gmail.com Reply: Greg Snow 538...@gmail.com Date: March 12, 2014 at 8:41:31 PM To: T Bal studentt...@gmail.com Cc: r-help r-help@r-project.org Subject:  Re: [R] Assign numbers in R Here are a couple more options if

[R] On ^ returning a matrix when operated on a data.frame

2013-11-13 Thread Arunkumar Srinivasan
Dear R-users, I am wondering why ^ operator alone returns a matrix, when operated on a data.frame (as opposed to all other arithmetic operators). Here's an example: DF - data.frame(x=1:5, y=6:10) class(DF*DF) # [1] data.frame class(DF^2) # [1] matrix I posted here on SO:

Re: [R] On ^ returning a matrix when operated on a data.frame

2013-11-13 Thread Arunkumar Srinivasan
Duncan, Thank you. What I meant was that ^ is the only *arithmetic operator* to result in a matrix on operating in a data.frame. I understand it's quite old code. Also, your explanation makes sense, with the exception of / operator, I suppose (I could be wrong here). Arun On Thursday,

Re: [R] calculating mean matrix

2013-01-19 Thread Arunkumar Srinivasan
One way using `Reduce`: set.seed(45) grp - factor(rep(letters[1:10], each=10)) # equivalent of your column x # dummy data df - as.data.frame(matrix(sample(1:1000, replace=T), ncol=length(levels(grp # solution Reduce('+', split(df, grp))/length(levels(grp)) Arun On Saturday, January