Re: [R] Why missing values are not allowed in 'poly'?

2016-03-28 Thread Liviu Andronic
t;)) >> > return(px) >> > } >> >> > and get nice results in the usual raw=FALSE case as well. Similar >> stuff >> > could be done in the multivariate cases. >> >> I don't have too much time for that now, >> and I know that Bill

Re: [R] Why missing values are not allowed in 'poly'?

2016-03-23 Thread Liviu Andronic
is: > poly(x, degree = 2, raw=TRUE) 1 2 [1,] NA NA [2,] 1 1 [3,] 2 4 [4,] 3 9 [5,] 4 16 [6,] 5 25 [7,] 6 36 [8,] 7 49 [9,] 8 64 [10,] 9 81 [11,] 10 100 attr(,"degree") [1] 1 2 attr(,"class") [1] "poly" "matrix" Regards, Liviu > > Bill Du

[R] Why missing values are not allowed in 'poly'?

2016-03-23 Thread Liviu Andronic
Dear all, I'm a bit surprised by this behavior in poly: x <- c(NA, 1:10) poly(x, degree = 2, raw=TRUE) ## Error in poly(x, degree = 2, raw = TRUE) : ## missing values are not allowed in 'poly' x^2 ## [1] NA 1 4 9 16 25 36 49 64 81 100 As you can see, poly() will fail if the vector contains

Re: [R] creating an equivalent of r-help on r.stackexchange.com ? (was: Re: Should there be an R-beginners list?)

2014-02-08 Thread Liviu Andronic
On Sat, Feb 8, 2014 at 4:41 AM, Patrick Connolly p_conno...@slingshot.co.nz wrote: | Dear Don and Bert, | Allow me to address some of your concerns below. Which you do very clearly by positioning your responses underneath what you're commenting on. That doesn't seem to be possible on SE. In

Re: [R] creating an equivalent of r-help on r.stackexchange.com ? (was: Re: Should there be an R-beginners list?)

2014-02-04 Thread Liviu Andronic
Dear all, On Sun, Feb 2, 2014 at 10:49 PM, Liviu Andronic landronim...@gmail.com wrote: It seems that StackOverflow is officially proposing user-generated content for download/mirroring: http://blog.stackoverflow.com/2014/01/stack-exchange-cc-data-now-hosted-by-the-internet-archive/?cb=1

Re: [R] creating an equivalent of r-help on r.stackexchange.com ? (was: Re: Should there be an R-beginners list?)

2014-02-03 Thread Liviu Andronic
in comparison. Kind regards, Liviu -Don -- Don MacQueen Lawrence Livermore National Laboratory 7000 East Ave., L-627 Livermore, CA 94550 925-423-1062 On 2/2/14 1:49 PM, Liviu Andronic landronim...@gmail.com wrote: Dear Duncan, I discovered something interesting wrt

Re: [R] creating an equivalent of r-help on r.stackexchange.com ? (was: Re: Should there be an R-beginners list?)

2014-02-03 Thread Liviu Andronic
, WA 98504-7600 Parcels:300 Desmond Drive, Lacey, WA 98503-1274 On Tue, 4 Feb 2014, Liviu Andronic wrote: Dear Don and Bert, Allow me to address some of your concerns below. On Mon, Feb 3, 2014 at 9:56 PM, Bert Gunter gunter.ber...@gene.com wrote: I find SO's voting

[R] creating an equivalent of r-help on r.stackexchange.com ? (was: Re: Should there be an R-beginners list?)

2014-02-02 Thread Liviu Andronic
Dear Duncan, I discovered something interesting wrt to the licensing and mirroring of user-contributed material on StackExchange. Please read below. On Sun, Nov 24, 2013 at 9:00 PM, Duncan Murdoch murdoch.dun...@gmail.com wrote: I'm not aware of a discussion on this, but I would say no.

Re: [R] convert data frame: two variables into _one_ binary variable

2013-11-26 Thread Liviu Andronic
== 'agree' -tgs On Mon, Nov 25, 2013 at 4:24 AM, Liviu Andronic landronim...@gmail.com wrote: Dear all, I am trying to convert the following data frame into a format more useful for me: library(HSAUR2, lib.loc=C:/Program Files/R/R-3.0.2/library) Loading required package: tools

[R] convert data frame: two variables into _one_ binary variable

2013-11-25 Thread Liviu Andronic
Dear all, I am trying to convert the following data frame into a format more useful for me: library(HSAUR2, lib.loc=C:/Program Files/R/R-3.0.2/library) Loading required package: tools Attaching package: ‘HSAUR2’ The following object is masked _by_ ‘.GlobalEnv’: womensrole

Re: [R] R for a stats intro for undergrads in the US?

2013-11-18 Thread Liviu Andronic
Dear Spencer, In case you have similar questions you may want to ask them on r-sig-teaching, which deals specifically with such topics. Regards, Liviu On Sun, Nov 17, 2013 at 3:19 AM, Spencer Graves spencer.gra...@prodsyse.com wrote: Hello, All: Would anyone recommend R for an

[R] OT: The topic of reproducibility in the media

2013-10-26 Thread Liviu Andronic
Dear all, I know that reproducibility is a big concern for the R community, so it may be interesting to some of the readers on this list that The Economist recently ran a series of articles denouncing the alarming number of shoddy and non-reproducible published papers:

