Re: [R] How to apply a function to subsets of a data frame *and* obtain a data frame again?

2011-08-17 Thread Nick Sabbe
You might want to look at package plyr and use ddply. HTH, Nick Sabbe -- ping: nick.sa...@ugent.be link: http://biomath.ugent.be wink: A1.056, Coupure Links 653, 9000 Gent ring: 09/264.59.36 -- Do Not Disapprove -Original Message- From: r-help-boun...@r-project.org [mailto:r-help

Re: [R] glmnet

2011-08-10 Thread Nick Sabbe
selected in the previous step. Good luck! Nick Sabbe -- ping: nick.sa...@ugent.be link: http://biomath.ugent.be wink: A1.056, Coupure Links 653, 9000 Gent ring: 09/264.59.36 -- Do Not Disapprove -Original Message- From: r-help-boun...@r-project.org [mailto:r-help-bounces@r

Re: [R] counting columns that fulfill specific criteria

2011-06-24 Thread Nick Sabbe
t, as this is also the function for transposing a matrix, and could end up being confusing at the least. Second: for most practical purposes, it's better to leave out the *100. Good luck, Nick Sabbe -- ping: nick.sa...@ugent.be link: http://biomath.ugent.be wink: A1.056, Coupure Links 653, 9000

Re: [R] problem (and solution) to rle on vector with NA values

2011-06-23 Thread Nick Sabbe
making the new behavior optional (through a new parameter na.action or similar, with the default the original behavior) is an option? Feel free to run your own version of rle in any case. I suggest you rename it, though, as it may cause problems for some packages. Nick Sabbe -- ping: nick.sa

Re: [R] Rcpp and Object Factories

2011-06-09 Thread Nick Sabbe
You might want to send this message to the Rcpp mailing list at: Rcpp-devel mailing list rcpp-de...@lists.r-forge.r-project.org https://lists.r-forge.r-project.org/cgi-bin/mailman/listinfo/rcpp-devel It will improve your chances of getting a swift (if not helpful) reply. Nick Sabbe -- ping

Re: [R] Simple order() data frame question.

2011-05-12 Thread Nick Sabbe
Try (df1[order(-df1[,2]),]) Adding the minus within the [ leaves out the column (in this case column 2). See ?[. HTH. Nick Sabbe -- ping: nick.sa...@ugent.be link: http://biomath.ugent.be wink: A1.056, Coupure Links 653, 9000 Gent ring: 09/264.59.36 -- Do Not Disapprove -Original

Re: [R] Looping over graphs in igraph

2011-05-06 Thread Nick Sabbe
return(c(v=vcount(g), e=ecount(g))) }) colnames(result)-unique(dfr$Graph.ID) print(result) HTH, Nick Sabbe -- ping: nick.sa...@ugent.be link: http://biomath.ugent.be wink: A1.056, Coupure Links 653, 9000 Gent ring: 09/264.59.36 -- Do Not Disapprove -Original Message

Re: [R] Lasso with Categorical Variables

2011-05-03 Thread Nick Sabbe
, the difference surely adds up... More improvements may be possible. This function only works if you don't include interactions, though. Nick Sabbe -- ping: nick.sa...@ugent.be link: http://biomath.ugent.be wink: A1.056, Coupure Links 653, 9000 Gent ring: 09/264.59.36 -- Do Not Disapprove

Re: [R] Reference variables by string in for loop

2011-04-29 Thread Nick Sabbe
Hi Michael. This is a classic :-) ObjectsOfInterest- list(one_df, two_df, three_df) for(namedf in ObjectsOfInterest){...} or probably even better sapply(ObjectsOfInterest, function(namedf){...}) hth. Nick Sabbe -- ping: nick.sa...@ugent.be link: http://biomath.ugent.be wink: A1.056, Coupure

[R] abline outside of plot region

2011-04-29 Thread Nick Sabbe
col.ticks to match the color of my abline (in the nonsimplified code), and this works too, but unfortunately, the label below the tick is not in this color, and a parameter for this is not present in axis. Suggestions for either? Note: I'm on windows 7 with R 2.13. Nick Sabbe -- ping: nick.sa

Re: [R] Assignments inside lapply

2011-04-27 Thread Nick Sabbe
No, that does not work. You cannot do assignment within (l)apply. Nor in any other function for that matter. Nick Sabbe -- ping: nick.sa...@ugent.be link: http://biomath.ugent.be wink: A1.056, Coupure Links 653, 9000 Gent ring: 09/264.59.36 -- Do Not Disapprove -Original Message

