Re: [R] concatenating a string to a column

2010-11-09 Thread Peter Langfelder
On Tue, Nov 9, 2010 at 9:09 PM, wrote: > > Hi All, > > Suppose I want to concatenate a zero to all the values to a column called > period in data frame A. I want to do the following but the following > command actually deletes the entire column altogether. > >  A$period<-cat(A$period,"0",sep="");

Re: [R] Inserting Missing Data

2010-11-10 Thread Peter Langfelder
On Wed, Nov 10, 2010 at 1:38 PM, wrote: > > Greetings >     I'm attempting to insert missing data on the smallest size class of > cave cricket instars into a data frame. The data involve censusing > photoplots (plots) of roosting cave crickets in which we discern in four > instars or size classes

Re: [R] Populating then sorting a matrix and/or data.frame

2010-11-11 Thread Peter Langfelder
On Thu, Nov 11, 2010 at 11:33 AM, Noah Silverman wrote: > Still doesn't work. > > When using rbind to build the data.frame, it get a structure mostly full of > NA. > The data is correct, so something about pushing into the data.frame is > breaking. > > Example code: > results <- data.frame() > > f

Re: [R] Populating then sorting a matrix and/or data.frame

2010-11-11 Thread Peter Langfelder
On Thu, Nov 11, 2010 at 1:19 PM, William Dunlap wrote: > Peter, > > Your example doesn't work for me unless I > set options(stringsAsFactors=TRUE) first. > (If I do set that, then all columns of 'results' > have class "character", which I doubt the user > wants.) You probably mean stringsAsFactor

Re: [R] Populating then sorting a matrix and/or data.frame

2010-11-11 Thread Peter Langfelder
On Thu, Nov 11, 2010 at 1:19 PM, William Dunlap wrote: > Peter, > > Your example doesn't work for me unless I > set options(stringsAsFactors=TRUE) first. Yes, you need to set options(stringsAsFactors=FALSE) (note the FALSE). I do it always so I forgot about that, sorry. _

Re: [R] Populating then sorting a matrix and/or data.frame

2010-11-11 Thread Peter Langfelder
I see 4 ways to write the code: 1. make the frame very long at the start and use my code - this is practical if you know that your data frame will not be longer than a certain number of rows, be it a million; 2a. use something like result1 = data.frame(a=a, b=b, c=c, d=d) within the loop to cre

Re: [R] what's wrong with this 'length' in function?

2010-11-11 Thread Peter Langfelder
You change x from a single value to a vector of size 2, for example here: if (j==2) {x=x+c(-1,1)*0.5} That makes c( qchisq(1-alpha/2,df=2*x)/2, qchisq(alpha/2,df=2*x+2)/2) a vector of 4 numbers that you are trying to assign to a row of a matrix with two columns.

Re: [R] dnorm and qnorm

2010-11-12 Thread Peter Langfelder
Not sure if there's a pre-defined function for it, but use your basic math skills: the normal distribution is dnorm(x) = 1/(sqrt(2*pi)) * exp(-x^2/2), so the inverse function (on the interval [0, infinity] is f = function(x) {sqrt( -2*log(sqrt(2*pi) * x)) } Since the dnorm function is not 1-to-

Re: [R] How to permanently remove [Previously saved workspace restored]

2010-11-13 Thread Peter Langfelder
On Sat, Nov 13, 2010 at 10:33 PM, Stephen Liu wrote: > Win 7 64 bit > R version 2.11.1 (2010-05-31) > > > How to permanently remove; > [Previously saved workspace restored] > >> rm (list = ls( )) > > On next start it still displays; > . > [Previously saved workspace restored] > > > There is a

Re: [R] hclust, does order of data matter?

2010-11-15 Thread Peter Langfelder
On Mon, Nov 15, 2010 at 2:07 PM, rchowdhury wrote: > > Hello, > > I am using the hclust function to cluster some data.  I have two separate > files with the same data.  The only difference is the order of the data in > the file.  For some reason, when I run the two files through the hclust > funct

Re: [R] hclust, does order of data matter?

2010-11-15 Thread Peter Langfelder
On Mon, Nov 15, 2010 at 2:19 PM, Reshmi Chowdhury wrote: > Here is the code I am using: > > m <- read.csv("data_unsorted.csv",header=TRUE) > m <- na.omit(m) > cs <- hclust(dist(t(m),method="euclidean"),method="complete") > ds <- as.dendrogram(cs) As Christian said, you may want to plot the cs tre

Re: [R] Non-positive definite cross-covariance matrices

2010-11-16 Thread Peter Langfelder
On Tue, Nov 16, 2010 at 9:40 AM, Jeff Bassett wrote: > Giovanni, > > Both matrices describing the points (A and B in my example) are the > same size, so the resulting matrix will always be square.  Also, the > equation I'm using is essentially the following identity: > > Var(A + B) = Var(A) + Var(

Re: [R] Non-positive definite cross-covariance matrices

