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

2016-03-28 Thread Liviu Andronic
gt; > 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 Dunlap cannot provide patches for R --- for >> go

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

2016-03-23 Thread Liviu Andronic
I get this: > 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 > >

[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 NAs,

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 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 addition to Yihui'

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 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
(360) 407-7534 > Olympia, WA 98504-7600 > > USPS: PO Box 47600, Olympia, 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 addres

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
x27;m not an SE evangelist, and only truly discovered it about a month ago or so (even though it seems that I had registered more than a year ago), and initially I was quite very skeptical of this "fancy forum". But when I actually realized how _efficient_ this Q&A interface is, I qui

[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 wrote: >> I'm not aware of a discussion on this, but I would say no. >> Fragmentation is bad. Furt

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

2013-11-26 Thread Liviu Andronic
ader=TRUE, stringsAsFactors=FALSE); > close(z) > > zzz <- melt(zz,id.var=c("education","gender","sexe")) > <- zzz[rep(1:nrow(zzz), zzz$value), 1:4 ] > $agree <- $variable == 'agree' > > > > -tgs > > &

[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 > head(women

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 wrote: > Hello, All: > > > Would anyone recommend R for an introductory statistics class fo

[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: http://www.economist.com/news

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 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 ones that the C isaln

[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 kn

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 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 tried apply(m, 1, "

[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] generate simple function with pre-defined constants

2013-06-09 Thread Liviu Andronic
-Original Message- >> From: r-help-boun...@r-project.org [mailto:r-help-boun...@r-project.org] On >> Behalf >> Of Liviu Andronic >> Sent: Thursday, June 06, 2013 8:00 AM >> To: r-help@r-project.org Help >> Subject: Re: [R] generate simple function with

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

2013-06-06 Thread Liviu Andronic
TF-8 LC_IDENTIFICATION=C > > attached base packages: > [1] stats graphics grDevices utils datasets methods base > > 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 > >

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 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 +

[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] More discussion on R usage statistics

2013-05-30 Thread Liviu Andronic
On Thu, May 30, 2013 at 2:40 PM, Johnny Zhang 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 > > > From: Michael Weyl

[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) #Sep

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 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 explanations.

[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

[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 inter

[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.

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 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 loaded. >> (This

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

2013-04-25 Thread Liviu Andronic
On Wed, Apr 24, 2013 at 9:23 PM, Santosh 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) and tried to > acce

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 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 accidentally end up > w

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 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 loaded. (This > goes

[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 packag

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 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 <- tabular(((p=factor(p))*(a=factor(a))+1) ~ (N = 1) +

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 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' package that could ac

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 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 14.6 3.7771 56.5

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 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 lo

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 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 time I tried to u

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 wrote: >> b c >> p a N mean sdmean sd >> A 1 10 16.30 2.49

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

2013-04-19 Thread Liviu Andronic
3.9 3.4 3.4 2.9 3.1 ... > # $ : num 1.4 1.4 1.3 1.5 1.4 1.7 1.4 1.5 1.4 1.5 ... > # $ : num 0.2 0.2 0.2 0.2 0.2 0.4 0.3 0.2 0.2 0.1 ... > # $ : Factor w/ 3 levels "setosa","versicolor",..: 1 1 1 1 1 1 1 1 1 1 ... > # $ : num 5 5 5 5 5 5 5 5 4 5 ... > # $ : num

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 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) > Xe[i

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

2013-04-19 Thread Liviu Andronic
r",..: 1 1 1 1 1 1 1 > 1 1 1 ... > # $ var1: num 5 5 5 5 5 5 5 5 4 5 ... > # $ var2: num 4 3 3 3 4 4 3 3 3 3 ... > # - attr(*, "label")= chr "Some df label" > A.K. > > > > - Original Message - > From: arun > To: Liviu

Re: [R] remove higher order interaction terms

2013-04-17 Thread Liviu Andronic
On Wed, Apr 17, 2013 at 2:33 PM, Marc Schwartz 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 parse ?formula

[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 S

[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.

[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

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 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, sep = ' ')

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 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 World""Something Else" > Thanks fo

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

2013-04-15 Thread Liviu Andronic
words(z) [1] "R Project" "Hello World""Something Else" "NANA" Liviu > Regards, > Pascal > > > On 04/15/2013 03:50 PM, Liviu Andronic wrote: >> >> Dear all, >> Given the following vector: >>> >>> (z

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

2013-04-15 Thread Liviu Andronic
alize(z) [1] "R project" "Hello world""Something Else" "NANA" Any pointers how to work around that? Thanks, Liviu > Henrik > > On Apr 14, 2013 11:51 PM, "Liviu Andronic" wrote: >> >> Dear all, >> Given the following

[R] how to transform string to "Camel Case"?

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

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 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 the 'sos' package. Not

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 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 > tables and figures an

Re: [R] RExcel, ROOo and LibreOffice inquiry

2012-11-25 Thread Liviu Andronic
On Sun, Nov 25, 2012 at 2:38 PM, John Kane 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 with ROOo? O

[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 OpenOff

Re: [R] Odp: Object Browser

2012-11-23 Thread Liviu Andronic
On Fri, Nov 23, 2012 at 6:44 AM, wampeh 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, maintain

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 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 fancyvrb packages

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

2012-08-30 Thread Liviu Andronic
; Regards, > Yihui > -- > Yihui Xie > 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 > wrote: >> Hey Yihui >> >> >>

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 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 > Thanks

[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 L

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 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 > fine, eg. my default settin

[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 ide

Re: [R] don't print object attributes

2012-08-29 Thread Liviu Andronic
On Tue, Aug 28, 2012 at 9:05 PM, Duncan Murdoch 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', 

Re: [R] don't print object attributes

2012-08-28 Thread Liviu Andronic
On Tue, Aug 28, 2012 at 7:34 PM, Duncan Murdoch 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) > } > > class(x) <-

[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

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 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 defining

Re: [R] add leading zeros

2012-08-07 Thread Liviu Andronic
On Tue, Aug 7, 2012 at 10:48 PM, David Winsemius 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

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 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 be found > by usin

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 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] <- paste(x[

Re: [R] issue with nzchar() ?

2012-08-07 Thread Liviu Andronic
On Mon, Aug 6, 2012 at 5:27 PM, R. Michael Weylandt wrote: > On Mon, Aug 6, 2012 at 9:53 AM, Liviu Andronic wrote: >> On Mon, Aug 6, 2012 at 4:48 PM, Liviu Andronic >> wrote: >>> string, something that I find strange. At best NA is the equivalent of >>> an empt

Re: [R] add leading zeros

2012-08-07 Thread Liviu Andronic
Hello On Fri, Jul 27, 2012 at 6:54 AM, R. Michael Weylandt 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))){ sprintf(paste('%0', width, 'i', sep

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 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() ), but would in

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 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"

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

2012-08-06 Thread Liviu Andronic
"21" "22" "23" "24" "25" "26" > nzchar(x) & !is.na(x) [1] TRUE TRUE TRUE TRUE TRUE TRUE TRUE TRUE TRUE TRUE TRUE TRUE TRUE TRUE TRUE TRUE TRUE [18] TRUE TRUE TRUE TRUE TRUE TRUE TRUE TRUE TRUE TRUE TRUE TRUE TRUE TRUE TRUE TRUE TR

[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" "j

Re: [R] issue with nzchar() ?

2012-08-06 Thread Liviu Andronic
On Mon, Aug 6, 2012 at 4:48 PM, Liviu Andronic 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 and &

[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

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 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

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 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"

[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" [

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 wrote: > Venables & Ripley: > "Modern Applied Statistics with S (fourth Edition)" > [..] > > On Sat, Jul 14, 2012 at 4:01 PM, Larry White wrote: >> I'm looking for a single book that provides a deep, yet readable >> introduction to applied data a

Re: [R] HLOOKUP in R

2012-07-15 Thread Liviu Andronic
On Fri, Jul 13, 2012 at 9:25 PM, Silje Nord 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 https://stat.ethz.ch/mailman/listinfo/r-he

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 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 (i.e., > a bug) in

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 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 does. > T

[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 0-le

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 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 >

[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,

Re: [R] QQplot normally distributed

2012-06-19 Thread Liviu Andronic
Dear Özgür On Wed, Jun 20, 2012 at 7:37 AM, Özgür Asar 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 rarely informative:

Re: [R] QQplot normally distributed

2012-06-19 Thread Liviu Andronic
On Tue, Jun 19, 2012 at 12:42 PM, Özgür Asar 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 gurus on this

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

2012-05-29 Thread Liviu Andronic
On Tue, May 29, 2012 at 8:30 AM, stefan23 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 estimated slope > parameter fo

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

2012-05-22 Thread Liviu Andronic
> > On Tue, May 22, 2012 at 9:44 AM, Liviu Andronic > wrote: >> >> Dear Richard >> >> >> On Tue, May 22, 2012 at 3:20 PM, Richard M. Heiberger >> wrote: >> > mydata <- data.frame( >> >    row.names=c("group1", "gro

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 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), pan

Re: [R] sweave tables as images?

2012-05-22 Thread Liviu Andronic
On Tue, May 22, 2012 at 3:24 PM, Alexander Shenkin 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 correct me if I'm

Re: [R] sweave tables as images?

2012-05-22 Thread Liviu Andronic
On Mon, May 21, 2012 at 10:29 PM, Alexander Shenkin 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, there are Sweav

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

2012-05-22 Thread Liviu Andronic
On Tue, May 22, 2012 at 11:22 AM, Vincy Pyne 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) > mean(x) [1] 1

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

2012-05-22 Thread Liviu Andronic
On Tue, May 22, 2012 at 9:01 AM, jiangxijixzy 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 vectorization problem

Re: [R] Menus - best practices?

2012-05-19 Thread Liviu Andronic
On Sat, May 19, 2012 at 9:31 AM, peter dalgaard 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 __ R-help@r-project.org mailing

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 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 reproducible example, as

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 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. Liviu _

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

2012-05-05 Thread Liviu Andronic
On Sat, May 5, 2012 at 8:34 PM, David Winsemius 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 __ R-help@r-project.org mailing li

[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] 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 wrote: > <>= > 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. The advantage (for me) is that I have only one place

  1   2   3   4   5   6   >