[R] Optimization to fit data to custom density distribution

2015-03-21 Thread Johannes Radinger
Hi, I am looking for a way to fit data (vector of values) to a density function using an optimization (ordinary least squares or maximum likelihood fit). For example if I have a vector of 100 values generated with rnorm: rnorm(n=100,mean=500,sd=50) How can I fit these data to a Gaussian density

Re: [R] Optimization to fit data to custom density distribution

2015-03-21 Thread Johannes Radinger
ion: > > library(MASS) > ?fitdistr > > No optimization is needed to fit a normal distribution, though. > > > On 21/03/2015 13:05, Johannes Radinger wrote: > >> Hi, >> >> I am looking for a way to fit data (vector of values) to a density >> functi

Re: [R] Optimization to fit data to custom density distribution

2015-03-23 Thread Johannes Radinger
On Sat, Mar 21, 2015 at 3:41 PM, Prof Brian Ripley wrote: > On 21/03/2015 14:27, Johannes Radinger wrote: > >> Thanks for the fast response. The fitdistr() function works well for the >> predefined density functions. However, what is the recommended approach >> to optimiz

[R] Match beginning and end of string (grepl)

2014-09-02 Thread Johannes Radinger
Hi, I'd like to match the beginning and the end of a string. E.g. I want to extract all strings from a vector that beginn with "12" and end with "Apples": a <- "2 green Apples" b <- "12 green Apples" c <- "12 Apples and 2 green Bananas" d <- "12 yellow Bananas" fruitlist <- c(a,b,c,d) # This is

[R] Two wireframe plots (lattice) aside (grid.arrange) without outer box

2014-12-02 Thread Johannes Radinger
Hi, I'd like to arrange two wireframe plots (library "lattice") next to each other using the grid.arrange function of the library "gridExtra". However the two wireframe plots should be closer to each other and the outer 2D box should be removed (to save space). To remove the outer box for a single

[R] Package dismo: Extracting sensitivity and specificity from gbm.step() object

2015-08-24 Thread Johannes Radinger
Dear R-User! This is a question to all of you that are familiar with the 'dismo' package, in particular we are interested in the gbm.step() function to create a boosted regression tree model in R. From the model output object we can use the $cv.statistics to get information on the cross-validation

[R] regex sub with specified number of characters

2015-10-06 Thread Johannes Radinger
Hi I'd like to remove a leading "3" if my number is 7 digits long, if it is only 6 I don't want to anything. I think this should be possible with a 1-liner using sub() but I am not sure how to define the number of characters following the leading one. For example my vector: a <- c(3593857,384723

[R] Calculate geographic/euclidian distance between consecutive XY-pairs

2012-12-18 Thread Johannes Radinger
Hi, I have a dataframe containing 3 columns: data.frame(X=c(100,102,104,102,103),Y=c(12,14,14,13,16),Time=c(1,2,3,4,5)) where X and Y are coordinates and "Time" refers to an index of a timestep. Now I would like to get the distance between the consecutive timesteps. This should actually provide

Re: [R] Calculate geographic/euclidian distance between consecutive XY-pairs

2012-12-18 Thread Johannes Radinger
Hi Ray, thank you very much. That one-line approach is what I was looking for. A very simple but very efficient way without loading any other packages. /j On Tue, Dec 18, 2012 at 11:17 AM, Ray Brownrigg wrote: > On 18/12/2012 10:56 p.m., Johannes Radinger wrote: >> >> Hi,

[R] Merging list of dataframes with reshape merge_all

2013-01-11 Thread Johannes Radinger
Hi, I'd like to merge mutliple dataframes from a list of dataframes by some common columns. The approach for simply merging 2 dataframes is working with: merge(df1,df2,by=c("col1","col2","col3"),all=TRUE) For mutliple dataframes in a list I try to use the merge_all command from the package resha

Re: [R] Merging list of dataframes with reshape merge_all

2013-01-11 Thread Johannes Radinger
.x=TRUE, all.y=TRUE) > > > Contact the package maintainer for more info. > > maintainer('reshape') > [1] "Hadley Wickham " > > > Hope this helps, > > Rui Barradas > > Em 11-01-2013 10:08, Johannes Radinger escreveu: >> >> Hi, >>

[R] split & rbind (cast) dataframe

2013-01-11 Thread Johannes Radinger
Hi, I would like to split dataframe based on one colum and want to connect the two dataframes by rows (like rbind). Here a small example: # The orgininal dataframe df1 <- data.frame(col1 = c("A","A","B","B"),col2 = c(1:4), col3 = c(1:4)) # The datafame how it could look like df2 <- data.frame(A.

[R] Which df to extract from ANCOVA model