Re: [R] programming: telling a function where to look for the entered variables

2011-04-01 Thread Nick Sabbe
, lvar==subgroup, select=c(xvar,yvar)) Which should become something like (untested but should be close): Data.tmp - Fulldf[Fulldf[,lvar]==subgroup, c(xvar,yvar)] This should be a lot easier to translate based on column names, as the column names are now used as such. HTH, Nick Sabbe -- ping

Re: [R] programming: telling a function where to look for the entered variables

2011-04-01 Thread Nick Sabbe
, and pass that instead of c(xvarname, yvarname) ) return(indextable) } myfunct.better(yes, lvarname=lvar, xvarname=xvar, yvarname=yvar, dataframe=Fulldf) HTH, Nick Sabbe -- ping: nick.sa...@ugent.be link: http://biomath.ugent.be wink: A1.056, Coupure Links 653, 9000 Gent ring: 09/264.59.36

Re: [R] Graph many points without hiding some

2011-03-31 Thread Nick Sabbe
an axis, use -1 in the statement above axes3d() #Show axes title3d(main = main, sub=paste(Green is low, ulab, , red is high) xlab = xlab, ylab = ylab, zlab = zlab) } HTH, Nick Sabbe -- ping: nick.sa...@ugent.be link: http://biomath.ugent.be wink: A1.056, Coupure

Re: [R] choosing best 'match' for given factor

2011-03-31 Thread Nick Sabbe
more but similar index trickery required then. HTH, Nick Sabbe -- ping: nick.sa...@ugent.be link: http://biomath.ugent.be wink: A1.056, Coupure Links 653, 9000 Gent ring: 09/264.59.36 -- Do Not Disapprove -Original Message- From: r-help-boun...@r-project.org [mailto:r-help-boun...@r

Re: [R] a for loop to lapply

2011-03-30 Thread Nick Sabbe
with two columns, create a vector holding the differences and the sums of the columns - I know this can be done without *apply as well, but apart from that it is a more attainable exercise). Good luck to you on that! HTH, Nick Sabbe -- ping: nick.sa...@ugent.be link: http://biomath.ugent.be wink

Re: [R] A question on glmnet analysis

2011-03-25 Thread Nick Sabbe
is not differentiable). Some 'solutions' exist (bootstrap, for one), but they have all been shown to have (statistical) properties that make them - at the least - doubtful. I know, because I'm working on this. Short answer: there is no way to do this (at this time). HTH (and hang on there in Japan), Nick Sabbe

Re: [R] One to One Matching multiple vectors

2011-03-16 Thread Nick Sabbe
Hello Vincy. You probably want y[match(z,x)] Or, more instructional: whereAreZInX-match(z, x) y[whereAreZInX] HTH, Nick Sabbe -- ping: nick.sa...@ugent.be link: http://biomath.ugent.be wink: A1.056, Coupure Links 653, 9000 Gent ring: 09/264.59.36 -- Do Not Disapprove -Original Message

[R] Generic mixup?

2011-03-04 Thread Nick Sabbe
misunderstanding of what comprises a generic function? Thx, Nick Sabbe -- ping: nick.sa...@ugent.be link: http://biomath.ugent.be/ http://biomath.ugent.be wink: A1.056, Coupure Links 653, 9000 Gent ring: 09/264.59.36 -- Do Not Disapprove [[alternative HTML version

Re: [R] speed up process

2011-02-25 Thread Nick Sabbe
)[k]) lapply(seq_along(mydata_list), function(j){ foo_reg(dat=mydata_list[[j]], xvar=ind.xvar, yvar=k, mycol=j, pos=mypos[j], name.dat=names(mydata_list)[j]) return(NULL) }) invisible(NULL) }) HTH, Nick Sabbe -- ping: nick.sa...@ugent.be link: http://biomath.ugent.be wink: A1.056

Re: [R] glmnet with binary predictors

2011-02-03 Thread Nick Sabbe
(see ?plot.cv.glmnet), or you can use some numerical argument to find the reasonable extreme value for the criterion. Really boilerplate, I guess. Good luck. Nick Sabbe -- ping: nick.sa...@ugent.be link: http://biomath.ugent.be wink: A1.056, Coupure Links 653, 9000 Gent ring: 09/264.59.36 -- Do

