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

[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

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 rip...@stats.ox.ac.uk 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 optimize/fit

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

2015-03-21 Thread Johannes Radinger
the standard R distribution: 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 function using an optimization (ordinary least squares

[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 how to extract

[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

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

2014-07-14 Thread Johannes Radinger
77840-4352 -Original Message- From: r-help-boun...@r-project.org [mailto:r-help-boun...@r-project.org] On Behalf Of Johannes Radinger Sent: Wednesday, July 9, 2014 7:07 AM To: R help Subject: [R] Cutting hierarchical cluster tree at specific height fails Hi, I'd like to cut

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

2014-07-11 Thread Johannes Radinger
Department of Anthropology Texas AM University College Station, TX 77840-4352 -Original Message- From: r-help-boun...@r-project.org [mailto:r-help-boun...@r-project.org] On Behalf Of Johannes Radinger Sent: Wednesday, July 9, 2014 7:07 AM To: R help Subject: [R] Cutting

[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 the base value (where var1=c) which is

[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

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

2013-12-12 Thread Johannes Radinger
-help-boun...@r-project.org [r-help-boun...@r-project.org] ; meghatalmaz#243;: 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 follwowing example of pnorm here: http://www.r

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

2013-12-12 Thread Johannes Radinger
)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 wanted to reverse following equation: r=0.67 q=-150 sd1

[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

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

2013-11-19 Thread Johannes Radinger
: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 the x-axis ticks for both plots are differently spaced: The boxplot ticks are closer

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 =

[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

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

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

2013-05-10 Thread Johannes Radinger
, Johannes Radinger wrote: This email has already been sent to the R-mailing list, but maybe you as the author of the package sets can help here best Hi, I am trying to use the fuzzy_inference system on multiple input values. Basically I combine two variables (depth, velocity

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

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],, ,suitability %is%

[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

[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 vectors.. Any idea

Re: [R] string split at xth position

2013-03-13 Thread Johannes Radinger
substr(x, 3, 4) [1] b1 b2 b2 HTH, Jorge.- On Wed, Mar 13, 2013 at 7:37 PM, Johannes Radinger wrote: 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

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

[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

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

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

2013-01-11 Thread Johannes Radinger
Hope this helps, Rui Barradas Em 11-01-2013 10:08, Johannes Radinger escreveu: 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

[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.col2 =

[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 ray.brownr...@ecs.vuw.ac.nz wrote: On 18/12/2012 10:56 p.m., Johannes Radinger wrote: Hi

[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

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

2012-12-11 Thread Johannes Radinger
. - Original Message - From: Johannes Radinger johannesradin...@gmail.com To: r-help@r-project.org Cc: Sent: Tuesday, December 11, 2012 5:55 AM Subject: [R] Renaming column names according to another dataframe Hi, I've got a dataframe having a code as column name. Addtionally I have

[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

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

2012-09-28 Thread Johannes Radinger
Barradas Em 28-09-2012 11:10, Johannes Radinger escreveu: 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

[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 want but 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 istaz...@gmail.com wrote: Hi Johannes, On Thu, Sep 27, 2012 at 7:25 AM, Johannes Radinger johannesradin...@gmail.com wrote: Hi, I am using colsplit (package = reshape) to split all

[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
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 install some packages required by my old and working scripts. Unfortunately 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 -

[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

[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 achim.zeil...@uibk.ac.at An: Johannes Radinger jradin...@gmx.at CC: R-help@r-project.org Betreff

[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

[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

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 thierry.onkel...@inbo.be An: Johannes Radinger jradin...@gmx.at, R-help@r-project.org R-help@r-project.org Betreff: RE: [R] Transform counts into presence/absence Just use the logical

[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
with name B. I have to think about this /Johannes Original-Nachricht Datum: Thu, 31 May 2012 09:20:27 -0500 Von: J Toll jct...@gmail.com An: Johannes Radinger jradin...@gmx.at CC: R-help@r-project.org Betreff: Re: [R] Remove columns from dataframe based on their statistics

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

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

[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

[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 of A and

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 wolfs...@msu.edu An: \'David Winsemius\' dwinsem...@comcast.net, \'Johannes Radinger\' jradin...@gmx.at CC: R-help@r-project.org

[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

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

[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

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

[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

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 murdoch.dun...@gmail.com An: R. Michael Weylandt michael.weyla...@gmail.com CC: Johannes Radinger jradin...@gmx.at, R-help@r-project.org Betreff: Re: [R] Save/Load function()-result to file

[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] 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 michael.weyla...@gmail.com An: Johannes Radinger jradin...@gmx.at CC: R-help@r-project.org Betreff: Re: [R] Wildcard for indexing? I think the grep()-family (regular expressions

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 sarah.gos...@gmail.com An: Johannes Radinger jradin...@gmx.at CC: R-help@r-project.org Betreff: Re: [R] Wildcard for indexing? Hi, You should probably do a bit of reading about regular

[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] 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 d.rizopou...@erasmusmc.nl An: Johannes Radinger jradin...@gmx.at CC: R-help@r-project.org Betreff: Re: [R] remove

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

Re: [R] List to dataframe

2012-02-08 Thread Johannes Radinger
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:50 AM, Johannes Radinger wrote: Hi, I want to melt my list and get

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

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 in a new variable. I tried to split the dataframe using

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: Hi, I want to split a dataframe based on a grouping variable (in one column

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

2012-02-03 Thread Johannes Radinger
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://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R

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

2012-02-03 Thread Johannes Radinger
:22:30 -0800 Von: Joshua Wiley jwiley.ps...@gmail.com An: Johannes Radinger jradin...@gmx.at CC: r-help@r-project.org Betreff: Re: [R] Assigning objects to variable and variable to list in a for loop Hi Johannes, There is a relatively elegant solution if you assign in a list: reslist

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 mailinglist.honey...@gmail.com An: Johannes Radinger jradin...@gmx.at CC: Joshua Wiley jwiley.ps...@gmail.com, r-help@r-project.org Betreff: Re: [R] Assigning objects to variable and variable

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

2012-01-25 Thread Johannes Radinger
rainer.schuerm...@gmx.net An: Johannes Radinger jradin...@gmx.at CC: r-help@r-project.org 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 - melt( df

[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

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 always supports raster rendering. Is there any add

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 raster image but nothing gets displayed. I found some pages where it is mentioned that x11() not always

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

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

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 r.m.k...@gmail.com An: Johannes Radinger jradin...@gmx.at CC: R-help@r-project.org Betreff: Re: [R] test

Re: [R] Split values in vector

2012-01-20 Thread Johannes Radinger
... best regards, /johannes Original-Nachricht Datum: Thu, 19 Jan 2012 13:42:24 +0100 (MET) Von: Gerrit Eichner gerrit.eich...@math.uni-giessen.de An: Johannes Radinger jradin...@gmx.at CC: R-help@r-project.org Betreff: Re: [R] Split values in vector Hi, Johannes, maybe

Re: [R] Split values in vector

2012-01-20 Thread Johannes Radinger
-Nachricht Datum: Thu, 19 Jan 2012 13:42:24 +0100 (MET) Von: Gerrit Eichner gerrit.eich...@math.uni-giessen.de An: Johannes Radinger jradin...@gmx.at CC: R-help@r-project.org Betreff: Re: [R] Split values in vector Hi, Johannes, maybe X - unlist( strsplit( as.character( x$ART

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

Re: [R] Split values in vector

2012-01-19 Thread Johannes Radinger
-giessen.de An: Johannes Radinger jradin...@gmx.at CC: R-help@r-project.org Betreff: Re: [R] Split values in vector Hi, Johannes, maybe X - unlist( strsplit( as.character( x$ART), split = ;, fixed = TRUE)) X - strsplit( X, split = -, fixed = TRUE) X - sapply( X, function( x

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 Johannes Radinger wrote on 01/13/2012 12:28:46 PM: Hello

[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

[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,e)) FAM -

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 petr.pi...@precheza.cz An: Johannes Radinger jradin...@gmx.at CC: r-help@r-project.org Betreff: Re: [R] summary per group Hi Hello, I know that it'll be quite easy to do what I want

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 Extensions. So far everything works really fine, the script works

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

[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
(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 michael.weyla...@gmail.com An: Johannes Radinger jradin...@gmx.at CC: r-help@r

Re: [R] Argument validation within functions

2011-12-06 Thread Johannes Radinger
-Nachricht Datum: Tue, 6 Dec 2011 07:57:44 -0500 Von: R. Michael Weylandt michael.weyla...@gmail.com An: r-help r-help@r-project.org, Johannes Radinger jradin...@gmx.at Betreff: Re: [R] Argument validation within functions Use the ! (not) operator. Not sure what you mean

[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 B). How

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

  1   2   >