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

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

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

[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

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

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

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

[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

[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

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

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

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

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

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

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

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

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

[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

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

[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

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

[R] text(): combine expression and line break

2012-05-11 Thread Johannes Radinger
Hi, I would like to plot some extra text in my plot. This should be a two line text including a special character (sigma). I tried so far a to use expression in combination with paste and "\n"... but I can't get the line break... Here what I've done so far: plot(1,type="n", xaxt='n', yaxt='n', a

[R] plotting legend-grob with grid.layout

2012-05-10 Thread Johannes Radinger
Hi, I am using ggplot2 and arrange differnet plots into one viewport by dividing it into rows and columns: pushViewport(viewport(layout = grid.layout(nrow=2,ncol=2,widths = unit(c(50, 50), "mm"),heights = unit(c(50, 50), "mm" with following function I can extract the legend of a previously

[R] Correct use of ddply with own function

2012-05-05 Thread Johannes Radinger
Hi, I am really confused how ddply work, so maybe you can help me. I created a function that sorts a vector etc. fn <- function(x){ x1 <- sort(x) x2 <- seq(length(x)) x3 <- x2/max(x2) df <- data.frame(x1,x2,x3) df } Probably this is not the best form of t

[R] Generate strings from multiple variables

2012-05-04 Thread Johannes Radinger
Hi, it is easiest to explain what I want to do by an example: lets assume there are two factors/variables: A <- c(1,2,3) B <- c(1,3,3) Now I would like to generate a list of strings that should look like ("A1_B1","A1_B2","A2_B1","A2_B2"). So actually the string contains all possible combinations

[R] Absolute cumulative curve with ecdf/stepfun?

2012-05-04 Thread Johannes Radinger
Hi, I have two variables ranging both from 0 to 1 (n=500 each). Now I am interested in plotting them both in one plot (using ggplot2). So far I used ecdf() (from an example I found with google) to get values for the cumulatice distribution function which gives a relative curve. I also want to do

Re: [R] Two ecdf with log-scales

2012-05-03 Thread Johannes Radinger
Thank you Steve, thats the thing I was looking for /Johannes Original-Nachricht > Datum: Thu, 3 May 2012 08:20:51 -0400 > Von: "Steven Wolf" > An: "\'David Winsemius\'" , "\'Johannes Radinger\'" > > CC:

[R] Two ecdf with log-scales

2012-05-02 Thread Johannes Radinger
Hi, i want to plot empirical cumulative density functions for two variables in one plot. For better visualizing the differences in the two cumulative curves I'd like to log-scale the axis. So far I found 3 possible functions to plot ecdf: 1) ecdf() from the package 'stats'. I don't know how to

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

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] 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] Wildcard for indexing?

2012-02-14 Thread Johannes Radinger
Original-Nachricht > Datum: Tue, 14 Feb 2012 10:18:33 -0500 > Von: Sarah Goslee > An: Johannes Radinger > CC: R-help@r-project.org > Betreff: Re: [R] Wildcard for indexing? > Hi, > > You should probably do a bit of reading about regular expressio

Re: [R] Wildcard for indexing?

2012-02-14 Thread Johannes Radinger
Hi, Original-Nachricht > Datum: Tue, 14 Feb 2012 09:59:39 -0500 > Von: "R. Michael Weylandt" > An: Johannes Radinger > CC: R-help@r-project.org > Betreff: Re: [R] Wildcard for indexing? > I think the grep()-family (regular expressions) will be

[R] Wildcard for indexing?

2012-02-14 Thread Johannes Radinger
Hi, I'd like to know if it is possible to use wildcards * for indexing... E.g. I have a vector of strings. Now I'd like to select all elements which start with A_*? I'd also need to combine that with logical operators: "Select all elements of a vector that start with A (A*) OR that start with B

Re: [R] Split dataframe into new dataframes

2012-02-08 Thread Johannes Radinger
Am 08.02.2012 um 23:47 schrieb David Winsemius: > > On Feb 8, 2012, at 5:06 PM, Johannes Radinger wrote: > >> >> Am 08.02.2012 um 22:19 schrieb David Winsemius: >> >>> >>> On Feb 8, 2012, at 4:11 PM, Johannes Radinger wrote: >>> >

Re: [R] Split dataframe into new dataframes

2012-02-08 Thread Johannes Radinger
Am 08.02.2012 um 22:19 schrieb David Winsemius: > > On Feb 8, 2012, at 4:11 PM, Johannes Radinger wrote: > >> Hi, >> >> I want to split a dataframe based on a grouping variable (in one column). >> The resulting new >> dataframes should be stored

[R] Split dataframe into new dataframes

2012-02-08 Thread Johannes Radinger
Hi, I want to split a dataframe based on a grouping variable (in one column). The resulting new dataframes should be stored in a new variable. I tried to split the dataframe using split() and to store it using a FOR loop, but thats not working so far: df <- data.frame(A=c("A1","A1","A2","A2"),B

Re: [R] List to dataframe

2012-02-08 Thread Johannes Radinger
s used for the rownames. I'd like to have them as an own column and no row names... like for the list: list <- list(A=1:4, B=1:6, C=1:9) t(sapply(list, function(x) c(length(x), sum(x > 5), sum(x < 5 /Johannes > HTH, > Jorge.- > > > On Wed, Feb 8, 2012 at 8:5

[R] List to dataframe

2012-02-08 Thread Johannes Radinger
Hi, I want to "melt" my list and get certain deskriptive factors (length of a vector etc.) into a dataframe. Best to describe it with an example: A <- seq(4) B <- seq(6) C <- seq(9) ls <- list(A,B,C) # this is my list with vectors of different length # thats the dataframe how it should look lik

Re: [R] remove NAs from list collectively

2012-02-08 Thread Johannes Radinger
Hi, lapply(df, function (x) x[!is.na(x)]) thats is really great! Thank you! Original-Nachricht > Datum: Wed, 08 Feb 2012 12:01:17 +0100 > Von: Dimitris Rizopoulos > An: Johannes Radinger > CC: R-help@r-project.org > Betreff: Re: [R] remove NAs from list coll

[R] remove NAs from list collectively

2012-02-08 Thread Johannes Radinger
Hi, I am importing dataframe from an Excel file (xlsx package). The columns contain acutally measurements for single species and the column-length is of variable. As it is imported as a dataframe the difference to the "longest" column is filled with NA. To explain it with an example, my dataframe

Re: [R] Assigning objects to variable and variable to list in a for loop

2012-02-03 Thread Johannes Radinger
hi, Original-Nachricht > Datum: Fri, 3 Feb 2012 09:04:19 -0500 > Von: Steve Lianoglou > An: Johannes Radinger > CC: Joshua Wiley , r-help@r-project.org > Betreff: Re: [R] Assigning objects to variable and variable to list in a for > loop > Hi, > &g

Re: [R] Assigning objects to variable and variable to list in a for loop

2012-02-03 Thread Johannes Radinger
n #one variable. Thank you very much, best regards, Johannes Original-Nachricht > Datum: Fri, 3 Feb 2012 02:22:30 -0800 > Von: Joshua Wiley > An: Johannes Radinger > CC: r-help@r-project.org > Betreff: Re: [R] Assigning objects to variable and variable to list in a f

[R] Assigning objects to variable and variable to list in a for loop

2012-02-03 Thread Johannes Radinger
inside the loop to assign values. But here it is about assigning ojects to variables and coercing these to a list. Any suggestions are mostly welcomme. Thank you, best regards, Johannes Radinger -- __ R-help@r-project.org mailing list https://sta

Re: [R] x11() graphic device, displaying raster

2012-01-25 Thread Johannes Radinger
> > On 25.01.2012 13:42, Johannes Radinger wrote: > > > >> > >> On 25.01.2012 12:45, Johannes Radinger wrote: > >>> Hello, > >>> > >>> I am wondering about the X11() graphic device on Windows. > >>> I try to plot a

Re: [R] x11() graphic device, displaying raster

2012-01-25 Thread Johannes Radinger
> > On 25.01.2012 12:45, Johannes Radinger wrote: > > Hello, > > > > I am wondering about the X11() graphic device on Windows. > > I try to plot a raster image but nothing gets displayed. I > > found some pages where it is mentioned that x11() not > >

[R] x11() graphic device, displaying raster

2012-01-25 Thread Johannes Radinger
Hello, I am wondering about the X11() graphic device on Windows. I try to plot a raster image but nothing gets displayed. I found some pages where it is mentioned that x11() not always supports raster rendering. Is there any add on for x11, any update or any R-package which solves that displaying

Re: [R] reshape dataframe to array (pivot table)

2012-01-25 Thread Johannes Radinger
> An: Johannes Radinger > CC: "r-help@r-project.org" > Betreff: Re: [R] reshape dataframe to array (pivot table) > Hi, > > I wouldn't know how to fill the data into the array form you want, but > you can get the aggregated data with > > dfm <-

[R] reshape dataframe to array (pivot table)

2012-01-24 Thread Johannes Radinger
Hello, I would like to reshape a dataframe into an array. This is kind a similar task as Excel performs with a Pivot table. To illustrate it: LOC <- factor(c(1,2,2,3,1,1)) SPEC1 <- c(0,0,23,0,12,11) SPEC2 <- c(1,2,0,0,0,4) df <- data.frame(LOC,SPEC1,SPEC2) # original dataframe a <- array(NA,d

Re: [R] Split values in vector

2012-01-20 Thread Johannes Radinger
("01","02","03","04")) { x[i,paste("var3_",column,sep="")]<- as.numeric(value) } else print("Problem with category") } } }

Re: [R] Split values in vector

2012-01-20 Thread Johannes Radinger
(paste("x$var3_",column,sep=""))[i]<- as.numeric(value) } else print("Problem with category") } } } I think there is a problme with (paste("x$var3_",column,sep=""))[i] which is not recognized co

Re: [R] test if text is part of vector

2012-01-20 Thread Johannes Radinger
Hi, thank you very much... %in% is the operator I was looking for. cheers, johannes Original-Nachricht > Datum: Fri, 20 Jan 2012 13:01:54 +0100 > Von: Rainer M Krug > An: Johannes Radinger > CC: R-help@r-project.org > Betreff: Re: [R] test if text is

[R] test if text is part of vector

2012-01-20 Thread Johannes Radinger
Hello, this is a very simple question: How can I find out if a word is part of a list of words like: a <- "word1" b <- "word4" vector <- c("word1","word2","word3") I tried it with match(a,vector) but this gives the position of the word. I am not sure if and how that can be done with a logical

Re: [R] Split values in vector

2012-01-19 Thread Johannes Radinger
on't know how this can be handled best regards, johannes Original-Nachricht > Datum: Thu, 19 Jan 2012 13:42:24 +0100 (MET) > Von: Gerrit Eichner > An: Johannes Radinger > CC: R-help@r-project.org > Betreff: Re: [R] Split values in vector >

[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

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

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

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

  1   2   >