2013-01-18 Thread Johannes Radinger
Hi, I am running an ANCOVA model like: aov(Y ~ Var1 + Var2 + Var3 + Var4 + CoVar1 + CoVar2) where Y is the response (metric, 1.0-1000.0), VarX are all metric predictors, and CoVarX are two Covariates each a factor of 4-5 levels. So far as I can remember results of an ANCOVA for a Covariate of i

[R] Colour branches/labels of dendrogram according to a grouping variable

2013-03-07 Thread Johannes Radinger
Hi, is there a way to color the branches or text label of the branches of dendrograms e.g. from hclust() according to a grouping variable. Here I have something in mind like: http://www.sigmaaldrich.com/content/dam/sigma-aldrich/life-science/biowire/biowire-fall-2010/proteome-figure-1.Par.0001.Ima

[R] string split at xth position

2013-03-13 Thread Johannes Radinger
Hi, I have a vector of strings like: c("a1b1","a2b2","a1b2") which I want to spilt into two parts like: c("a1","a2","a2") and c("b1","b2,"b2"). So there is always a first part with a+number and a second part with b+number. Unfortunately there is no separator I could use to directly split the vecto

Re: [R] string split at xth position

2013-03-13 Thread Johannes Radinger
x > [1] "a1b1" "a2b2" "a1b2" >> substr(x, 1, 2) > [1] "a1" "a2" "a1" >> substr(x, 3, 4) > [1] "b1" "b2" "b2" > > HTH, > Jorge.- > > > On Wed, Mar 13, 2013 at 7:37 PM, Johann

[R] Fuzzy rules definition (package "sets") from data.frame

2013-05-08 Thread Johannes Radinger
Hi, I just discovered the package "sets" and its ability to perform fuzzy systems calculations. The example in the manual of fuzzyinference() gives an overview how to develop rules. However my "rules" are already available as data.frame and I'd like to convert them into the format that is needed

Re: [R] Fuzzy rules definition (package "sets") from data.frame

2013-05-08 Thread Johannes Radinger
Following my last mail, I found a simple solution using eval(parse)): df <- data.frame(depth=c("low","medium","high"),velocity=c("medium","medium","low"),suitability=c("low","medium","low")) df$rule <- paste("fuzzy_rule(depth %is% ",df[,"depth"]," && ","velocity %is% ",df[,"velocity"],", ","suitab

[R] NaN-result from fuzzy_inference (package "sets") with certain input

2013-05-08 Thread Johannes Radinger
Hi, I am trying to use the fuzzy_inference system on multiple input values. Basically I combine two variables (depth, velocity) into the variable suitability. Both depth and velocity have 3 trapezoid classes (verylow,medium,high) each. The consequent (suitability) has 4 fuzzy levels (none,low,medi

Re: [R] Fwd: NaN-result from fuzzy_inference (package "sets") with certain input

2013-05-10 Thread Johannes Radinger
iverse to [0,1], so the fuzzy inference > returns empty sets for those entries in your df with values larger than 1 > ... > > David > > > On 2013-05-08 14:53, Johannes Radinger wrote: > >> This email has already been sent to the R-mailing list, >> but maybe y

[R] Margins in dcast (reshape2)

2013-06-26 Thread Johannes Radinger
Hi, I'd like to get mean values for the margins of my casted data.frame. For the casting I am using dcast() from reshape2. However, when I set the margins parameter (margins=c("grand\_row")) I get following error concerning an unrecognized escape character '\_'. So what is the correct command to

[R] Error when using median as aggregation function in dcast

2013-06-26 Thread Johannes Radinger
Hi, I am trying to calculated various summary statistics using the dcast function of reshape2. This works perfectly for getting the mean, sum, length, sd. But when I want to calculate the median I get an error. I tried it with and without removing NAs: my_median <- function(x) median(x, na.rm =

[R] Colsplit, removing parts of a string

2012-09-27 Thread Johannes Radinger
Hi, I am using colsplit (package = reshape) to split all strings in a column according to the same patterns. Here an example: library(reshape2) df1 <- data.frame(x=c("str1_name2", "str3_name5")) df2 <- data.frame(df1, colsplit(df1$x, pattern = "_", names=c("str","name"))) This is nearly what I

Re: [R] Colsplit, removing parts of a string

2012-09-27 Thread Johannes Radinger
Thank you, this works perfectly... best regards, Johannes On Thu, Sep 27, 2012 at 1:43 PM, Ista Zahn wrote: > Hi Johannes, > > On Thu, Sep 27, 2012 at 7:25 AM, Johannes Radinger > wrote: >> Hi, >> >> I am using colsplit (package = reshape) to split all strings &

[R] Crosstable-like analysis (ks test) of dataframe

2012-09-28 Thread Johannes Radinger
Hi, I have a dataframe with multiple (appr. 20) columns containing vectors of different values (different distributions). Now I'd like to create a crosstable where I compare the distribution of each vector (df-column) with each other. For the comparison I want to use the ks.test(). The result sho

Re: [R] Crosstable-like analysis (ks test) of dataframe

2012-09-28 Thread Johannes Radinger
Y=runif(n), Z=rchisq(n, df=3)) > > apply(dat, 2, function(x) apply(dat, 2, function(y) f(x, y))) > > Hope this helps, > > Rui Barradas > Em 28-09-2012 11:10, Johannes Radinger escreveu: >> >> Hi, >> >> I have a dataframe with multiple (appr. 20) columns co

[R] Cutting hierarchical cluster tree at specific height fails

2014-07-09 Thread Johannes Radinger
Hi, I'd like to cut a hierachical cluster tree calculated with hclust at a specific height. However ever get following error message: "Error in cutree(hc, h = 60) : the 'height' component of 'tree' is not sorted (increasingly)" Here is a working example to show that when specifing a height in

Re: [R] Cutting hierarchical cluster tree at specific height fails

2014-07-11 Thread Johannes Radinger
ven height is only possible for ultrametric trees > (with monotone clustering heights)." > > Use a different method (but not median). > > - > David L Carlson > Department of Anthropology > Texas A&M University > College Station, TX 77840-4352 > > -Original

Re: [R] Cutting hierarchical cluster tree at specific height fails

2014-07-14 Thread Johannes Radinger
y the resulting dendrograms can > have so called inversions (which are hard to interpret)." > > The cutree manual page: > > "Cutting trees at a given height is only possible for ultrametric trees > (with monotone clustering heights)." > > Use a different method

[R] Set file path in Biomod2

2014-07-15 Thread Johannes Radinger
Hi, I am wondering if it is possible to set the path to the output file of the function BIOMOD_Modeling() from the 'Biomod2' package. I can see the option SaveObj to state if the output should be save to the hard disk. When this is enabled, all files are printed to the working directory. So is Bio

[R] Renaming column names according to another dataframe

2012-12-11 Thread Johannes Radinger
Hi, I've got a dataframe having a code as column name. Addtionally I have another dataframe with a two columns (and lots of rows), the first containing the code and the second some Text (real name). Now I'd like to use the information (pairs of code and name) of the second dataframe to rename all

Re: [R] Renaming column names according to another dataframe

2012-12-11 Thread Johannes Radinger
A","Col > B","Col D","Col E","Col C")) > > names(df)<-df_names$name[match(names(df),df_names$code)] > > > A.K. > > - Original Message - > From: Johannes Radinger > To: r-help@r-project.org > Cc: > Sent: Tue

[R] dataframe calculations based on certain values of a column

2014-03-26 Thread Johannes Radinger
Hi, I have data in a dataframe in following structure var1 <- c("a","b","c","a","b","c","a","b","c") var2 <- c("X","X","X","Y","Y","Y","Z","Z","Z") var3 <- c(1,2,2,5,2,6,7,4,4) df <- data.frame(var1,var2,var3) Now I'd like to calculate relative values of var3. This values should be relative to th

[R] Latin Hypercube Sample and transformation to uniformly distributed integers or classes

2013-10-08 Thread Johannes Radinger
Hi, I'd like to use Latin Hypercube Sampling (LHC) in the the context of uncertainty / sensitivity analysis of a complex model with approximately 10 input variables. With the LHC approach I'd like to generate parameter combinations for my model input variables. Therefore I came across an simple ex

Re: [R] indicating significant differences in boxplots

2013-10-28 Thread Johannes Radinger
Hi, I'd like to follow up an older discussion on adding significance stars to boxplots. ( http://r.789695.n4.nabble.com/indicating-significant-differences-in-boxplots-td862335.html ) As suggested by Jim Lemon, there is following solution for a single boxplot: boxplot(count ~ spray, data = InsectS

[R] Overlay boxplot and scatter.smooth line

2013-11-19 Thread Johannes Radinger
Hi, I'd like to plot a boxplot and use a scatter.smooth line plot as an overlay for this plot. This works except for the problem that the x-axis ticks for both plots are differently spaced: The boxplot ticks are closer and the space between the outer most boxplots and the plot region (box) is larg

Re: [R] Overlay boxplot and scatter.smooth line

2013-11-19 Thread Johannes Radinger
n Tue, Nov 19, 2013 at 4:43 AM, Johannes Radinger < > johannesradin...@gmail.com> wrote: > >> Hi, >> >> I'd like to plot a boxplot and use a scatter.smooth line plot as an >> overlay >> for this plot. >> This works except for the problem that

[R] Solving a normal distribution pnorm for q

2013-12-12 Thread Johannes Radinger
Hi, I found follwowing example of pnorm here: http://www.r-tutor.com/elementary-statistics/probability-distributions/normal-distribution Problem Assume that the test scores of a college entrance exam fits a normal distribution. Furthermore, the mean test score is 72, and the standard deviat

Re: [R] Solving a normal distribution pnorm for q

2013-12-12 Thread Johannes Radinger
gt; Feladó: r-help-boun...@r-project.org [r-help-boun...@r-project.org] ; > meghatalmazó: Johannes Radinger [johannesradin...@gmail.com] > Küldve: 2013. december 12. 14:56 > To: R help > Tárgy: [R] Solving a normal distribution pnorm for q > > Hi, > > > > I found follwowin

Re: [R] Solving a normal distribution pnorm for q

2013-12-12 Thread Johannes Radinger
ion(x)pnorm(q=x,sd=sd1)*r+pnorm(q=x,sd=sd2)*(1-r)-X,c(-1e6,1e6)) > > > Cheers > > Am 12.12.2013 15:58, schrieb Johannes Radinger: > > Thanks for the fast response. Of course I totally overlooked qnorm as I > had > > a more complex task in my head. > > > > I

Re: [R] Regression with ranges and displaying them in an XY-Plot

2011-08-05 Thread Johannes Radinger
:00 +0200 From: "Johannes Radinger" To: r-help@r-project.org Subject: [R] Regression with ranges and displaying them in an XY-Plot Message-ID: <20110728124900.198...@gmx.net> Content-Type: text/plain; charset="utf-8" Hello UseRs, I've got 3 variables, the dependent variab

[R] function runif in for loop

2011-08-10 Thread Johannes Radinger
Hello, I'd like to perform a regression using MCMCregress (MCMCpack). One variable therefore should be a function rather than a variable: I want to use X as an input and X should be defined as a random number between to values. Therefore I want to use the function runif like: X <-(1, Xa, Xb) but

Re: [R] function runif in for loop

2011-08-10 Thread Johannes Radinger
inal-Nachricht > Datum: Wed, 10 Aug 2011 08:19:07 -0500 > Von: Jean V Adams > An: "Johannes Radinger" > CC: r-help@r-project.org > Betreff: Re: [R] function runif in for loop > Johannes, > > You have the loop set up right, you just need to add indexing to

Re: [R] function runif in for loop

2011-08-10 Thread Johannes Radinger
Original-Nachricht > Datum: Wed, 10 Aug 2011 09:38:38 -0400 > Von: Duncan Murdoch > An: Johannes Radinger > CC: r-help@r-project.org > Betreff: Re: [R] function runif in for loop > On 10/08/2011 7:28 AM, Johannes Radinger wrote: > > Hello, >

[R] MCMC regress, using runif()

2011-08-15 Thread Johannes Radinger
Hello, just to follow up a question from last week. Here what I've done so far (here an example): library(MCMCpack) Y=c(15,14,23,18,19,9,19,13) X1=c(0.2,0.6,0.45,0.27,0.6,0.14,0.1,0.52) X2a=c(17,22,21,18,19,25,8,19) X2b=c(22,22,29,34,19,26,17,22) X2 <- function()runif(length(X2a), X2a, X2b)

Re: [R] MCMC regress, using runif()

2011-08-15 Thread Johannes Radinger
is not working /johannes Original-Nachricht Datum: Mon, 15 Aug 2011 10:20:53 +0200 Von: "Johannes Radinger" An: r-help@r-project.org Betreff: MCMC regress, using runif() Hello, just to follow up a question from last week. Here what I've done so far

[R] Extracting information from lm results (multiple model runs)

2011-08-15 Thread Johannes Radinger
1000 model runs? Thank you very much /johannes Original-Nachricht > Datum: Mon, 15 Aug 2011 08:33:52 -0300 > Von: Alexandre Camargo Martensen > An: Johannes Radinger > Betreff: Re: [R-sig-eco] Extracting information from lm results > Hi Johannes, >

[R] plotting segments only and in color

2011-08-15 Thread Johannes Radinger
Hello, I've a question concerning the display of interval data. A sample dataset where X is an interval between Xa and Xb which should be displayed: Y=c(15,14,23,18,19,9,19,13) Xa=c(17,22,21,18,19,25,8,19) Xb=c(22,22,29,34,19,26,17,22) X = (Xa+Xb)/2 It's easily possible to plot the mean of the

[R] ggplot - some questions concerning histograms

2011-08-16 Thread Johannes Radinger
Hello, I am a beginner with ggplot and after doing simple graphs (histogram, segments etc.) some questions came up: 1) I tried to do a histogram, but nothing is displayed although it works with another vector. I think it is because of the very small values (n=1000, min=1.222e-24 max, 1.890e-20

[R] read.xlsx handle NAs

2011-09-01 Thread Johannes Radinger
Hello, I import a xlsx-table with read.xlx which contains NAs in 4 columns. In the excel table these 4 columns contain floats/integers and the word NA. But when I am importing the NAs are recognized as strings rather than as missing values. How can I set that if a cell contains the word NA tha

[R] plot regression line, log-transformation

2011-09-05 Thread Johannes Radinger
Hello UseRs, I've somehow general questions. I've got a dataset which shows signs of heteroscedasticity and non-normality in errors if I do a normal linear regression of the form Y~X. So to things came into my mind, either transforming the variables (log or log10) or using robust regression. So

[R] linear regression, log-transformation and plotting

2011-09-07 Thread Johannes Radinger
Hello, I've some questions concerning log-transformations and plotting of the regression lines. So far as I know is it a problem to log-transform values smaller than 1 (0-1). In my statistics lecture I was told to do a log(x+1) transformation in such cases. So I provide here a small example to

[R] Extract r.squared using cbind in lm

2011-09-08 Thread Johannes Radinger
Hello, I am using cbind in a lm-model. For standard lm-models the r.squared can be easily extracted with summary(model)$r.squared, but that is not working in in the case with cbind. Here an example to illustrate the problem: a <- c(1,3,5,2,5,3,1,6,7,2,3,2,6) b <- c(12,15,18,10,18,22,9,7,9,23,12,

[R] Transform counts into presence/absence

2012-05-31 Thread Johannes Radinger
Hi, I am looking for a very easy way to transform a column in a dataframe from counts (eg. c(1,0,21,2,0,0,234,2,0)) into a binary form to get presence/absence values e.g. c(1,0,1,1,0,0,1,1,0). Is there a simple built-in function? or do I have do to it with a replaceement funciton using IF x > 0 TH

Re: [R] Transform counts into presence/absence

2012-05-31 Thread Johannes Radinger
Original-Nachricht > Datum: Thu, 31 May 2012 11:16:32 + > Von: "ONKELINX, Thierry" > An: Johannes Radinger , "R-help@r-project.org" > > Betreff: RE: [R] Transform counts into presence/absence > Just use the logical operators.

[R] Remove columns from dataframe based on their statistics

2012-05-31 Thread Johannes Radinger
Hi, I have a dataframe and want to remove columns from it that are populated with a similar value (for the total column) (the variation of that column is 0). Is there an easier way than to calculate the statistics and then remove them by hand? A <- runif(100) B <- rep(1,100) C <- rep(2.42,100) D

Re: [R] Remove columns from dataframe based on their statistics

2012-05-31 Thread Johannes Radinger
exept for column with name "B". I have to think about this /Johannes Original-Nachricht > Datum: Thu, 31 May 2012 09:20:27 -0500 > Von: J Toll > An: Johannes Radinger > CC: R-help@r-project.org > Betreff: Re: [R] Remove columns from dataframe based on their

[R] Redefine multiple columns (using grep) as factor variables

2012-06-01 Thread Johannes Radinger
Hi, I have a dataframe with around 100 columns. Now I want to redefine some of the columns as factors (using as.factor). Luckily all the names of the columns I want to redefine start with "crast". Thus I thought I can use grep() for that purpose... ...I found an example for redefining a single co

[R] Sort 1-column dataframe with rownames

2012-06-08 Thread Johannes Radinger
Hi, I have a 1-column dataframe with rownames and I want to sort it based on the single column. The typical procedure that is recommended in diverse posts is to use order in the index. But that "destroys" my dataframe structure. Probabaly it is a very simple solution. Here is a short reproducable

Re: [R] Sort 1-column dataframe with rownames

2012-06-08 Thread Johannes Radinger
Hi Achim, thank you for your good explanation and the solution to my question... cheers, /j Original-Nachricht > Datum: Fri, 8 Jun 2012 09:30:42 +0200 (CEST) > Von: Achim Zeileis > An: Johannes Radinger > CC: R-help@r-project.org > Betreff: Re: [R] Sort 1-c

[R] Complex summary of counts of rank positions over multiple dataframes

2012-06-14 Thread Johannes Radinger
Hi, I've kind of a tricky question, which I don't know how to solve yet: I get multiple dataframes loaded (readRDS) in a loop function. Each loaded dataframe contains two columns one with a var-name and one with a value. The rownumber (order) is very important as it is a value of the rank (1:x

[R] special question on regression

2011-07-17 Thread Johannes Radinger
Hello R-people! I have a general statistical question about regressions. I just want to describe my case: I have got a dataset of around 150 observations and 1 dependent and 2 independent variables. The dependent variable is of metric nature (in my case meters in a range from around 0.5-1

Re: [R] special question on regression

2011-07-17 Thread Johannes Radinger
try such a service, for example: http://stackoverflow.com/ FWIW, this is an example of censoring in regression. R has packages for this, but you need to learn more or get help to use them properly, as you, yourself, indicated. -- Bert On Sun, Jul 17, 2011 at 3:01 AM, Johannes Radinger wrote

[R] Regression with ranges and displaying them in an XY-Plot

2011-07-28 Thread Johannes Radinger
Hello UseRs, I've got 3 variables, the dependent variable Y as well as a max and a min value of the independent variable (Xa and Xb) where in some cases Xa=Xb (so actually a single value for X). First I'd like to perform a regression, but my problem is that my X is a range (acutally a censored

[R] Installing packages "xslx" on Ubuntu (32bit)

2012-07-25 Thread Johannes Radinger
Hi, I just recently changed my OS to Ubuntu 12.04 (32bit). Now I tried to install some packages required by my old and working scripts. Unfortunately I fail when trying to install the package "xslx". Maybe it is related to the 32bit version of my R (its not possible to install a 64 bit version)

Re: [R] Installing packages "xslx" on Ubuntu (32bit) [On R 2.14.1]

2012-07-25 Thread Johannes Radinger
ew packages are not available for > it. Please do as the posting guide suggests and update to R 2.15.1 (or > R-patched). > > > On 25/07/2012 09:47, Johannes Radinger wrote: > > Hi, > > > > I just recently changed my OS to Ubuntu 12.04 (32bit). Now I tried to > insta

[R] reshape -> reshape 2: function cast changed?

2012-07-25 Thread Johannes Radinger
Hi, I used to use reshape and moved to reshape2 (R 2.15.1). Now I tried some of my older scripts and was surprised that my cast function wasn't working like before. What I did/want to do: 1) Melt a dataframe based on a vector specifying column names as measure.vars. Thats working so far: dfm <-

[R] size of pdf/eps output

2011-11-14 Thread Johannes Radinger
Hello, I am using a grid.layout for combining multiple ggplot-plots. So far I am doing it this way to get a pdf/eps: pdf("/path/to/my/file.pdf") #or postscript("/path/to/my/file.eps") grid.newpage() pushViewport(viewport(layout = grid.layout(nrow=2, ncol=2, widths = unit(c

[R] grid.arrange, grid.layout - legend, global y axis title

2011-11-15 Thread Johannes Radinger
Hello, I created several plot with ggplot2 dev mode. Now I want to combine the plots in a grid e.g. 2x2 with a fixed size of the output. What I am doing at the moment is: grid.newpage() pushViewport(viewport(layout = grid.layout(nrow=2, ncol=2, widths = unit(c(7.5,6.5),

[R] How to resample one per group

2011-11-17 Thread Johannes Radinger
Hello, I have got a dataframe which looks like: y <- c(1,5,6,2,5,10) # response x <- c(2,12,8,1,16,17) # predictor group <- factor(c(1,2,2,3,4,4)) # group df <- data.frame(y,x,group) Now I'd like to resample that dataset. I want to get dataset (row) per group. So per total sample I get 4 rows i

[R] lm and loop over variables

2011-11-21 Thread Johannes Radinger
Hello, I think I am not to far from a solution. I want to do lm regressions with several variables which I define before in a list. What I've done so far is like: y <- c(1,5,6,2,5,10) # response x1 <- c(2,12,8,1,16,17) # predictor x2 <- c(2,14,5,1,17,17) df <- data.frame(y,x1,x2) predictorlist

Re: [R] lm and loop over variables

2011-11-21 Thread Johannes Radinger
Hi, Original-Nachricht > Datum: Mon, 21 Nov 2011 14:46:17 +0100 > Von: Uwe Ligges > An: Johannes Radinger > CC: r-help@r-project.org > Betreff: Re: [R] lm and loop over variables > > > On 21.11.2011 13:34, Johannes Radinger wrote: > > Hello, &

[R] Combining pairs-plot with other plot

2011-11-23 Thread Johannes Radinger
Hello, I want to arrange a pairs-plot and a simple boxplot next to each other. A similar problem was already posted here: http://r.789695.n4.nabble.com/combining-pairs-plot-with-other-plots-in-one-output-td3946235.html but still I don't really know how to do it... Here a some code lines for the s

[R] dataframe indexing by number of cases per group

2011-11-24 Thread Johannes Radinger
Hello, assume we have following dataframe: group <-c(rep("A",5),rep("B",6),rep("C",4)) x <- c(runif(5,1,5),runif(6,1,10),runif(4,2,15)) df <- data.frame(group,x) Now I want to select all cases (rows) for those groups which have more or equal 5 cases (so I want to select all cases of group A and

[R] pairs(), expression in label and color in text.panel

2011-11-24 Thread Johannes Radinger
Hello, I'd like to add custom labels to my pair() plot. These labels include math expression but they aren't correctly displayed... Further, I want that the boxes for the text.panel (diagonal) have an other background color (grey80). Is that generally possible? If yes how do I have to set it? W

Re: [R] dataframe indexing by number of cases per group

2011-11-24 Thread Johannes Radinger
t; Datum: Thu, 24 Nov 2011 09:12:57 -0500 > Von: Gabor Grothendieck > An: Johannes Radinger > CC: r-help@r-project.org > Betreff: Re: [R] dataframe indexing by number of cases per group > On Thu, Nov 24, 2011 at 7:02 AM, Johannes Radinger > wrote: > > Hello, > > &g

[R] Argument validation within functions

2011-12-06 Thread Johannes Radinger
Hi, I just started with writing functions in R and so some questions popped up. I provide some values as argument to my function such as: function(a,b,c){} Now i want that the function first checks if the arguments are valid for the function. E.g argument "a" has to be a number in the range 0-1

Re: [R] Argument validation within functions

2011-12-06 Thread Johannes Radinger
ric(a)) stop("a is not numeric") if(0 > a && a > 1) stop("a must be a value between 0 and 1") a } /Johannes Original-Nachricht > Datum: Tue, 6 Dec 2011 07:04:59 -0500 > Von: "R. Michael Weylandt" > An: Joh

Re: [R] Argument validation within functions

2011-12-06 Thread Johannes Radinger
the function call not outside the function or before etc. /Johannes Original-Nachricht > Datum: Tue, 6 Dec 2011 07:57:44 -0500 > Von: "R. Michael Weylandt" > An: r-help , Johannes Radinger > Betreff: Re: [R] Argument validation within functions > Use the ! (n

[R] Titelpage pdf-manual, packaging

2011-12-09 Thread Johannes Radinger
Hi, I am trying to get write my first own package. I followed the instructions in "Creating R Packages: A Tutorial" and "Writing R Extensions". So far everything works really fine, the script works and even the man-pages don't show any problems during the check process. During "check" there is al

Re: [R] Titelpage pdf-manual, packaging

2011-12-11 Thread Johannes Radinger
Am 10.12.2011 um 16:50 schrieb Uwe Ligges: > > > On 09.12.2011 14:15, Johannes Radinger wrote: >> Hi, >> >> I am trying to get write my first own package. >> I followed the instructions in "Creating R Packages: A Tutorial" >> and "Writing

[R] summary per group

2012-01-02 Thread Johannes Radinger
Hello, I know that it'll be quite easy to do what I want but somehow I am lost as I am new to R. I want to get summary results arranged by groups. In detail I'd like get the number (levels) of Species per Family like for this dataset: SPEC <- factor(c("a","a","b","b","c","c","c","d","e","e","e",

Re: [R] summary per group

2012-01-02 Thread Johannes Radinger
Original-Nachricht > Datum: Mon, 2 Jan 2012 14:29:07 +0100 > Von: Petr PIKAL > An: "Johannes Radinger" > CC: r-help@r-project.org > Betreff: Re: [R] summary per group > Hi > > > > > Hello, > > > > I know that it&#

[R] Combine variables of different length

2011-11-01 Thread Johannes Radinger
Hi, I have got a dataset with the variables Y,X1,X2,X3. Some of these variables contain NAs. Therefore incomplete datasets aren't recognized when I am doing a regression like: model <- lm(Y~X1+X2+X3) so the resulting vector of resid(model) is obviousely shorter then the original variables. How

[R] variable transformation for lm

2011-11-03 Thread Johannes Radinger
Hello, I am doing a simple regression using lm(Y~X). As my response and my predictor seemed to be skewed and I can't meet the model assumptions. Therefore I need to transform my variables. I wanted to ask what is the preferred way to find out if predictor and/or response needs to be transformed a

[R] reorder data.frame

2011-11-09 Thread Johannes Radinger
Hello, I very general question but probably usefull to others as well: Is there any prebuild function that reorders a dataframe from: x1x2 1 100 200 2 101 201 3 102 202 4 103 203 5 104 204 6 105 205 to 1 100 x1 2 101 x1 3 102 x1 4 103 x1 5 104 x1 6 105 x1 7

[R] reshape - reshape2 problem

2011-11-10 Thread Johannes Radinger
Hi, I'd like to use the reshape2 package for melting datasets. The problem is that I've also loaded the gglot2 package which automatically loads the reshape-package. And the reshape is masking my reshape2. Thats why I tried reshape2::melt(df_test,id=c("X1", "X2"),variable.name="variable_test",v

Re: [R] reshape - reshape2 problem

2011-11-10 Thread Johannes Radinger
> Have you tried loading reshape2 after ggplot2 and all it's requirements? > Usually whatever is loaded last masks earlier loaded packages with functions > of the same name so if reshape2 is last then it should mask reshape(1) and > all of it's similarly named functions. > > Brandon Yes, res

Re: [R] reshape - reshape2 problem

2011-11-10 Thread Johannes Radinger
quot;melt", data) > } > > > Brandon No doesn't work either...value.name is ignored as well when I call reshape2::melt() /Johannes > On Thu, Nov 10, 2011 at 08:45, Johannes Radinger wrote: > > > Have you tried loading reshape2 after ggplot2 and all it's requ

Re: [R] reshape - reshape2 problem

2011-11-10 Thread Johannes Radinger
t2 0.8.9 cheers /j Original-Nachricht > Datum: Thu, 10 Nov 2011 08:51:55 -0300 > Von: Luciano Selzer > An: Johannes Radinger > CC: Brandon Hurr , r-help@r-project.org, > ggpl...@googlegroups.com > Betreff: Re: reshape - reshape2 problem > I had the same is

[R] Save/Load function()-result to file in a loop

2012-03-08 Thread Johannes Radinger
Hi, I am looking for a way to save the result of a function, e.g the lm()-function to a file and reload it afterwards again. I'd like to do that in order to minimize the used memory when running the function in a loop. The actual function I want to store is the evaluate() from the dismo package

Re: [R] Save/Load function()-result to file in a loop

2012-03-08 Thread Johannes Radinger
Original-Nachricht > Datum: Thu, 08 Mar 2012 09:51:01 -0500 > Von: Duncan Murdoch > An: "R. Michael Weylandt" > CC: Johannes Radinger , R-help@r-project.org > Betreff: Re: [R] Save/Load function()-result to file in a loop > On 08/03/2012 8:42 A

[R] Enhance Pairs Scatterplot Matrix

2012-03-26 Thread Johannes Radinger
Hi, I am trying to do plot a scatterplot matrix using pairs() from the package graphics. There are now a few things I'd like to improve for a better understanding. 1) My scatterplot uses two log-scaled axis...as I don't know how to set them in pairs() I calculated the log before but now the label

[R] Make package out of own function

2012-04-02 Thread Johannes Radinger
Hello, I already posted that on stackoverflow[1], but although it's crossposting, I think this question can probably easier to be answered by other R-users on this list, which maintain packages etc. I would like to make a package out of a function. The function is working in a script, but when I

[R] Unwanted page break in Rd2pdf

2012-04-02 Thread Johannes Radinger
Hi, I want to create a pdf of my Man-pages from my package. Therefore I run in the terminal Rd2pdf on the package and a pdf of all the pages is created. After the titlepage there is the general package page, which includes "Description" and "Details" etc. Unfortunately after the Subtitle "Details

[R] output of several "results" from a function

2012-04-03 Thread Johannes Radinger
Hi, I try my first time to write a summary method for my function. The result of my function is a list of two objects (2 arrays). In my summary both objects should be displayed but with a some introductory text like: ls <- list(A="A123",B="B123") summaryout=function(x,...){ cat("This i

[R] Scatterplot matrix with partly transformed axis

2012-04-10 Thread Johannes Radinger
Hi, I am wondering if anybody has experience with scatterplot matrices where some (but NOT all) axis are transformed and the labels are nicely plotted. So far I looked into 1) pairs() 2) scatterplotMatrix() from package 'car' 3) splom() from packagae 'lattice' 4) plotmatrix() from 'ggplot2' I ca

[R] multidimensional array calculation

2012-01-13 Thread Johannes Radinger
Hello, probably it is quite easy but I can get it: I have mulitple numeric vectors and a function using all of them to calculate a new value: L <- c(200,400,600) AR <- c(1.5) SO <- c(1,3,5) T <- c(30,365) fun <- function(L,AR,SO,T){ exp(L*AR+sqrt(SO)*log(T)) } How can I get an array or

Re: [R] multidimensional array calculation

2012-01-14 Thread Johannes Radinger
Dear Jean, Thank you, expand.grid was the function I needed. /johannes > > See > ?expand.grid > > For example, > df <- expand.grid(L=L, AR=AR, SO=SO, T=T) > df$y <- fun(df$L, df$AR, df$SO, df$T) > > Jean > > > Johanne

[R] Split values in vector

2012-01-19 Thread Johannes Radinger
Hello, I have a vector which looks like x$ART ... [35415] 0001-1;02-1;05-1; [35417] 01-1; 01-1;02-1; [35419] 01-1; 00 [35421] 01-1;04-1;05-1; [35

  1   2   >