2010-11-16 Thread Peter Langfelder
> Peter, > > I see your point.  As it turns out though, what I'm trying to > calculate is heritability using a slightly modified version of an > equation from multivariate quantitative genetics.  Theoretically I > suppose a heritability matrix could be non-positive definite, but in > practice it al

Re: [R] cluster analysis: predefined clusters

2010-11-26 Thread Peter Langfelder
On Fri, Nov 26, 2010 at 6:55 AM, Derik Burgert wrote: > Dear list, > > running a hierachical cluster analysis I want to define a number of objects > that build a cluster already. In other words: I want to force some of the > cases to be in the same cluster from the start of the algorithm. > > An

[R] Does stats::cor use the underlying BLAS? 32- vs. 64-bit issue

2010-12-03 Thread Peter Langfelder
Hi all, I'm curious whether the standard correlation calculation implemented in stats::cor uses the underlying BLAS (at least in the default case use = "all.obs"). On a 32-bit linux system using R-2.11.1 compiled with GotoBLAS, stats::cor is as fast as matrix multiplication, so it would appear st

Re: [R] tcltk error compiling R 2.13.0 under Windows 7 x64

2010-12-13 Thread Peter Langfelder
On Mon, Dec 13, 2010 at 4:33 PM, Joshua Wiley wrote: > Hi All, > > I am trying to compile R 2.13.0 r53834 on 64-bit Windows 7 (home > premium) using Rtools212.exe from Duncan Murdoch's site.  I (think) I > followed the installation guide for Windows.  When installing Rtools, > made sure I was inst

Re: [R] Nested layout()

2010-12-16 Thread Peter Langfelder
On Thu, Dec 16, 2010 at 7:00 PM, Dario Strbenac wrote: > Hello, > > Is it possible to call a graphing function that uses layout() multiple times > and layout those outputs ? Here's a minimal example : > > myplot <- function() > { >        layout(matrix(1:2, nrow=1), widths = c(1, 1)) >        plo

Re: [R] sample() issue

2010-12-20 Thread Peter Langfelder
On Mon, Dec 20, 2010 at 11:04 AM, cory n wrote: >> length(sample(25000, 25000*(1-.55))) > [1] 11249 > >> 25000*(1-.55) > [1] 11250 > >> length(sample(25000, 11250)) > [1] 11250 > >> length(sample(25000, 25000*.45)) > [1] 11250 > > So the question is, why do I get 11249 out of the first command and

Re: [R] finding and opening C source called from R functions.

