Re: [R] Why don't the comments appear in the function?

2019-11-25 Thread Neal Fultz
ion around this at https://github.com/DeclareDesign/DesignLibrary/issues/50 and linked issues from the last time I encountered this weird corner of R. If anyone finds a better solution (or for the related problem of preserving whitespace), I would be interested as well. Very respectfully, Neal Fultz O

Re: [R] Packages

2019-01-23 Thread Neal Fultz
I'd recommend you upgrade to R version 3.5.2, the version you have is quite out of date. On Wed, Jan 23, 2019 at 9:42 AM AbouEl-Makarim Aboueissa < abouelmakarim1...@gmail.com> wrote: > here is the messages I got when I install the "car" package: > > > install.packages("car") > Installing

Re: [R] Question about function scope

2018-10-30 Thread Neal Fultz
I'm going to n-th Duncan's recommendations to try to keep your functions small and try not to mess with environments. ... So I'm ashamed that I wrote the following - I apologize in advance. But as an intellectual exercise, we can cannibalize the code for `dynGet` and create a `dynSet` function

Re: [R] Thoughts for faster indexing

2013-11-21 Thread Neal Fultz
Noah, If N is # of rows, k is # of unique IDs Using which() is O(N), using which() in a loop is going to be O(Nk); sorting the entire data is O(N ln N) and then you can process it in contiguous blocks, no which required. -Neal On Thu, Nov 21, 2013 at 8:48 AM, William Dunlap

Re: [R] Console Output Formatting

2013-09-04 Thread Neal Fultz
print(1:100) [1] 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 [27] 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 [53] 53 54 55 56 57 58 59 60 61 62 63 64 65 66

Re: [R] load() into a data frame with my chosen name = .ThisEnv ?

2013-06-17 Thread Neal Fultz
For your problem, you might want to use saveRDS and readRDS instead of save and load. I would also use dir to get a list of files rather than paste. Then your solution might look like: run - function(filename) { df - readRDS(filename); coef( lm(df[,1] ~ df[,2]) ) } results - lapply(

Re: [R] recode: how to avoid nested ifelse

2013-06-08 Thread Neal Fultz
, hs, es))) user system elapsed 0.950.030.98 R version 3.0.0 (2013-04-03) Platform: x86_64-w64-mingw32/x64 (64-bit) On Fri, Jun 7, 2013 at 7:25 PM, Neal Fultz nfu...@gmail.com wrote: I would do this to get the highest non-missing level: x - pmax(3*cg, 2*hs, es, 0

Re: [R] recode: how to avoid nested ifelse

2013-06-07 Thread Neal Fultz
I would do this to get the highest non-missing level: x - pmax(3*cg, 2*hs, es, 0, na.rm=TRUE) rock chalk... -nfultz On Fri, Jun 07, 2013 at 06:24:50PM -0700, Joshua Wiley wrote: Hi Paul, Unless you have truly offended the data generating oracle*, the pattern: NA, 1, NA, should be a data

Re: [R] flatten lists

2012-06-26 Thread Neal Fultz
do.call(c, x) maybe? On Tue, Jun 26, 2012 at 02:25:40PM -0700, Jeroen Ooms wrote: I am looking for a function to flatten a list to a list of only 1 level deep. Very similar to unlist, however I don't want to turn it into a vector because then everything will be casted to character vectors:

Re: [R] Subset and order at the same time?

2012-05-12 Thread Neal Fultz
can be done in one line, but it is annoying and ugly, so you probably shouldn't be doing it that way: sleep[sleep$group == 1,] -sleep[sleep$group == 1,][order(sleep[sleep$group == 1,1]),] sleep extra group ID 1 -1.6 1 2 2 -1.2 1 4 3 -0.2 1 3 4 -0.1 1 5 50.0

Re: [R] datastructure for multi-choice factors

2011-07-07 Thread Neal Fultz
I had a similar survey, and ended up stuffing everything into one field using the bitops library. On Thu, Jul 7, 2011 at 4:18 AM, jeroen00ms jeroen.o...@stat.ucla.eduwrote: I am working on a system to visualize survey responses. Survey responses typically include factors, numeric, timestamps,