Re: [R] Errorbar
Have you seen the examples at docs.ggplot2.org/0.9.3.1/geom_errorbar.html ? On Feb 18, 2014, at 10:57, Alzahrani, Ahmad K A aka...@essex.ac.uk wrote: Hi All, Can anyone show me how to add a error bar to my graphs. I am currently using this code g-ggplot(means,aes(x=variable,y=value)) g-g+geom_bar(stat=identity)+facet_wrap(~Site+Season) g Thanks, Akaalz [[alternative HTML version deleted]] __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code. __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.
Re: [R] Setting up an R server.
Perhaps http://www.rstudio.com/ide/docs/server/getting_started Michael On Mon, Jan 20, 2014 at 9:12 AM, John Sorkin jsor...@grecc.umaryland.edu wrote: Can someone provide suggestions about how to best set up an R server? I would like to be able to run R on my IPad. It sounds like the only way to do this is to have the IPad access an R server. The server will be at my home, connected to the internet via my cable company (comcast). I don't yet know if the server will be a linux box or a windows box. I would appreciate advice about setting up both kinds of servers. Thank you, John John David Sorkin M.D., Ph.D. Professor of Medicine Chief, Biostatistics and Informatics University of Maryland School of Medicine Division of Gerontology and Geriatric Medicine Baltimore VA Medical Center 10 North Greene Street GRECC (BT/18/GR) Baltimore, MD 21201-1524 (Phone) 410-605-7119 (Fax) 410-605-7913 (Please call phone number above prior to faxing) Confidentiality Statement: This email message, including any attachments, is for ...{{dropped:14}} __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.
Re: [R] quotation marks and scan
They're not actually there so don't try too hard to rid yourself of them: x - \' length(x) print(x) cat(x, \n) Make sure you're clear on the difference between what's stored by the computer and what it print()s. Rarely the same, though cat() is often slightly more honest. On Nov 17, 2013, at 17:07, Erin Hodgess erinm.hodg...@gmail.com wrote: Dear R People: I'm sure that this is a very simple problem, but I have been wresting with it for some time. I have the following file that has the following one line: CRS(+init=epsg:28992) Fair enough. I scan it into R and get the following: u [1] CRS(\+init=epsg:28992\) gsub(pattern='\',replacement='',x=u) [1] CRS(\+init=epsg:28992\) I need to get rid of the extra quotation marks and slashes. I've tried all sorts of things, including gsub, as you see, but no good. Thank you for any help. Sincerely, Erin -- Erin Hodgess Associate Professor Department of Computer and Mathematical Sciences University of Houston - Downtown mailto: erinm.hodg...@gmail.com [[alternative HTML version deleted]] __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code. __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.
Re: [R] quotation marks and scan
On Sun, Nov 17, 2013 at 6:24 PM, Barry Rowlingson b.rowling...@lancaster.ac.uk wrote: On Sun, Nov 17, 2013 at 10:42 PM, R. Michael Weylandt michael.weyla...@gmail.com michael.weyla...@gmail.com wrote: Did you mean to do 'nchar(x)' to show that \ was one character? 'length' gives the number of elements in a vector, which in this case is also one. x=c(\, '\'') length(x) [1] 2 nchar(x) [1] 1 1 D'oh! Fair enough, MW __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.
Re: [R] Manually setting coefficients in an lm.
On Nov 12, 2013, at 11:59, coll...@pitt.edu wrote: Think you're going to have to explicitly define hand tailor. I haven't a clue what you mean. (Someone else might of course). Ah, I want to set a specific coefficient value for each of the terms rather than rely on training. Thus given: y ~ x0 + x1 + x2 + a I would like to set: a = 10 b0 = 20 b2 = 90, etc. I'm trying out my own training model and I would like to use the machinery of the lm for evaluation and reporting but I would like to fix the beta coefficients and other trained values independently of least-squares regression. I'm quite confused: if you set all the coefficients in advance, in what sense are you doing a linear regression? Even if this is possible, won't all the other estimates (i.e., standard error of betas) produced be junk since they aren't derived from the associated estimators? Michael Collin. __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code. __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.
Re: [R] Load Tawny package on R 2.15.3
The release version of tawny has no such dependency and builds just fine on CRAN. Try updating that instead. Michael On Nov 1, 2013, at 7:10, Tstudent tstud...@gmail.com wrote: I have R version 2.15.3 When i try to load it: library (tawny) i receive this response: package ‘parser’ could not be loaded The package Parser in not on Cran anymore, it seems a dead project! http://cran.r-project.org/web/packages/parser/index.html If i try to manual install parser_0.1.tar.gz i receive an error and can't install it. The question is. Is today impossible to use tawny package? Is there a way to solve this problem that seems caused by parser package? Thank you very much __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code. __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.
Re: [R] an rpy2, R cgi type question
On Oct 31, 2013, at 1:50, Erin Hodgess erinm.hodg...@gmail.com wrote: Hi again: Here is the web output: Internal Server Error The server encountered an internal error or misconfiguration and was unable to complete your request. So your Python code is raising an exception somewhere, not the apache config. Please contact the server administrator, webmas...@erinm.info and inform them of the time the error occurred, and anything you might have done that may have caused the error. More information about this error may be available in the server error log. Can you check these? Additionally, a 404 Not Found error was encountered while trying to use an ErrorDocument to handle the request. I did indeed check permissions and they seem to be in order. Yes, they do seem to be; you'd be getting a 403 otherwise. Thanks, Erin On Wed, Oct 30, 2013 at 10:51 PM, Collin Lynch coll...@cs.pitt.edu wrote: Erin can you share the internal error details? As a first guess are the files executable by all? CGI requires world rwx. Best, Collin. On Wed, 30 Oct 2013, Erin Hodgess wrote: Hi again. I'm putting together a little project with R, python, and a website. So I have an HTML file, a py file, an R file. Here is the HTML file: form action=/cgi-bin/radio4.py method=post target=_blank input type=radio name=subject value=Integrate / Integrate input type=radio name=subject value=Differentiate / Differentiate input type=radio name=subject value=Graph / Graph Function input type=text name=func1 br / input type=submit value=Select Subject / /form Now the radio4.py file: # Import modules for CGI handling import cgi, cgitb from sympy import * import sys from rpy2.robjects.packages import SignatureTranslatedAnonymousPackage as STAP with open(bz2.R,r) as f: string=''.join(f.readlines()) etest = STAP(string,etest) etest.etest(500) # Create instance of FieldStorage form = cgi.FieldStorage() # Get data from fields if form.getvalue('subject'): subject = form.getvalue('subject') else: subject = Not set if form.getvalue('func1'): func1 = form.getvalue('func1') else: func1 = Not entered print Content-type:text/html\r\n\r\n print html print head print titleTest Project/title print /head print body print h2 Selected Action is %s/h2 % subject print h3 output function is %s/h3 % func1 print /body print /html Finally, the bz2.R file: etest - function(n=100) { y - rnorm(n) pdf(file=lap1.png) plot(y) dev.off() } The radio4.py file is in a cgi-bin directory, along with the bz2.R file. I keep getting the Internal server error. Thanks for any help. Sincerely, Erin This is R version 3.0.2 and Python 2.7.5 -- Erin Hodgess Associate Professor Department of Computer and Mathematical Sciences University of Houston - Downtown mailto: erinm.hodg...@gmail.com [[alternative HTML version deleted]] __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code. -- Erin Hodgess Associate Professor Department of Computer and Mathematical Sciences University of Houston - Downtown mailto: erinm.hodg...@gmail.com [[alternative HTML version deleted]] __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code. __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.
Re: [R] an rpy2, R cgi type question
This really has become a python discussion and is probably better held elsewhere, but my hunch is that you give a relative path and Apache doesn't start python with the pwd you expect. Michael On Oct 31, 2013, at 9:12, Erin Hodgess erinm.hodg...@gmail.com wrote: I checked the error logs, and the error appears on the line in which I open the bz2.R file. It's definitely there, and I set the permissions to 777 for experimental permissions. On Thu, Oct 31, 2013 at 7:04 AM, R. Michael Weylandt michael.weyla...@gmail.com michael.weyla...@gmail.com wrote: On Oct 31, 2013, at 1:50, Erin Hodgess erinm.hodg...@gmail.com wrote: Hi again: Here is the web output: Internal Server Error The server encountered an internal error or misconfiguration and was unable to complete your request. So your Python code is raising an exception somewhere, not the apache config. Please contact the server administrator, webmas...@erinm.info and inform them of the time the error occurred, and anything you might have done that may have caused the error. More information about this error may be available in the server error log. Can you check these? Additionally, a 404 Not Found error was encountered while trying to use an ErrorDocument to handle the request. I did indeed check permissions and they seem to be in order. Yes, they do seem to be; you'd be getting a 403 otherwise. Thanks, Erin On Wed, Oct 30, 2013 at 10:51 PM, Collin Lynch coll...@cs.pitt.edu wrote: Erin can you share the internal error details? As a first guess are the files executable by all? CGI requires world rwx. Best, Collin. On Wed, 30 Oct 2013, Erin Hodgess wrote: Hi again. I'm putting together a little project with R, python, and a website. So I have an HTML file, a py file, an R file. Here is the HTML file: form action=/cgi-bin/radio4.py method=post target=_blank input type=radio name=subject value=Integrate / Integrate input type=radio name=subject value=Differentiate / Differentiate input type=radio name=subject value=Graph / Graph Function input type=text name=func1 br / input type=submit value=Select Subject / /form Now the radio4.py file: # Import modules for CGI handling import cgi, cgitb from sympy import * import sys from rpy2.robjects.packages import SignatureTranslatedAnonymousPackage as STAP with open(bz2.R,r) as f: string=''.join(f.readlines()) etest = STAP(string,etest) etest.etest(500) # Create instance of FieldStorage form = cgi.FieldStorage() # Get data from fields if form.getvalue('subject'): subject = form.getvalue('subject') else: subject = Not set if form.getvalue('func1'): func1 = form.getvalue('func1') else: func1 = Not entered print Content-type:text/html\r\n\r\n print html print head print titleTest Project/title print /head print body print h2 Selected Action is %s/h2 % subject print h3 output function is %s/h3 % func1 print /body print /html Finally, the bz2.R file: etest - function(n=100) { y - rnorm(n) pdf(file=lap1.png) plot(y) dev.off() } The radio4.py file is in a cgi-bin directory, along with the bz2.R file. I keep getting the Internal server error. Thanks for any help. Sincerely, Erin This is R version 3.0.2 and Python 2.7.5 -- Erin Hodgess Associate Professor Department of Computer and Mathematical Sciences University of Houston - Downtown mailto: erinm.hodg...@gmail.com [[alternative HTML version deleted]] __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code. -- Erin Hodgess Associate Professor Department of Computer and Mathematical Sciences University of Houston - Downtown mailto: erinm.hodg...@gmail.com [[alternative HTML version deleted]] __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code. -- Erin Hodgess Associate Professor Department of Computer and Mathematical Sciences University of Houston - Downtown mailto: erinm.hodg...@gmail.com [[alternative HTML version deleted]] __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.
Re: [R] rpy2 and user defined functions from R
Could you produce a full working example then? Bit hard to debug without knowing what you did. Michael On Oct 30, 2013, at 9:11, Erin Hodgess erinm.hodg...@gmail.com wrote: I did...just didn't show it On Wed, Oct 30, 2013 at 7:01 AM, Michael Weylandt michael.weyla...@gmail.com wrote: Presumably you need to define 'buzz' first, but I don't see evidence that you've done so. Michael On Oct 30, 2013, at 0:06, Erin Hodgess erinm.hodg...@gmail.com wrote: Hello again! I'm using python with a module rpy2 to call functions from R. It works fine on built in R functions like rnorm. However, I would like to access user-defined functions as well. For those of you who use this, I have: import rpy2.robjects as R x = R.r.buzz(3) R object as no attribute buzz (user defined function of buzz) This is on a Centos 5 machine with R-3.0.2 and python of 2.7.5. Thanks for any help. Sincerely, Erin -- Erin Hodgess Associate Professor Department of Computer and Mathematical Sciences University of Houston - Downtown mailto: erinm.hodg...@gmail.com [[alternative HTML version deleted]] __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code. -- Erin Hodgess Associate Professor Department of Computer and Mathematical Sciences University of Houston - Downtown mailto: erinm.hodg...@gmail.com [[alternative HTML version deleted]] __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.
Re: [R] An Apply function question about changing type of variable
On Sep 27, 2013, at 11:27, Vincent Guyader vincent.guya...@allstat.fr wrote: Hi everyone, plese can you look at this few lines : data(iris) res-apply(iris,MARGIN=2,is) res[1,] the result is : Sepal.Length Sepal.Width Petal.Length Petal.Width Species character character character character character How can I conserve the type off each colum? apply seems to convert it into character adn it could be a problem for me. lapply(iris, is) apply() coerces to a matrix before doing its thing, here the lowest common denominator was character so that's what you got. M Regards [[alternative HTML version deleted]] __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code. __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.
Re: [R] problem with rJython and modules
On Sep 12, 2013, at 13:42, Erin Hodgess erinm.hodg...@gmail.com wrote: Dear R People: I have been experimenting with rPython, rSymPy, and rJython. Here is my latest snag: library(rJython) Loading required package: rJava Loading required package: rjson library(rSymPy) rJython - rJython() x - x y - y rJython$exec(from sympy import *) Error in .jcall(RJavaTools, Ljava/lang/Object;, invokeMethod, cl, : Traceback (most recent call last): File string, line 1, in module ImportError: No module named sympy This is on Windows 32 bit, with Version 3.0.1 of R and python 2.7.5. Also, sypmy is available with regular python. But is it installed under jython? Different platform. Michael Any help would be much appreciated. Sincerely, Erin -- Erin Hodgess Associate Professor Department of Computer and Mathematical Sciences University of Houston - Downtown mailto: erinm.hodg...@gmail.com [[alternative HTML version deleted]] __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code. __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.
Re: [R] Appropriateness of R functions for multicore
On Mon, Aug 19, 2013 at 2:08 PM, Patrick Connolly p_conno...@slingshot.co.nz wrote: On Sat, 17-Aug-2013 at 05:09PM -0700, Jeff Newmiller wrote: | In most threaded multitasking environments it is not safe to | perform IO in multiple threads. In general you will have difficulty | performing IO in parallel processing so it is best to let the | master hand out data to worker tasks and gather results from them | for storage. Keep in mind that just because you have eight cores | for processing doesn't mean you have eight hard disks, so if your | problem is IO bound in single processor operation then it will also | be IO bound in threaded operation. For tasks which don't involve I/O but fail with mclapply, how does one work out where the problem is? The handy browser() function which allows for interactive diagnosis won't work with parallel jobs. What other approaches can one use? browser() requires I/O doesn't it? Anyways -- my rule of thumb is anything involving the outside world won't work so I/O covers most of it, but you also need to be aware of things like RNG (which can involve subtle IO with a global random seed if you're not aware of the concerns in the parallel package vignette). More precisely, anything that would be hard in a functional language (like Haskell) should keep you wary. Cheers, MW __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.
Re: [R] How to rebuild an R package that has been removed from CRAN?
On Mon, Aug 19, 2013 at 6:07 PM, Shang Zuofeng zuofengsh...@gmail.com wrote: So this is an alternative method. The package can be installed from source() rather than rebuilt. Although the warnings exist, the package itself may still be useful. Can you let me know how to installed from source? Note that these discussions don't have anything to do with the source() function. Building from source has the sense of primal origin, not source the verb. Cheers, MW __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.
Re: [R] model syntax processed --- probably common
On Aug 19, 2013, at 16:05, ivo welch ivo.we...@gmail.com wrote: thank you. but uggh...sorry for my html post. and sorry again for having been obscure in my attempt to be brief. here is a working program. fama.macbeth - function( formula, din ) { I think most users would expect 'din' to be 'data' here fnames - terms( formula ) dnames - names( din ) stopifnot( all(dimnames(attr(fnames, factors))[[1]] %in% dnames) ) monthly.regressions - by( din, as.factor(din$month), function(dd) coef(lm(model.frame( formula, data=dd as.m - do.call(rbind, monthly.regressions) colMeans(as.m) } ## a test data set d - data.frame( month=rep(1:5,10), y= rnorm(50), x= rnorm(50), z=rnorm(50) ) ## this works beautifully, exactly how I want it. the names are there, the formula works. print(fama.macbeth( y ~ x , din=d )) ## now I want something like the following statement to work, too for (nm in c(x)) print(fama.macbeth( y ~ nm, din=d )) or for (nm in c(x)) print(fama.macbeth( y ~ d[[nm]], din=d )) or whatever. the output in both cases should be the same, preferably even knowing that the name of the variable is really x and not nm. is there a standard common way to do this? I don't think so -- most of the core modelling functions expect all the covariates to be passed in through a single data frame. Perhaps you're looking for programmatic construction of the formula using paste and as.formula: fama.macbeth(as.formula(paste(y ~, nm))) eval(parse(text = nm)) also works but you don't get nice names on the resulting object so I'd suggest as.formula() If there's something better, I'd love to know -- I always have to use tricks here when doing similar looped regressions. Michael regards, /iaw Ivo Welch (ivo.we...@gmail.com) http://www.ivo-welch.info/ J. Fred Weston Professor of Finance Anderson School at UCLA, C519 Director, UCLA Anderson Fink Center for Finance and Investments Free Finance Textbook, http://book.ivo-welch.info/ Editor, Critical Finance Review, http://www.critical-finance-review.org/ On Mon, Aug 19, 2013 at 12:48 PM, David Winsemius dwinsem...@comcast.net wrote: On Aug 19, 2013, at 9:45 AM, ivo welch wrote: dear R experts---I was programming a fama-macbeth panel regression (a fama-macbeth regression is essentially T cross-sectional regressions, with statistics then obtained from the time-series of coefficients), partly because I wanted faster speed than plm, partly because I wanted some additional features. my function starts as fama.macbeth - function( formula, din ) { names - terms( formula ) ## omitted : I want an immediate check that the formula refers to existing variables in the data frame with English error messages Look the structure of a terms result from a formula argument with str(): fama.macbeth - function( formula, din ) { fnames - terms( formula ) ; str(fnames) } fama.macbeth( x ~ y, data.frame(x=rnorm(10), y=rnorm(10) ) ) Classes 'terms', 'formula' length 3 x ~ y ..- attr(*, variables)= language list(x, y) ..- attr(*, factors)= int [1:2, 1] 0 1 .. ..- attr(*, dimnames)=List of 2 .. .. ..$ : chr [1:2] x y .. .. ..$ : chr y ..- attr(*, term.labels)= chr y ..- attr(*, order)= int 1 ..- attr(*, intercept)= int 1 ..- attr(*, response)= int 1 ..- attr(*, .Environment)=environment: R_GlobalEnv Then extract the dimnames from the factors attribute to compare to the names in hte data-object: fama.macbeth - function( formula, din ) { fnames - terms( formula ) ; dnames - names( din) dimnames(attr(fnames, factors))[[1]] %in% dnames } #[1] TRUE TRUE I couldn't tell if this was the main thrust of you question. It seems to meander a bit. -- David. monthly.regressions - by( din, as.factor(din$month), function(dd) coef(lm(model.frame( formula, data=dd ))) as.m - do.call(rbind, monthly.regressions) colMeans(as.m) ## or something like this. } say my data frame mydata has columns named month, r, laggedx and ... . I can call this function fama.macbeth( r ~ laggedx, din=mydata ) but it fails What fails? if I want to compute my x variables. for example, myx - d[,laggedx] fama.macbeth( r ~ myx) I also wish that the computed myx still remembered that it was really laggedx. it's almost as if I should not create a vector myx but a data frame myx to avoid losing the column name. I wouldn't say almost... rather that is exactly what you should do. R regression methods almost always work better when formulas are interpreted in the environment of the data argument. I wonder why such vectors don't keep a name attribute of some sort. there is probably an R way of doing this. is there? /iaw Ivo Welch (ivo.we...@gmail.com) [[alternative HTML version deleted]] Still posting HTML? PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented,
Re: [R] constructing a daily time series
On Mon, Jul 22, 2013 at 11:17 PM, Pascal Oettli kri...@ymail.com wrote: Hello, ?zoo Regards, Pascal 2013/7/23 shanxiao shanx...@umail.iu.edu Dear all, I have a vector of observations through day, and based on it, I try to construct a daily time series with the R function ts(), but it seems that it only enables to construct a weekly, monthly, quarterly and yearly time series, does anyone know whether there is an option to build a daily time series? Thanks. Like Pascal said, you probably want to use the zoo/xts time series classes, but if you have reason to stick to ts() you can set the frequency to 365. I've written on this list before that frequency is a slightly subtle idea with time series (and you can find that post if you're interested), but it's not hard-coded to anything in particular. MW __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.
Re: [R] how to calculate the average values of each row in a matrix
On Jul 19, 2013, at 20:19, Elaine Kuo elaine.kuo...@gmail.com wrote: Hello, I have a matrix (class matrix) composed of GridCell (row and column). The matrix value is the beta diversity index value between two grids. Now I would like to get the average value of each GridCell. Please kindly advise how to make the calculation. Thank you. Perhaps the rowMeans() function? MW Elaine The matrix looks like (cited from Michael Friendly) I would like to get the average value of each color. Obs stim RPur Red Yel Gy1 Gy2 Green Blue BlP Pur1 Pur2 1 RPur . . . . . . . . . . 2 Red11.5. . . . . . . . . 3 Yel13.1 6.0. . . . . . . . 4 Gy112.6 7.9 6.2. . . . . . . 5 Gy210.6 8.4 8.4 5.2. . . . . . 6 Green 10.6 9.4 9.9 6.5 4.1 . . . . . 7 Blue 10.8 10.2 10.3 8.8 7.06.4. . . . 8 BlP 7.3 11.3 12.7 11.2 10.49.9 4.2 . . . 9 Pur15.4 11.5 12.9 11.7 10.89.4 8.4 4.5. . 10 Pur25.0 11.5 10.7 10.2 10.6 10.1 8.1 6.43 . [[alternative HTML version deleted]] __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code. __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.
Re: [R] Announcing TIBCO Enterprise Runtime for R
Hi Louis, I apologize in advance if this isn't the right forum; feel free to direct me elsewhere. Can you say a bit more about what exactly constitute the advantages of TERR over R as most readers of this list know it? Some random points of interest to me: 1. Do you have concrete benchmarks of what sorts of operations are faster? In particular, are you, like Revolution, licensing MKL? 2. Your white-paper boasts of superior memory management; can you give more details? Are we now reference counting, or abandoning copy-on-write to play better with fork(), or running concurrently? In turn, does this mean the C-API is not kept as is and any package with compiled code isn't usable? 3. You speak of being more robust: is this at a language level (i.e.,something simpler to use than try()/tryCatch()) or an implementation level? If the latter, what non-robustnesses are being addressed? 4. What are y'all's plans for supporting TERR as 'regular R' evolves? Will it track or will things diverge over time? 5. Known (and not intended to change) differences? 6. Is the whole R-level API exposed or only a selected subset? I'm thinking in particular of (1) things like .colMeans() which seem rather tied to the implementation; (2) graphics devices; (3) the promise mechanism and copy-on-write semantics? Cheers, Michael On Wed, Jul 10, 2013 at 4:42 AM, Louis Bajuk-Yorgan lba...@tibco.com wrote: In honor of the kickoff of useR 2013 today, I'm proud to announce the availability of TIBCO Enterprise Runtime for R (or TERR for short), our new enterprise-grade, high-performance statistical engine, fully compatible with the R language. For more information on TERR, and a link to download the free Developer's Edition via the TERR Community site, check out http://spotfire.tibco.com/terr--or come to my talk at useR on Thursday morning. As part of our development of TERR, we have also contributed new packages to CRAN: sjdbc (a JDBC driver interface, previously developed for S-PLUS) and tibbrConnector (an R interface to tibbr, TIBCO's Social Network for the Enterprise). -- Lou Bajuk-Yorgan @loubajuk TIBCO Spotfire __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code. __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.
Re: [R] how to get growth rate of a (time series) data?
On Wed, Jun 19, 2013 at 12:04 PM, Yanyuan Zhu y...@tongji.edu.cn wrote: Hello all, now I'm trying to switch from Excel to R to deal with the data, and as a newbie i got the problem as follows. suppose I have a data named test test- data.frame(year=c(1996:2011), Y=c(74163.6,81658.5,86531.6,91125.0,98749.0,109028.0,120475.6,136613.4,160956.6,187423.5,222712.5,266599.2,315974.6,348775.1,402816.5,465731.3)) in which Y means the GDP of a country If i want to get Delta Y = Y(t)-Y(t-1) , i could use diff() in R diff(test$Y) but what if i want to get gY=(Y(t)-Y(t-1))/Y(t-1)? seems diff(test$Y)/(test$Y)[-1] doesnt work ... Odd, I would have thought it did. No matter anyways: if you are using time series data, I'd strongly recommend that you place your data in an object of the xts class and use all of the time series functionality available for those objects. Notably, you'll also want to load the TTR package (all of these are available through the install.packages() function off the CRAN mirror system) and to use its ROC function. Cheers, MW thanks in advance [[alternative HTML version deleted]] __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code. __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.
Re: [R] p values of lmer
On Wed, Jun 19, 2013 at 10:27 AM, meng laomen...@163.com wrote: Hi all: I met a question about lmer. fm1 - lmer(Reaction ~ Days + (Days|Subject), sleepstudy) summary(fm1) ... Fixed effects: Estimate Std. Error t value (Intercept) 251.405 6.825 36.84 Days 10.467 1.5466.77 ... My question: Why p values of (Intercept) and Days are not given? Take a look at R FAQ 7.35. http://cran.r-project.org/doc/FAQ/R-FAQ.html#Why-are-p_002dvalues-not-displayed-when-using-lmer_0028_0029_003f Many thanks! Best. [[alternative HTML version deleted]] __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code. __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.
Re: [R] chi square test
On Mon, Jun 17, 2013 at 9:14 AM, Dave Clark d...@mailbox.co.uk wrote: I`m doing the chi square test in R, see below code: row1 - c(27,17,13,21,80,24,35,41,18,51) #Category A (1-10) counts row2 - c(27,11,26,13,30,28,17,30,10,21) #Category B (1-10) counts data.table - rbind(row1,row2) data.table then: chisq.test(data.table) This gives me the chi figure, degrees of freedom and p value. But how do I get the results of individual cells? What do you mean 'results of individual cells'? As documented in ?chisq.test, you might be looking for one or more of data.table$observed data.table$expected data.table$residuals data.table$stdres Pick your poison. ;-) MW And has anyone got any good ideas on a decent post hoc test to the chi square test. Thanks all in advance, Dave Clark [[alternative HTML version deleted]] __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code. __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.
Re: [R] chi square test
On Mon, Jun 17, 2013 at 10:07 AM, peter dalgaard pda...@gmail.com wrote: On Jun 17, 2013, at 10:36 , R. Michael Weylandt wrote: What do you mean 'results of individual cells'? As documented in ?chisq.test, you might be looking for one or more of data.table$observed data.table$expected data.table$residuals data.table$stdres Pick your poison. ;-) MW Replace with chisq.test(data.table)$observed, etc. D'Oh! Thanks for that, Peter. MW __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.
Re: [R] rename and concatenate name of columns
On Sat, Jun 15, 2013 at 1:45 AM, David Winsemius dwinsem...@comcast.net wrote: On Jun 14, 2013, at 1:25 PM, Bert Gunter wrote: For the record: ... A bit of commentary: Something did happen. It's just that you didn't do anything with _what_ happened. The copy of the 'dataset'-object got modified but you never returned it from the function, and and also didn't reassign it to the original 'dataset'. Functions return their last assignment. This line was probably more worthy of criticism. Functions return the result of last evaluated expression. (Which is often not what the beginning R programmer expected.) In the case of the 'for'-function, it somewhat surprisingly returns a NULL. It is a rather odd function in the functional R world, since its main role in life is doing things by side-effects, - for() is **not** a function. ?for describes it as a basic control-flow [sic] construct. Which is implemented as a function in C, as can be seen by examining the table in names.c. It fails, however, to be a closure as are most things which are defined with the function keyword in R. That is, admittedly, only an implementation detail and cannot be found (on brief examination) in the language definition. Nonetheless it does return NULL. Ergo, it's behavior is not odd. That remains a matter of opinion. Note that the foreach developers do take advantage of foreach() returning a value, so there's at least some reason to expect for could return a value. I could also see a case being made for consistency with if/else. MW __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.
Re: [R] highlighted a certain time period on multiple plots
On Thu, Jun 6, 2013 at 6:43 AM, Ye Lin ye...@lbl.gov wrote: Hey All, I have a dataset like this: DatedayVar1Var2Var3Obs1/1/2013Tue23411/2/2013Wed23521/3/2013Thu24631/4/2013 Fri24741/5/2013Sat24.5851/6/2013Sun24.9961/7/2013Mon25.31071/8/2013Tue25.711 81/9/2013Wed26.11291/10/2013Thu26.513101/11/2013Fri26.914111/12/2013Sat27.3 15121/13/2013Sun27.716131/14/2013Mon28.117141/15/2013Tue28.518151/16/2013Wed 28.919161/17/2013Thu29.320171/18/2013Fri29.721181/19/2013Sat210.12219 1/20/2013Sun210.523201/21/2013Mon210.924211/22/2013Tue211.325221/23/2013Wed2 11.726231/24/2013Thu212.127241/25/2013Fri212.528251/26/2013Sat212.92926 1/27/2013Sun213.330271/28/2013Mon213.731281/29/2013Tue214.132291/30/2013Wed2 14.533301/31/2013Thu214.93431 Here is the code I use to plot: par(mar=c(10, 0.5, 0.5, 0.5)) par(mfrow=c(3,1)) plot(Var1~Obs,data=dat,xaxt=n,xlab=) plot(Var2~Obs,data=dat,xaxt=n,xlab=) plot(Var3~Obs,data=dat,xaxt=n,xlab=) axis(1,at=dat$Obs,label=dat$Date) mtext(1,text=Date,line=2.5) axis(1,at=dat$Obs,label=dat$day,line=4) mtext(1,text=Day of week,line=7) How can I remove the extra white space between plots and emphasize time periods=weekend with dashed area?? I have attached original output and ideal output I am looking for. Take a look at my xtsExtra package off of R-forge: ## Using your data as Jean arranged it. library(xtsExtra) dat2 - xts(dat[,c(3,4,5)], as.Date(dat[,1], format = %m/%d/%Y)) plot(dat2, yax.loc = left) and look at example(plot.xts) for how to do shading / lines as desired. Cheers, MW Any suggestion to emphasize/highlight weekend periods is really appreciate! Thanks! __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code. __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.
Re: [R] Finding Beta
Put your data in a real time series (xts) object and use the CAPM.* functions from the PerformanceAnalytics package. MW On Tue, Jun 4, 2013 at 10:15 AM, Katherine Gobin katherine_go...@yahoo.com wrote: Dear R forum I have a dataframe (of prices) as given below - dat = data.frame(company = rep(c(A, B, C, D, index), each = 5), prices = c(runif(5, 10, 12), runif(5, 108, 112), runif(5, 500, 510), runif(5, 40, 50), runif(5, 1000, 1020))) company prices 1A 10.61727 2A 10.51892 3A 11.80495 4A 11.15243 5A 10.77543 6B 111.23817 7B 109.19825 8B 108.80053 9B 110.79876 10 B 108.84385 11 C 504.71801 12 C 504.11778 13 C 502.89416 14 C 500.65996 15 C 502.26748 16 D 42.35901 17 D 43.71947 18 D 46.46092 19 D 43.62220 20 D 48.47480 21 index 1017.24476 22 index 1002.88139 23 index 1005.16148 24 index 1014.54480 25 index 1014.12103 I need to find the beta of A, B, C and D w.r.t index. Beta between two variables X and Y (where Y is dependent) is given by, beta = coef(lm(Y ~ X))[2] Any guidance is appreciated. With regards Katherine [[alternative HTML version deleted]] __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code. __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.
Re: [R] cURL ?
On Fri, May 3, 2013 at 11:31 AM, jawad hussain miyanja...@hotmail.com wrote: Dear Sir I tried to find cURL on web but I do not find reliable file; there are some files on http://curl.haxx.se/. But I do not know which is suitable for R and how to install? Kind Regards As usual, the OS is relevant here. What are you running? Linux package managers should be able to handle this for you. And I'd have guessed this was a Just works for OS X. MW Jawad Hussain Ashraf VPO Aroop, Tehsil and District GujranwalaMobile phone# 03016673275 Date: Sun, 28 Apr 2013 19:07:05 +0100 From: rip...@stats.ox.ac.uk To: miyanja...@hotmail.com CC: r-help@r-project.org Subject: Re: [R] unsupported url scheme On 28/04/2013 15:32, jawad hussain wrote: fileUrl - https://data.baltimorecity.gov/api/views/dz54-2aru/rows.csv?accessType=DOWNLOADdownload.file(fileUrl,destfile=./data/Cameras.csv,method=curl) I tried it after installing package RCurl but it give error message: Error in download.file(fileUrl, destfile = Cameras.csv) : unsupported URL schemeI can you help me to solve this problem. JAWAD HUSSAIN ASHRAF Yes, simply install a version of cURL which supports that scheme, then re-install RCurl. [[alternative HTML version deleted]] __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code. That does apply to you, too. No HTML, tell us your sessionInfo() -- Brian D. Ripley, rip...@stats.ox.ac.uk Professor of Applied Statistics, http://www.stats.ox.ac.uk/~ripley/ University of Oxford, Tel: +44 1865 272861 (self) 1 South Parks Road, +44 1865 272866 (PA) Oxford OX1 3TG, UKFax: +44 1865 272595 [[alternative HTML version deleted]] __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code. __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.
Re: [R] task percentage completion
On Wed, May 1, 2013 at 12:19 PM, Fabio Berzaghi f...@dmu.dk wrote: so in other words there is no easy way of doing this? That's not what I said. It's easy to make a progress bar if you use plyr:e.g., ddply(baseball, .(id), mutate, career_year = year - min(year) + 1, .progress = time) Our cautions were against taking it all too seriously. MW I don't want to spend too much time figure out how this progress bar works. I am not clear if the code should run in the main R or where. On 4/30/2013 13:11, R. Michael Weylandt wrote: On Tue, Apr 30, 2013 at 10:40 AM, Fabio Berzaghi f...@dmu.dk wrote: Dear All, Is it possible to add a percentage completion bar to R? I find it frustrating when running long calculations that I don't know at what point the process is. It would be very helpful so I am not guessing if I should wait a few minutes or hours. I believe recent-ish versions of the plyr package include this feature. Note, however, Prof Ripley's caution: it's not as trivial as it might seem to do so _accurately_. With a bit of squinting, one might even see the halting problem... Obligatory: http://xkcd.com/612/ MW __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.
Re: [R] rpy2 postgres qgis problem
On Wed, May 1, 2013 at 3:05 PM, Enzo Cocca enzo@gmail.com wrote: Hello every body, I am using rpy2_2.0.8 with postgres and Qgis. The code that I wrote is the following: def on_calcola_pressed (self): # bottone per calcoli statistici import rpy2 import rpy2.robjects as robjects import rpy2.robjects as ro Redundant no? r = robjects.r robjects.r Why? r.library(RPostgreSQL) r.library(gstat) r.library(zoo) rcmd_drv = r[dbDriver] rcmd_con = r[dbConnect] rcmd = r[dbListTables] rcmd_archezoology_table = r[dbReadTable] png = r.png drv = rcmd_drv(PostgreSQL) con = rcmd_con(drv, host=127.0.0.1, dbname=pyarchinit, port=5432, password=enzo, user=postgres) archezoology_table = rcmd_archezoology_table(con,archeozoology_table) r.png(file=/home/enzo/Scrivania/prova.png,width=512,height=512) plot = r.plot zoo = r.zoo ('VGM_PARAM_A3 - gstat(id=bos_bison, formula=combusto~1,locations=~coord_x+coord_y, data=archezoology_table, nmax = 10) VGM_PARAM_A3 - gstat(VGM_PARAM_A3, calcinati, strie~1, locations=~coord_x+coord_y, archezoology_table, nmax = 10)VGM_PARAM_A3 - gstat(VGM_PARAM_A3, camoscio, cervo~1, locations=~coord_x+coord_y,archezoology_table, nmax = 10) VGM_PARAM_A3 - gstat(VGM_PARAM_A3, model=vgm(1, Sph, 5, 0), fill.all=TRUE ESV_A3 - variogram(VGM_PARAM_A3, cutoff=9) VARMODEL_A3 = fit.lmc(ESV_A3, VGM_PARAM_A3)') plot(zoo('ESV_A3, model = VARMODEL_A3,xlab=,ylab=,pch=20, cex=0.7, col=red,main=Linear Model of Coregionalization for A3 variables')) As this appeared in my mailer, it's not valid python or R; perhaps you could try resending not in HTML? It's rather dificult to debug as is. Even better would be to see if you can get it working solely within R -- post that code -- and then work on translating into rpy2. Cheers, MW The error is the following: res = super(RFunction, self).__call__(*new_args, **new_kwargs) RRuntimeError: Error in plot.window(...) : invalid 'ylim' value Do you have a suggestion or examples about how to call a function with the gistat module on a postgress tab using rpy2? Thank you, Enzo -- Enzo Cocca (PhD Candidate) Research Fellow Università di Napoli L'Orientale mail: enzo@gmail.com cell: +393495087014 [[alternative HTML version deleted]] __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code. __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.
Re: [R] task percentage completion
On Tue, Apr 30, 2013 at 10:40 AM, Fabio Berzaghi f...@dmu.dk wrote: Dear All, Is it possible to add a percentage completion bar to R? I find it frustrating when running long calculations that I don't know at what point the process is. It would be very helpful so I am not guessing if I should wait a few minutes or hours. I believe recent-ish versions of the plyr package include this feature. Note, however, Prof Ripley's caution: it's not as trivial as it might seem to do so _accurately_. With a bit of squinting, one might even see the halting problem... Obligatory: http://xkcd.com/612/ MW __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.
Re: [R] News package
On Wed, Apr 24, 2013 at 9:02 AM, Aswathy Nair ashy4...@gmail.com wrote: Hi, Is there any package available in R to download news content? What news source are you looking for? You could, e.g., use the twitteR package, but to my knowledge for things like Google News or the BBC you'll need to likely roll your own with the XML and RCurl packages. MW __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.
Re: [R] identify object that causes Error in loadNamespace(name) : there is no package called ‘R.utils’
On Wed, Apr 24, 2013 at 4:08 PM, Liviu Andronic landronim...@gmail.com wrote: 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 accidentally end up with a workspace being loaded, delete it. I must admit that I'm a bit surprised by this. I was always under the impression that saving/restoring workspaces was the proper workflow in R. If you use R interactively (e.g., not by running scripts), how else would you store your data, intermediary results, etc., while working on a project? Am I missing something? I save the objects themselves (rather than the whole workspace) using saveRDS() and readRDS() -- which I *think* are considered better practice than save() and load() because they don't force names on you. Cheers, MW __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.
Re: [R] [r] Problems with Fortran calls when loaded a dll compiled with gfortran-4 Cygwin 4.5.3
On Apr 24, 2013, at 7:46 PM, Jens Olofsson jens.olofs...@gmail.com wrote: Ok. I apologise for not understanding. So, I have installed R-tools. It changed my PATH-variable. I didn't installed Cygwin dlls as stated by http://cran.r-project.org/doc/manuals/R-admin.html#The-Windows-toolset. Instead my PATH-variable contains the path to the Cygwin dlls AFTER the path to R... So, I started RTerm (32-bit) and tried R CMD SHLIB mango.f95 Repeating what Duncan said -- R CMD SHLIB is to be done outside of R, not within R. Some recent discussion also suggests its perhaps easier to do this with RStudio + devtools as part of a package than as a standalone shared object. MW and got the same error as earlier Error: unexpected symbol in R CMD. The same goes for RTerm (64-bit). Can you pls advice me on how to proceed? Sincerely Jens On 24 April 2013 20:08, Duncan Murdoch murdoch.dun...@gmail.com wrote: On 13-04-24 1:51 PM, Jens Olofsson wrote: Dear Duncan, I know this isn't a forum for Cygwin, but for R. Pls treat me as a noob and also remember I am on Windows. How should I use R CMD SHLIB as if I write that at the prompt I get the error: unexpected symbol in R CMD. I have mango.f95 in the working directory. That's a command-line command, not something done with R. You can use it from your bash shell if you have R and the Rtools directories on your path, or from the Windows CMD shell. BTW, my comment wasn't trying to tell you to go to a Cygwin forum, it was telling you that Cygwin's gfortran is unsupported. You need to use the MinGW-64 one that we distribute if you want us to be able to help. Duncan Murdoch //Jens On 24 April 2013 19:46, Duncan Murdoch murdoch.dun...@gmail.com wrote: On 13-04-24 1:36 PM, Jens Olofsson wrote: Dear users of R I have a subroutine in Fortran95, compiled to a DLL with gfortran in Cygwin 4.5.3. We don't support Cygwin. You should use the gfortran in Rtools, and get R to set the command line options for you, either by putting the code in a package, or by using R CMD SHLIB Mango.f95. Duncan Murdoch The subroutine is: subroutine MyPBP( S, p, N ) ! Expose subroutine rtest to users of this DLL !DEC$ ATTRIBUTES DLLEXPORT, C, REFERENCE, ALIAS: mypbp_ ::mypbp ! This function computes the Poisson-Binomial distribution ! of size N using p double precision, intent(inout) :: S(N+1) double precision, intent(in) :: p(N) integer, intent(in) :: N double precision :: X(N+1) integer i, j !X=0 !S=0 X(1) = 1 - p(1) X(2) = p(1) do i = 2, N S(1) = X(1)*(1-p(i)) do j = 2,i S(j) = X(j-1)*p(i) + X(j)*(1-p(i)) end do S(i+1) = X(i)*p(i) X = S if (i == N) then S = X end if end do end subroutine MyPBP and it is saved into Mango.f95 I compile it from the bash shell using: gfortran-4 c- Mango.f95 and gfortran-4 -shared -o Mango.dll Mango.o I am on a Windows machine running Windows 7 with Intel i7. I load the dll in a 32-bit R by dyn.load(Mango.dll). Using getLoadedDLLs I can see the DLL. However, is.loaded(Mango.dll) = FALSE. In addition, R stop responding when I try .Fortran(MyPBP, as.numeric(S), as.numeric(p), as.integer(N)), where N-5, S-array(0,N+1) and p- c(0.1, 0.2, 0.5, 0.8, 0.9). What am I doing wrong? Any ideas, thoughts and/or comments are highly appreciated. Jens [[alternative HTML version deleted]] __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-helphttps://stat.ethz.ch/mailman/**listinfo/r-help https://stat.**ethz.ch/mailman/listinfo/r-**helphttps://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/** posting-guide.html http://www.R-project.org/**posting-guide.htmlhttp://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code. [[alternative HTML version deleted]] __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code. __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.
Re: [R] question
On Tue, Apr 23, 2013 at 2:54 PM, nafiseh hagiaghamohammadi n_hajiaghamohammadi2...@yahoo.com wrote: Hi I fit one linear quantile regression with package quantreg and I want to khow this model is good or not.Is there method for checking it? Thanks your advice I ask this question because there is 2 models,f0 and f1 in (R1 - 1 - f1$rho/f0$rho ), is it true? but I fit 1 model and I want to check goodness of fit for 1 model . Please keep your responses on list so you can get a quick reply even when I'm otherwise busy. I think you could -- for a rough and ready comparison -- compare against a constant (empirical quantile) model (not unlike how basic OLS models compare against the constant mean predictor) but someone else might know if there's any subtleties about quantile regression that should be noted here. MW __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.
Re: [R] question
On Tue, Apr 23, 2013 at 2:54 PM, nafiseh hagiaghamohammadi n_hajiaghamohammadi2...@yahoo.com wrote: Hi I fit one linear quantile regression with package quantreg and I want to khow this model is good or not.Is there method for checking it? Thanks your advice How is this different than the question you asked and were answered here: https://stat.ethz.ch/pipermail/r-help/2013-April/352074.html Michael __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.
Re: [R] Need to replicate Boltzman Signmodial Curve fit from Graph Pad
On Tue, Apr 23, 2013 at 3:55 PM, J J rnoob...@gmail.com wrote: Hello useRs (please don't kill me), I've fairly new to R having only a few months of playing around with R. What little I've learned has been extremely useful. If someone could point me as to how to replicate the Boltzman Sigmodial curve fit as provided by Graphpad software I'd be eternally grateful. Where we currently use Graphpad for only this one function,its seems highly inefficient for a $100 piece of software to be used for only one function (which isn't nearly as bad as the company's pandemic reliance on Excel for nearly everything else). so anyway, what I'd normally do is take a set of data like this: pH counts 3.8 968 5.0 1347 5.8 2867 6.6 9203 7.0 15817 7.4 20297 8.2 31916 9.2 35756 then fit this to a Boltzman sigmodial in Graphpad. Graphpad spits out a much longer set of vectors and also information about v50 and confidence intervals etc (if anyone is familiar with that software). This is what i'd like to replicate. It might be that I just don't know what i'm doing,so feel free to call me an idiot but any help is greatly appreciated! Being unfamiliar with the problem domain, I'd imagine that nls() would probably be what you're looking for. Does ? nls seem promising? If so, we can help you get started. MW __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.
Re: [R] How to set frequncy?
On Mon, Apr 22, 2013 at 9:54 AM, Rui Barradas ruipbarra...@sapo.pt wrote: Hello, If stock prices are daily data, use frequency = 1. Err, maybe... The frequency attribute for a ts class time series is somewhat subtle. It's the amount of observations per seasonal period / relevant cycle, where relevant is a bit of a judgement call. E.g., suppose I have hourly readings of some sort of astronomical data. If it's one sort solar data, I might want to have my frequency equal to 24, being the number of hours in a daily. If it's based on moon things, I might want to have my frequency being 24*28 (roughly the hours in a lunar cycle). And if it's based on the movement of the earth through it's orbit, perhaps 24*365 makes sense. Still, this is all hourly data The assumption underlying this then is that there's a single major structural frequency to your data and that you want modelling functions to respect this frequency. If the OP has daily data, either 21 or 252 might make sense, depending on whether we're trying to model monthly or yearly cycles. (Or perhaps some other frequency, such as quarterly giving 84 for a frequency if we're looking at something driven by earnings announcements or the like). Ultimately, the base ts series isn't great for financial data. 252 trading days is not uniform across all markets and assets, nor will daily data be truly uniform. (weekends, holidays, etc) There's also some interesting research on what one might call non-linear time for modelling financial data, but that's now getting somewhat out of the scope of the original question. In short, I'd advise the OP use xts instead which uses truly time stamped (and quite likely irregular) data. Cheers, Michael __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.
Re: [R] numerical integration of a bivariate function
On Mon, Apr 22, 2013 at 2:04 PM, Hicham Mezouara hicham_d...@yahoo.fr wrote: hello I work on the probabilities of bivariate normal distribution. I need integrate the following function. f (x, y) = exp [- (x ^ 2 + y ^ 2 + x * y)] with - ∞ ≤ x ≤ 7.44 and - ∞ ≤ y ≤ 1.44 , either software R or matlab Version R 2009a Well, we're not going to help you with MATLAB, but I might suggest you look at the function pmvnorm() in the mvtnorm package available off CRAN at http://cran.r-project.org/web/packages/mvtnorm/index.html or by the installation methods relevant to your OS and version of R. Best, Michael __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.
Re: [R] Scatterplot and Causality
On Mon, Apr 22, 2013 at 3:48 PM, Lorenzo Isella lorenzo.ise...@gmail.com wrote: Dear All, I hope this is not too off topic. I am given a set of scatteplots (nothing too fancy; think about a normal x-y 2D plot). I do not deal with two time series (indeed I have no info about time). If I call A=(A1,A2,...) and B=(B1, B2, ...) the 2 variables (two vectors of numbers most of the case, but sometimes they can be categorical variables), I can plot one against the other and I essentially I need to determine whether A=f(B, noise) or B=g(A, noise) What's the mathematical difference in these two cases? It seems only a matter of interpretation. where the noise is the effect of other possibly unknown variables, measurement errors etc and f and g are two functions. Without the noise, if I want to test if A=f(B) [B causes A], then I need at least to ensure that f(B1)!=f(B2) must imply B1!=B2 (different effects must have a different cause), whereas it is not ruled out that f(B1)=f(B2) for B1!=B2 (different causes may lead to the same effect). However, in presence of the noise, these properties will hold only approximately Do they even hold approximately? soany idea about how a statistical test, rather than eyeballing, to tell apart A=f(B, noise) vs B=g(A, noise)? Any suggestion is welcome. http://xkcd.com/552/ Lorenzo __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code. __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.
Re: [R] Vector with zeros and ones
On Mon, Apr 22, 2013 at 7:21 PM, Ayyappa ayyapp...@gmail.com wrote: Dear group, I want to generate a vector of 10 elements that always has 20% zeroes, but with a random ordering of zeroes and ones. Can you please suggest a function to do that in R? I tried 'sample' function but the 20% zeros was not always guaranteed. v - numeric(10) # Make a vector of 10 elements v[sample(10, 2)] - 1 # Set two random elements to one Best, Michael __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.
Re: [R] Welcome to the R-help mailing list
On Sun, Apr 21, 2013 at 4:04 AM, 李究 li...@hotmail.com wrote: You must know your password to change your options (including changing the password, itself) or to unsubscribe without confirmation. It is: [[*snip*]] Not an answer to your question, but I'd like to point out that you just sent your password to the thousands of r-help readers and several archive mirrors so you might wish to change it now. Cheers, MW __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.
Re: [R] Source Code
On Apr 20, 2013, at 6:23 PM, Eva Prieto Castro evapcas...@yahoo.es wrote: Dear all, How can I get the source code of text function? What is the 'text function'? Try typing the name of the function at the prompt without any parentheses after it. If its written in R, then it should be visible. Michael Regards Eva [[alternative HTML version deleted]] __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code. __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.
Re: [R] Source Code
On Apr 20, 2013, at 7:13 PM, David Winsemius dwinsem...@comcast.net wrote: On Apr 20, 2013, at 4:05 PM, Eva Prieto Castro wrote: Thanks!. The problem is that I can't see the source code in .Internal(txt... Exactly which was why I provided the link to Ligges' article. (So now you _are_ expected to do some self-study.) Note also that the graphics code isn't exactly the easiest either (to my mind) -- perhaps you could say a bit about what you are after and we'll try to give pointers as best we're able. MW (Sorry for brain borking in the text() function earlier -- I blame it on the travel!) -- David. text.default function (x, y = NULL, labels = seq_along(x), adj = NULL, pos = NULL, offset = 0.5, vfont = NULL, cex = 1, col = NULL, font = NULL, ...) { if (!missing(y) (is.character(y) || is.expression(y))) { labels - y y - NULL } labels - as.graphicsAnnot(labels) if (!is.null(vfont)) vfont - c(typeface = pmatch(vfont[1L], Hershey$typeface), fontindex = pmatch(vfont[2L], Hershey$fontindex)) .Internal(text(xy.coords(x, y, recycle = TRUE), labels, adj, pos, offset, vfont, cex, col, font, ...)) } bytecode: 0x12b4cdb4 environment: namespace:graphics Regards, Eva --- El dom, 21/4/13, David Winsemius dwinsem...@comcast.net escribió: De: David Winsemius dwinsem...@comcast.net Asunto: Re: [R] Source Code Para: R. Michael Weylandt michael.weyla...@gmail.com michael.weyla...@gmail.com CC: Eva Prieto Castro evapcas...@yahoo.es, r-h...@stat.math.ethz.ch r-h...@stat.math.ethz.ch Fecha: domingo, 21 de abril, 2013 00:45 On Apr 20, 2013, at 3:34 PM, R. Michael Weylandt michael.weyla...@gmail.com wrote: On Apr 20, 2013, at 6:23 PM, Eva Prieto Castro evapcas...@yahoo.es wrote: Dear all, How can I get the source code of text function? What is the 'text function'? Try typing the name of the function at the prompt without any parentheses after it. If its written in R, then it should be visible. (It's not, .. or at least it might not seem so to a newbR.) text function (x, ...) UseMethod(text) bytecode: 0x10191f780 environment: namespace:graphics methods(text) text.default graphics:::trext.formula And then to go further ... I think she may need the added information in Uwe Ligges classic R-News article: http://cran.r-project.org/doc/Rnews/Rnews_2006-4.pdf -- David Winsemius Alameda, CA, USA David Winsemius Alameda, CA, USA __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.
Re: [R] proper way to handle obsolete function names
On Apr 17, 2013, at 10:17 AM, Jannis bt_jan...@yahoo.de wrote: Dear R community, what would be the proper R way to handle obsolete function names? I have created several packages with functions and sometimes would like to change the name of a function but would like to create a mechanism that other scripts of functions using the old name still work. It sounds like you want .Deprecate ?.Deprecate Michael Cheers Jannis __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code. __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.
Re: [R] R process slow down after a amount of time
On Apr 16, 2013, at 9:52 AM, Chris82 rubenba...@gmx.de wrote: Hi R users, I have mentioned that R is getting slower if a process with a loop runs for a while. Is that normal? Let's say, I have a code which produce an output file after one loop run. Now after 10, 15 or 20 loop runs the time between the created files is stongly increasing. Is there maybe any data which fill some memory? Possibly, but I were to put money on it, I'd guess there's an ever-expanding object problem: x - NULL for(i in 1:1e6) x - c(x, rnorm(1)) which is not-so-secretly quadratic and should instead be: x - rnorm(1e6) Perhaps a small reproducible example would help us help you. Michael Chris -- View this message in context: http://r.789695.n4.nabble.com/R-process-slow-down-after-a-amount-of-time-tp4664358.html Sent from the R help mailing list archive at Nabble.com. __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code. __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.
Re: [R] checkUsage from codetools shows errors when function uses functions from loaded packages
On Wed, Apr 10, 2013 at 4:47 AM, Jannis bt_jan...@yahoo.de wrote: Well, its mentioned in the function itself by library(xxx) or require(xxx). Well, most probably codetools is more aimed towards checking packages in whcih case such information is in the depends section of the package declaration. Yes -- it's written as a static analyzer so it doesn't execute the function in question; hence it won't experience the side effects of package loading. For example: f - function(x){print(Hello World!); x + 3} checkUsage(f) # Doesn't print anything Similarly, library() in f won't have any effect until f is executed. MW __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.
Re: [R] Behaviors of diag() with character vector in R 3.0.0
On Tue, Apr 9, 2013 at 7:15 AM, Mike Cheung mikewlche...@gmail.com wrote: Dear all, According to CHANGES IN R 3.0.0: o diag() as used to generate a diagonal matrix has been re-written in C for speed and less memory usage. It now forces the result to be numeric in the case diag(x) since it is said to have 'zero off-diagonal entries'. diag(x) does not work for character vector in R 3.0.0 any more. For example, v - c(a, b) ## R 2.15.3 diag(v) [,1] [,2] [1,] a 0 [2,] 0 b ## R 3.0.0 diag(v) [,1] [,2] [1,] NA0 [2,]0 NA Warning message: In diag(v) : NAs introduced by coercion Regarding the character matrix, it still works. For example, m - matrix(c(a, b, c, d), nrow=2) diag(m) ## Both R 2.15.3 and 3.0.0 [1] a d n - matrix(0, ncol=2, nrow=2) diag(n) - v n ## Both R 2.15.3 and 3.0.0 [,1] [,2] [1,] a 0 [2,] 0 b I understand that the above behavior follows exactly what the manual says. It appears to me that the version in 2.15.3 is more general as it works for both numeric and character vectors and matrices, whereas the version in 3.0.0 works for character matrices but not character vectors. Would it be possible to retain the behaviors of diag() for character vectors? Thanks. Persuant to what the NEWS file says, I'm not sure it's a good idea, but here's a patch against a recent R-devel which I believe restores the old behavior. It's not coming out of svn diff too cleanly, but it applies as it should. Should it be adopted, someone with more taste might want to move case VECSXP or case RAWSXP to error out as well. Michael Index: array.c === --- array.c (revision 62536) +++ array.c (working copy) @@ -1539,26 +1539,41 @@ error(_(too many elements specified)); #endif - if (TYPEOF(x) == CPLXSXP) { + int nx = LENGTH(x); + R_xlen_t NR = nr; + + switch(TYPEOF(x)){ + case CPLXSXP: PROTECT(ans = allocMatrix(CPLXSXP, nr, nc)); - int nx = LENGTH(x); - R_xlen_t NR = nr; - Rcomplex *rx = COMPLEX(x), *ra = COMPLEX(ans), zero; + Rcomplex *cx = COMPLEX(x), *ca = COMPLEX(ans), zero; zero.r = zero.i = 0.0; - for (R_xlen_t i = 0; i NR*nc; i++) ra[i] = zero; - for (int j = 0; j mn; j++) ra[j * (NR+1)] = rx[j % nx]; - } else { - if(TYPEOF(x) != REALSXP) { + for(R_xlen_t i = 0; i NR*nc; i++) ca[i] = zero; + for(int j = 0; j mn; j++) ca[j*(NR+1)] = cx[j % nx]; + break; + case LGLSXP: + case REALSXP: + case INTSXP: + case RAWSXP: + case VECSXP: + if(TYPEOF(x) != REALSXP){ PROTECT(x = coerceVector(x, REALSXP)); nprotect++; } PROTECT(ans = allocMatrix(REALSXP, nr, nc)); - int nx = LENGTH(x); - R_xlen_t NR = nr; double *rx = REAL(x), *ra = REAL(ans); for (R_xlen_t i = 0; i NR*nc; i++) ra[i] = 0.0; for (int j = 0; j mn; j++) ra[j * (NR+1)] = rx[j % nx]; + break; + case STRSXP: + PROTECT(ans = allocMatrix(STRSXP, nr, nc)); + for (R_xlen_t i = 0; i NR*nc; i++) SET_STRING_ELT(ans, i, mkChar(0)); // Odd to put character 0 here? + for (R_xlen_t j = 0; j mn; j++) SET_STRING_ELT(ans, j*(NR+1), STRING_ELT(x, j)); + break; + default: + error(_('data' must be of a vector type, was '%s'), + type2char(TYPEOF(x))); } + UNPROTECT(nprotect); return ans; } __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.
Re: [R] [R-SIG-Finance] EM algorithm with R manually implemented?
Moved to R-help because there's no obvious financial content. Michael On Sat, Apr 6, 2013 at 10:56 AM, Stat Tistician statisticiangerm...@gmail.com wrote: Hi, I want to implement the EM algorithm manually, with my own loops and so. Afterwards, I want to compare it to the normalmixEM output of mixtools package. Since the notation is very advanced, I used LaTex and attached the two screenshots I also attached the data. Alternatively, the data can be found here:http://uploadeasy.net/upload/py6j4.rar and the screenshots here: http://uploadeasy.net/upload/9i04.PNG http://uploadeasy.net/upload/vloku.PNG I want to fit two gaussian mixtures. My main question is: Did I implement the EM algorithm correctly? It does not work, because I get such odd values especially for sigma, that the likelihood of some observations is zero and therefore the log is -Inf. Where is my mistake? My code: # EM algorithm manually # dat is the data # initial values pi1-0.5 pi2-0.5 mu1--0.01 mu2-0.01 sigma1-0.01 sigma2-0.02 loglik[1]-0 loglik[2]-sum(pi1*(log(pi1)+ log(dnorm(dat,mu1,sigma1+sum(pi2*(log(pi2)+log(dnorm(dat,mu2,sigma2 tau1-0 tau2-0 k-1 # loop while(abs(loglik[k+1]-loglik[k])= 0.1) { # E step tau1-pi1*dnorm(dat,mean=mu1,sd=sigma1)/(pi1*dnorm(x,mean=mu1,sd=sigma1)+pi2*dnorm(dat,mean=mu2,sd=sigma2)) tau2-pi2*dnorm(dat,mean=mu2,sd=sigma2)/(pi1*dnorm(x,mean=mu1,sd=sigma1)+pi2*dnorm(dat,mean=mu2,sd=sigma2)) # M step pi1-sum(tau1)/length(dat) pi2-sum(tau2)/length(dat) mu1-sum(tau1*x)/sum(tau1) mu2-sum(tau2*x)/sum(tau2) sigma1-sum(tau1*(x-mu1)^2)/sum(tau1) sigma2-sum(tau2*(x-mu2)^2)/sum(tau2) loglik[k]-sum(tau1*(log(pi1)+log(dnorm(x,mu1,sigma1+sum(tau2*(log(pi2)+log(dnorm(x,mu2,sigma2 k-k+1 } # compare library(mixtools) gm-normalmixEM(x,k=2,lambda=c(0.5,0.5),mu=c(-0.01,0.01),sigma=c(0.01,0.02)) gm$lambda gm$mu gm$sigma gm$loglik Thanks [[alternative HTML version deleted]] ___ r-sig-fina...@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-sig-finance -- Subscriber-posting only. If you want to post, subscribe first. -- Also note that this is not the r-help list where general R questions should go. __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.
Re: [R] convert annual data to quarterly frequency
On Apr 5, 2013, at 2:12 PM, Ravshonbek Otojanov r.otoja...@qmul.ac.uk wrote: Hi, I was wondering if there is a package I can use to convert my 22 annual observations to quarterly time series so that I will have 88 observations. Please don't post to two lists -- and I think the package you're looking for is a crystal ball, coincidentally my OED Word of the Dat. Michael Also, will there be any harm in doing so? will I loose any important data specific info? I want to run VARs in levels using TY method. Due to small sample, i will probably use a bootstrap method. Thanks! [[alternative HTML version deleted]] __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code. __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.
Re: [R] [R-SIG-Finance] error message sending question to the list
Post in plain text (not HTML) which is a choice within your email client. And please (!!) don't post the same question to multiple lists. If your question is off-topic, the list membership will redirect as needed. Double posting simply wasted the community's energies by duplicating responses. Michael On Apr 6, 2013, at 3:42 PM, Stat Tistician statisticiangerm...@gmail.com wrote: Hi, I tried to send several questions to the lists (both normal R and R-Sig-Finance), but everytime I look them up in the archives my messages end up with the following An embedded and charset-unspecified text was scrubbed... for example see my post here: https://stat.ethz.ch/pipermail/r-sig-finance/2013q2/011496.html This one was a real important for me. Can subscribers still read it? Shall I repost, how can I post correctly? Thanks [[alternative HTML version deleted]] See -- HTML! ___ r-sig-fina...@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-sig-finance -- Subscriber-posting only. If you want to post, subscribe first. -- Also note that this is not the r-help list where general R questions should go. __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.
Re: [R] arrayInd and which
On Fri, Apr 5, 2013 at 2:08 PM, Keith S Weintraub kw1...@gmail.com wrote: And to the rest of you good R folks I would still be interested to see a working example of arrayInd, what it's supposed to do and what it's used for. A little utility function for dealing with the matrix-is-really-a-vector indexing duality. (Elemental (1,3) vs linear #4 indexing) E.g., x - matrix(rnorm(9), 3, 3) which.min(x) # Not super helpful where.min - function(x) arrayInd(which.min(x), dim(x), dimnames(x), T) where.min(x) # Perhaps better Cheers, Michael __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.
Re: [R] Internet connection
On Fri, Apr 5, 2013 at 3:20 PM, Gary gwengst...@yahoo.com wrote: Tried several ways to connect to Internet. Perhaps R help could point me in the right direction to make this connection work. setInternet2(use = TRUE) download.file( + http://image.shutterstock.com/display_pic_with_logo/322090/322090,1307359665,10/stock-photo-car-silhouette-for-race-sports-design-vector-version-also-available-in-gallery-78667174.jpg + , + destfile=file.path(.., Desktop/racing_car.jpg), mode=wb) Error in download.file(\nhttp://image.shutterstock.com/display_pic_with_logo/322090/322090,1307359665,10/stock-photo-car-silhouette-for-race-sports-design-vector-version-also-available-in-gallery-78667174.jpg\n;, : Off the cuff, it seems that the newline breaks around the link but inside the quote marks are your problem. See the \n at the front and back of the URL -- shouldn't be there. MW unsupported URL scheme G [[alternative HTML version deleted]] __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code. __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.
Re: [R] categorized complete list of R commands?
On Apr 4, 2013, at 12:34 AM, ivo welch ivo.we...@anderson.ucla.edu wrote: every time I read the R release notes for the next release, I see many functions that I had forgotten about and many functions that I never knew existed to begin with. (who knew there were bibtex facilities in R? obviously, everyone except me.) 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. I am thinking one categorization for function area (e.g., programming related for, say, deparse; and statistical model related for lm; and another categorization for importance (e.g., like common for lm and obscure for ..). Such categorizations require intelligence. if I am going to do this for myself, I think a csv spreadsheet may be a good idea to make it easy to resort by keys. I don't think all if those exist already, but the help system gives indices for each package and, within the core packages, things are relatively well categorized simply by knowing the package they're in. Not a full answer, but perhaps saves you a bit of time. Michael regards, /iaw Ivo Welch (ivo.we...@gmail.com) [[alternative HTML version deleted]] __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code. __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.
Re: [R] categorized complete list of R commands?
On Thu, Apr 4, 2013 at 3:57 PM, ivo welch ivo.we...@gmail.com wrote: thanks, michael. how do I get all functions, not just my own, that can possibly be used? It's somewhat ill-defined as functions can be created at any moment. But as a start lapply(search(), ls) might get you going. Though my original idea was to access the indices of the HTML help system, with something like help.start() - packages - whichever package you want. I'm sure this can all be accessed automatically as well. Also, let's please keep emails on the list and avoid top-posting in so far as possible. Michael I guess I could just start with each letter and then try escape for command completion, but this seems silly. ls(environ=parentenv) did not work (ignore capitalization) at the top level for me. /iaw Ivo Welch (ivo.we...@gmail.com) http://www.ivo-welch.info/ J. Fred Weston Professor of Finance Anderson School at UCLA, C519 Director, UCLA Anderson Fink Center for Finance and Investments Free Finance Textbook, http://book.ivo-welch.info/ Editor, Critical Finance Review, http://www.critical-finance-review.org/ On Thu, Apr 4, 2013 at 7:44 AM, R. Michael Weylandt michael.weyla...@gmail.com michael.weyla...@gmail.com wrote: On Apr 4, 2013, at 12:34 AM, ivo welch ivo.we...@anderson.ucla.edu wrote: every time I read the R release notes for the next release, I see many functions that I had forgotten about and many functions that I never knew existed to begin with. (who knew there were bibtex facilities in R? obviously, everyone except me.) 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. I am thinking one categorization for function area (e.g., programming related for, say, deparse; and statistical model related for lm; and another categorization for importance (e.g., like common for lm and obscure for ..). Such categorizations require intelligence. if I am going to do this for myself, I think a csv spreadsheet may be a good idea to make it easy to resort by keys. I don't think all if those exist already, but the help system gives indices for each package and, within the core packages, things are relatively well categorized simply by knowing the package they're in. Not a full answer, but perhaps saves you a bit of time. Michael regards, /iaw Ivo Welch (ivo.we...@gmail.com) [[alternative HTML version deleted]] __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code. __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.
Re: [R] custom startup/welcome message
On Thu, Apr 4, 2013 at 9:49 AM, lejeczek pelj...@yahoo.co.uk wrote: yeap, I've done it, I was hoping for a complete customization, and even Rprofile.site adds only to what is being printed by default anyway, I mean that header is always there. R version. untill Type 'q()'.. and R -q silences everything :( I'm not sure what the question is now (and please context post instead of top-posting) -- I suppose you could patch the C code that prints that message if you want it to say something else. You'd have to re-build R but it's easy code to change. It's at the top of $R_HOME/src/main/version.c: http://svn.r-project.org/R/trunk/src/main/version.c Michael On 04/04/13 15:01, Michael Weylandt wrote: On Apr 4, 2013, at 6:20, lejeczek pelj...@yahoo.co.uk wrote: hi everybody I wonder if there is a simple way, but not simple would be ok too, to customize info/welcome page at session start time? Probably easiest to do it by way of some cat() calls in your .Rprofile. See ?Startup for details. MW what I'd like to do is to put together simple short howto / dos don'ts page for users, I'm thinking it would be great if it was possible many thanks [[alternative HTML version deleted]] __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code. __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code. __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.
Re: [R] plot in log scale in both x-axis and y-axis
On Thu, Apr 4, 2013 at 3:35 PM, capricy gao capri...@yahoo.com wrote: I am trying to plot(x,y, log=y), which gives me log scale on y axis only. I wonder if there is way so that I can plot log scale on both of x and y axis. plot(x, y, log = 'xy') Cheers, MW Thanks a lot:) [[alternative HTML version deleted]] __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code. __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.
Re: [R] about subsetting vectors/list in R
On Thu, Apr 4, 2013 at 7:46 PM, Abhishek Pratap abhishek@gmail.com wrote: Hey Guys Getting spinned about a slick way to join every 2 entry in a list / vector in R x=(rep(c('A','G','C','T'),1000)) A G C T A G C T etc form another list with entries as AG CT AG etc Not super slick but: by_two - function(x, collapse = ){ dim(x) - c(length(x) / 2, 2) apply(x, 1, function(y) paste(y, collapse = collapse)) } Cheers, MW __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.
Re: [R] categorized complete list of R commands?
On Thu, Apr 4, 2013 at 1:54 PM, ivo welch ivo.we...@gmail.com wrote: ## must be started with R --vanilla all.sources - search() d - NULL for (i in 1:length(all.sources)) { all.functions - ls(search()[i]) N - length(all.functions) if (N==0) next d - rbind(d, data.frame( src=rep(all.sources[i], N), index=1:N, fname=all.functions ) ) } Allowing myself to get slightly off-topic, this is really rough code and commits all sorts of performance / style sins. The big one, however, is the strange use of iteration: what is the point of all.sources? Do we need to run search() so many times? We never actually need the index, only the values, so why not iterate on those. The same code could be written like this: d - NULL for(pkg in search()){ all.functions - ls(pkg) N - length(all.functions) if(N == 0) next d - rbind(d, data.frame(src = rep(pkg, N), index = 1:N, fname = all.functions) } For more on why / how this is better, check out the talk Loop like a Native from the recent PyCon. But wait, there's more! repeated rbinding is not great for performance. Better to collect all the results in a list and then put them together in one step: base_packages - search() L - vector(list, length(base_packages)) for(pkg_no in seq_along(back_packages)){ pkg - base_packages[pkg_no] all.functions - ls(pkg) N - length(all.functions) if(N == 0) next L[[pkg_no]] - data.frame(src = rep(pkg, N), index = 1:N, fname = all.functions) } do.call(rbind, L) But now we're back to the almost unnecessary loop variable: we can kill it by using named lookups on L. base_packages - search() L - vector(list, length(base_packages)) names(L) - base_packages for(pkg in back_packages){ all.functions - ls(pkg) N - length(all.functions) if(N == 0) next L[[pkg]] - data.frame(src = rep(pkg, N), index = 1:N, fname = all.functions) } do.call(rbind, L) But do we really want to handle the set up ourselves? Probably best to let R take care of it for us. If we can abstract our loop into a function we can lapply() it. The insight is that we are taking the output of search() as a list and doing our operation to it, so let's try: do.call(rbind, lapply(search(), function(pkg){ all.functions - ls(pkg) N - length(all.functions) if(N == 0) NULL else data.frame(src = rep(pkg, N), index = 1:N, fname = all.functions) }) Note that we don't assign, but simply return from the anonymous function in this case. I've also passed straight to rbind() just to make it quick. And, as Bert noted, it'd be best to actually filter on functions, but let's leave that as an exercise to the reader for now. None of this code is tested, but hopefully it's more efficient and idiomatic. Cheers, Michael __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.
Re: [R] about subsetting vectors/list in R
On Thu, Apr 4, 2013 at 7:55 PM, Abhishek Pratap abhishek@gmail.com wrote: On Thu, Apr 4, 2013 at 5:53 PM, R. Michael Weylandt michael.weyla...@gmail.com wrote: by_two - function(x, collapse = ){ dim(x) - c(length(x) / 2, 2) apply(x, 1, function(y) paste(y, collapse = collapse)) } Thanks.. just wondering if this will be slick for list/vectors with 100 thousands of entries. ? No, the apply() loop likely isn't optimal. But I can do x - rep(letters, length.out = 1e6) system.time(by_two(x)) # Approx 15 seconds on my slow old machine so this might be one of those cases of good enough and come worry about it if profiling shows its a real bottle neck later. __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.
Re: [R] speedometer charts in R
Look at the R GoogleVis package. MW On Tue, Apr 2, 2013 at 9:42 AM, andrija djurovic djandr...@gmail.com wrote: Hi useRs. Does anybody know if there is some function that creates speedometer chart in R? Or if anybody has proposals where to start looking and which functions I can modify in order to create this kind of chart? Thanks for any help Andrija [[alternative HTML version deleted]] __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code. __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.
Re: [R] plot
On Mon, Apr 1, 2013 at 5:05 PM, Trying To learn again tryingtolearnag...@gmail.com wrote: Hi all if I plot a graph on R, I press on the plot Export/Save Plot as Image I assume this means you're using R-Studio? I change name on File name: I select DirectoryBibliotecas\Documentos And select Width 800 and Height 800 And finally save in format JPEG It is posible to type code so that I can run my function and it is not necessary to make it manually? Yes -- in fact that's the way you're supposed to do it and the RStudio way you mentioned above is a shortcut. E.g., jpeg() plot(1:5) dev.off() Read ?jpeg for more details. MW Thanks in advance. [[alternative HTML version deleted]] __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code. __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.
Re: [R] 0e+00
On Fri, Mar 29, 2013 at 10:44 AM, Shane Carey careys...@gmail.com wrote: Hi, Rather than a graph label to display labels as 0e+00, how do I get it to display the real value? Hi Shane, Is 0e+00 not a real value? I'd assume it's roughly equal to zero... ;-) More seriously, could we have a reproducible example: http://stackoverflow.com/questions/5963269/how-to-make-a-great-r-reproducible-example focusing particularly on whether you are using base, lattice, or ggplot2 graphics. Michael Thanks -- Shane [[alternative HTML version deleted]] __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code. __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.
Re: [R] QUESTION ON ROUNDING
On Thu, Mar 28, 2013 at 6:21 PM, Andras Farkas motyoc...@yahoo.com wrote: Dear All, wonder if you have a thought on the following: I am using the round(x,digits=3) command, but some of my values come out as: 0.07099 AND 0.06901. Any thoughts on why this maty be happening or how to eliminate the problem? I'd guess you've played with the default digits for print() (perhaps via options) but a reproducible example would be terribly lovely. MW apreciate the help, Andras [[alternative HTML version deleted]] __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code. __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.
Re: [R] From Java to R OOP
On Mon, Mar 25, 2013 at 6:51 AM, Francisco J. Bido b...@mac.com wrote: Hi, I'm new to OOP in R so please forgive the naiveness of some of the questions. Here are a couple of them. It would be great if you can contrast to OOP in Java. Java is not the end-all of OOP (in fact S is a good bit older than Java) and you might find that the Lisp or Dylan object systems are a better analogy. (I'm only going by hearsay on Dylan; never used it myself) You might also quickly breeze through: https://github.com/hadley/devtools/wiki/S3 1. R's S4 appears to centered around a dispatch mechanism which in my understanding is just a way to implement polymorphism. Now, here's the snag, I thought polymorphism was an aspect of OOP not by itself the definition of OOP. What am I missing here? Is any language that implements polymorphism automatically OO? If you accept the immutability of objects, then arguably yes, I suppose polymorphism gives you a great deal of it. The remaining weaknesses are generally addressed by the S4 object system. (Not immutability of bindings like Haskell, but the fact that x - y - 1:5; y[3] - 10 won't change x. In theory this is done by creating a new y with the modified 3rd element and binding the name y to that; not entirely thus in practice for performance reasons ) 2. Can someone provide a simple example of how NextMethod() works? I read some things about but I can't make any sense out of it. It's supposed to facilitate inheritance but how? Why is it needed, what happens if it's ignored? An example would be useful. Is there a Java equivalent of NextMethod()? Grepping through R's source, it seems that the print system uses a fair amount of NextMethod for the AsIs and noquote print methods. You might take a look at those: also, section 7 of http://cran.r-project.org/doc/manuals/r-devel/R-exts.html MW Many Thanks! __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code. __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.
Re: [R] error while extracting the p-value from adf.test
On Fri, Mar 22, 2013 at 2:03 PM, Yuan, Rebecca rebecca.y...@bankofamerica.com wrote: Hello all, I tried to extract the p-value from adf.test in tseries; however, I got the error message such as ht=adf.test(list.var$aa) ht$p-value Error in ht$p - value : non-numeric argument to binary operator ht Augmented Dickey-Fuller Test data: list.var$aa Dickey-Fuller = -2.3147, Lag order = 4, p-value = 0.4461 alternative hypothesis: stationary ht$data [1] list.var$aa ht$p-value Error in ht$p - value : non-numeric argument to binary operator ht$p NULL I do not have problem extracting the data in ht, but why not p-value? Is that because the - between p and value? Basically yes: x$p-value parses as x[[p, exact = FALSE]] - value instead of x[[p-value, exact = FALSE]] because `p-value` is not a syntactic name. I think a more common name for R would be p.value which is perfectly fine. MW Thanks, Rebecca -- This message, and any attachments, is for the intended r...{{dropped:5}} __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code. __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.
Re: [R] How to look at the source code for predict()
getS3method(predict, arima) Cheers, MW On Wed, Mar 20, 2013 at 6:43 PM, Yuan, Rebecca rebecca.y...@bankofamerica.com wrote: Hello all, I thought I found it, it is in the arima.R if I use arima to fit the model. But how could we see the source code of some function in R? Thanks, Rebecca From: Yuan, Rebecca Sent: Wednesday, March 20, 2013 2:38 PM To: R help Subject: How to look at the source code for predict() Hello, I try to look at the source code of predict() it turns out that I cannot find it. I can see it with debug(library), but not efficient. Can someone help? Thanks, Rebecca -- This message, and any attachments, is for the intended r...{{dropped:5}} __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code. __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.
Re: [R] How to look at the source code for predict()
On Wed, Mar 20, 2013 at 6:49 PM, R. Michael Weylandt michael.weyla...@gmail.com wrote: getS3method(predict, arima) Pardon -- it's either Arima or arima0 but not arima in this case. But, in general, getS3method is what you're looking for. Cheers, MW __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.
Re: [R] creating a new variable.
On Tue, Mar 19, 2013 at 4:33 AM, Nicole Ford nicole.f...@me.com wrote: Hello, all. The following is for my own research. I have attached the relevant data in pdf from Transparency International. I am only interested in the CPI 2010 scores column. I am interested in creating a variable for several of these countries. The idea is, they will become a country level aggregate IV corruption. I am running models on about 10 countries, individually. The DV will be essentially democracy with some other controls. I have the dv coded and need help with the IV. I am interested in how to create a new variable for CPI. This is new to me. I have created some variables (some complex some not so complex) but usually I do not need to create variables my own variables from scratch so I really don't know how to do this. I looked online but have not been able to find anything relevant. I am sure something is out there and I am missing it. CPI is ranked 1-10. 10= least amount of corruption, 1 being the most. It is continuous. For example, Russia is ranked at 2.1; how would I create a variable for Russia? Once I get one, I know I will get the others. How is that 2.1 calculated? You might want the ?transform or ?within functions if it's easily expressed as a function of other variables in your data frame. MW Any direction would be very helpful: a link, command, etc. Thanks in advance. ~Nicole Ford Ph.D. student Graduate Assistant/ Instructor University of South Florida Government and International Affairs office: SOC 012M __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code. __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.
Re: [R] phyper returning zero
On Fri, Mar 15, 2013 at 8:52 AM, elliott harrison e.harri...@epistem.co.uk wrote: Hi, I am attempting to use phyper to test the significance of two overlapping lists. I keep getting a zero and wondered if that was determining non-significance of my overlap or a p-value too small to calculate? overlap = 524 lista = 2784 totalpop = 54675 listb = 1296 phyper(overlap, lista, totalpop, listb,lower.tail = FALSE, log.p=F) [1] 0 If you set log.p = T, you see that the _log_ of the desired value is -800, so it's likely simply too small to fit in a IEEE double. In sort, for all and any practical purposes, your p-value is zero. Cheers, MW __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.
Re: [R] Creating a hyperlink in a csv file
On Fri, Mar 15, 2013 at 10:52 AM, Brian Smith bsmith030...@gmail.com wrote: Hi, I was wondering if it is possible to create a hyperlink in a csv file using R code and some package. For example, in the following code: A csv file is a plan text file and by definition doesn't have hyperlinks. If you want a hyperlink, you'll need to export to a different format or use a reader which will interpret a URL as a hyperlink automatically. MW __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.
Re: [R] plotting
I think you'll find this easiest with ggplot2: library(ggplot2) ggplot(dat, aes(x = value, y = time, color = group, symbol = id)) + geom_point() # symbol = might not be the right argument -- I'm doing this from memory or similar MW On Thu, Mar 14, 2013 at 3:46 PM, li li hannah@gmail.com wrote: Hi alL, I have a data frame with 4 columns: value, time, group and id. I would like to plot value vs. time with different colors for different levels of group and different symbols for different values of id. I think I could do this but I would like to see what is an easier way to plot the data this way. Thank you vey much. Hanna [[alternative HTML version deleted]] __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code. __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.
Re: [R] Calculation with date
On Sat, Mar 9, 2013 at 11:41 AM, Christofer Bogaso bogaso.christo...@gmail.com wrote: Hello again, Let say I have an non-negative integer vector (which may be random): Vec - c(0, 13, 10, 4) And I have a date: Date - as.Date(Sys.time()) Date [1] 2013-03-09 Using these 2 information, I want to get following date-vector: New_Vec - c(2013-03-01, 2014-04-01, 2014-01-01, 2013-07-01) Basically the month-difference between 'New_Vec' and 'Date' will be 'Vec ' Is there any R function to do it programmatically? Do you always want the first day of the month? If so, I think library(zoo) ?yearmon is what you are looking for. Specifically: convert to yearmon, add in the month difference, convert back to date to get the first day of the month. Cheers, MW Thanks for your help. __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code. [[alternative HTML version deleted]] __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.
Re: [R] quesion about lm function
On Sat, Mar 9, 2013 at 10:35 AM, meng laomen...@163.com wrote: Hi all: My data is in the attachment. I want to analysis the mean difference of y between 2 sex. My code: result_lm-lm(y~factor(sex) + x1 + x2) summary(result_lm) The result of factor(sex)m 136.83, is the mean difference of y between 2 sex,and the corresponding p value is 0.07618. My question is: how to get the mean y of sex(m) and sex(f) respectively via lm function? lm() would be overkill no? I'd just use tapply(), by(), ave(), or the like: e.g., tapply(dat$y, dat$sex, mean) Cheers, MW [[alternative HTML version deleted]] __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.
Re: [R] Feedback – Regarding R Programming Language Version 2.15.1 (2012-06-22) Usage
Please do not massively cross-post and provide a reproducible example (search stack overflow or other sites for advice on how to do so) I _guarantee_ you R is not broken in this sense. MW On Sat, Mar 9, 2013 at 4:02 PM, Sujit Das reach.sujit...@gmail.com wrote: Dear Sir / Madam, I am using R Programming Language Version 2.15.1 (2012-06-22) for sometime in a 32 bit PC running Windows OS (Platform: i386-pc-mingw32/i386 (32-bit)). During the execution / interpretation of the R script, sometimes it is found that behavior of the program is not consistent with the program structure. For example, it has been seen that, even if a condition inside an IF statement is not TRUE, the sequence of statements enclosed by parentheses { }, which follows IF statement is executed. And this should not be the case. May I know the exact reason for such kind of Erroneous behavior of the R program? Is it the flaw in the Design of R Interpreter or there is some other reason behind that? Though as a user of R Programming Language, I understand that R is free software and comes with ABSOLUTELY NO WARRANTY. Your valuable remark and guidance will lead us to destiny. With regards, Yours faithfully, SUJIT DAS -- SUJIT DAS KOLKATA,INDIA PHONE:0-9891348950(O) PHONE:0-9830658211(H) [[alternative HTML version deleted]] __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code. [[alternative HTML version deleted]] __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.
Re: [R] Unexpected behavior looping through sequence of dates
On Sat, Mar 9, 2013 at 6:50 PM, David Winsemius dwinsem...@comcast.net wrote: I was unable to find the reason for the original coercion in the help(for) page or the R Language Definition entry regarding for-loops. On the hunch that coercion via as.vector might be occurring, Behaviorally, it seems to, but the code for do_for in eval.c has factors special-cased to call asCharacterFactor so that might not be a robust detail to rely on. The relevant behavior seems instead to be that there's a switch on val_type which creates the loop index but doesn't copy all attributes (like class) Note that this means a user's as.vector wouldn't be called here: as.vector.flub - function(x, ...) letters[x] foo - 1:5 class(foo) - flub as.vector(foo) for(j in foo) {print(j); print(class(j))} as.vector.grub - function(x, ...) match(x, letters) bar - letters[1:5] class(bar) - grub as.vector(bar) for(j in bar) {print(j); print(class(j))} Cheers, Michael __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.
Re: [R] Error: no 'dimnames' attribute for array
On Thu, Mar 7, 2013 at 11:02 AM, eliza botto eliza_bo...@hotmail.com wrote: Dear XpeRts, I prepared a no qoute Character string by the following command s-noquote(paste (b1, collapse=,)) where, b1 is the vector of 24 intergers. dput(b1) c(1L, 2L, 6L, 7L, 12L, 16L, 17L, 20L, 21L, 23L, 25L, 34L, 46L, 48L, 58L, 64L, 65L, 68L, 82L, 97L, 98L, 101L, 113L, 115L) dput(s) structure(1,2,6,7,12,16,17,20,21,23,25,34,46,48,58,64,65,68,82,97,98,101,113,115, class = noquote) I want to use s in the following command matb1-res[,c(s))] The objective is to call those columns of matrix res, whose numbers have been defined in s. But when i plug s into matb1 i get the following error Error: no 'dimnames' attribute for array How can i get rid of it?? thanks in advance I may be way off-base here, but can't you just use res[, b1]? As to the explanation as to why you get that error, let's just say it's because c(s) doesn't result in a numerical vector and leave it at that. Cheers, MW Eliza [[alternative HTML version deleted]] __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code. __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.
Re: [R] Error: no 'dimnames' attribute for array
On Thu, Mar 7, 2013 at 11:19 AM, eliza botto eliza_bo...@hotmail.com wrote: Thankyou very much M. Weylandt. i was actually more interested in knowing about the error. Let's talk you through it then: As you said before you have b1 - c(1L, 2L, 6L, 7L, 12L, 16L, 17L, 20L, 21L, 23L, 25L, 34L, 46L, 48L, 58L, 64L, 65L, 68L, 82L, 97L, 98L, 101L, 113L, 115L) in your session. And from there you create: s-noquote(paste (b1, collapse=,)) So let's take that apart: you take a set of integers (and integer vector) and collapse it using the paste() function. This returns a character string. You pass the resulting character string to noquote() which is a relatively obscure function. However, it's not a hard one: it basically attaches the noquote class to the object which allows it to act in almost entirely the same way, but to be printed without quotes. Note the difference in print(paste(b1, collapse = , )) and print(noquote(paste(b1, collapse = , ))) So anyways, now you've got s and you use it to subscript a matrix. Here R makes a decision that surprises you: it tries to interpret s as a character vector! (because it is one) So what does it mean when you subset by a character vector instead of a numeric index: well, to pull out the apropriate row or column by _name_ instead of by position. To do this requires knowing the names: so R looks for the relevant names, which are normally stored in a property called dimnames (dimension names). Your matrix, however, doesn't seem to have any dimnames, so R throws an error saying (in effect) you want me to get the rows by this name and I am totally willing to do so, but there's this tiny little issue: there aren't any names... Now this could have turned out differently: your matrix could have had some names, but none which matched s. Then you'd simply have successful subsetting with no result, not unlike computing b1[0]. A much more subtle error. So you should actually consider yourself lucky you got the error at this stage instead of having to hunt it down in a much more subtle form later. So how did I know all of this? Aside from some general familiarity with R, I used the str() function which lets me take a look at what sort of thing things in R are. (Say that three times fast!) When I applied it to str(s) I found that s was a character vector of class noquote -- and that's what made it all clear that your numbers weren't really being interpreted as numbers because, well, they really weren't numbers from R's point of view. Again, and just to make that last point clear: they weren't numbers because there's a fundamental difference between 3 and 3 in computers. One is the integral successor of 2, the other is a way that humans happen to denote it at certain points in history in certain computational contexts. Some languages like Perl let you play a bit fast and loose with this distinction, but I don't think anyone would argue that R needs to be more forgiving in its type system. Cheers, MW __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.
Re: [R] lm Regression takes 24+ GB RAM - Error message
On Wed, Mar 6, 2013 at 9:51 AM, Jonas125 schleeberge...@pg.com wrote: Hello, I am a rather unexperienced r-user (learned the language 1 month ago) and run into the following problem using a local computer with 6 cores 24 GB RAM and R 2.15 64-bit. I didn't install any additional packages 1. Via the read.table command I load a data table (with different data types) which is about 730 MB large 2. I add 2 calculated columns 3. I split the dataset by 5 criteria 4. I run the lm command on the split with the calculated columns as the variables The RAM consumption goes rapidly up and stays at 24 GB for a couple of minutes. The result: Error: cannot allocate vector size of 5.0 Mb In addition: There ware 50 or more warnings (use warnings() to see the first 50) -- Reached total allocation of 24559Mb So it seems R has access to all your memory. My guess is that you have so-called factors [Categorical variables] in your dataset and this makes the linear regression a much larger calculation (in the intermediate steps) than you might realize because the design matrix has to deal with all the crossed categories. Can you provide the output of str(DATA_SET)? MW My code works perfectly fine for a smaller dataset. I am surprised about the errors as the CPU should do all the work with the lm calculations and the output cannot be that large, can it??? (I cannot check the object size of the lm object due to the error) Right now I am running only 1 linear model, but actually I wanted to run 6! Is Windows putting some restrictions on R regarding the RAM usage? Can I change any settings? A RAM upgrade is not an option. Do I need to use a different R package instead (bigmemory?)? Not a bad idea. Thanks in advance for your help!! -- View this message in context: http://r.789695.n4.nabble.com/lm-Regression-takes-24-GB-RAM-Error-message-tp4660434.html Sent from the R help mailing list archive at Nabble.com. __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code. __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.
Re: [R] Simulate binary correlated data
On Tue, Mar 5, 2013 at 7:07 PM, Marbles max-ihm...@gmx.de wrote: Dear R experts, I am trying to simulate correlated binary data and have stumbled upon the following problem: With the help of binarySimCLF or mvpBinaryEp I have been able to simulate correlating binary vectors given certain mean values and a desired correlation. My problem is that these procedures do not allow you to specify the exact vector for which you want to generate a correlated vector. Is there anyway to do this? Maybe I can clarify my question by explaining what my goal is: I want to generate one Binary Vector (A), generate a correlated binary Vector (B), then generate a third binary Vector (C) that is correlated to B so that I can then see the occuring correlations between A and C. IIRC, knowing the correlation between A B and the correlation between B C is not enough to uniquely specify the correlation between A C (or perhaps even to bound it). Therefore i think your question is ill-defined. Though I might be wrong in the specific case of binary variates... Cheers, MW Thank you in advance, Marbles -- View this message in context: http://r.789695.n4.nabble.com/Simulate-binary-correlated-data-tp4660366.html Sent from the R help mailing list archive at Nabble.com. __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code. __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.
[R] Wilcox-Off?
A potentially ridiculous question, but why does R use wilcox (e.g., pwilcox or wilcox.test) instead of the full name Wilcoxon? I've browsed (but not scoured) the help files and Peter Dalgaard's book, but I'm coming up empty. Purely for brevity or have I missed something massive? ## Reproducible example ;-) ? wilcox.test ## End Reproducible Example Cheers, Michael __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.
Re: [R] Errors-In-Variables in R
Based on your comments in the (not-a-)bug report, I *think* this might help: quanttrader.info/public/betterHedgeRatios.pdf or more generally, the idea of total least squares regression. Cheers, MW On Sat, Mar 2, 2013 at 9:55 PM, Cedric Sodhi man...@gmx.net wrote: Perhaps it would have been clearer that this is no homework if I hadn't forgotten to say what [1] is. Sorry for that. [1] https://bugs.r-project.org/bugzilla3/show_bug.cgi?id=15225 (This is no homework but genuinely adresses the problem that R to my knowledge does not have models for error in variables) On Sat, Mar 02, 2013 at 09:34:21PM +, Rui Barradas wrote: There's a no homework policy in R-help. Rui Barradas Em 02-03-2013 18:28, Cedric Sodhi escreveu: In reference to [1], how would you solve the following regression problem: Given observations (X_i,Y_i) with known respective error distributions (e_X_i,e_Y_i) (say, 0-mean Gaussian with known STD), find the parameters a and b which maximize the Likelihood of Y = a*X + b Taking the example further, how many of the very simplified assumptions from the above example can be lifted or eased and R still has a method for finding an errors-in-variables fit? __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code. __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code. __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.
Re: [R] R software installation problem
On Mon, Feb 25, 2013 at 10:24 AM, Andy Siddaway andysidda...@googlemail.com wrote: Dear Sarah, Thanks for your email. I'll describe the problm but without the screenshots then. Firstly, I think I’ve correctly installed R. I have installed R for Windows via the R site, CRAN and then UK – University of Bristol or UK – Imperial College London. Both times, I have installed the ‘base’ version. I installed the 64-bit version, which I’m running (I’ve got Office 2010). When installed, R appears to be same (in terms of the menus and layout) as the screenshots shown as part of youtube R installation tutorials - except for the following (error?) message, which I have exactly copied and pasted below. This message is displayed in the R Console box and I cannot close this box or open a new script: That's not an error message; it's the regular 'welcome to R' message. Not on though, so no comments on new script / closing boxes and all that. Cheers, MW R version 2.15.2 (2012-10-26) -- Trick or Treat Copyright (C) 2012 The R Foundation for Statistical Computing ISBN 3-900051-07-0 Platform: x86_64-w64-mingw32/x64 (64-bit) R is free software and comes with ABSOLUTELY NO WARRANTY. You are welcome to redistribute it under certain conditions. Type 'license()' or 'licence()' for distribution details. Natural language support but running in an English locale R is a collaborative project with many contributors. Type 'contributors()' for more information and 'citation()' on how to cite R or R packages in publications. Type 'demo()' for some demos, 'help()' for on-line help, or 'help.start()' for an HTML browser interface to help. Type 'q()' to quit R. This ‘Trick or Treat’ message also appears (in the Console box) when I downloaded RStudio. Any tips or guidance on resolving this problem would be really appreciated! Many thanks, Andy Siddaway On 25 February 2013 00:10, Sarah Goslee sarah.gos...@gmail.com wrote: Hi Andy, This list strips most forms of attachments. Instead, you need to tell us what OS and version you're using, how you're trying to install, and what's going wrong, in detail. Sarah On Sun, Feb 24, 2013 at 8:58 AM, Andy Siddaway andysidda...@googlemail.com wrote: Dear R-help, Please could I have some quick guidance on what I'm doing wrong when trying to instal R software? (I have read the R-FAQs and instructions, and watched youtube instructional videos on installing R, but they didn't help) I've attached screenshots to hopefully make what I've done clearer. Basically, R doesn't seem to be installing correctly and I can't figure out why. It's probably a simple error which a non-(complete)-novice would notice. Thanks very much, Andy Siddaway Trainee Clinical Psychologist University of Hertordshire (UK) -- Sarah Goslee http://www.functionaldiversity.org [[alternative HTML version deleted]] __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code. __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.
Re: [R] How to debug the C programs associated with R-packages?
On Sun, Feb 10, 2013 at 4:30 PM, Pulkit Mehrotra mehrotra.pul...@gmail.com wrote: Dear sir, Thank you for your reply and suggestions. Gdb is exactly the thing I was looking for. Will certainly report the bug on R-devel if found so. More likely (though not impossible that it's otherwise) the bug is in a CRAN (contributed) package and you would be advised to contact the package maintainer (whose contact info is available through the maintainer() function) instead as he would be the only one who could fix it. MW __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.
Re: [R] different behavior of $ with string literal vs string variable as argument
On Sun, Feb 10, 2013 at 9:06 PM, David Romano drom...@stanford.edu wrote: Hi everyone, I ran into the issue below while trying to execute a command of the form apply(list.names,1, function(x) F(favorite.list$x) ) where list.names is a character vector containing the names of the elements of favorite.list and F is some function defined on a list element. Namely, the $ operator doesn't treat the string variable 'x' as the string it represents, so that, e.g. ll - list(ss=abc) ll$ss [1] abc ll$ss [1] abc but name - ss ll$name NULL I can get around this by using integers and the [[ and [ operators, but I'd like to be able to use names directly, too -- how would I go about doing this? You've already found it: the bracket operators MW Thanks for your help in clarifying what might be going on here. David [[alternative HTML version deleted]] __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code. __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.
Re: [R] Saving model and other objects from caret
On Thu, Feb 7, 2013 at 9:58 PM, James Jong ribonucle...@gmail.com wrote: What are the *RDS counterparts? What is the difference? apropos(RDS) ? readRDS ? saveRDS They allow serialization of an individual object and restoring it -- the advantage is that you can restore to a different name instead of clobbering any pre-existing object with the name under which it was originally serialized. MW __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.
Re: [R] R intermittently crashes across cluster
On Thu, Feb 7, 2013 at 2:07 PM, Ken Weiss kgwe...@umich.edu wrote: Greetings, I am having an interesting problem and I wonder if anyone else has seen this behavior. I am running R 2.11.1 with SNOW 0.3-3 on a Dell cluster running CentOS 5.5. Simplest suggestion -- can you update to current R and use the inbuilt parallelism facilities there? It's not improbable that your problem has already been dealt with. MW I create my cluster using: cluster- makeCluster(nodes,type=SOCK,port=10191) # nodes is a vector of compute nodes I then wrap a loop around clusterApplyLB to evaluate my function multiple times, with different parameters, without recreating the cluster every time. The following code segment shows what I am trying to do: for (j in loopstart:loopend) { call.m=list( step1=T, dat=x.m[,c(1:7, j)] # x.m is data from a csv file read into a table ) clusterApplyLB(cluster,c(10:100),test.each.term,call=call.m) } stopCluster(cluster) The problem that I am having is that sometimes it will run for 50 iterations of this loop then crash. Sometimes 15 iterations, sometimes 2. When the crash happens, I receive the following error message every time: Error in checkForRemoteErrors(val) : one node produced an error: cannot open the connection Calls: clusterApplyLB - dynamicClusterApply - checkForRemoteErrors Execution halted Any ideas as to what might be going on? I have run this code successfully many times when I do not use the loop. I have a lot of data to process and recreating the cluster every time that I want to run my function is a waste of time. Thanx, Ken For I know the plans I have for you, declares the LORD, plans to prosper you and not to harm you, plans to give you hope and a future. - Jeremiah 29:11 Check out the website http://www.amazingfacts.org/ for answers to Bible questions that will change your life. [[alternative HTML version deleted]] __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code. __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.
Re: [R] compare objects in two different workspaces
On Thu, Feb 7, 2013 at 5:53 PM, Shi, Tao shida...@yahoo.com wrote: Hi list, Is there a easy way to compare objects in two different workspace files (i.e. .RData files) in R? I can use some generic file compare softwares (e.g. BeyondCompare) to binary comparison, but when it says they're different you can't tell where the difference are from. Load them both and compare within R? MW Thanks! Tao __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code. __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.
Re: [R] Split xts data set into weeks
On Sun, Feb 3, 2013 at 6:57 AM, Seimizu Joukan saim...@gmail.com wrote: Would you please paste the following codes to R console and make a confirmation? Indeed, well done and much appreciated. #Codes start from here library(quantmod) tmp-structure(c(112.34, 112.89, 112.75, 113.5, 115.16, 115.21, 114.84, 114.93, 115.05, 114.46, 113.34, 113.71, 113.56, 115.08, 115.97, 115.26, 115.22, 115.24, 115.24, 114.98, 111.96, 112.75, 112.5, 113.1, 114.85, 114.55, 114.55, 114.75, 114.2, 112.92, 112.87, 112.8, 113.54, 115.05, 115.06, 114.85, 114.93, 115.09, 114.28, 113.92), class = c(xts, zoo), .indexCLASS = Date, tclass = Date, .indexTZ = , tzone = , index = structure(c(1298818800, 1298905200, 1298991600, 1299078000, 1299164400, 1299423600, 129951, 1299596400, 1299682800, 1299769200), tzone = , tclass = Date), .Dim = c(10L, 4L), .Dimnames = list(NULL, c(Open, High, Low, Close))) class(tmp) (res1-split(tmp,f=weeks)) (res2-split(tmp,frequency=weeks)) Looking at args(split.xts) I think you actually do want split(..., f = ) here, not split(..., frequency = ), which would ignore and default to months. I get the following for res1, running R-Devel on OS X 10.6.8: res1 [[1]] Open HighLow Close 2011-02-27 112.34 113.34 111.96 112.87 [[2]] Open HighLow Close 2011-02-28 112.89 113.71 112.75 112.80 2011-03-01 112.75 113.56 112.50 113.54 2011-03-02 113.50 115.08 113.10 115.05 2011-03-03 115.16 115.97 114.85 115.06 2011-03-06 115.21 115.26 114.55 114.85 [[3]] Open HighLow Close 2011-03-07 114.84 115.22 114.55 114.93 2011-03-08 114.93 115.24 114.75 115.09 2011-03-09 115.05 115.24 114.20 114.28 2011-03-10 114.46 114.98 112.92 113.92 so I think it's likely a timezone issue. Try setting indexTZ(tmp) - GMT or something similar and giving it another shot. You might also want to move to the R-SIG-Finance class where the authors of xts are more frequently seen. It might also help to report Sys.timezone() in addition to your specific linux distro. Cheers, MW __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.
Re: [R] arithmetic and logical operators
R FAQ 7.31 (Note, this isn't R specific, rather it's a problem with the finitude of computers) MW On Wed, Jan 30, 2013 at 8:32 PM, Dave Mitchell dmmtc...@gmail.com wrote: Why, in R, does (0.1 + 0.05) 0.15 evaluate to True? What am I missing here? How can I ensure this (ostensibly incorrect) behavior doesn't introduce bugs into my code? Thanks for your time. Dave Mitchell [[alternative HTML version deleted]] __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code. __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.
Re: [R] platform specific Depends argument?
I think this is only a legacy question, right? In recent R, you can/should use parallel instead of either multicore or snowfall. That said, no answer if you want back compatability with older versions of R. MW On Mon, Jan 28, 2013 at 10:43 AM, Florian Schwaiger schwa...@mathematik.uni-marburg.de wrote: Dear R users, we have a problem when building R packages which depend on platform specific packages. The following example will illustrate our problem: For parallel computing (in our own package) we want to use the multicore package. Since multicore is not available for Windows we subtitute it by the snowfall package. Currently we create two packages with different Depends argument in the DESCRIPTION files (one for unix and one for Windows). We considered using the .onLoad function and calling library(multicore) resp. library(snowfall) depending on the employed system, but it is said in the help of that function that it is not Good practice to do so. Is there a better practice than building two packages (with the same name and almost same code) for the different platforms. Any help is appreciated. Matthias and Florian __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code. __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.
Re: [R] Query on package to use for investment quotes
I'd look into the quantmod package. Cheers, MW On Mon, Jan 28, 2013 at 1:52 PM, Bruce Miller batsnc...@gmail.com wrote: Hi all, Diverging from my research based number crunching I am interested to see what, if any R packages are out there that can access daily market values of investment funds (e.g. using http://quote.morningstar.com/fund/f.aspx?t=PDMIX) then store the data value (i.e. NAV =$11.56 ) with date retrieved so these can be plotted with ggplot2 on some regular basis. A web search turned up a confusing and complex array of R prediction models etc. but I am looking for plain vanilla way to retrieve fund values and store the values. Thanks, Bruce -- Bruce W. Miller, Ph.D. Conservation Ecologist Neotropical Bat Projects office details 11384 Alpine Road Stanwood, Mi. 49346 Phone (231) 679-6059 __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code. __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.
Re: [R] importing data
On Fri, Jan 25, 2013 at 6:11 AM, Ray Cheung ray1...@gmail.com wrote: Dear Michael, Thanks for your codes. However, lapply does not work in my case since I've some files missing in the data (say, the file data101.dat). Do you have any suggestions on this?? Thank you very much. You could simply add a test using file.exists() but I'm not sure what you want to do with the M matrix then -- omit the slice (so the others are all shifted down one) or fill it entirely with NA's. Michael __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.
Re: [R] How to name the elements of list
names(X) - c(0-10, 11-20) MW On Fri, Jan 25, 2013 at 9:39 AM, Tammy Ma metal_lical...@live.com wrote: HI, I have the array list: X-vector(list, 2) X[[1]] : data frame 1 X[[2]]: dataframe2 now i want to change index 1 and 2 into: 0-10 , 11-20 ,. finally I want to have X[[0-10]]:dataframe1 X[[11-20]]:dataframe2 how do I get them? Thanks a lot. Kind regards, Tammy [[alternative HTML version deleted]] __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code. __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.
Re: [R] importing data
On Wed, Jan 23, 2013 at 9:16 AM, Ray Cheung ray1...@gmail.com wrote: Dear All, Sorry for asking a newbie question. I want to ask how to import 1000 datasets whose file names are labelled from data1.dat to data1000.dat into R so that they are named M[1, , ] to M[1000, , ] accordingly. Thank you very much. , Hi Ray, I'm pretty sure you don't mean named M[1,,] etc. but rather that there's only one object M and that's how the slices come into existence: What you'll want to do is something like this: little_helpful_function(n){ file_name - paste(data, n, .dat, sep = ) read.dta(file_name, ##OTHER PARAMETERS) } list_of_datasets - lapply(1:1000, little_helpful_function) output - do.call(c, list_of_datasets) dim(output) - c(dim(list_of_datasets[[1]]), 1000) Or something like that. Note that I'm not quite sure what a dta file is, so I'll leave it to you to find an appropriate read.dta function. Feel free to write back (cc'ing the list) if you don't understand all of the above. Cheers, Michael Best Regards, Ray [[alternative HTML version deleted]] __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code. __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.
Re: [R] foreach takes foreever?
You're probably being killed by the overhead of parallelization which is, in this case, far more than actual computation time. I've not dug through foreach() in a while, but I think this winds up spawning many many subprocesses which isn't cheap in Windows. MW On Mon, Jan 21, 2013 at 3:59 PM, Andre Zege az...@yahoo.com wrote: I started to look at ways to improve times of certain very parallel tasks and thought that foreach should be a valid candidate to do the job. So, i opened foreach tutorial by Steve Weston and started timing examples from it. First example from tutorial is system.time(for(i in 1:10) sqrt(i)) user system elapsed 0.060.000.06 system.time(foreach(i=1:10) %do% sqrt(i)) user system elapsed 102.370.21 103.38 Hmm, 1700 time slower? second example is system.time(x - exp(1:100)) user system elapsed 0.340.030.42 system.time(x - foreach(i=1:100, .combine='c') %do% exp(i)) I stopped it at 958 seconds, didn't have enough patience -- it basically seems that foreach slows down this one down naive by more than 2000 times. I must be doing something very wrong. Am i supposed to set some environment variables before it works properly? I am running 64bit R on win7 dual core 2.27GHZ CPUs and 4GB memory laptop. [[alternative HTML version deleted]] __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code. __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.
Re: [R] Issue while installing Hmisc package
On Thu, Jan 17, 2013 at 12:57 PM, vaseem shaikh vsma...@gmail.com wrote: Hello Michael, I have tried with different CRAN but still i am getting the same error. Most likely you've got something blocking your network. Can you download the source / binary from the CRAN pages (using your web-browser) and then install from the command line? Hmisc doesn't require any special tools to build so that shouldn't be too hard. But still, i am also trying to install the package by locally giving absolute path with repos= Null and type = Source, will CRAN have any role to play here??? You can't escape CRAN entirely in this case (unless you know where the source is, which I don't) -- it's the distribution network. MW BR- Vaseem Shaikh On Thu, Jan 17, 2013 at 3:03 PM, Michael Weylandt michael.weyla...@gmail.com wrote: Try a different CRAN mirror. MW On Jan 17, 2013, at 7:42 AM, vaseem shaikh vsma...@gmail.com wrote: Hi, Please find the snap shot attached for the error reported wile installing Hmisc Package. Is there any thing you can help me with. Currently using R i386 2.15.2 Version of R on windows 7 platform. Ragards Vaseem Shaikh Instalation_Issue_HMISC.png __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code. __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.
Re: [R] how to use ...
On Thu, Jan 17, 2013 at 2:36 PM, Ivan Calandra ivan.calan...@u-bourgogne.fr wrote: Dear users, I'm trying to learn how to use the I have written a function (simplified here) that uses doBy::summaryBy(): # 'dat' is a data.frame from which the aggregation is computed # 'vec_cat' is a integer vector defining which columns of the data.frame should be use on the right side of the formula # 'stat_fun' is the function that will be run to aggregate stat.group - function(dat, vec_cat, stat_fun){ require(doBy) df - summaryBy(as.formula(paste0(.~,paste0(names(dat)[vec_cat],collapse=+))), data=dat, FUN=stat_fun) return(df) } [SNIP EXAMPLE -- THANK YOU FOR IT] Now summaryBy() has an ... argument and I would like to use it. For example, I would like to be able to add the trim argument to my call like this: stat.group(dat=my_data, vec_cat=1, stat_fun=mean, trim=0.2) Thanks for the great working examples! It's actually not too hard here -- just pass ... down as if it were an argument and let summaryBy() do the hard work of actually handling the dots: stat.group - function(dat, vec_cat, stat_fun, ...){ require(doBy) df - summaryBy(as.formula(paste0(.~,paste0(names(dat)[vec_cat],collapse=+))), data=dat, FUN=stat_fun, ...) return(df) } Also, note that as a matter of style, you can actually clean this up a little bit: R follows the trend of many functional languages in automatically returning the value of the last expression evaluated: stat.group - function(dat, vec_cat, stat_fun, ...){ require(doBy) summaryBy(as.formula(paste0(.~,paste0(names(dat)[vec_cat],collapse=+))), data=dat, FUN=stat_fun, ...) } Cheers, Michael __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.
Re: [R] Need help: R for repetitive tasks
list.files() to get all the files in the directory (use the pattern argument to be more specific). Then loop over the file names, reading in the data one at a time, do the desired processing, and then use the file name to make the graphics file name as well. Cheers, MW On Tue, Jan 15, 2013 at 12:30 PM, Simonas Kecorius simolas2...@gmail.com wrote: Dear R users, First of all I would like to thank all of you who replayed to my previous questions and problems. Thank you a lot for being great and helpful community. I highly appreciate your suggestions and ideas even if I do not respond after my question! But it means that your help was exactly what I needed. Thank you again! Now the following question I need help: Suppose I do have a file.txt in the working directory. This file contains the names of other files in the same directory: First.txt Second.txt Third.txt etc... Files First.txt, Second.txt...are data files. What I need R to do, is to read this file.txt line by line, open files which names are listed ( First.txt, Second.txt...) and process it: lets say make a FirstPlot.bmp, FirstSummary.txt and save it to working directory, then automatically open Second.txt, do the same, Third.txt etc. until the end of the names in file.txt. This would help me with the following task: I do measurements each day, and I need to process my data: draw some plots, make some analysis. When I have 30 days of measurements each 1 second, there are huge amount of numbers I am dealing with. If you could suggest some automation via R, it would be perfect. Thank you in advance. Cheers. -- Simonas Kecorius **Lithuania [[alternative HTML version deleted]] __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code. __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.
Re: [R] The three-dot question
Hi Feng, I'm afraid I don't entirely understansd your question -- the `...` construct only allows you to pass variable numbers of arguments, not to have arbitrary access to the parent frames. You need to manually extract b from the dots inside of testFun. Also, it's quite frowned upon to put ##rm(list = ls())## in your examples: it's the mailing list equivalent of asking a buddy to come over to help you move and then punching him in the face when he tries to lift your sofa. Cheers, Michael On Mon, Jan 14, 2013 at 10:21 AM, Feng Li m...@feng.li wrote: Dear all, Why does not the three-dot accept arguments from the parent environment? I am just confused with this error, can someone give me a hint? rm(list=ls()) testFun - function(a, ...) + { + if(a){ + print(a) + }else + { + print(b) + } + } myTask - function(a) + { + b - 3 + testFun(a, b = b) + } myTask(FALSE) Error in print(b) : object 'b' not found Thanks in advance! Feng -- Feng Li Department of Statistics Stockholm University SE-106 91 Stockholm, Sweden http://feng.li/ __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code. __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.
Re: [R] function coverage
Possibly you could trace() all the functions you're interested in. E.g., lapply(ls(package:stats), trace) # Untested. MW On Mon, Jan 14, 2013 at 9:08 PM, Ross Boylan r...@biostat.ucsf.edu wrote: Is there an easy way to identify all the functions called as a result of invoking a function? Getting the calling hierarchy too would be nice, but is definitely not essential. I'm trying to understand someone else's package, which is in a namespace and has some S3 functions. I could probably live without tracing the S3 functions. All the functions I want to trace are in R. The code passes functions around as arguments, so that the function being called is not always obvious from inspection of the source immediately around the call. I can imagine a solution that went something like this: 1. identify all functions by searching the sources for - function( (probably only at the left margin, to avoid attempting to trace functions defined inside of functions). 2. Write a function that wraps another function to record the fact that it has been called. 3. Somehow replace all functions with their wrapped equivalents. 4. make the top level call. 5. inspect the data constructed by the wrapper. The code is recursive and iterative; manual stepping does not seem feasible. The package includes a lot of earlier versions of the code, and so I suspect that a lot of the code is not active. Thanks. Ross Boylan __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code. __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.
Re: [R] ./R: error while loading shared libraries
I'd move this to the R-SIG-Fedora list and, in doing so, give more info about your install process: built yourself, package manager, etc. MW On Wed, Jan 9, 2013 at 7:31 PM, Adam Dahman adamo...@yahoo.ca wrote: Hi, I have installed R on linux using a non root account. I am getting this error when trying to use it : ./R: error while loading shared libraries: libRblas.so: cannot open shared object file: No such file or directory Linux version I am using : Linux version 2.6.32-131.17.1.el6.x86_64 (mockbu...@x86-007.build.bos.redhat.com) (gcc version 4.4.5 20110214 (Red Hat 4.4.5-6) (GCC) ) #1 SMP Thu Sep 29 10:24:25 EDT 2011 Can someone help ? Regards, Adam [[alternative HTML version deleted]] __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code. __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.
Re: [R] Precision of values 53 bits
Perhaps here?: https://r-forge.r-project.org/projects/rmpfr/ M On Thu, Jan 10, 2013 at 10:58 AM, Stephan Mueller stephan.muel...@atsec.com wrote: I am working with large numbers and identified that R looses precision for such high numbers. The precision is lost exactly when the number is equal or larger than 53 bits. See the following output which shows that the numbers below 53 bit have proper precision: __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.