2010-12-20 Thread Peter Langfelder
On Mon, Dec 20, 2010 at 12:48 PM, Chiquoine, Ben wrote: > Hi, > > As will soon be very clear I'm an R novice.  I'm trying to better understand > the ks.test function in the stats package.  When I look at the source code > there are several calls to C functions (for example .C("pkstwo", > is.int

Re: [R] vectorised recovery of strsplit value ??

2010-12-22 Thread Peter Langfelder
There are several ways to get a matrix, for example mat = as.matrix(as.data.frame(splitIDs)) or mat = sapply(splitIDs, I) True experts may suggests even more ways. Peter On Wed, Dec 22, 2010 at 1:02 PM, maddox wrote: > > Dear Guru's > > My first steps with R have ground to a halt! I have a v

Re: [R] recovering names of factor levels ??

2010-12-22 Thread Peter Langfelder
see function levels() ?levels Peter On Wed, Dec 22, 2010 at 3:00 PM, maddox wrote: > > Hi, > > I have a factor with 3 levels. I'd like to recover the names of each level > so I can use them to search through another data structure. Is this > possible? > > Thanks > _

[R] Problem loading Tcl/Tk (?)

2011-01-03 Thread Peter Langfelder
Hello, a user of one of my packages has sent me the following problem that apparently appears when loading the tcltk package. I'm guessing something (Tcl/Tk? R open scripting framework?) is not installed correctly... can someone please confirm or correct my guess? The OS is Mac 10.6.5. Thanks, P

Re: [R] packagename:::functionname vs. importFrom

2011-01-03 Thread Peter Langfelder
On Mon, Jan 3, 2011 at 3:48 PM, Hadley Wickham wrote: > Hi Frank, > > I think you mean packagename::functionname?  The three colon form is > for accessing non-exported objects. Normally two colons suffice, but within a package you need three to access exported but un-imported objects :) Peter _

Re: [R] packagename:::functionname vs. importFrom

2011-01-03 Thread Peter Langfelder
Well, I'm pretty sure that, inside package A, calling B::functionName will not work if B has not been imported. That's why I use ::: (after spending some time trying to figure out why :: didn't work). At least that was the state of affairs as of R 2.9 or so, perhaps things have changed since then.

Re: [R] Converting Fortran or C++ etc to R

2011-01-05 Thread Peter Langfelder
On Tue, Jan 4, 2011 at 4:02 PM, Murray Jorgensen wrote: > I'm going to try my hand at converting some Fortran programs to R. Does > anyone know of any good articles giving hints at such tasks? I will post a > selective summary of my gleanings. If the code uses functions/subroutines, keep in mind

Re: [R] Cairo pdf canvas size

2011-01-05 Thread Peter Langfelder
On Wed, Jan 5, 2011 at 7:35 PM, Eduardo de Oliveira Horta wrote: > Something like this: > > u=seq(from=-pi, to=pi, length=1000) > f=sin(u) > Cairo("example.pdf", type="pdf",width=12,height=12,units="cm",dpi=300) > par(cex.axis=.6,col.axis="grey",ann=FALSE, lwd=.25,bty="n", las=1, tcl=-.2, > mgp=c(

Re: [R] Help with IF operator

2011-01-06 Thread Peter Langfelder
Several possibilities: if (length(teams)!=length(unique(teams)) stop("Some teams are duplicated") or if (max(table(teams))>1) stop("Some teams are duplicated") I'm sure there are others, too. On Thu, Jan 6, 2011 at 12:21 PM, ADias wrote: > > Hi, > > I am with a problem on how to do a compar

Re: [R] Waaaayy off topic...Statistical methods, pub bias, scientific validity

2011-01-06 Thread Peter Langfelder
>From a purely statistical and maybe somewhat naive point of view, published p-values should be corrected for the multiple testing that is effectively happening because of the large number of published studies. My experience is also that people will often try several statistical methods to get the

Re: [R] Problems creating a PNG file for a dendrogram: "Error in plot.window(...) : need finite 'xlim' values"

2011-01-11 Thread Peter Langfelder
I'm guessing that your code actually generates two plots, one with the command p <- plot(hc) and one with plot(p), which doesn't work for a png. Try getting rid of the plot(p). Peter On Tue, Jan 11, 2011 at 4:01 PM, Richard Vlasimsky wrote: > > Has anyone successfully created a PNG file for a de

Re: [R] ordering a vector

2011-01-21 Thread Peter Langfelder
I think you want the following, assuming you defined your function g(): gValues = apply(S, 1, g); Sordered = S[order(gValues), ] Peter On Fri, Jan 21, 2011 at 11:38 AM, Francesco Petrogalli wrote: > Hi, > is there a R function that order a matrix according to some criteria > based on the rows(

Re: [R] Masking commands - Permutation in gregmisc and e1071

2011-01-24 Thread Peter Langfelder
On Mon, Jan 24, 2011 at 2:47 PM, Yanika Borg wrote: > I am using the function permutations from the package *gregmisc*. However, I > am also making use of the package *e1071*, which also contains a function > called permutations. I want to use the function permutations from the * > gregmisc* packa

Re: [R] matrix

2011-04-26 Thread Peter Langfelder
On Tue, Apr 26, 2011 at 2:28 PM, Val wrote: > Hi all, > > Assume I have a matrix > xv=  [1 0 0 0 0 12, >      0 1 0 0 0 10, >  *    0 0 1 0 0 -9,* >      0 0 0 1 0 20, >    *  0 0 0 0 1 -5]* > > if the last column of "xv"  less than  0 then I want to set zero the entire > row. > The desired output

Re: [R] Pretty printing numbers

2011-05-08 Thread Peter Langfelder
On Sun, May 8, 2011 at 4:41 PM, Worik R wrote: > Friends > > I am trying to format a number to a string so 2189.745 goes to "2,189.35" > and 309283.929 goes to "309,283.93" > > I have tried to use formatC(X, big.mark=",",drop0trailing=FALSE, format="f") > but it does not get the number of decimals

Re: [R] hierarchical clustering within a size limit

2011-05-11 Thread Peter Langfelder
On Wed, May 11, 2011 at 10:12 AM, rna seq wrote: > Hello List, > > I am trying to implement a hierarchical cluster using the hclust method > agglomerative single linkage method with a small wrinkle. I would like to > cluster a set of numbers on a number line only if they are within a distance > of

Re: [R] Help with 2-D plot of k-mean clustering analysis

2011-05-18 Thread Peter Langfelder
On Wed, May 18, 2011 at 7:41 AM, Meng Wu wrote: > Hi, all > >  I would like to use R to perform k-means clustering on my data which > included 33 samples measured with ~1000 variables. I have already used > kmeans package for this analysis, and showed that there are 4 clusters in my > data. Howeve

Re: [R] How to do covariate adjustment in R

2011-05-19 Thread Peter Langfelder
On Thu, May 19, 2011 at 7:21 PM, karena wrote: > Hi, I have a question about how to do covariate adjustment. > > I have two sets of 'gene expression' data. They are from two different > tissue types, 'liver' and 'brain', respectively. > The purpose of my analysis is to compare the pattern of the w

Re: [R] How to do covariate adjustment in R

2011-05-20 Thread Peter Langfelder
On Thu, May 19, 2011 at 10:58 PM, karena wrote: > Thank you so much for this reply, Peter. It helps. > > I know this is one way to adjust for covariates. However, if what I want is > to get the 'remaining values' after adjustment. For example, say, 'gene > expression' value is denoted as 'ge', and

Re: [R] Random Forest

2011-05-24 Thread Peter Langfelder
On Tue, May 24, 2011 at 3:18 PM, Unger, Rachel wrote: > I'm analyzing data using Random Forest Regression.  For some of the > species I am analyzing, the percent variation explained is negative. > Could you please explain to me what that means?  If you need more > information, please let me know.

Re: [R] R import glitch "missing data"

2011-05-26 Thread Peter Langfelder
On Thu, May 26, 2011 at 10:03 AM, StatBat2 wrote: > Hello! > > I am trying import data into R and im running into a snag. > > GOAL: > Import a 4 column, 8,000 row table into R including headers. > > WHAT I'VE ATTEMPTED: > Original data was in Excel format. > Converted data to both a .txt and .csv

Re: [R] Value of 'pi'

2011-05-30 Thread Peter Langfelder
On Sun, May 29, 2011 at 11:53 PM, wrote: > There is an urban legend that says Indiana passed a law implying pi = 3. > > (Because it says so in the bible...) > Apparently the Fortran language has a DATA statement just for this purpose. This is allegedly a quote from an early Fortran manual: The

Re: [R] correlatation matrix

2011-05-31 Thread Peter Langfelder
The WGCNA package contains function corAndPvalue that will calculate the correlation and the associated p-values for two matrices more efficiently and quickly. HTH, Peter On Tue, May 31, 2011 at 12:03 AM, Unger, Kristian, Dr. wrote: > Hi there, > > I wonder if there is a way of efficiently gene

Re: [R] Problem with % in an example when running R CMD check

2011-05-31 Thread Peter Langfelder
I observed the same behaviour some time ago. The .Rd files are pre-processed using a latex-like typesetter that discards everything following a % sign as comments, even in example R code. http://r.789695.n4.nabble.com/Rd-file-processing-suggestion-sign-in-examples-td3459570.html HTH, Peter On

Re: [R] Plotting nondetects a different color

2011-05-31 Thread Peter Langfelder
On Tue, May 31, 2011 at 2:19 PM, David Doyle wrote: > I often have data sets that have nondetects in them.  For example > Result     Detected ( 0=No 1=Yes) > 14               1 > 20               1 > 10                0 > 19                1 > 12                0 > 9                   1 > 15      

Re: [R] Use line break at scrip but avoid line break on graphics

2011-06-02 Thread Peter Langfelder
On Thu, Jun 2, 2011 at 3:13 PM, Rolf Turner wrote: > On 03/06/11 09:03, Walmes Zeviani wrote: >> >> Hello list, >> >> I have plots with long strings in main=, ylab= or xlab=. So, in I my >> script >> I use break long lines to avoid lines hiden on my monitor and in sweave >> document pages. I use g

Re: [R] Use line break at scrip but avoid line break on graphics

2011-06-02 Thread Peter Langfelder
> Absolutely not!  Did you *read* the OP's question?  He wants to break > the line in the code --- for readable code presumably --- but ***not*** > in the output!   Your advice is the antithesis of what is required. > >    cheers, > >        Rolf Turner I stand corrected, indeed I missed the cruci

Re: [R] remove commas in a number when reading a text file

2011-06-13 Thread Peter Langfelder
On Mon, Jun 13, 2011 at 8:48 AM, Lee, Eric wrote: > Hello, > > I'm running version R x64 v2.12.2 on a 64bit windows 7 PC.  I'm trying to > read a text file using read.table where the values have a format like > "1,234,567".  What I want is "1234567".  Is there a quick way to strip out > the com

[R] "Optional" package dependency

2010-05-24 Thread Peter Langfelder
Hi all, apologies if this has been answered before, I didn't find the answer in the archives. I am putting together a package that I would like to have optional functionality if another package is installed. In normal, non-package code, I would simply write something like if (require(qvalue)) {

Re: [R] R and ATLAS

2010-05-26 Thread Peter Langfelder
If you didn't specify an external BLAS when you ran R configure script, you are not using ATLAS. If you're not sure and you still have the output of the configure script, at the end it'll say whether it uses an external BLAS. Alternatively, you may also want to generate two random 5000x5000 matric

Re: [R] list of complex objects?

2010-05-26 Thread Peter Langfelder
c concatenates all arguments. For example, c(c(0,1,2), c(3,4,5)) gives a vector 0,1,2,3,4,5. Another example: > c(list(a=c(0,1), b = c(2,3)), list(c = c(4,5), d = c(5,6))) $a [1] 0 1 $b [1] 2 3 $c [1] 4 5 $d [1] 5 6 So instead of a list of two lists, you get a single list with 4 components. I

Re: [R] list of complex objects?

2010-05-26 Thread Peter Langfelder
list_of_fits, fitJC1) > > # still works, from original list construction > x[3] > > # but this doesn't work > x[4] > > Cheers! > Nick > > > > Peter Langfelder wrote: > >> c concatenates all arguments. For example, c(c(0,1,2), c(3,4,5)) gives >> a

Re: [R] R and ATLAS

2010-05-27 Thread Peter Langfelder
t; > I did notice during the VERY long compilation that it seemed to > correctly identify that I have 4 CPUs. > > Can someone confirm that the test: > > a = matrix(rnorm(5000*5000), 5000, 5000) > b = matrix(rnorm(5000*5000), 5000, 5000) > c = a%*%b > > Should illicit a multi-

Re: [R] list of complex objects?

2010-05-27 Thread Peter Langfelder
On Thu, May 27, 2010 at 9:43 AM, William Dunlap wrote: >> -Original Message- >> Unlike with vectors, with lists you don't have to specify >> length and can add >> as many list components as you want later  The length of the list will >> automatically adjust. > > 'Nonrecursive' vectors (i.e

Re: [R] if negative value, make zero

2010-05-28 Thread Peter Langfelder
temp2 = tempr temp2[temp2<0] = 0 HTH On Fri, May 28, 2010 at 8:37 AM, wrote: > I have a data frame with both positive and negative values, and I want to > make all the negative values equal zero, so i can eventually take an > average. > I've tried > temp2 <- ifelse(tempr<0, 0, tempr) > but it

Re: [R] Problem using apply

2010-06-01 Thread Peter Langfelder
Well, your example matrix is symmetric, so row and column operations naturally return the same values. You may want to note though that if you apply your function to a matrix along rows, the results will be stored in the __columns__ of the resulting matrix. Thus, if you want to simply divide the r

Re: [R] Wrong symbol rendering in plots (Ubuntu)

2010-06-04 Thread Peter Langfelder
On Fri, Jun 4, 2010 at 1:44 PM, Ben Bolker wrote: > Eduardo J. Chica gmail.com> writes: >> Hi I am having problems with the rendering of scientific symbols (mu and >> degree) in my plots. Whenever I use these symbols they are rendered >> changed (mu is changed to the proportionality symbol and de

Re: [R] Wrong symbol rendering in plots (Ubuntu)

2010-06-04 Thread Peter Langfelder
> > This issue is already in the Notes section of ?pdf.  It remains to be seen > if the OP's problem was this exact one, since they didn't specify an > example. aahhh, thank you for pointing this out. I never noticed this note. Peter __ R-help@r-projec

Re: [R] 380x380 dataframe to list

2010-06-04 Thread Peter Langfelder
c(as.matrix(data)) will not do it? Peter On Fri, Jun 4, 2010 at 5:47 PM, Nick Matzke wrote: > Hi, > > This can't be hard, but I can't find the solution.  I have a 380x380 data > frame of numbers.  I would like to turn it into a single column so I can do > e.g. hist and mean on it without writing

Re: [R] classification algorithms with distance matrix

2010-06-07 Thread Peter Langfelder
On Mon, Jun 7, 2010 at 9:05 AM, sidahmed BENABDERRAHMANE wrote: > Dear all, > > I have a problem when using some classification functions (Kmeans, PAM, > FANNY...)  with a distance matrix, and i would to understand how it proceeds > for the positioning of centroids after one execution step. > > In

Re: [R] counting across leves of factors

2010-06-09 Thread Peter Langfelder
To get the counts, assuming your data frame is called factors and it only contains the 17 factors, you can do n = nrow(factors) aux = rep(1, n); tab = tapply(aux, as.list(factors), sum); example: factors = matrix(sample(c(1:3), 3000, replace = TRUE), 1000, 3) lfactors = as.list(data.fran = nrow(

Re: [R] question about "mean"

2010-06-09 Thread Peter Langfelder
apply(iris[, -5], 2, tapply, iris$Species, mean) On Wed, Jun 9, 2010 at 3:43 PM, SH.Chou wrote: > Hi there: > I have a question about generating mean value of a data.frame. Take > iris data for example, if I have a data.frame looking like the following: > - >Sepal.Len

Re: [R] identifying when one element of a row has a positive number

2011-01-26 Thread Peter Langfelder
Here's a solution., maybe not the most elegant but works. df.r = df1[, c(3:5)]; # restricted data nNonZero = apply(df.r!=0, 1, sum); one = nNonZero==1; oneZero = nNonZero==2; whichOne = apply(df.r[one, ]!=0, 1, which); whichZero = apply(df.r[oneZero, ]==0, 1, which); colNames = colnames(df.r);

Re: [R] computing var-covar matrix with much missing data

2011-01-31 Thread Peter Langfelder
On Mon, Jan 31, 2011 at 9:30 AM, Mike Miller wrote: > Is there an R function for computing a variance-covariance matrix that > guarantees that it will have no negative eigenvalues?  In my case, there is > a *lot* of missing data, especially for a subset of variables.  I think my > tactic will be t

Re: [R] how to check if an attribute exists

2011-02-02 Thread Peter Langfelder
On Wed, Feb 2, 2011 at 7:22 PM, Nick Matzke wrote: > Oh wait, this basically does it: > >> if ("a" %in% attributes(z)$names) > + print(TRUE) > [1] TRUE > > (but there may be a better way) If z is a list, you can test is.null(z$a) Peter __ R-help@r-pr

[R] Fortran and long integers

2011-02-06 Thread Peter Langfelder
Hi all, I'm hoping someone more knowledgeable in Fortran than I can chime in with opinion. I'm the maintainer of the flashClust package that implements fast hierarchical clustering. The fortran code fails when the number of clustered objects is larger than about 46300. My guess is that this is be

Re: [R] Fortran and long integers

2011-02-07 Thread Peter Langfelder
> This only helps to some extent. > > If you set I=N and J=N then with N somewhere between 113000 and 114000 > ioffset will turn negative. Thanks to all for suggestions. N=113000 is by far out of range since (as far as I can tell) the distance structure would be longer than R can presently handle,

Re: [R] Plot where points are treatment letter

2011-02-08 Thread Peter Langfelder
Here's an example: x = c(1,2,3,4,5); y = rnorm(5); labels = LETTERS[1:5]; plot(x,y, type = "n") # This sets up the plot but doesn't actually plot the points text(x,y, labels) # This adds labels to positions (x,y) HTH, Peter On Tue, Feb 8, 2011 at 12:42 PM, Schatzi wrote: > > I would like to

Re: [R] Prediction accuracy from Bagging with continuous data

2011-02-10 Thread Peter Langfelder
On Thu, Feb 10, 2011 at 8:45 AM, Simon Gillings wrote: > I am using bagging to perform Bagged Regression Trees on count data (bird > abundance in Britain and Ireland, in relation to climate and land cover > variables). Predictions from the final model are visually believable but I > would reall

Re: [R] expected behavior when parsing lines with special characters

2011-02-15 Thread Peter Langfelder
On Tue, Feb 15, 2011 at 9:21 AM, Robert M. Flight wrote: > Say I have a tab-delimited table I want to read into R. What should I > expect to happen if some of the entries contain the character " ' "? I > thought it would read the file fine, but that is not what happens. > Instead, all the values i

Re: [R] Write File to Shared Drive

2011-02-15 Thread Peter Langfelder
On Tue, 15 Feb 2011, Stuart Jaffe wrote: > Hi, >   I'm trying to write a file to a shared drive on a network. I use the > "write.csv" function with the correct path but R doesn't recognize the > directory. Is there something different I have to do since it's a shared > drive? > Thanks. Check that

Re: [R] Write File to Shared Drive

2011-02-15 Thread Peter Langfelder
On Tue, Feb 15, 2011 at 11:56 AM, Kevin Wright wrote: > The original poster did not say what operating system was being used.  From > my own experience on Windows, I always used "/" for reading from the local > hard drive, but when I started working with Windows network shares/folders, > I had to

Re: [R] image() with a vector

2011-02-15 Thread Peter Langfelder
On Tue, Feb 15, 2011 at 8:43 PM, Steven Cordwell wrote: > Hi, > > I have a vectors x and z, for example, > > x <- 0:20 > z <- round(runif(20,1,7)) > y <- 0.5 > > and I want to display z as an image. However if I then call image() with a > vector > > image(x,y,t(z),zlim=c(1,7),col=heat.colors(7),x

[R] Line spacing in graphics

2011-02-18 Thread Peter Langfelder
Hi all, tried to google but found nothing, so here goes the question: is there a way to control line spacing when displaying text in graphical mode (for example, using text())? As an example, run the following code: plot(c(0,1), c(0,1), type = "n", axes = FALSE, xlab = "", ylab = "") text(0.5, 0

Re: [R] Line spacing in graphics

2011-02-18 Thread Peter Langfelder
On Fri, Feb 18, 2011 at 3:55 PM, Sarah Goslee wrote: > Peter, > > Try par()$lheight > > The catch is, you need to set it *before* the call to text() > > par(lheight=.8) # closer together > text(x, y, "whatever\nsecondline") > > The best place to find options like lheight is in ?par Thanks - I had

Re: [R] Generating uniformly distributed correlated data.

2011-02-19 Thread Peter Langfelder
On Sat, Feb 19, 2011 at 6:17 PM, Søren Faurby wrote: > I wish to generate a vector of uniformly distributed data with a defined > correlation to another vector > > The only function I have been able to find doing something similar is corgen > from the library ecodist. > > The following code gener

Re: [R] set argument of a function by string variable

2011-02-24 Thread Peter Langfelder
On Thu, Feb 24, 2011 at 10:03 AM, Duke wrote: > Hi folks, > > I am wondering if the following is possible: I want to control the arguments > sent to a function by string variables. For example, instead of >> heatmap.2( A, col=greenred(75) ) > I would want to have something like: >> heatmap.2 ( pas

Re: [R] error in saved .csv

2011-03-01 Thread Peter Langfelder
On Tue, Mar 1, 2011 at 1:36 PM, Tamas Barjak wrote: > Help me please! > > I would like to be saved a data table: > > write.csv(random.t1, "place", dec=",", append = T, quote = FALSE, sep = " ", > qmethod = "double", eol = "\n", row.names=F) > > It's OK! > > But the rows of file >  1,1,21042,-4084

Re: [R] *** caught segfault *** when using impute.knn (impute package)

2011-03-02 Thread Peter Langfelder
On Wed, Mar 2, 2011 at 6:31 AM, Bettina Kulle Andreassen wrote: > hi, > > i am getting an error when calling the impute.knn > function (see the screenshot below). > what is the problem here and how can it be solved? > > > screenshot: > > ## >  *** caught segfault *** > address 0x51

Re: [R] Problem with tcltk

2011-03-04 Thread Peter Langfelder
On Fri, Mar 4, 2011 at 8:02 AM, Arnaud Mosnier wrote: > Dear all, > > Since I installed the x64 version of R (v2.12.1), I got a problem with tcltk > that I did not achieve to resolve. > When loading the library, it gives me the following error message: > > Loading Tcl/Tk interface ...Error : .onLo

Re: [R] Conditional coloring

2011-03-14 Thread Peter Langfelder
On Mon, Mar 14, 2011 at 1:06 PM, Pavan G wrote: > Hello All, > I have a histogram with values above and below 0. I would like to color the > +ve bars green and -ve bars red. I am plotting data using: > > hist(a[,2],breaks=100,main="W3",xlab="Movement towards site (A)") > > Can someone please comme

Re: [R] Element by element mean of a list of matrices

2011-03-15 Thread Peter Langfelder
On Tue, Mar 15, 2011 at 1:17 PM, hihi wrote: > Hi All, > is there any effiective and dense/compact method to calculate the mean of a > list of - of course coincident - matrices on an element by element basis? The > resulting matrix' [i, j]-th element is the mean of the list's matrices' [i, > j]

Re: [R] Singularity problem

2011-03-16 Thread Peter Langfelder
On Wed, Mar 16, 2011 at 8:28 AM, Feng Li wrote: > Dear R, > > If I have remembered correctly, a square matrix is singular if and only if > its determinant is zero. I am a bit confused by the following code error. > Can someone give me a hint? > >> a <- matrix(c(1e20,1e2,1e3,1e3),2) >> det(a) > [1]

Re: [R] Replacing Period in String

2011-03-20 Thread Peter Langfelder
I think it is as simple as adding the argument fixed=TRUE to the function call. txt = "this. is. a. test." gsub(".", "", txt, fixed = TRUE) result [1] "this is a test" HTH, Peter On Sun, Mar 20, 2011 at 9:49 PM, Sparks, John James wrote: > Dear R Users, > > I am working with gsub for the firs

Re: [R] Correlation for no of variables

2011-03-21 Thread Peter Langfelder
On Mon, Mar 21, 2011 at 8:34 AM, Vincy Pyne wrote: > Dear R helpers, > > Suppose I have stock returns data of say 1500 companies each for say last 4 > years. Thus I have a matrix of dimension say 1000 * 1500 i.e. 1500 columns > representing companies and 1000 rows of their returns. > > I need to

Re: [R] affymetrix human gene 1.0 st gene level

2011-03-22 Thread Peter Langfelder
On Tue, Mar 22, 2011 at 11:35 AM, Unger, Kristian, Dr. wrote: > Hi there > > I recently got some affymetrix human gene 1.0 st array. I only get out the > probe level data and I wonder if there is a function that is able to average > the probe level data for each gene? In the WGCNA package we ha

Re: [R] Estimating correlation in multiple measures data

2011-03-23 Thread Peter Langfelder
On Wed, Mar 23, 2011 at 1:17 PM, Michal Figurski wrote: > Dear R-helpers, > > This may sound simple to you, but I'm a beginner in this, so please be > forgiving. > I have a following problem: two analytes were measured in patient's blood on > 4 occasions: ProteinA and ProteinB. How to correctly ev

Re: [R] to draw a too big clutering picture

2011-03-25 Thread Peter Langfelder
On Fri, Mar 25, 2011 at 2:57 PM, wang peter wrote: > i did clustering on a data with 497 rows and  71 columns > but the result picture is too big to display > how can i display it partly > this is the code: > x<-read.table("x",sep=",") > dim(x) > library(cluster) > t<-agnes(x) > par(ask=T) > plot(

Re: [R] comparing heatmaps

2011-03-28 Thread Peter Langfelder
On Mon, Mar 28, 2011 at 6:36 PM, Benton, Paul wrote: > Benno, > > That helps but it only makes the color bar symmetrical. I want to be able to > compare 2 different heatmaps so that 0.7 (for example) is always the same > tone of green and not shifted slightly. Is this possible? > > Paul >From w

Re: [R] Graph many points without hiding some

2011-03-31 Thread Peter Langfelder
On Wed, Mar 30, 2011 at 10:04 PM, Samuel Dennis wrote: > I have a very large dataset with three variables that I need to graph using > a scatterplot. However I find that the first variable gets masked by the > other two, so the graph looks entirely different depending on the order of > variables.

Re: [R] Cluster analysis, factor variables, large data set

2011-03-31 Thread Peter Langfelder
On Thu, Mar 31, 2011 at 11:48 AM, Hans Ekbrand wrote: > > The variables are unordered factors, stored as integers 1:9, where > > 1 means "Full-time employment" > 2 means "Part-time employment" > 3 means "Student" > 4 means "Full-time self-employee" > ... > > Does euclidean distances make sense on

Re: [R] regular expression

2011-03-31 Thread Peter Langfelder
On Thu, Mar 31, 2011 at 5:49 PM, array chip wrote: > Thanks Bernd! I tried your approach with my real example, sometimes it worked, > sometimes it didn't. For example > > grep('[^(arg)]\\.symptom',"stomach.symptom",value=T) > [1] "stomach.symptom" > > grep('[^(arg)]\\.symptom',"liver.symptom",valu

Re: [R] problem with all/all.equal

2011-04-06 Thread Peter Langfelder
On Wed, Apr 6, 2011 at 3:09 PM, Laura Smith wrote: > Hi! > > In a function, I may have an instance in which all elements are equal. > >> x <- rep(1,5) >> >> x > [1] 1 1 1 1 1 >> identical(x) > Error in .Internal(identical(x, y, num.eq, single.NA, attrib.as.set)) : >  'y' is missing >> all.equal(x)

Re: [R] Where is the tcltk package?

2011-04-07 Thread Peter Langfelder
On Thu, Apr 7, 2011 at 5:32 PM, Rolf Turner wrote: > On 08/04/11 12:22, Erik Iverson wrote: >> >> Rolf, >> >> What does >> >>  >  capabilities("tcltk") >> >> return? > > FALSE > As others have indicated, your R was compiled without Tcl/Tk support. Most likely because Tcl/Tk was/is not installed o

Re: [R] count number of TRUEs in each row

2011-04-10 Thread Peter Langfelder
On Sun, Apr 10, 2011 at 2:24 PM, Wendy wrote: > Hi all, > > I have a huge matrix of TRUE/FALSE table like following, and I want to count > the number of TRUEs in each row. Instead of looping through each row and do > length(Z[Z==TRUE]), I am wondering if there is an easier way of doing this. > >  

Re: [R] In need of help with correlations

2011-04-11 Thread Peter Langfelder
On Sat, Apr 9, 2011 at 10:24 AM, Sean Farris wrote: > I am in need of someone's help in correlating gene expression. I'm somewhat > new to R, and can't seem to find anyone local to help me with what I think > is a simple problem. > > I need to obtain pearson and spearman correlation coefficients,

Re: [R] regular expression question

2011-04-11 Thread Peter Langfelder
On Mon, Apr 11, 2011 at 10:49 PM, Erin Hodgess wrote: > Dear R People: > > I have a data frame with the following column names: > >> names(funky) >  [1] "UHD.1"   "UHD.2"   "UHD.3"   "UHD.4"   "L..W..1" "L..W..2" "L..W..3" >  [8] "L..W..4" "B..W..1" "B..W..2" "B..W..3" "B..W..4" "W..B..1" "W..B..2

Re: [R] qvalue

2011-04-18 Thread Peter Langfelder
On Mon, Apr 18, 2011 at 9:12 AM, Jim Silverton wrote: > I am using storey's qvalue package but I keep on getting errors. Why is > this? > >> qvalue(p, lambda=0.5)$pi0 > [1] "ERROR: p-values not in valid range." > Error in qvalue(p, lambda = 0.5)$pi0 : >  $ operator is invalid for atomic vectors S

[R] Rd file processing suggestion - % sign in examples

2011-04-18 Thread Peter Langfelder
Hi folks, I have come across a simple quirk that took me a long time to figure out. The gist is that if I write, in the example section of an Rd file, the line c = a %*% b what R will see when running the example is c = a since the % signs are apparently considered comment signs even in the \e

Re: [R] Trouble Passing a for loop variable (iteration #) to a data frame

2011-04-25 Thread Peter Langfelder
You need to index the variable iter: instead of iter = x[i], say iter[i] = x[i]. But a better solution is to simply say iter = x at the beginning and don't update it in the loop. The way your code is written, iter just holds the last x[i], and the last x[i] at the end of each loop is 4. Peter

[R] R CMD check thinks my function is an S3 method

2011-08-03 Thread Peter Langfelder
Hi all, in my package I have a function with name plot.cor (this function is inherited from another legacy package). According to CRAN package checks reports, the check apparently thinks plot.cor is a method for the plot generic (I hope I'm using the correct terminology). checking Rd \usage secti

[R] Can R handle a matrix with 8 billion entries?

2011-08-09 Thread Peter Langfelder
Sorry if this is a duplicate... my email is giving me trouble this evening... On Tue, Aug 9, 2011 at 8:38 PM, Chris Howden wrote: > Hi, > > I’m trying to do a hierarchical cluster analysis in R with a Big Data set. > I’m running into problems using the dist() function. > > I’ve been looking at a

<    1   2   3   4   5   >