[R] list of valid characters in object names

2013-07-27 Thread Liviu Andronic
Dear all, Could someone please point me to the definitive list of valid characters that are allowed in object names in R? I believe that the following list covers them: _.abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789 but I would like to make sure. Thank you, Liviu -- Do you

Re: [R] list of valid characters in object names

2013-07-27 Thread Liviu Andronic
On Sat, Jul 27, 2013 at 3:08 PM, Duncan Murdoch murdoch.dun...@gmail.com wrote: Your question is a little ambiguous. All characters are allowed in object names, but the parser will only recognize some of them if they are quoted in backticks. The ones it recognizes without the backticks are

[R] union of a list of logical values

2013-07-22 Thread Liviu Andronic
Dear all, How can I obtain the union of a list of logical values? Consider the following: x - head(iris) x[,c(2,4)] - NA x[c(2,4),] - NA # x # Sepal.Length Sepal.Width Petal.Length Petal.Width Species # 1 5.1 NA 1.4 NA setosa # 2 NA NA

Re: [R] union of a list of logical values

2013-07-22 Thread Liviu Andronic
On Mon, Jul 22, 2013 at 11:37 AM, Prof Brian Ripley rip...@stats.ox.ac.uk wrote: This really only makes sense for a list of logical vectors of the same length. And by 'union' you seem to mean 'or'. Indeed. Two approaches 1) Make a logical matrix and use apply(m, 1, any) Of course! I

Re: [R] generate simple function with pre-defined constants

2013-06-09 Thread Liviu Andronic
Andronic Sent: Thursday, June 06, 2013 8:00 AM To: r-help@r-project.org Help Subject: Re: [R] generate simple function with pre-defined constants On Thu, Jun 6, 2013 at 4:48 PM, Liviu Andronic landronim...@gmail.com wrote: Dear all, Given: a - 2 b - 3 I'd like to obtain

[R] generate simple function with pre-defined constants

2013-06-06 Thread Liviu Andronic
Dear all, Given: a - 2 b - 3 I'd like to obtain the following function: f - function(x) 2 + 3*x but when I do this: f - function(x) a + b*x ##f ##function(x) a + b*x the 'a' and 'b' objects do not get evaluated to their constants. How could I do that? Thanks, Liviu -- Do you know how to

Re: [R] generate simple function with pre-defined constants

2013-06-06 Thread Liviu Andronic
On Thu, Jun 6, 2013 at 4:48 PM, Liviu Andronic landronim...@gmail.com wrote: Dear all, Given: a - 2 b - 3 I'd like to obtain the following function: f - function(x) 2 + 3*x but when I do this: f - function(x) a + b*x ##f ##function(x) a + b*x the 'a' and 'b' objects do not get

Re: [R] generate simple function with pre-defined constants

2013-06-06 Thread Liviu Andronic
other attached packages: [1] arrayhelpers_0.76-20120816 abind_1.4-0 [3] plyr_1.8 stringr_0.6.2 [5] reshape2_1.2.2 loaded via a namespace (and not attached): [1] tools_3.0.0 - Original Message - From: Liviu Andronic landronim...@gmail.com To: r-help@r-project.org Help

Re: [R] More discussion on R usage statistics

2013-05-30 Thread Liviu Andronic
On Thu, May 30, 2013 at 2:40 PM, Johnny Zhang johnny...@yahoo.com wrote: I'd be very happy to change its name and welcome any input on another name. Zhiyong collect_rstats or RCollectStats or a variation thereof would do just fine. My 2 cents, Liviu

[R] configure ddply() to avoid reordering of '.variables'

2013-05-27 Thread Liviu Andronic
Hello, I'm using ddply() in plyr and I notice that it has the habit of re-ordering the levels of the '.variables' by which the splitting is done. I'm concerned about correctly retrieving the original ordering. Consider: require(plyr) x - iris[ order(iris$Species, decreasing=T), ] head(x) #

[R] strange behaviour with loops and lists