[R] Preparing dataset for glmnet: factors to dummies

2011-02-01 Thread Nick Sabbe
the imputation, so I really need the conversion itself to work quickly. Thanks, Nick Sabbe -- ping: nick.sa...@ugent.be link: http://biomath.ugent.be wink: A1.056, Coupure Links 653, 9000 Gent ring: 09/264.59.36 -- Do Not Disapprove __ R-help@r-project.org

[R] plot not generic

2011-01-28 Thread Nick Sabbe
, and noticed that R does not recognize 'plot' as a generic function, and as such, showMethods does not work. This seems to conflict with the documentation for plot. So 2 questions: . How can I find the code of plot.glmnet . Why is plot not seen as generic? Thx. Nick Sabbe

[R] get type functions (was: RE: plot not generic)

2011-01-28 Thread Nick Sabbe
Muggeo (UniPa) [mailto:vito.mug...@unipa.it] Sent: vrijdag 28 januari 2011 14:42 To: Nick Sabbe Cc: r-help@r-project.org Subject: Re: [R] plot not generic dear Nick, getAnywhere(plot.glmnet) Note the message you get when you type methods(plot) ... Non-visible functions are asterisked Il

[R] Injecting code in a package?

2011-01-28 Thread Nick Sabbe
copy of the function, I want to make sure that when I call pkg::plot.something, this works as before, but when, from within this function, pkg:: plot.something.internal is called, I want it to call _my_ version of it. Any takes? Nick Sabbe -- ping: nick.sa...@ugent.be link: http

[R] Using a list as multidimensional indexer

2011-01-20 Thread Nick Sabbe
like to get the element pointed at by the list. The obvious solutions don't seem to work, and I can't seem to get do.call to call the indexer ('[') on my multidimensional object. Any suggestions? Thanks in advance, Nick Sabbe -- ping: nick.sa...@ugent.be link: http://biomath.ugent.be wink: A1.056

Re: [R] Using a list as multidimensional indexer

2011-01-20 Thread Nick Sabbe
,NULL) do.call([, Ind3) But all of these return integer(0). So the actual new question is: how do I pass a 'missing' argument through a do.call? Thanks for any pointers, Nick Sabbe -- ping: nick.sa...@ugent.be link: http://biomath.ugent.be wink: A1.056, Coupure Links 653, 9000 Gent ring: 09

[R] expand.grid

2011-01-19 Thread Nick Sabbe
writing my own stuff (get the number of levels per column, then use some apply magic) to using what is there, so thanks for any hints, Nick Sabbe -- ping: nick.sa...@ugent.be link: http://biomath.ugent.be/ http://biomath.ugent.be wink: A1.056, Coupure Links 653, 9000 Gent ring: 09/264.59.36

Re: [R] expand.grid

2011-01-19 Thread Nick Sabbe
(levels with na: , rv, \n) return(rv) } expand.combs-function(dfr, includeNA=FALSE, onlyOccurring=FALSE) { expand.grid(lapply(dfr, getLevels, includeNA, onlyOccurring)) } Thx. Nick Sabbe -- ping: nick.sa...@ugent.be link: http://biomath.ugent.be wink: A1.056, Coupure Links 653

Re: [R] Repeating value occurence

2011-01-13 Thread Nick Sabbe
(-1,0,1,0) rep(pattern, ceiling(n/length(pattern)))[1:n] If you want a sequence of random real numbers between -1 and 1, use runif(10, min=-1, max=1) Here's hoping I haven't just solved your homework... Nick Sabbe -- ping: nick.sa...@ugent.be link: http://biomath.ugent.be wink: A1.056, Coupure

Re: [R] Numbers in a string

2010-12-15 Thread Nick Sabbe
Hi Felipe, gsub([^0123456789], , AB15E9SDF654VKBN?dvb.65) results in 15965465. Would that be what you are looking for? Nick Sabbe -- ping: nick.sa...@ugent.be link: http://biomath.ugent.be wink: A1.056, Coupure Links 653, 9000 Gent ring: 09/264.59.36 -- Do Not Disapprove -Original

Re: [R] problem accessing complex list data frames

2010-12-08 Thread Nick Sabbe
Hello Germán. You probably want something like: sapply(vmat, function(curMat){ curMat[,999] != 0 }) Or if you want the indices, just surround this with a which. HTH. Nick Sabbe -- ping: nick.sa...@ugent.be link: http://biomath.ugent.be wink: A1.056, Coupure Links 653

