[R] Is there a tool to find unused functions?

2017-11-15 Thread Alexander Engelhardt
I've inherited a large R codebase which has grown over a few years and a few different developers. It contains many things I'd like to delete: - Unused functions - Variable definitions that are never called - Unreachable code I'd write that myself, it would even be fun, but I don't want to rei

Re: [R] Is there a tool to find unused functions?

2017-11-15 Thread Alexander Engelhardt
17 10:44 AM, Michael Hannon wrote: mvbutils::foodweb produces a graphical display of the hierarchy (or network or ...) of function calls. Isolated functions are not called. This might help you. -- Mike On Wed, Nov 15, 2017 at 12:44 AM, Alexander Engelhardt wrote: I've inherited a large R

[R] foreach/dopar's processes accumulate RAM

2014-10-29 Thread Alexander Engelhardt
Hello all, I have a triple nested loop in R like this: all <- list() for(a in A){ all[[a]] <- list() for(b in B){ all[[a]][[b]] <- foreach(c=C, .combine=rbind) %dopar% { ## I'm leaving out some preprocessing here this_GAM <- gam(formula, data=data, family=

[R] X11 plot window doesn't show graphic immediately

2013-01-12 Thread Alexander Engelhardt
Hi r-help, I have a weird problem. When I plot anything, say plot(1:10), a plot window opens but it's empty. It looks just like this: http://i.imgur.com/9uqO6.png I have to resize the window, either by clicking the fullscreen icon on the menu bar, or by dragging the borders. Then the plot is

Re: [R] X11 plot window doesn't show graphic immediately

2013-01-13 Thread Alexander Engelhardt
tions(type="nbcairo"). See ?X11 for details, and http://stackoverflow.com/questions/13235100/empty-plot-in-r for reference. Best, Ista On Sat, Jan 12, 2013 at 1:04 PM, Alexander Engelhardt wrote: Hi r-help, I have a weird problem. When I plot anything, say plot(1:10), a plot window open

[R] Problems plotting a sparse time series in R

2012-10-29 Thread Alexander Engelhardt
Hi guys, I am logging data about my body (weight, body fat, blood pressure, ..) in a .csv file and would like to plot this as a time series. I uploaded the (noisified) .csv, you can see the link in the code I have so far (you can run the code directly as-is): df.raw <- read.csv("http://

Re: [R] Problems plotting a sparse time series in R

2012-10-29 Thread Alexander Engelhardt
ts <- na.approx(ts) Thanks again! -- Alex On Oct 29, 2012, at 8:14 AM, Alexander Engelhardt wrote: Hi guys, I am logging data about my body (weight, body fat, blood pressure, ..) in a .csv file and would like to plot this as a time series. I uploaded the (noisified) .csv, you can see

[R] Why are integers coded as e.g. "2L" in R functions?

2014-05-15 Thread Alexander Engelhardt
Hello R-help, I keep noticing R functions that don't compare integers like if(x == 2) but instead if(x == 2L) Is this a long integer? Also, when do the two notations have a different effect on the code? Thanks in advance, Alex __ R-help@r-proj

Re: [R] Why are integers coded as e.g. "2L" in R functions?

2014-05-15 Thread Alexander Engelhardt
So in essence, it always provides the same output, but saves space and speed. Thanks everyone! - Alex On 05/15/2014 01:06 PM, Prof Brian Ripley wrote: On 15/05/2014 11:54, Alexander Engelhardt wrote: Hello R-help, I keep noticing R functions that don't compare integers like if(x

[R] mgcv: I can't manually reconstruct a P-spline from a GAM's coefficients

2014-06-17 Thread Alexander Engelhardt
Hello R-helpers, I am working through Simon Wood's GAM book and want to specify my own knot locations (on even tens, i.e. 10, 20, 30, etc.). Then, I want to compute a GAM on that area, and given the coefficients, reconstruct the same P-spline that is drawn in plot(my_gam). I'm failing. Here

Re: [R] mgcv: I can't manually reconstruct a P-spline from a GAM's coefficients

2014-06-18 Thread Alexander Engelhardt
emoves one coefficient and shifts the curve... best, Simon On 17/06/14 15:40, Alexander Engelhardt wrote: Hello R-helpers, I am working through Simon Wood's GAM book and want to specify my own knot locations (on even tens, i.e. 10, 20, 30, etc.). Then, I want to compute a GAM on that area,

Re: [R] Binomial

2011-05-12 Thread Alexander Engelhardt
Am 12.05.2011 10:46, schrieb blutack: Hi, I need to create a function which generates a Binomial random number without using the rbinom function. Do I need to use the choose function or am I better just using a sample? Thanks. I think I remember other software who generates binomial data with e

Re: [R] Binomial

2011-05-12 Thread Alexander Engelhardt
insemius wrote: From: David Winsemius Subject: Re: [R] Binomial To: "Alexander Engelhardt" Cc: r-help@r-project.org, "blutack" Date: Thursday, May 12, 2011, 11:08 AM I hope Allan knows this and is just being humorous here, but for the less experienced in the audience ...

Re: [R] Assistance R

2011-05-12 Thread Alexander Engelhardt
Am 12.05.2011 20:14, schrieb Carlosmagno: Assistance R, When trying to insert data in txt format already set up R pr is the following error: "Erro em scan(file, what, nmax, sep, dec, quote, skip, nlines, na.strings, : linha 1 não tinha 10 elementos" I would like to know how to remedy this

Re: [R] All possible samples for two variables

2011-05-21 Thread Alexander Engelhardt
Am 21.05.2011 06:30, schrieb Sharma D: How to generate all possible samples of size 5 for the two variables in one analysis. Like this? > x <- 1:5 > y <- 6:10 > expand.grid(x,y) __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listi

[R] One main caption for an mfrow=c(2,1) plot window

2011-05-29 Thread Alexander Engelhardt
Hello, I'm trying to plot a series of pages in a pdf with one main caption for each page. Each page should then have two plots in one row, preferably with an own caption. I can't plot the main caption in a window, and subsequently plot the two graphics (next to each other) below it. Here is w

Re: [R] One main caption for an mfrow=c(2,1) plot window

2011-05-30 Thread Alexander Engelhardt
Am 30.05.2011 10:39, schrieb Uwe Ligges: On 29.05.2011 22:52, Alexander Engelhardt wrote: Hello, I'm trying to plot a series of pages in a pdf with one main caption for each page. Each page should then have two plots in one row, preferably with an own caption. I can't plot the main

Re: [R] OT: Pie charts

2011-05-31 Thread Alexander Engelhardt
Am 31.05.2011 20:15, schrieb Sarah Goslee: We regularly get questions about making pie charts, and frequently veer off into the philosophical and practical issues surrounding that form of data graphic: human perception of angles and so on. So while this isn't an R issue, I thought some of you mi

Re: [R] OT: Pie charts

2011-05-31 Thread Alexander Engelhardt
Am 31.05.2011 21:10, schrieb Alexander Engelhardt: Please find attached a rather splendid use of pie charts. Do not question the pie chart. Pffft no attachment rule. http://www.medialogy.de/blog/wp-content/uploads/2008/09/pacmancharthumor.jpg __ R

Re: [R] R² for non-linear model

2011-03-17 Thread Alexander Engelhardt
Hi, thank you for your elaborate answer. I downloaded Prof. Dayton's pdf and will read it tomorrow. A friend also told me that our professor said you can actually compare AICs for different distributions. Apparently it's not correct strictly speaking, because of the two different likelihoods,

Re: [R] How to find position in bin-data?

2011-03-19 Thread Alexander Engelhardt
Am 19.03.2011 13:18, schrieb Antje Niederlein: Hi there, probably there is a very simple solution, but I cannot think of one... I have a vector with values: data<- c(1,6,3,4,8,4,2,9) and I have a vector with bin breaks: bins<- c(1,3,5,7,9,11) cut() does what you want: > cut(data, bins) [1]

Re: [R] Computing row differences in new columns

2011-03-21 Thread Alexander Engelhardt
(mods: can you un-flag me if I am still flagged?) Hi, First, I would convert the DATE column to an integer. I found this by quick googling, perhaps as.Date is your weapon of choice: https://stat.ethz.ch/pipermail/r-help/2008-August/169870.html For the column generation I think you will have t

[R] Sweave: include a multi-page-pdf plot

2011-03-27 Thread Alexander Engelhardt
Hi, I'm just starting out with Sweave, and I can't get a plot(linmod) to display all four plots: << bild >>= x1 <- runif(100) x2 <- rexp(100) y <- 3 + 4*x1 + 5*x2 + rnorm(100) mod <- lm(y~x1+x2) plot(mod) @ Some Text <>= <> @ This plots only the first image of the four-page plot.lm() result

[R] That dreaded floating point trap

2011-03-31 Thread Alexander Engelhardt
Hi, I had a piece of code which looped over a decimal vector like this: for( i in where ){ thisdata <- subset(herde, herde$mlr >= i) # do stuff with thisdata.. } 'where' is a vector like seq(-1, 1, by=0.1) My problem was: 'nrow(thisdata)' in loop repetition 0.4 was different if 'where' wa

Re: [R] That dreaded floating point trap

2011-03-31 Thread Alexander Engelhardt
A very straightforward way to avoid this problem is to construct the sequence by multiplying a sequence of integers by an approriate constant. E.g. for your first example: for( i in where ){ thisdata<- subset(herde, herde$mlr>= i) # do stuff with thisdata.. } 'where' is a vecto

Re: [R] That dreaded floating point trap

2011-03-31 Thread Alexander Engelhardt
Am 31.03.2011 14:41, schrieb Sarah Goslee: On Thu, Mar 31, 2011 at 8:14 AM, Alexander Engelhardt this helps, thank you. But if this code is in a function, and some user supplies a vector, I will still have to round it in the function, I guess. It's weird how 0.1 is different from roun

Re: [R] another statistical question

2011-03-31 Thread Alexander Engelhardt
Am 31.03.2011 15:46, schrieb Anna Lee: Dear List! I have a unverse (basic population) which is not normally distributed. Now from this universe I take some subsets. Each subset is normally distributed within itself. I now want to compare the subsets and see if they differ significantly. So what

Re: [R] Syntax coloring in R console

2011-04-01 Thread Alexander Engelhardt
Am 01.04.2011 17:02, schrieb Joshua Wiley: Dear January, Have you looked at Emacs + ESS? http://ess.r-project.org/ It highlights in the text editor and the actual R process besides coming with a rich set of features and a mailing list filled with helpful Emacs& R users. I've tried several di

[R] I think I just broke R

2011-04-02 Thread Alexander Engelhardt
I swear, I didn't touch it! I can't fit GLM's anymore, and I can't make it talk english (for googling the error messages) anymore. y <- c(1,1,0,1,0,1) x <- c(2,7,3,5,2,4) glm(y~x, binomial) Fehler in runif(length(pi)) : Element 1 ist leer; Der Teil der Argumentliste 'length' der berechne

Re: [R] I think I just broke R

2011-04-03 Thread Alexander Engelhardt
Am 03.04.2011 03:51, schrieb Daniel Malter: Check whether x, y, or glm have been redefined. If not, restart R. I wouldn't call my function 'glm'. However, I did call one 'binomial'. That was my mistake. Thanks :) A few weeks ago I asked how to set my error messages to english, and Richard H

Re: [R] I think I just broke R

2011-04-03 Thread Alexander Engelhardt
Am 03.04.2011 13:12, schrieb Prof Brian Ripley: On Sun, 3 Apr 2011, Uwe Ligges wrote: Use "LANGUAGE" rather than "LANG" as the environment variable. Also, set it outside your R session, e.g. in your .Renviron file. You are supposed to be able to change this during an R session, but if you rel

Re: [R] I think I just broke R

2011-04-03 Thread Alexander Engelhardt
Am 03.04.2011 14:10, schrieb Duncan Murdoch: That's not weird: you just created an R variable named LANGUAGE, not an environment variable. Duncan Murdoch Silly me. It works now: alexx@derp:~$ cat ~/.Renviron LANGUAGE="EN" Thanks :) __ R-help@r-pro

Re: [R] Need a more efficient way to implement this type of logic in R

2011-04-06 Thread Alexander Engelhardt
Am 06.04.2011 22:02, schrieb Walter Anderson: I have cobbled together the following logic. It works but is very slow. I'm sure that there must be a better r-specific way to implement this kind of thing, but have been unable to find/understand one. Any help would be appreciated. hh.sub <- househo

Re: [R] glmnet

2011-04-13 Thread Alexander Engelhardt
Am 13.04.2011 16:58, schrieb Janina Hemmersbach: Hello, I´m trying to in install the package 'glmnet' but I get always the error massage "package ‘Matrix’ is not available". I search on you site, but I coundn´t find the package there either. Is their still a package called "Matrix"? Or how can

Re: [R] (no subject)

2011-04-18 Thread Alexander Engelhardt
Am 18.04.2011 14:58, schrieb Ramnath R: Hai i just wanted to know how we can find the package of a dataset, eg: how can i find the package in which the dataset *iris* is present Ram Hi, if you have the package installed, go > ?iris to find out which package it belongs to. If not, just googl

Re: [R] Integrate na.rm in own defined functions

2011-04-20 Thread Alexander Engelhardt
Am 20.04.2011 10:59, schrieb Mauro: It`s probably an easy question, but couldn`t figure it out. I`ve defined a function like: rmse<-function (x){ dquared<-x^2 sum1<-sum(x^2) rmse<-sqrt((1/length(x))*sum1) rmse} My problem is, that I have NA Values in x and the above function returns NA. I`m l

Re: [R] Question on Import

2011-04-25 Thread Alexander Engelhardt
Am 25.04.2011 09:58, schrieb Georgina Salazar: Hi! I have the data in a tab delimited text file titled "ken_data_try_anova." I tried to import it into R entering read.delim(ken_data_try_anova) but received the error message Error in read.table(file = file, header = header, sep = sep, quote

Re: [R] Generalized Linear Model

2011-04-25 Thread Alexander Engelhardt
Am 25.04.2011 21:28, schrieb Megan: Hello, I am trying to run a generalized linear model but do not know where to begin. I have attached my data to R but do not know where to go from there. I have two independent variables (each has two factors associated with them) What do you mean by this? Y

Re: [R] RPMs needed to compile R using the tar.gz file

2011-08-05 Thread Alexander Engelhardt
Am 05.08.2011 12:24, schrieb Patrick Connolly: I don't wish to install R by rpm. I need to know what Fedora rpms I need to install to give me the capability to install R using the tar.gz source file as I've done for years. Try this command: rpm -qpR your_R.rpm | xargs rpm -ivh The part befor

[R] Gamma distribution parameter estimation

2011-08-06 Thread Alexander Engelhardt
Hey, I have a set of income data which I'd like to fit to a gamma distribution. How can I estimate the two parameters of the gamma distribution for a vector, e.g. c(2039L, 2088L, 5966L, 2353L, 1966L, 2312L, 3305L, 2013L, 3376L, 3363L, 3567L, 4798L, 2032L, 1699L, 3001L, 2329L, 3944L, 2568L, 169

Re: [R] Gamma distribution parameter estimation

2011-08-06 Thread Alexander Engelhardt
On 08/06/2011 09:23 PM, Jorge Ivan Velez wrote: Hi Alex, Try require(MASS) Loading required package: MASS b<- c(2039L, 2088L, 5966L, 2353L, 1966L, 2312L, 3305L, 2013L, 3376L, + 3363L, 3567L, 4798L, 2032L, 1699L, 3001L, 2329L, 3944L, 2568L, + 1699L, 4545L) fitdistr(b, 'gamma') shape

Re: [R] X11 problem

2011-08-25 Thread Alexander Engelhardt
Am 25.08.2011 15:05, schrieb carol white: both. But it worked for R-2-10. I added deb http://cran.ma.imperial.ac.uk/bin/linux/ubuntu lucid/ into /etc/apt/sources.list and ran apt-get update as root and got the following error message: W: GPG error: http://cran.ma.imperial.ac.uk lucid/ Re

[R] The elegant way to test if a number is a whole number

2011-09-08 Thread Alexander Engelhardt
Hi, x <- 0.2*5 is.integer(x) gives me FALSE because R stores it as a float number, right? Is there an elegant way to work around that problem? Right now I'm using x <- 0.2*5 round(x) == x which returns TRUE. But more strictly I should use all.equal(), right? I somehow just don

Re: [R] The elegant way to test if a number is a whole number

2011-09-08 Thread Alexander Engelhardt
Am 08.09.2011 20:48, schrieb Marc Schwartz: > There was a post from Martin Maechler some years ago and I had to search a bit to find it. For these sorts of issues, I typically trust his judgement. > > The post is here: > >https://stat.ethz.ch/pipermail/r-help/2003-April/032471.html > > His

Re: [R] WG: R-Problem

2011-06-21 Thread Alexander Engelhardt
Am 21.06.2011 16:43, schrieb Bleicher Niels (AFS): Dear forumites As a newbie I try to figure out whether R can do a certain job quicker than other programs and it seems so, but I don't find a solution to a seemingly simple problem: I have built a matrix of distance with as.matrix(dist()) w

[R] Why is looping in R inefficient, but in C not?

2011-06-25 Thread Alexander Engelhardt
Hey, I just read another post about calling R from C. Someone on stackoverflow (DWin makes me suspect its David W.?) referenced this: http://www.math.univ-montp2.fr/~pudlo/R_files/call_R.pdf Which made me think: Why is a loop in R bad, but in C not? And where exactly does looping cost the most

Re: [R] Simple simulations

2011-06-27 Thread Alexander Engelhardt
Here's a one-liner. Let's see their software do that! sum(replicate(100, sum(sample(c(rep(0, 20), seq(1:37)), 3, replace = FALSE)) == 0)) Am 27.06.2011 23:08, schrieb robcinm: I am taking a basic statistics course this summer, and while the majority of the class is using a statistical packa

Re: [R] Vertical Labels in plot graph - normally working fine but not on this graph

2011-07-08 Thread Alexander Engelhardt
Hey, from what I see, you try to use the par(las=3) function after the plot command. You should use it before it, though. Somewhat liek this: ExtAvgCWV = rnorm(200) ExtAvgDemand = rnorm(200) ExtGasDays = seq(from = as.Date("2010-8-4", "%Y-%m-%d"), along.with = ExtAvgCWV, by = "days") op <- p

Re: [R] Ploting gradient

2011-07-27 Thread Alexander Engelhardt
Am 28.07.2011 03:25, schrieb Fernando Andreacci: I have a simple bar chart with annual precipitation (jan to dez). I want to plot, above each bar (on a line), a square wich is color based on a scale (0-100%). With 0 being white and 100 black, like a gradient. Is it possible? How to? Thanks He

[R] How to draw 4 random weights that sum up to 1?

2011-10-10 Thread Alexander Engelhardt
Hey list, This might be a more general question and not that R-specific. Sorry for that. I'm trying to draw a random vector of 4 numbers that sum up to 1. My first approach was something like a <- runif(1) b <- runif(1, max=1-a) c <- runif(1, max=1-a-b) d <- 1-a-b-c but this kind of