Re: [R] Forward stepwise regression using lmStepAIC in Caret

2012-03-05 Thread Allan Engelhardt
Not sure I really like stepwise variable selection, but the function should work, of course. Compare data(BostonHousing, package = "mlbench") lmFit <- train(medv ~ ., data = BostonHousing, "lmStepAIC", scope = list(lower = ~., upper = ~.^2), direction = "forward") with lmFit <- train(medv ~

Re: [R] Does replacing some values of a zoo object by NA reduce it's size ?

2011-09-27 Thread Allan Engelhardt
It is not an anomaly. The object is the same size (object.size(f1)==object.size(f2)); its file representation is different. On 27/09/2011 07:00, Ashim Kapoor wrote: Dear R-helpers, Please have a look at the following. f1 is the same as f2 except that it has some values replaced by NA. But it'

Re: [R] How to terminate R program if found any execution error

2011-09-27 Thread Allan Engelhardt
The original poster may also be interested in options("error") to capture the 'any execution error' requirement. From the examples in help("options"): ## Not run: ## on error, terminate the R session with error status 66 options(error = quote(q("no", status=66, runLast=FALSE))) stop("test it")

Re: [R] Disabling Auto-complete

2011-09-26 Thread Allan Engelhardt (CYBAEA)
The $ operator does partial matching by default so for example > print(b$u) [1] 1 The [[ operator does not > print(b[["unit"]]) NULL > print(b[["unit1"]]) [1] 1 See help("$") for more details and also the warnPartialMatch* arguments in help("options"). Try testfunction <- function(x) if (e

Re: [R] Ignoring loadNamespace errors when loading a file

2011-08-22 Thread Allan Engelhardt
On 22/08/11 12:26, Martin Morgan wrote: On 08/21/2011 11:52 PM, Allan Engelhardt wrote: [...] Obligatory reproducible example: On the Unix machine do library("multicore") a <- list(data = 1:10, fun = mclapply) save(a, file = "a.RData") and then try to load the "a

[R] Ignoring loadNamespace errors when loading a file

2011-08-21 Thread Allan Engelhardt
On a Unix machine I ran caret::rfe using the multicore package, and I saved the resulting object using save(lm2, file = "lm2.RData"). [Reproducible example below.] When I try to load("lm2.RData") on my Windows laptop, I get Error in loadNamespace(name) : there is no package called 'multicore'

Re: [R] reflecting a PCA biplot

2011-08-09 Thread Allan Engelhardt (CYBAEA)
Something like opar<- par(mfcol = c(1, 2)) z<- prcomp(USArrests, scale = TRUE) biplot(z, cex = 0.5) z$x[,1]<- -z$x[,1] z$rotation[,1]<- -z$rotation[,1] biplot(z, cex = 0.5, xlab = "-PC1") par(opar) perhaps? Allan On 09/08/11 13:57, Andrew Halford wrote: Hi Listers, I am trying to reflect a

Re: [R] cdplot error

2011-08-02 Thread Allan Engelhardt (CYBAEA)
On 03/08/11 05:52, wildernessness wrote: Fairly new at this. Trying to create a conditional density plot. cdplot(status~harvd.l,data=phy) Error in cdplot.formula(status~harvd.l,data=phy): dependent variable should be a factor What does this error mean? Status is a binary response of infestat

Re: [R] How to remove the double or single quote from a string (unquote?)?

2011-04-18 Thread Allan Engelhardt
This should be a FAQ: you are confusing the value with its printed representation. Try print(paste("V", 3:8, sep=""), quote=FALSE) to see that there are no quotes, and you may want to read up on help("as.formula", package="stats") which has the examples you are searching for. Allan On 18/

Re: [R] From nested loop to mclapply

2011-04-18 Thread Allan Engelhardt
Try help("expand.grid", package="base") for one way to create the combinations of (i,j) outside the loop, or perhaps vignette("nested", package="foreach") which does it "automatically" (rather: naturally). Allan On 18/04/11 16:53, Alaios wrote: Dear all, I am trying to find a decent way to sp

Re: [R] Deleting the last value of a vector

2011-04-18 Thread Allan Engelhardt
This is unlikely to be the kind of operation where speed is essential, but nevertheless on my build of 2.14.0 (with byte compiled base packages): stopifnot(getRversion()>= "2.14") library("compiler") f1<- function (x, n) head(x, length(x) - n)# suggested by baptiste auguie f2<- function (x, n)

Re: [R] R licence

2011-04-07 Thread Allan Engelhardt
The licences are available on the web site and you really should have yor lawyers look at them and give you professional advise. The GPL2+ is probably the relevant one for your purposes and essentially require you to provide the source for the parts of R that you distribute. However, the R lice

Re: [R] Popularity of R, SAS, SPSS, Stata, Statistica, S-PLUS updated

2011-03-25 Thread Allan Engelhardt
Not R, but just to get the data (format is month year,week,count) to compare with your students' output: perl -MLWP::UserAgent -e 'my $ua = LWP::UserAgent->new(); my $l = $ua->request(HTTP::Request->new(GET => qq{http://www.listserv.uga.edu/archives/sas-l.html}))->content(); while ( $l =~ m{h

Re: [R] Plotting graph problem!!

2011-03-19 Thread Allan Engelhardt
On 19/03/11 15:04, Allan Engelhardt wrote: You should probably tell us which part of a<- read.csv("http://r.789695.n4.nabble.com/file/n3389613/Life_Expectancies_2008.csv";) hist(a) Should be hist(a$Life.Expectancies.at.Birth), of course. Sorry. doesn't do what you expe

Re: [R] Plotting graph problem!!

2011-03-19 Thread Allan Engelhardt
You should probably tell us which part of a<- read.csv("http://r.789695.n4.nabble.com/file/n3389613/Life_Expectancies_2008.csv";) hist(a) doesn't do what you expect. (Though often when people say "histogram" they want something else - what's with that anyhow?) Allan On 19/03/11 13:10, and

Re: [R] cross-validation in rpart

2011-03-19 Thread Allan Engelhardt
I assume you mean rpart::xpred.rpart ? The beauty of R means that you can look at the source. For the simple case (where xval is a single number) the code does indeed do simple random sampling xgroups<- sample(rep(1:xval, length = nobs), nobs, replace = FALSE) If you want another sampling,

Re: [R] How do I delete multiple blank variables from a data frame?

2011-03-19 Thread Allan Engelhardt
On 19/03/11 01:35, Joshua Wiley wrote: Hi Rita, This is far from the most efficient or elegant way, but: ## two column data frame, one all NAs d<- data.frame(1:10, NA) ## use apply to create logical vector and subset d d[, apply(d, 2, function(x) !all(is.na(x)))] This works, but apply conve

Re: [R] Need help with error

2011-03-19 Thread Allan Engelhardt
As it says at the bottom of every post: PLEASE do read the posting guidehttp://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code. Without an example that fails, it is hard to help. Allan On 18/03/11 16:26, Savitri N Appana wrote: Hi R use

Re: [R] Regex query (Apache logs)

2011-03-17 Thread Allan Engelhardt
Some comments: 1. [^\s] matches everything up to a literal 's', unless perl=TRUE. 2. The (.*) is greedy, so you'll need (.*?)"\s"(.*?)"\s"(.*?)"$ or similar at the end of the expression With those changes (and removing a space inserted by the newsgroup posting) the expression works for me.

Re: [R] table() reading problem

2011-03-16 Thread Allan Engelhardt
On 16/03/11 09:20, fre wrote: I have the following problem: I have some string with numbers like k. I want to have a table like the function table() gives. However I am not able to call the first row, the 1, 2, 3, 5, 6 or 9. I tried to do that by a data.frame, but that doesn't seem The first

Re: [R] Singularity problem

2011-03-16 Thread Allan Engelhardt
Numeric underflow. Try qr.solve(a) Allan On 16/03/11 15:28, Feng Li wrote: Dear R, If I have remembered correctly, a square matrix is singular if and only if its determinant is zero. I am a bit confused by the following code error. Can someone give me a hint? a<- matrix(c(1e20,1e2,1e3,1e3),

Re: [R] Does R have a "const object"?

2011-03-16 Thread Allan Engelhardt
On 16/03/11 15:04, Gabor Grothendieck wrote: On Wed, Mar 16, 2011 at 10:54 AM, Allan Engelhardt wrote: [...] Yes, but you can still print(base::pi) and rm(pi) to get back to our flat world, and you can't assign("pi", 4, pos = "package:base") Error in assign(&qu

Re: [R] Does R have a "const object"?

2011-03-16 Thread Allan Engelhardt
On 16/03/11 13:04, Michael Friendly wrote: On 3/15/2011 2:23 PM, Uwe Ligges wrote: On 15.03.2011 15:53, xiagao1982 wrote: Hi, all, Does R have a "const object" concept like which is in C++ language? I want to set some data frames as constant to avoid being modified unintentionally. Thanks!

Re: [R] how do we read netcdf / hdf files in R?

2011-03-16 Thread Allan Engelhardt
(For hdf5 you might want to try the development version at http://xweb.geos.ed.ac.uk/~hcp/Rhdf5 which improves error handling, cf. this thread: https://stat.ethz.ch/pipermail/r-devel/2011-March/060111.html .) Allan On 16/03/11 08:53, Allan Engelhardt wrote: Try the ncdf, ncdf4, and hdf5

Re: [R] how do we read netcdf / hdf files in R?

2011-03-16 Thread Allan Engelhardt
Try the ncdf, ncdf4, and hdf5 packages from CRAN. (I have never used the hdf format, but the ncdf4? packages seem to work well.) Allan On 16/03/11 07:25, Yogesh Tiwari wrote: Dear R Users, How do we read netcdf / hdf format files in R ? Also, can we convert netcdf to hdf format in R? Great

Re: [R] Finding the name "vector"

2011-03-15 Thread Allan Engelhardt
On 15/03/11 05:17, Joshua Wiley wrote: Hi Laura, ?is.vector Consider methods::is if you might ever use attributes: x<- 1:10 is.vector(x) # [1] TRUE comment(x)<- "Mine!" is.vector(x) # [1] FALSE is(x, "vector") # [1] TRUE Allan __ R-help@r-projec

Re: [R] Serial Date

2011-03-15 Thread Allan Engelhardt
On 14/03/11 16:00, David Winsemius wrote: On Mar 14, 2011, at 6:36 AM, Allan Engelhardt wrote: On 14/03/11 02:00, Raoni Rosa Rodrigues wrote: [...] I'm working in a project with a software that register date and time data in serial time format. This format is used by excel, for exempl

Re: [R] install.packages barfs on dependencies= argument

2011-03-15 Thread Allan Engelhardt
Groan! Thanks. New baby mean no sleep. I'll make some more coffee. Allan On 15/03/11 08:18, Jim Lemon wrote: On 03/15/2011 06:57 PM, Allan Engelhardt wrote: I'm sure I used to be able to do ... unused argument(s) (dependecies = c("Depends", "Imports", &qu

[R] install.packages barfs on dependencies= argument

2011-03-15 Thread Allan Engelhardt
I'm sure I used to be able to do my.dependencies<- c("Depends", "Imports", "LinkingTo", "Suggests", "Enhances") install.packages("animation", lib = Sys.getenv("R_LIBS_USER"), dependecies = my.dependencies) but now I get Error in download.file(url, destfile, method, mode = "wb", ...) : unused

Re: [R] creating character vector

2011-03-14 Thread Allan Engelhardt
You could try scan(what=character(0), sep=",", file=textConnection("first,second,third")) but better to put the strings in a file (say, strings.txt), one per line, and read it using scan("strings.txt", what=character(0), sep="\n") Even better is to understand what you are really trying to

Re: [R] Serial Date

2011-03-14 Thread Allan Engelhardt
On 14/03/11 02:00, Raoni Rosa Rodrigues wrote: > Hello R Help, > > I'm working in a project with a software that register date and time data in > serial time format. This format is used by excel, for exemple. In this > format, 40597.3911423958 is 2011/2/23 09:23:15. Not on my system, but this

Re: [R] switch and factors

2011-03-14 Thread Allan Engelhardt
Maybe I am misunderstanding you, but I think it is documented? The help page says switch(EXPR, ...) [...] If the value of ‘EXPR’ is not a character string it is coerced to integer. [...] Since is.character( factor('x', levels=c('y', 'x')) ) [1] FALSE you get as.integer( factor('x', leve

Re: [R] positions and margins differ between X11 and SVG device

2011-03-08 Thread Allan Engelhardt
Looks the same on my machine, albeit using svg() instead of CairoSVG - what version are you using? One sometimes useful technique is to create the first graphics in a vector format (pdf, svg) and then use an editing program like Inkscape or Illustrator to do any touch-up before publication, as

Re: [R] transaction list transformation to use rpart.

2011-03-07 Thread Allan Engelhardt
On 06/03/11 22:34, John Dennison wrote: [...] from data like Customer-ID | Item-ID cust1 | 2 cust1 | 3 cust1 | 5 cust2 | 5 cust2 | 3 cust3 | 2 ... #read in data to a sparse binary transaction matrix txn = read.transactions(file="tranacti

Re: [R] Probabilities outside [0, 1] using Support Vector Machines (SVM) in e1071

2011-03-07 Thread Allan Engelhardt
predict.svm only returns probabilities for model types (Model$type) less than 2, which I guess are classification models (?). In any case, the probabilities are returned as an attribute which your result clearly lacks. Trivial example: model<- svm(Species ~ ., data = iris[-1,], probability

Re: [R] openNLP package error

2011-01-05 Thread Allan Engelhardt
Apologies that I am late on this thread. On 02/12/10 17:39, Sascha Wolfer wrote: I seem to have a problem with the openNLP package, I'm actually stuck in the very beginning. Here's what I did: > install.packages("openNLP") > install.packages("openNLPmodels.de", repos = "http://datacube.wu.ac.a

Re: [R] Questions about Probit Analysis

2010-11-17 Thread Allan Engelhardt
Sorry I am a bit late to this discussion, but I can't see if you ever got an answer. Anyhow, on your first question: On 31/10/10 19:14, Lorenzo Isella wrote: Dear All, I have some questions about probit regressions. I saw a nice introduction at http://bit.ly/bU9xL5 and I mainly have two ques

Re: [R] [semi-OT] Using fortune() in an email signature

2010-09-01 Thread Allan Engelhardt
On 01/09/10 22:18, Dirk Eddelbuettel wrote: [...] Doing the same with Rscript is left as an exercise I like exercises: Rscript --default-packages="fortunes" -e "print(fortune())" Allan __ R-help@r-project.org mailing list https://stat.ethz

Re: [R] any statement equals to 'goto'?

2010-08-31 Thread Allan Engelhardt
Sounds like you want help("tryCatch") # Catch the error and do something help("next") # Go to the next value of the surrounding loop Hope this helps a little. Allan On 31/08/10 19:34, karena wrote: I have the following code: ---

Re: [R] Remove "Loading required package" message

2010-08-31 Thread Allan Engelhardt
On 27/08/10 10:19, Barry Rowlingson wrote: On Fri, Aug 27, 2010 at 9:09 AM, Sébastien Moretti wrote: [...] require it quietly: require(sp,quietly=TRUE) Doesn't work for me: > require("Matrix", quietly=TRUE) Loading required package: lattice Attaching package: 'Matrix'

Re: [R] Finding pairs

2010-08-31 Thread Allan Engelhardt
Something like this may get you started library("igraph") df<- data.frame(A=0:7, B=c(rep(NA,3), 0, 1, 3, 7, 2)) # Assuming this is your data b<- as.matrix(df) print(b) # A B #[1,] 0 NA #[2,] 1 NA #[3,] 2 NA #[4,] 3 0 #[5,] 4 1 #[6,] 5 3 #[7,] 6 7 #[8,] 7 2 z<- graph.edgelist(na.omit(b))

Re: [R] Shifting of Principal amount while calculating Present Value

2010-08-28 Thread Allan Engelhardt
Matrix operations work "the other way" to what you expect on rows and columns. Try ## Your data: time <- c(1, 2, 3) # Please don't use `t' as a variable name cash_flow <- c(7, 7, 107) zero_rate <- data.frame(rating=factor(c("AAA","AA","A","B")), year1=c(3.60, 3.65, 3.72

[R] OT: Re: Fwd: R SOFTWARE

2010-08-27 Thread Allan Engelhardt
On 18/08/10 10:46, Nokuzola Simakuhle wrote: > NB: This email and its contents are subject to the Eskom Holdings Limited > EMAIL LEGAL NOTICE > > which can be viewed at http://www.eskom.co.za/email_legalnotice > > Since your email policy allows for no copying or distribution of your message,

Re: [R] Linear regression on several groups

2010-08-13 Thread Allan Engelhardt
Please read the posting guide and include a standalone example. Maybe you want something like the results from lm(weight ~ Time, data = ChickWeight, subset = Diet==1) lm(weight ~ Time, data = ChickWeight, subset = Diet==2) ## ... etc ... Then you could do (m <- lm(weight ~ Time*Diet, data = C

Re: [R] memory use without running gc()

2010-08-09 Thread Allan Engelhardt
How about asking the operating system, e.g. ### Method 1 ## Setup cmd <- paste("ps -o vsz", Sys.getpid()) ## In your logging routine z <- system(cmd, intern = TRUE) cat("Virtual size: ", z[2], "\n", sep = "") ### Method 2 ## Setup file <- paste("/proc", Sys.getpid(), "stat", sep = "/") what <- v

Re: [R] About R base

2010-08-09 Thread Allan Engelhardt
Yes, there are differences between R on Windows and R on Linux. You probably want this document: http://cran.r-project.org/bin/windows/base/rw-FAQ.html Hope this helps a little. Allan On 06/08/10 16:47, Stephen Liu wrote: Hi folks, I have R x64 2.11.1 installed on Win 7 64 bit which is runn

Re: [R] [OT] R on Atlas library

2010-08-09 Thread Allan Engelhardt
I don't know about the specific function (a simple, stand-alone reproducible example is always helpful, see the posting guide for details), but ATLAS certainly uses all my cores on a test like this: s <- 7500 # Adjust for your hardware a <- matrix(rnorm(s*s), ncol = s, nrow = s) b <- crosspro

Re: [R] REmove level with zero observations

2010-08-05 Thread Allan Engelhardt
On 03/08/10 21:50, GL wrote: If I have a column with 2 levels, but one level has no remaining observations. Can I remove the level? Like this? d <- data.frame(a = factor(rep("A", 3), levels = c("A", "B"))) levels(d$a) # [1] "A" "B" d$a <- d$a[,drop=TRUE] levels(d$a) # [1] "A" Hope this h

Re: [R] Using apply for logical conditions

2010-08-02 Thread Allan Engelhardt
`|` is a binary operator which is why the apply will not work. See help("Reduce") For example, set.seed(1) data <- data.frame(A = runif(10) > 0.5, B = runif(10) > 0.5, C = runif(10) > 0.5) Reduce(`|`, data) # [1] TRUE FALSE TRUE TRUE TRUE TRUE TRUE TRUE TRUE TRUE Hope this helps.

Re: [R] Is there paid support for R?

2010-08-02 Thread Allan Engelhardt
On 02/08/10 13:17, Chris Murphy wrote: Hi, I am trying to get R installed at work and I was asked if there were any companies that offered support. There are. What country are you looking to support? What do you mean by "support"? (It can be anything from installation through SLAs for

Re: [R] Function to return variable name

2010-07-29 Thread Allan Engelhardt
On 29/07/10 04:21, Jeremy Miles wrote: I'd like a function that returns the variable name. As in: MyData$Var1 Would return: Var1 Not quite sure what you mean, but does this get you started? nn <- function(x) deparse(substitute(x)) str( z <- nn(airquality$Month) ) # chr "airquality$Mon

Re: [R] Reading timestamp column from MySQL

2010-07-29 Thread Allan Engelhardt
On 29/07/10 00:20, harsh yadav wrote: Hi, I am reading a SQL (MySQL) table in R data frame. When I read in the table that has a timestamp data-type field, R gives it the following format:- 1.236887e+12 So when I want to manipulate a column with timestamp = 1236887146615 It returns me multi

Re: [R] Checking package licences including dependencies?

2010-07-27 Thread Allan Engelhardt
"EVER" "TSA" "akima" "degreenet" "difR" [7] "ergm" "ff""gam" "isa2" "latentnet" "locfit" [13] "mapproj" "rtiff" &

Re: [R] Checking package licences including dependencies?

2010-07-27 Thread Allan Engelhardt
On 27/07/10 13:20, Ben Bolker wrote: Allan Engelhardt cybaea.com> writes: I only recently discovered options("available_packages_filters" = list(add = TRUE, "license/FOSS")) [cf. help("available.packages", package="utils") in R 2.10.0

[R] Checking package licences including dependencies?

2010-07-27 Thread Allan Engelhardt
I only recently discovered options("available_packages_filters" = list(add = TRUE, "license/FOSS")) [cf. help("available.packages", package="utils") in R 2.10.0 or later] which goes nicely with my options("checkPackageLicense" = TRUE) [new in R 2.11]. But now I want to purge my library of pack

Re: [R] the real dimnames

2010-07-26 Thread Allan Engelhardt
On 26/07/10 19:01, Michael Lachmann wrote: Hi, R seems to have a feature that isn't used much, which I don't really now how to call. But, the dimnames function, can in addition to giving names to rows/columns/dim 3 rows/dim 4 rows... can also give labels to the dimensions themselves. Thus,

Re: [R] sparsity

2010-07-23 Thread Allan Engelhardt
The functions {summary,bandwidth}.rq() in the package quantreg looks promising, but it is not really my area... http://lmgtfy.com/?q=Hall-Sheater+sparsity+%22r-project%22 Hope this helps a little. Allan On 23/07/10 21:02, Nathalie Gimenes wrote: Hi All, I would like to estimate the "sparsit

Re: [R] How to deal with more than 6GB dataset using R?

2010-07-23 Thread Allan Engelhardt
On 23/07/10 17:36, Duncan Murdoch wrote: On 23/07/2010 12:10 PM, babyfoxlo...@sina.com wrote: [...] You probably won't get much faster than read.table with all of the colClasses specified. It will be a lot slower if you leave that at the default NA setting, because then R needs to figure ou

Re: [R] How to deal with more than 6GB dataset using R?

2010-07-23 Thread Allan Engelhardt
read.table is not very inefficient IF you specify the colClasses= parameter. scan (with the what= parameter) is probably a little more efficient. In either case, save the data using save() once you have it in the right structure and it will be much more efficient to read it next time. (In fa

Re: [R] converting a time to nearest half-hour

2010-07-23 Thread Allan Engelhardt
The arithmetic that David describes should work fine (POSIXct is internally in UTC) unless you are in the Chatham Islands (which has a UTC+12:45 time zone [1]) or Nepal (UTC+05:45 [2]) or some such place with a funny idea about when the 1/2 hour mark is. The formatting of the output may be tr

Re: [R] Regex in an IF statement?

2010-07-23 Thread Allan Engelhardt
help("difftime") is probably what you want. If not, please post a standalone example Allan On 23/07/10 15:18, Jim Hargreaves wrote: Dear List I have the POSIX timestamps of two events, A and B respectively. I want an expression that tests if A occurs within 4 weeks of B. Something like: i

Re: [R] start and end times to yes/no in certain intervall

2010-07-23 Thread Allan Engelhardt
I like loops for this kind of thing so here is one: df<- structure(list(start = c("15:00", "15:00", "15:00", "11:00", "14:00", "14:00", "15:00", "12:00", "12:00", "12:00", "12:00", "12:00", "12:00", "12:00", "12:00", "12:00", "12:00", "12:00", "12:00", "12:00"), end = c("16:00", "16:00", "16:00",

Re: [R] Sweave special characters problem

2010-07-22 Thread Allan Engelhardt
A standalone example is always helpful. The following works for me, so I am probably not understanding your problem: ---[BEGIN: umlaut.Rnw]--- \documentclass[a4paper]{article} \usepackage{ucs} \usepackage[utf8x]{inputenc} \begin{document} <>= x <- data.frame(Geschäftslage=1:10) summary(x) @ \

Re: [R] SQL/R

2010-07-22 Thread Allan Engelhardt
There are so many ways Here is one: aggregate(v ~ u, data=X, function(...) length(unique(...))) #u v # 1 T1 2 # 2 T2 1 Hope this helps Allan. On 22/07/10 12:52, Gildas Mazo wrote: Dear R users, I want to aggregate data in the following way: ### X<- data.frame(u = c("T1","T1","T1",

Re: [R] Drop firms in unbalanced panel if not more than 5 observations in consecutive years for all variables

2010-07-22 Thread Allan Engelhardt
One option: /## Your data:/ data <- structure(list(id = structure(c(1L, 2L, 2L, 3L, 3L, 3L, 3L, 4L, 4L, 4L, 4L, 4L), .Label = c("a", "b", "c", "d"), class = "factor"), year = c(2000L, 2000L, 2001L, 1999L, 2000L, 2001L, 2002L, 1998L, 1999L, 2000L, 2001L, 2002L), y = c(1L, NA, 3L, 1L,

Re: [R] please help me for this Error: cannot listen to TCP port 15259

2010-07-22 Thread Allan Engelhardt
The short-term work-around is probably to use the help_type= argument to help, e.g. help("help", help_type="text") Hope this helps a little. Allan On 22/07/10 07:30, Na.Ebrahimi wrote: hi, I get an Error when I try to run function "help" in R, it says "starting httpd help server ...Error:

Re: [R] Recommended way of requiring packages of a certain version?

2010-07-16 Thread Allan Engelhardt
On 16/07/10 09:32, Paul Hiemstra wrote: Hi Allan, When you create an R package you can specify in the DESCRIPTION file that your package depends on a certain R version and versions of packages. For example: [...] Depends: R (>= 2.7.0), methods, sp (>= 0.9-4), gstat (>= 0.9-58) Thanks Paul,

Re: [R] FW: coeficient of determination

2010-07-16 Thread Allan Engelhardt
Try RSiteSearch("coefficient of determination") which seems to list some promising candidates. Allan On 15/07/10 16:47, Alireza Ehsani wrote: Hello there how can i calculate coefficient of determination with R? Kind regards Ali Reza Ehsani Ph.d. student [[alternative HTML version

[R] Recommended way of requiring packages of a certain version?

2010-07-16 Thread Allan Engelhardt
What is the recommended way of requiring a certain version when loading a package (or, indeed, from R itself)? Perl has the require module version use module version require version use version constructs which is kind of what I am looking for (especially 'use' which is evaluated at compile t

Re: [R] qplot in ggplot2 not working any longer - (what did I do?)

2010-07-15 Thread Allan Engelhardt
The problem is that install.packages() and friends forks R and there is no way to specify general options to that process (you can do the configure.{args,vars} but nothing else). One work-around could be to download the package and install it with R --vanilla CMD INSTALL from the command line.

Re: [R] Convergent series

2010-07-15 Thread Allan Engelhardt
Not 100% if this is what you are looking for, but maybe Reduce("+", x) will do it? E.g. Reduce("+", 1/2^(1:10)) # [1] 0.9990234 Hope this helps. Allan On 14/07/10 11:57, David Bickel wrote: What are some reliable R functions that can compute the value of a convergent series? David ___

Re: [R] question regarding "varImpPlot" results vs. model$importance data on package "RandomForest"

2010-07-15 Thread Allan Engelhardt
Use the source, Luke. varImpPlot calls randomForest:::importance.randomForest (yeah, that is three colons) and reading about the scale= parameter in help("importance", package="randomForest") should enlighten you. For the impatient, try varImpPlot(mtcars.rf, scale=FALSE) Hope this helps a l

Re: [R] SARIMA model

2010-07-15 Thread Allan Engelhardt
Try RSiteSearch("SARIMA") Allan On 13/07/10 14:15, FMH wrote: Dear All, Could someone please advice me the appropriate package for fitting the SARIMA model? Thanks Fir __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/

Re: [R] [R-pkgs] New package "list" for analyzing list surveyexperiments

2010-07-14 Thread Allan Engelhardt
On 13/07/10 19:16, Erik Iverson wrote: Raubertas, Richard wrote: I agree that 'list' is a terrible package name, but only secondarily because it is a data type. The primary problem is that it is so generic as to be almost totally uninformative about what the package does. For some reason pack

Re: [R] taking daily means from hourly data

2010-07-14 Thread Allan Engelhardt
This is one way: df<- data.frame(Time=as.POSIXct("2009-01-01", format="%Y-%m-%d") + seq(0, 60*60*24*365-1, 60*60), lev.morgan=3+runif(24*365), lev.lock2=3+runif(24*365), flow=1000+rnorm(24*365, 200), direction=runif(24*365, 0

Re: [R] apply is slower than for loop?

2010-07-12 Thread Allan Engelhardt
On 12/07/10 08:16, Liviu Andronic wrote: > On Fri, Jul 9, 2010 at 9:11 PM, Gene Leynes wrote: > >> [...] > Check Rnews for an article discussing "proper" usage of apply and for. > Liviu > I am guessing you are referencing @article{Rnews:Ligges+Fox:2008

Re: [R] apply is slower than for loop?

2010-07-10 Thread Allan Engelhardt
On 09/07/10 21:19, Duncan Murdoch wrote: On 09/07/2010 4:11 PM, Gene Leynes wrote: I thought the "apply" functions are faster than for loops, but my most recent test shows that apply actually takes a significantly longer than a for loop. Am I missing something? Probably not. apply() need

Re: [R] how can achive step by step execution of the script

2010-07-09 Thread Allan Engelhardt
Sounds like you want devAskNewPage(TRUE) or the related options("device.ask.default"). See help("devAskNewPage", package="grDevices"). Hope this helps. Allan On 09/07/10 13:54, vijaysheegi wrote: Hi R Experts, I have certain code ,i want to achive interactive execution . For ex: 1. as part

Re: [R] Current script name from R

2010-07-09 Thread Allan Engelhardt
On 09/07/10 12:18, Ralf B wrote: I am using RGUI, the command line or the StatET Eclipse environment. Should this not all be the same? No, there is no particular reason why they should. Allan Ralf On Fri, Jul 9, 2010 at 7:11 AM, Allan Engelhardt wrote: I'm assuming you are

Re: [R] Current script name from R

2010-07-09 Thread Allan Engelhardt
I'm assuming you are using Rscript (please provide self-contained examples when posting) in which case you could look for the element in (base|R.utils)::commandArgs() that begin with the string "--file=" - the rest is the file name. See the asValues= parameter in help("commandArgs", package="R

Re: [R] Why Rscript behaves strangely with file name starting with 'size'?

2010-07-08 Thread Allan Engelhardt
line else if(strncmp(*av+7, "size", 4) == 0) { which looks like a nasty hack that just happens to match --file=size.R as well as --min-vsize=N et al that it tries to detect. But seriously: there are libraries for options parsing! On 08/07/10 07:49, Allan Engelhardt wrote: &g

Re: [R] Why Rscript behaves strangely with file name starting with 'size'?

2010-07-07 Thread Allan Engelhardt
It looks like a bug in R, not Rscript: what Rscript does is effectively R --file=size.R and you can easily test that echo 'print("Hello world")'> size.R R --file=size.R give you the error while cp size.R asize.R R --file=asize.R works as expected. None of which helps you directly, but p

Re: [R] plotmath vector problem; full program enclosed

2010-07-07 Thread Allan Engelhardt
On 07/07/10 18:52, Paul Johnson wrote: > [...] > 1: > axis(1, line=6, at=mu+dividers*sigma, > labels=as.expression(c(b1,b2,b3,b4,b5), padj=-1)) > > > 2: > axis(1, line=9, at=mu+dividers*sigma, > labels=c(as.expression(b1),b2,b3,b4,b5), padj=-1) > > This second one shouldn't work, I think.

Re: [R] Wavelet

2010-07-07 Thread Allan Engelhardt
Try RSiteSearch("MORLET") before you post. Allan On 07/07/10 09:38, nuncio m wrote: Hi useRs, Is it possible to get MORLET wavelet in R Thanks nuncio __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help P

Re: [R] Visualization of coefficients

2010-07-07 Thread Allan Engelhardt
Thanks Tal. Nice summary on the web page. I think the last example would be even better if it was a stand-alone piece of code (i.e.: with data) that we could run. For example library("arm") data("Mroz", package = "car") M1<- glm(lfp ~ ., data = Mroz, family = binomial) M2<- bayesglm(lfp

Re: [R] plotmath vector problem; full program enclosed

2010-07-07 Thread Allan Engelhardt
Ooops, I didn't convert this one to text right for the list. b1<- substitute( mu - d*sigma, list(d=*-round(dividers[1],2))* ) should be b1<- substitute( mu - d*sigma, list(d=-round(dividers[1],2)) ) and similarly for labels=*as.expression(c(b1,b2,b3,b4,b5))*, padj=-1) read label

Re: [R] grayscale wireframe??

2010-07-07 Thread Allan Engelhardt
A standalone example is always appreciated (cf. the posting guide) but try and see if help("gray.colors", package="grDevices") is the sort of thing you are looking for. Hope this helps Allan On 06/07/10 23:30, Marlin Keith Cox wrote: I need grayscale formatting for a wireframe. The only col.

Re: [R] plotmath vector problem; full program enclosed

2010-07-07 Thread Allan Engelhardt
On 07/07/10 06:03, Paul Johnson wrote: > [...] > Hi, Duncan and David > > Thanks for looking. I suspect from the comment you did not run the > code. The expression examples I give do work fine already. But I > have to explicitly put in values like 1.96 to make them work. I'm > trying to avid

Re: [R] plotmath vector problem; full program enclosed

2010-07-06 Thread Allan Engelhardt
On 06/07/10 18:51, David Winsemius wrote: Easily addressed in this case with "~" instead of "-". The value of "d" provides the minus: b1 <- substitute( mu ~ d*sigma, list(d=round(dividers[1],2)) ) Neat trick! But it gives a slightly different minus sign in the display, so perhaps simply

Re: [R] Pseudo F statistics with index.G1

2010-07-06 Thread Allan Engelhardt
I guess that in R you have to be explicit about what you want to do. You can't just drop them, so you'll have to assign them some (other) value. Try which(table(C)==1) to give you the values you need to change and then decide what to change them to. The SAS documentation may tell you what it

Re: [R] Pseudo F statistics with index.G1

2010-07-06 Thread Allan Engelhardt
Always use set.seed in your examples. Running your code after set.seed(1) works fine but gives the error after set.seed(2). The problem in the latter case being that there is only one value 7 in C and you need two or more for the index.G1 code to make sense. Hope this helps a little Allan

Re: [R] Selection with changing number of columns

2010-07-06 Thread Allan Engelhardt
I'm not sure your question completely makes sense, but perhaps this will help: set.seed(1) d<- data.frame(matrix(floor(runif(100, max=10)), 10)) # Example data d[apply(d == 9, 1, any), ] # Select rows with 9 in any column ## Or more generally: d[ , c(1, 2, 3)] == c(2, 2, 9)

Re: [R] conditional dataframe search and find

2010-07-03 Thread Allan Engelhardt
> ct.df[ct.df$conc < 25,"time"] [1] 10 11 12 13 14 15 > ct.df[ct.df$conc < 25,"time"][1] > df[df$conc < 25,"time"][1] [1] 10 See also help("order") if conc is not ordered. On 02/07/10 22:50, oscar linares wrote: time conc 1 0 164.495456 2 1 133.671185 3 2 10

Re: [R] Problem with aggregating data across time points

2010-07-02 Thread Allan Engelhardt
On 02/07/10 16:21, Chris Beeley wrote: Hello- I have a dataset which basically looks like this: Location Sex Date Time VerbalSelf harm Violence_objects Violence A 1 1-4-2007 1800 3 0 1 3 A

Re: [R] Visualization of coefficients

2010-07-02 Thread Allan Engelhardt
http://addictedtor.free.fr/graphiques/RGraphGallery.php?graph=114 should get you started. On 02/07/10 07:10, Wincent wrote: Dear all, I try to show a subset of coefficients in my presentation. It seems that a "standard" table is not a good way to go. I found figure 9 (page 9) in this file ( ht

Re: [R] problems loading the twitteR package

2010-07-02 Thread Allan Engelhardt
If you are on a Unix machine try your package manager first to see if it has the packages you need. Otherwise, try install.package("twitteR", dependencies = TRUE) (or RCurl) and see if that helps. Allan On 01/07/10 22:51, lyolya wrote: Dear all, I cannot load the twitteR package. When I h

[R] Documentation for library() and how to specify missing arguments

2010-07-01 Thread Allan Engelhardt
I can, after carefully reading about the returned values, see why library("MASS", "MASS", character.only=TRUE) has to chose between loading the package and displaying the help (I thought I had found a nice shortcut), but wouldn't the documentation be better if it said that the two are incompat

[R] How best to set library search path so user libraries come first

2010-07-01 Thread Allan Engelhardt
I want my local libraries to have priority over the system installed ones, which, as far as I can make out from help(".libPaths"), means they have to come first in that list (it doesn't actually_say_ so, but that seems to be the idea). We have R_LIBS_USER which looks made for specifying where

Re: [R] Stacked Restricted Boltzmann Machine

2010-07-01 Thread Allan Engelhardt
I don't know of a native implementation, but you could probably use MDP along with RPy or R/S Plus as suggested here: http://www.ncbi.nlm.nih.gov/pmc/articles/PMC2628591/ Allan. On 01/07/10 09:01, Matthew OKane wrote: Hi, Are there any implementations of stacked RBMs either complete or plann

Re: [R] Export data frame of high dimension to txt

2010-07-01 Thread Allan Engelhardt
On 01/07/10 08:50, Loukia Spin. wrote: I managed with success to export a data frame of 367 columns and 37 rows to a txt file, but unfortunately I couldn't manage the same with the transposed data frame. Specifically, it seems like the notebook cannot "read" correctly 367 columns, so it reads

  1   2   >