2013-05-19 Thread Liviu Andronic
Dear all, I encountered this strange behaviour with loops and lists. Consider this: xl - list() for(i in 5:7){##loop over numeric vector xl[[i]] - rnorm(i) } xl [[1]] NULL [[2]] [1] -0.4448192 -1.3395014 [[3]] [1] 1.3214195 -1.2968560 -0.6327795 The above lists contained a NULL element

Re: [R] strange behaviour with loops and lists

2013-05-19 Thread Liviu Andronic
On Sun, May 19, 2013 at 7:02 PM, peter dalgaard pda...@gmail.com wrote: (The first example really had 2:3, not 5:7, right?) Indeed. I simplified the example mid-email. The essential bit is that to assign to the 2nd element of a list, it needs to have at least two elements: Thanks for the

[R] recommended workflow for creating functions (was: Re: [Rd] Patch proposal for R style consistency (concerning deparse.c))

2013-05-07 Thread Liviu Andronic
(moving to r-help) Dear all, I think Paul is raising a useful question here: What is the recommended workflow for creating a new function? R prides itself for letting users to create and use home-brewed functions: it's easy to maintain and re-use, doesn't clutter the global environment with

Re: [R] Tables package - remove NAs and NaN

2013-04-25 Thread Liviu Andronic
On Wed, Apr 24, 2013 at 9:23 PM, Santosh santosh2...@gmail.com wrote: Dear Rxperts, Sorry if I am posting a really really dumb request.. I am new to subversion and am trying to use subversion to download the tables package as suggested by Duncan. I installed subversion client(from collabnet)

Re: [R] identify object that causes Error in loadNamespace(name) : there is no package called ‘R.utils’

2013-04-25 Thread Liviu Andronic
Dear Duncan, On Wed, Apr 24, 2013 at 11:04 PM, Duncan Murdoch murdoch.dun...@gmail.com wrote: What I've done sometimes in debugging is to change that error to a warning in the getNamespace() function, and add some tracing code to the serialization code to print the names of objects as they

[R] tables: proper use of Hline() in tabular()

2013-04-25 Thread Liviu Andronic
Dear all, I am unable to understand how Hline() works in tabular(). I've read the vignette and the help page, and here this example compiles perfectly fine: latex( tabular( Species + Hline() + 1 ~ Heading()*mean*All(iris), data=iris) ) However, if I try it on my own data it fails.

[R] identify object that causes Error in loadNamespace(name) : there is no package called ‘R.utils’

2013-04-24 Thread Liviu Andronic
Dear all, I've bumped into the: Error in loadNamespace(name) : there is no package called ‘R.utils’ error. I've already read a bit on this ( http://www.cybaea.net/Blogs/Data/A-warning-on-the-R-save-format.html ) but I have a follow-up question. Given a workspace that automatically loads a package

Re: [R] identify object that causes Error in loadNamespace(name) : there is no package called ‘R.utils’

2013-04-24 Thread Liviu Andronic
Dear Duncan, On Wed, Apr 24, 2013 at 4:57 PM, Duncan Murdoch murdoch.dun...@gmail.com wrote: What I've done sometimes in debugging is to change that error to a warning in the getNamespace() function, and add some tracing code to the serialization code to print the names of objects as they are

Re: [R] identify object that causes Error in loadNamespace(name) : there is no package called ‘R.utils’

2013-04-24 Thread Liviu Andronic
Dear Duncan, On Wed, Apr 24, 2013 at 3:03 PM, Duncan Murdoch murdoch.dun...@gmail.com wrote: A better approach is to *never* save and load workspaces unless you know exactly what is in them. Always reply no to the question about saving your workspace (or set that as the default). If you

Re: [R] Tables package - remove NAs and NaN

2013-04-23 Thread Liviu Andronic
Dear David, I'm having the exact same issue as Santosh, and looking at the fix that you've provided it seems to me that results are slightly different. On Tue, Apr 23, 2013 at 4:40 AM, David Winsemius dwinsem...@comcast.net wrote: b c p a N mean sdmean sd A

Re: [R] tables package - error message of duplicate values

2013-04-23 Thread Liviu Andronic
Dear David, I'm once again facing the same issue as Santosh. On Sat, Apr 20, 2013 at 12:15 AM, David Winsemius dwinsem...@comcast.net wrote: On Apr 19, 2013, at 2:03 PM, Santosh wrote: Rounding was done to replicate the problem I faced in the original data set... I got an error every

Re: [R] Tables package - remove NAs and NaN

2013-04-23 Thread Liviu Andronic
On Tue, Apr 23, 2013 at 10:06 AM, David Winsemius dwinsem...@comcast.net wrote: On Apr 23, 2013, at 1:00 AM, David Winsemius wrote: On Apr 23, 2013, at 12:53 AM, Liviu Andronic wrote: Dear David, I'm having the exact same issue as Santosh, and looking at the fix that you've provided

Re: [R] Tables package - remove NAs and NaN

2013-04-23 Thread Liviu Andronic
Dear David, On Tue, Apr 23, 2013 at 10:00 AM, David Winsemius dwinsem...@comcast.net wrote: tabular( (`p a`=interaction(a,p, drop=TRUE, sep= )) ~ (N = 1) + (b + c)* (mean+sd),data=q) b c p a N mean sd mean sd 1 A 10 12.8 0.7888 52.1 8.020 3 A 10

Re: [R] Tables package - remove NAs and NaN

2013-04-23 Thread Liviu Andronic
Dear Duncan, Thank you for your explanations. On Tue, Apr 23, 2013 at 12:31 PM, Duncan Murdoch murdoch.dun...@gmail.com wrote: This isn't something that the package is designed to handle: if you say p*a, it wants all combinations of p and a. To your knowledge is there another 'complex tables'

Re: [R] Tables package - remove NAs and NaN

2013-04-23 Thread Liviu Andronic
Dear Duncan, On Tue, Apr 23, 2013 at 2:13 PM, Duncan Murdoch murdoch.dun...@gmail.com wrote: I've done this now, in version 0.7.54 on R-forge. To leave out the rows with N=0, you can select a subset of the table where N (the first column) is non-zero: tab -

Re: [R] avoid losing data.frame attributes on cbind()

2013-04-19 Thread Liviu Andronic
... # $ var2: num 4 3 3 3 4 4 3 3 3 3 ... # - attr(*, label)= chr Some df label A.K. - Original Message - From: arun smartpink...@yahoo.com To: Liviu Andronic landronim...@gmail.com Cc: R help r-help@r-project.org Sent: Tuesday, April 16, 2013 2:40 PM Subject: Re: [R

Re: [R] efficiently diff two data frames

2013-04-19 Thread Liviu Andronic
Dear Rui, Thanks for the pointer. On Tue, Apr 16, 2013 at 8:12 PM, Rui Barradas ruipbarra...@sapo.pt wrote: setdiffDF2 - function(A, B){ f - function(X, Y) !duplicated(rbind(Y, X))[nrow(Y) + 1:nrow(X)] ix1 - f(A, B) ix2 - f(B, A) ix1 ix2 } ix - setdiffDF2(Xe, Xf)

Re: [R] avoid losing data.frame attributes on cbind()

2013-04-19 Thread Liviu Andronic
A.K. - Original Message - From: Liviu Andronic landronim...@gmail.com To: arun smartpink...@yahoo.com Cc: R help r-help@r-project.org Sent: Friday, April 19, 2013 8:13 AM Subject: Re: [R] avoid losing data.frame attributes on cbind() Dear Arun, On Tue, Apr 16, 2013 at 10:45

[R] remove higher order interaction terms

2013-04-17 Thread Liviu Andronic
Dear all, Consider the model below: x - lm(mpg ~ cyl * disp * hp * drat, mtcars) summary(x) Call: lm(formula = mpg ~ cyl * disp * hp * drat, data = mtcars) Residuals: Min 1Q Median 3Q Max -3.5725 -0.6603 0.0108 1.1017 2.6956 Coefficients: Estimate

Re: [R] remove higher order interaction terms

2013-04-17 Thread Liviu Andronic
On Wed, Apr 17, 2013 at 2:33 PM, Marc Schwartz marc_schwa...@me.com wrote: If you only want up to say second order interactions: summary(lm(mpg ~ (cyl + disp + hp + drat) ^ 2, data = mtcars)) This is what I was looking for. Thank you so much. This is covered in ?formula Indeed. I tried to

[R] efficiently diff two data frames

2013-04-16 Thread Liviu Andronic
Dear all, What is the quickest and most efficient way to diff two data frames, so as to obtain a vector of indices (or logical) for rows/columns that differ in the two data frames? For example, Xe - head(mtcars) Xf - head(mtcars) Xf[2:4,3:5] - 55 all.equal(Xe, Xf) [1] Component 3: Mean

[R] avoid losing data.frame attributes on cbind()

2013-04-16 Thread Liviu Andronic
Dear all, How should I add several variables to a data frame without losing the attributes of the df? Consider the following: require(Hmisc) Xa - iris label(Xa, self=T) - Some df label str(Xa) 'data.frame': 150 obs. of 5 variables: $ Sepal.Length: num 5.1 4.9 4.7 4.6 5 5.4 4.6 5 4.4 4.9

[R] how to transform string to Camel Case?

2013-04-15 Thread Liviu Andronic
Dear all, Given the following vector: (z - c('R project', 'hello world', 'something Else')) [1] R project hello worldsomething Else I know how to obtain all capitals or all lower case letters: tolower(z) [1] r project hello worldsomething else toupper(z) [1] R PROJECT

Re: [R] how to transform string to Camel Case?

2013-04-15 Thread Liviu Andronic
Something Else NANA Any pointers how to work around that? Thanks, Liviu Henrik On Apr 14, 2013 11:51 PM, Liviu Andronic landronim...@gmail.com wrote: Dear all, Given the following vector: (z - c('R project', 'hello world', 'something Else')) [1] R project hello world

Re: [R] how to transform string to Camel Case?

2013-04-15 Thread Liviu Andronic
Something Else NANA Liviu Regards, Pascal On 04/15/2013 03:50 PM, Liviu Andronic wrote: Dear all, Given the following vector: (z - c('R project', 'hello world', 'something Else')) [1] R project hello worldsomething Else I know how to obtain all capitals or all lower case

Re: [R] how to transform string to Camel Case?

2013-04-15 Thread Liviu Andronic
On Mon, Apr 15, 2013 at 10:10 AM, Gergely Daróczi gerg...@snowl.net wrote: Dear Liviu, I have just updated tocamel to have a new argument, so the development version of the package would produce: tocamel(z, upper = TRUE, sep = ' ') [1] R Project Hello WorldSomething Else Thanks

Re: [R] how to transform string to Camel Case?

2013-04-15 Thread Liviu Andronic
On Mon, Apr 15, 2013 at 2:22 PM, Gergely Daróczi gerg...@snowl.net wrote: I have added an extra check in the function for NA values before applying `paste` at https://github.com/Rapporter/rapport/compare/34ca6a35fb...a04abc8b21 Alex might not like it :) Example: tocamel(z, upper = TRUE,

Re: [R] categorized complete list of R commands?

2013-04-08 Thread Liviu Andronic
On Thu, Apr 4, 2013 at 7:34 AM, ivo welch ivo.we...@anderson.ucla.edu wrote: I wonder whether there is a complete list of all R commands (incl the standard packages) somewhere, preferably each with its one-liner AND categorization(s). the one-liner can be generated from the documentation. Try

Re: [R] Export R generated tables and figures to MS Word

2013-03-13 Thread Liviu Andronic
On Wed, Mar 13, 2013 at 1:02 AM, Santosh santosh2...@gmail.com wrote: Dear Rxperts, I am aware of Sweave that generates reports into a pdf, but do know of any tools to generate to export to a MS Word document... Is there a way to use R to generate and export report/publication quality

[R] RExcel, ROOo and LibreOffice inquiry

2012-11-25 Thread Liviu Andronic
Dear all I'd like to give RExcel a decent spin, mainly to take advantage of Excel's data management facilities and automatic recalculations. However I cannot use this Windows-only solution on the platform of my choice, Linux. Alternatively I've been considering the cross-platform ROOo, the

Re: [R] RExcel, ROOo and LibreOffice inquiry

2012-11-25 Thread Liviu Andronic
On Sun, Nov 25, 2012 at 2:38 PM, John Kane jrkrid...@inbox.com wrote: Can you supply a link for ROOo ? I don't see it anywhere. Oh, sorry. I thought it was obvious: http://rcom.univie.ac.at/download.html#ROOo Also what do you mean OpenOffice is deprecated? Do you mean in terms of using it

Re: [R] Odp: Object Browser

2012-11-23 Thread Liviu Andronic
On Fri, Nov 23, 2012 at 6:44 AM, wampeh wam...@gmail.com wrote: How do I get gvarbrowser to display only data.frame named, say atab1 or atab2 or atab*? Also, how do I turn off the selection pull down box? Two remarks. If you hope to get an answer it would be a good idea to CC John Verzani,

Re: [R] latex \subfloat{} incompatible with sweave/knitr code

2012-08-31 Thread Liviu Andronic
On Thu, Aug 30, 2012 at 12:50 AM, Yihui Xie x...@yihui.name wrote: Do you know what environments are allowed inside \subfloat{}? The No, not really. From what I can tell, \subfloat{} is provided by the `subfig' package. Here's what their docs have to say about compatibility with verbatim and

Re: [R] latex \subfloat{} incompatible with sweave/knitr code

2012-08-30 Thread Liviu Andronic
, Yihui -- Yihui Xie xieyi...@gmail.com Phone: 515-294-2465 Web: http://yihui.name Department of Statistics, Iowa State University 2215 Snedecor Hall, Ames, IA On Wed, Aug 29, 2012 at 3:30 PM, Liviu Andronic landronim...@gmail.com wrote: Hey Yihui On Wed, Aug 29, 2012 at 6:17 PM, Yihui

Re: [R] don't print object attributes

2012-08-29 Thread Liviu Andronic
On Tue, Aug 28, 2012 at 9:05 PM, Duncan Murdoch murdoch.dun...@gmail.com wrote: On 28/08/2012 2:16 PM, Liviu Andronic wrote: I came up with a modified version of the above: print_noattr - function(x, keep.some=T, ...){ if(keep.some) xa - attributes(x)[c('names', 'row.names', 'class

[R] latex \subfloat{} incompatible with sweave/knitr code

2012-08-29 Thread Liviu Andronic
Dear all Are LaTeX \subfloat{} commands incompatible with Sweave code? I cannot get the following code to compile properly: \begin{table} \subfloat[asdfa]{= 2+2 @ } \caption{asdf} \end{table} If I replace the Sweave chunk with a random string or a table, the compilation works fine. Any ideas

Re: [R] latex \subfloat{} incompatible with sweave/knitr code

2012-08-29 Thread Liviu Andronic
On Wed, Aug 29, 2012 at 1:34 PM, Steve Lianoglou mailinglist.honey...@gmail.com wrote: This isn't exactly what you want, but I'm using kintr and building and saving my figures in the their own chunks then just inlining the path to the generated figure in the \subloat{..}. Things are working

[R] wind maps

2012-08-29 Thread Liviu Andronic
Dear all I was wondering what old hacks on this list were thinking about the shiny new wind map, which The Economist describes as breathtaking for its elegance and rich data presentation. [1] What do you think of it? And of authors' other graphs? Can something similar be done in R? Regards

Re: [R] latex \subfloat{} incompatible with sweave/knitr code

2012-08-29 Thread Liviu Andronic
Hey Yihui On Wed, Aug 29, 2012 at 6:17 PM, Yihui Xie x...@yihui.name wrote: Yes that is one possible solution, but the filename is hard-coded somehow. The key to this problem is a missing new line before =, which was addressed in https://github.com/downloads/yihui/knitr/knitr-subfloats.pdf

[R] don't print object attributes

2012-08-28 Thread Liviu Andronic
Dear all Suppose the object below: require(Hmisc) require(plyr) x - dlply(iris, .(Species), describe) How can I print the object without displaying the attributes? I inspected ?print and ?print.default with no luck. x $setosa x[, Sepal.Length] n missing uniqueMean .05 .10

Re: [R] don't print object attributes

2012-08-28 Thread Liviu Andronic
On Tue, Aug 28, 2012 at 7:34 PM, Duncan Murdoch murdoch.dun...@gmail.com wrote: Assign a class to the object, and write a print method for it. For example, this doesn't quite do what you want, but it's a start: print.noattributes - function(x, ...) { attributes(x) - NULL print(x) }

Re: [R] test if elements of a character vector contain letters

2012-08-08 Thread Liviu Andronic
On Tue, Aug 7, 2012 at 10:26 PM, Marc Schwartz marc_schwa...@me.com wrote: since there are alpha-numerics present, whereas the first option will: grepl([^[:alnum:]], ab%) [1] TRUE So, use the first option. And I should start reading more carefully. The above works fine for me. I ended up

Re: [R] test if elements of a character vector contain letters

2012-08-07 Thread Liviu Andronic
On Mon, Aug 6, 2012 at 7:35 PM, Marc Schwartz marc_schwa...@me.com wrote: is.letter - function(x) grepl([[:alpha:]], x) is.number - function(x) grepl([[:digit:]], x) Quick follow-up question. I'm always reluctant to create functions that would resemble the method of a function (here, is() ),

Re: [R] add leading zeros

2012-08-07 Thread Liviu Andronic
Hello On Fri, Jul 27, 2012 at 6:54 AM, R. Michael Weylandt michael.weyla...@gmail.com wrote: Much easier than you think: x - c(1L, 9000L) sprintf(%05i,x) For anyone interested, I came up with a small wrapper for the above: add.lead - function(x, width=max(nchar(x))){

Re: [R] issue with nzchar() ?

2012-08-07 Thread Liviu Andronic
On Mon, Aug 6, 2012 at 5:27 PM, R. Michael Weylandt michael.weyla...@gmail.com wrote: On Mon, Aug 6, 2012 at 9:53 AM, Liviu Andronic landronim...@gmail.com wrote: On Mon, Aug 6, 2012 at 4:48 PM, Liviu Andronic landronim...@gmail.com wrote: string, something that I find strange. At best NA

Re: [R] test if elements of a character vector contain letters

2012-08-07 Thread Liviu Andronic
On Mon, Aug 6, 2012 at 7:35 PM, Marc Schwartz marc_schwa...@me.com wrote: is.letter - function(x) grepl([[:alpha:]], x) is.number - function(x) grepl([[:digit:]], x) Another follow-up. To test for (non-)alphanumeric one would do the following: x - c(letters, 1:26, '+', '-', '%^') x[1:10] -

Re: [R] test if elements of a character vector contain letters

2012-08-07 Thread Liviu Andronic
On Tue, Aug 7, 2012 at 10:18 PM, Marc Schwartz marc_schwa...@me.com wrote: That will get you values where punctuation characters are used, but there may be other non-alphanumeric characters in the vector. There may be ASCII control codes, tabs, newlines, CR, LF, spaces, etc. which would not

Re: [R] add leading zeros

2012-08-07 Thread Liviu Andronic
On Tue, Aug 7, 2012 at 10:48 PM, David Winsemius dwinsem...@comcast.net wrote: On Aug 7, 2012, at 3:55 AM, Liviu Andronic wrote: For anyone interested, I came up with a small wrapper for the above: add.lead - function(x, width=max(nchar(x))){ sprintf(paste('%0', width, 'i', sep=''), x

[R] issue with nzchar() ?

2012-08-06 Thread Liviu Andronic
Dear all I'm a bit surprised by the results output from nzchar(). The help page says: nzchar is a fast way to find out if elements of a character vector are *non-empty strings*. (my emphasis. However, if you do x - c(letters, NA, '') nzchar(x) [1] TRUE TRUE TRUE TRUE TRUE TRUE TRUE TRUE

Re: [R] issue with nzchar() ?

2012-08-06 Thread Liviu Andronic
On Mon, Aug 6, 2012 at 4:48 PM, Liviu Andronic landronim...@gmail.com wrote: string, something that I find strange. At best NA is the equivalent of an empty string. In this sense, if you Hmisc::describe() the vector you get, as I would expect, that in the context of character vectors NA

[R] test if elements of a character vector contain letters

2012-08-06 Thread Liviu Andronic
Dear all I'm pretty sure that I'm approaching the problem in a wrong way. Suppose the following character vector: (x[1:10] - paste(x[1:10], sample(1:10, 10), sep='')) [1] a10 b7 c2 d3 e6 f1 g5 h8 i9 j4 x [1] a10 b7 c2 d3 e6 f1 g5 h8 i9 j4 k l m n [15] o p q r s t

Re: [R] test if elements of a character vector contain letters

2012-08-06 Thread Liviu Andronic
TRUE TRUE TRUE TRUE TRUE TRUE TRUE TRUE TRUE TRUE [52] TRUE I need to have TRUE when an element contains a letter, and FALSE when an element contains only numbers. The above returns TRUE for the entire vector. Regards Liviu On Mon, Aug 6, 2012 at 9:25 AM, Liviu Andronic landronim...@gmail.com

Re: [R] test if elements of a character vector contain letters

2012-08-06 Thread Liviu Andronic
On Mon, Aug 6, 2012 at 7:35 PM, Marc Schwartz marc_schwa...@me.com wrote: is.letter - function(x) grepl([[:alpha:]], x) is.number - function(x) grepl([[:digit:]], x) This does exactly what I wanted: x [1] a10 b8 c9 d2 e3 f4 g1 h7 i6 j5 k l m n [15] o p q r s t u v

Re: [R] replace values in vector from a replacement table

2012-07-31 Thread Liviu Andronic
On Mon, Jul 30, 2012 at 6:00 PM, jim holtman jholt...@gmail.com wrote: try this: (x - rep(letters,2)) [1] a b c d e f g h i j k l m n o p q r s t u v w [24] x y z a b c d e f g h i j k l m n o p q r s t [47] u v w x y z values - c(aa, a, b, NA, d, zz) repl - c(aa, A, B, NA, D, zz)

[R] replace values in vector from a replacement table

2012-07-30 Thread Liviu Andronic
Dear all I've got stuck when trying to replace values in a vector by selecting replacements from a replacement table. I'm trying to use only base functions. Here's a dummy example: (x - rep(letters,2)) [1] a b c d e f g h i j k l m n o p q r s t u v [23] w x y z a b c d e f g h i j k l m n o p q

Re: [R] replace values in vector from a replacement table

2012-07-30 Thread Liviu Andronic
On Mon, Jul 30, 2012 at 6:00 PM, jim holtman jholt...@gmail.com wrote: try this: indx - match(x, repl.tab[, 1], nomatch = 0) x[indx != 0] - repl.tab[indx, 2] x [1] A B c D e f g h i j k l m n o p q r s t u v w [24] x y z A B c D e f g h i j k l m n o p q r s t [47] u v w x y z This is

Re: [R] OT: Where's the new Tukey?

2012-07-18 Thread Liviu Andronic
On Wed, Jul 18, 2012 at 12:30 AM, Kjetil Halvorsen kjetilbrinchmannhalvor...@gmail.com wrote: Venables Ripley: Modern Applied Statistics with S (fourth Edition) [..] On Sat, Jul 14, 2012 at 4:01 PM, Larry White ljw1...@gmail.com wrote: I'm looking for a single book that provides a deep, yet

Re: [R] HLOOKUP in R

2012-07-15 Thread Liviu Andronic
On Fri, Jul 13, 2012 at 9:25 PM, Silje Nord silje.nordg...@gmail.com wrote: Is there a function similar to excel's hlookup in R ? Try match(). I think it provides hlookup() functionality. Liviu __ R-help@r-project.org mailing list

Re: [R] fill 0-row data.frame with 1 line of NAs

2012-07-11 Thread Liviu Andronic
On Tue, Jul 10, 2012 at 4:53 PM, Peter Ehlers ehl...@ucalgary.ca wrote: Both this and Liviu's original solution destroy the factor nature of 'Species' (which may not matter, of course). How about (.xb - iris[ iris$Species=='zz', ]) .xb - .xb[1, ] # this probably shouldn't work, but it

Re: [R] fill 0-row data.frame with 1 line of NAs

2012-07-11 Thread Liviu Andronic
On Wed, Jul 11, 2012 at 9:56 PM, William Dunlap wdun...@tibco.com wrote: Why does one want to replace a zero-row data.frame with a one-row data.frame of NA's? Unless this is for an external program that cannot handle zero-row inputs, this suggests that there is an unnecessary limitation

[R] fill 0-row data.frame with 1 line of NAs

2012-07-10 Thread Liviu Andronic
Dear all Is there a simpler method to achieve the following: When I obtain an empty data.frame after subsetting, I need for it to contain one line of NAs. Here's a dummy example: (.xb - iris[ iris$Species=='zz', ]) [1] Sepal.Length Sepal.Width Petal.Length Petal.Width Species 0 rows (or

[R] convert 'character' vector containing mixed formats to 'Date'

2012-06-21 Thread Liviu Andronic
Dear all I have a 'character' vector containing mixed formats (thanks Excel!) and I'd like to translate it into a default %Y-%m-%d Date vector. x - c(1/3/2005, 13/04/2004, 2/5/2005, 2/5/2005, 7/5/2007, 22/04/2004, 21/04/2005, 20080430, 13/05/2003, 20080529, NA, NA, 19/05/1999,

Re: [R] convert 'character' vector containing mixed formats to 'Date'

2012-06-21 Thread Liviu Andronic
On Thu, Jun 21, 2012 at 2:48 PM, Liviu Andronic landronim...@gmail.com wrote: The culprit is likely that the 'x' vector is 'character' throughout, but I'm not sure how to work around. For example, I couldn't figure how to create an empty 'Date' vector. Regards I think I managed to crack

Re: [R] QQplot normally distributed

2012-06-20 Thread Liviu Andronic
Dear Özgür On Wed, Jun 20, 2012 at 7:37 AM, Özgür Asar oa...@metu.edu.tr wrote: Why do you prefer robust methods in the example of Noor and why you need exact normality here? The idea is that when you do hypothesis testing to check whether a given distribution is normal, the results are

Re: [R] QQplot normally distributed

2012-06-19 Thread Liviu Andronic
On Tue, Jun 19, 2012 at 12:42 PM, Özgür Asar oa...@metu.edu.tr wrote: Following a straight line indicates less evidence towards non-normality. But QQ-Plot is an exploratory tool. You can confirm your ideas obtained from the QQ-Plot via noramlity tests such as Shapiro-Wilk test. Hmm, some

Re: [R] R quantreg - symmetry test - bootstrap SE

2012-05-29 Thread Liviu Andronic
On Tue, May 29, 2012 at 8:30 AM, stefan23 stefan.vo...@uni-konstanz.de wrote: He folks, I want to use quantile regression for doing a test of symmetrie of a distribution. Following Buchinsky I want to test, whether the square of \tau = \beta(p)+\beta(1-p)-2*\beta(0.5) (\beta(\tau) is the

Re: [R] “For” calculation is so slow

2012-05-22 Thread Liviu Andronic
On Tue, May 22, 2012 at 9:01 AM, jiangxijixzy jiangxiji...@163.com wrote: The function I wrote can run well with the small data, but with the large data, the function runs very very slowly. How can I correct it? Thank you very much. My function as below: I guess this is a classic loops vs

Re: [R] What's wrong with MEAN?

2012-05-22 Thread Liviu Andronic
On Tue, May 22, 2012 at 11:22 AM, Vincy Pyne vincy_p...@yahoo.ca wrote: Thanks a lot for pointing out such a silly mistake from my side. I was simply wondering how come I am not getting such a simple mean. To avoid such mistakes it would help to first store your data in a vector. x-c(16,18)

Re: [R] sweave tables as images?

2012-05-22 Thread Liviu Andronic
On Mon, May 21, 2012 at 10:29 PM, Alexander Shenkin ashen...@ufl.edu wrote: So, I think it will be better if I can somehow generate the tables as images.  Is there any way to generate tables as images in separate files in Sweave?  Or, is there another tree up which I should be barking? Hmm,

Re: [R] sweave tables as images?

2012-05-22 Thread Liviu Andronic
On Tue, May 22, 2012 at 3:24 PM, Alexander Shenkin ashen...@ufl.edu wrote: If I understand it correctly, odfWeave doesn't have a path backwards from the odf doc back to the original odfWeave doc (which is the main restriction of all these Sweave/knitr/etc solutions in my use case). Please

Re: [R] getting a Likert plot from a data frame

2012-05-22 Thread Liviu Andronic
Dear Richard On Tue, May 22, 2012 at 3:20 PM, Richard M. Heiberger r...@temple.edu wrote: mydata - data.frame(    row.names=c(group1, group2, group3, group4, group5),    males=c(20,30,45,12,5),    females=c(35,23,32,8,5)) ## make a pyramid Likert chart as.pyramidLikert(likert(mydata),

Re: [R] getting a Likert plot from a data frame

2012-05-22 Thread Liviu Andronic
, May 22, 2012 at 9:44 AM, Liviu Andronic landronim...@gmail.com wrote: Dear Richard On Tue, May 22, 2012 at 3:20 PM, Richard M. Heiberger r...@temple.edu wrote: mydata - data.frame(    row.names=c(group1, group2, group3, group4, group5),    males=c(20,30,45,12,5),    females=c

Re: [R] Menus - best practices?

2012-05-19 Thread Liviu Andronic
On Sat, May 19, 2012 at 9:31 AM, peter dalgaard pda...@gmail.com wrote: Best practice is a bit contentious, but several people have found that the tcltk package offers a path of low resistance. Additionally check gWidgets. Liviu __

Re: [R] Taking a lead in panel data

2012-05-08 Thread Liviu Andronic
On Tue, May 8, 2012 at 12:14 PM, Apoorva Gupta apoorva.ni...@gmail.com wrote: I have checked that. It allows me to get the t-1, t-2 value but not the t+1 value. Is there any other way of achieving this other than using the plm package? It would be easier to help if you provided a minimal

Re: [R] Taking a lead in panel data

2012-05-07 Thread Liviu Andronic
On Mon, May 7, 2012 at 3:21 PM, Apoorva Gupta apoorva.ni...@gmail.com wrote: Dear R users, I am working with panel data and I want the difference of a variable with its t+1 value. Could you tell me if such a function exists in the plm package? Perhaps diff() or lag(). See the plm vignette.

[R] alarm() doesn't beep

2012-05-05 Thread Liviu Andronic
Dear all I'd like to make a beeping sound in R, but alarm() doesn't beep? I checked ?alarm but I couldn't find any pointers to system configuration. Any ideas? Regards Liviu sessionInfo() R version 2.14.2 (2012-02-29) Platform: x86_64-pc-linux-gnu (64-bit) locale: [1] LC_CTYPE=en_US.UTF-8

Re: [R] alarm() doesn't beep

2012-05-05 Thread Liviu Andronic
On Sat, May 5, 2012 at 8:34 PM, David Winsemius dwinsem...@comcast.net wrote: Is there a command you could call with system()? Yes. Something like: system(play /tmp/02Canon.mp3) works jsut fine. But I was curious about alarm(). Liviu __

Re: [R] recommended way to group function calls in Sweave

2012-04-26 Thread Liviu Andronic
Dear Rainer On Wed, Apr 25, 2012 at 5:34 PM, Rainer Schuermann rainer.schuerm...@gmx.net wrote: chunk_name_1,eval=FALSE,echo=FALSE= I like the 'eval=FALSE' trick. SweaveInput( setup.Rnw ) and from here, I can suse the named chunks almost like function calls, as you you describe below.

  1   2   3   4   5   6   >