[R] Dataframe from list of similar lists: not _a_ way, but _the best_ way

2010-12-07 Thread Nick Sabbe
? Or is there any way in which this depends on the specifics of my function (for nontrivial functions and list sizes)? Thanks! Nick Sabbe -- ping: nick.sa...@ugent.be link: http://biomath.ugent.be/ http://biomath.ugent.be wink: A1.056, Coupure Links 653, 9000 Gent ring: 09/264.59.36

Re: [R] small problem in coding

2010-11-26 Thread Nick Sabbe
]) It looks like you've got a misunderstanding of how R variables work, but maybe I just misunderstood your question... HTH, Nick Sabbe -- ping: nick.sa...@ugent.be link: http://biomath.ugent.be wink: A1.056, Coupure Links 653, 9000 Gent ring: 09/264.59.36 -- Do Not Disapprove -Original Message

Re: [R] Simple Function

2010-11-10 Thread Nick Sabbe
want to avoid the for loop here altogether: y[i:10]-(i:10)+1 f[i:10]-y[(i-1):9]/2 gives you the same result, but more in the R fashion (in general, you want to avoid explicit for loops in R) HTH, Nick Sabbe -- ping: nick.sa...@ugent.be link: http://biomath.ugent.be wink: A1.056, Coupure Links 653

Re: [R] Help with Iterator

2010-11-09 Thread Nick Sabbe
the rest of your code is OK) Nick Sabbe -- ping: nick.sa...@ugent.be link: http://biomath.ugent.be wink: A1.056, Coupure Links 653, 9000 Gent ring: 09/264.59.36 -- Do Not Disapprove -Original Message- From: r-help-boun...@r-project.org [mailto:r-help-boun...@r-project.org] On Behalf

Re: [R] How to eliminate this for loop ?

2010-11-09 Thread Nick Sabbe
an example where they prove to be the better way to go (by any criteria, but preferably speed or perhaps other resource usage) Nick Sabbe -- ping: nick.sa...@ugent.be link: http://biomath.ugent.be wink: A1.056, Coupure Links 653, 9000 Gent ring: 09/264.59.36 -- Do Not Disapprove -Original Message

Re: [R] How to eliminate this for loop ?

2010-11-08 Thread Nick Sabbe
Whenever you use a recursion (that cannot be expressed otherwise), you always need a (for) loop. Apply and the like do not allow to use the intermediary results (i.e. a[i-1] to calculate a[i]). So: no, it cannot be avoided in your case, I guess. Nick Sabbe -- ping: nick.sa...@ugent.be link

Re: [R] Random Integer Number in Uniform Distribution

2010-10-25 Thread Nick Sabbe
Check ?sample. Nick Sabbe -- ping: nick.sa...@ugent.be link: http://biomath.ugent.be wink: A1.056, Coupure Links 653, 9000 Gent ring: 09/264.59.36 -- Do Not Disapprove -Original Message- From: r-help-boun...@r-project.org [mailto:r-help-boun...@r-project.org] On Behalf Of Gundala

Re: [R] if statement and truncated distribution

2010-10-25 Thread Nick Sabbe
) } Nick Sabbe -- ping: nick.sa...@ugent.be link: http://biomath.ugent.be wink: A1.056, Coupure Links 653, 9000 Gent ring: 09/264.59.36 -- Do Not Disapprove -Original Message- From: r-help-boun...@r-project.org [mailto:r-help-boun...@r-project.org] On Behalf Of Sally Luo Sent: maandag

Re: [R] Find index of a string inside a string?

2010-10-25 Thread Nick Sabbe
For simple searches, use grep with fixed=TRUE. Check ?grep. Nick Sabbe -- ping: nick.sa...@ugent.be link: http://biomath.ugent.be wink: A1.056, Coupure Links 653, 9000 Gent ring: 09/264.59.36 -- Do Not Disapprove -Original Message- From: r-help-boun...@r-project.org [mailto:r-help

Re: [R] printing a variable during a loop

2010-10-22 Thread Nick Sabbe
consequence will be that your code will run somewhat slower. For using some output as 'progress control' you definitely want to turn the option off. Nick Sabbe -- ping: nick.sa...@ugent.be link: http://biomath.ugent.be wink: A1.056, Coupure Links 653, 9000 Gent ring: 09/264.59.36 -- Do