Re: [R] Randomly shuffle an array multiple times

2010-10-18 Thread Peter Langfelder
On Mon, Oct 18, 2010 at 4:38 AM, John Haart anothe...@me.com wrote: Dear List, I have a table i have read into R: Name    Yes/No John    0 Frank   1 Ann             0 James   1 Alex    1 etc  - 800 different times. What i want to do is shuffle yes/no and randomly re-assign them to

Re: [R] how do I make a correlation matrix positive definite?

2010-10-21 Thread Peter Langfelder
On Thu, Oct 21, 2010 at 3:50 PM, HAKAN DEMIRTAS demir...@uic.edu wrote: Hi, If a matrix is not positive definite, make.positive.definite() function in corpcor library finds the nearest positive definite matrix by the method proposed by Higham (1988). However, when I deal with correlation

Re: [R] discerning plot dots using colors

2010-10-26 Thread Peter Langfelder
On Tue, Oct 26, 2010 at 3:13 PM, Daisy Englert Duursma daisy.duur...@gmail.com wrote: There are several ways to do this but the package ggplot2 library(ggplot2) qplot(displ,hwy,data=mpg,colour=factor(cyl)) That can of course be done also using the standard plot command (substitute variable

Re: [R] How to scan df from a specific word?

2010-10-29 Thread Peter Langfelder
Sorry, this isn't really an R solution, but here it goes anyway. You can isolate the block from Source to the first following blank line by the following unix/linux/cygwin command, assuming inFile is your input file and outFile is the output file: cat inFile | grep -A 100 Source | grep -m 1 -B

Re: [R] One question on heatmap

2010-11-02 Thread Peter Langfelder
Before plotting a heatmap we usually standardize all genes to mean zero and variance 1. That way the green/red represent under/over expression with respect to the mean expression, which is roughly what the original 2-color arrays (that literally produced such heatmaps) were measuring. Of course,

Re: [R] memory allocation problem

2010-11-02 Thread Peter Langfelder
You have (almost) exhausted the 10GB you limited R to (that's what the memory.size() tells you). Increase memory.limit (if you have more RAM, use memory.limit(15000) for 15GB etc), or remove large data objects from you session. Use rm(object), the issue garbage collection gc(). Sometimes garbage

Re: [R] memory allocation problem

2010-11-02 Thread Peter Langfelder
for data to be swapped to and from the disk. Peter On Tue, Nov 2, 2010 at 7:36 PM, Peter Langfelder peter.langfel...@gmail.com wrote: You have (almost) exhausted the 10GB you limited R to (that's what the memory.size() tells you). Increase memory.limit (if you have more RAM, use memory.limit

Re: [R] dll problem with C++ function

2010-11-03 Thread Peter Langfelder
Just a shot in the dark... Do you properly close the input/output files at the end of your function? If not and the file remains open, it may throw an error upon new attempt to read it. It is possible that dyn.unload, among other things, closes all open connections and hence upon re-load

Re: [R] Centre of gravity of a mountain

2010-11-08 Thread Peter Langfelder
Weighted mean of x and y coordinates (sorry for the pun :)), that is something like n = 21 y = matrix( c(1:n), n, n) x = matrix( c(1:n), n, n, byrow = TRUE) # These are the Center of mass coordinates: xCenter = sum(x * Z)/sum(Z); yCenter = sum(y * Z)/sum(Z); If you also need the z coordinate,

Re: [R] Centre of gravity of a mountain

2010-11-09 Thread Peter Langfelder
On Mon, Nov 8, 2010 at 11:31 PM, Ab Hu master.rs...@yahoo.com wrote: Thanks! Works great. I have more questions on this, so I'll continue here: Now that I have the weighted mean, is it possible to reduce the size of mountain based on this weighted mean such the original matrix remains 21x21

Re: [R] Centre of gravity of a mountain

2010-11-09 Thread Peter Langfelder
On Tue, Nov 9, 2010 at 3:40 PM, Barry Rowlingson b.rowling...@lancaster.ac.uk wrote: On Mon, Nov 8, 2010 at 5:15 PM, Peter Langfelder peter.langfel...@gmail.com wrote: If you also need the z coordinate, it simply the mean of the matrix Z. zCenter = mean(Z)  How can that be right? Suppose

Re: [R] Centre of gravity of a mountain

2010-11-09 Thread Peter Langfelder
zCenter = mean(Z)  How can that be right? Suppose your mountain is very flat, so that your mountain is effectively a cube. The Z values are all the same, and so their mean is the same. However the centre of mass is, by symmetry, clearly at height/2.  Similarly suppose your mountain

Re: [R] Exponent of asymmetric matrix

2010-11-09 Thread Peter Langfelder
the exponent of asymmetric matrix makes me very curious. can anyone please explain to me what will happen if we apply exponent to the asymmetric matrix? The gates of Hell will open, the world will come to an end, and we will all perish in a firestorm :) Sorry, couldn't resist. Exponentiating

Re: [R] concatenating a string to a column

2010-11-09 Thread Peter Langfelder
On Tue, Nov 9, 2010 at 9:09 PM, sachinthaka.abeyward...@allianz.com.au 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.  

Re: [R] Inserting Missing Data

2010-11-10 Thread Peter Langfelder
On Wed, Nov 10, 2010 at 1:38 PM, kurt_h...@nps.gov 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

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 n...@smartmediacorp.com 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 -

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 wdun...@tibco.com 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

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 wdun...@tibco.com 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

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

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 sati...@yahoo.com 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

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

2010-11-15 Thread Peter Langfelder
On Mon, Nov 15, 2010 at 2:07 PM, rchowdhury rchowdh...@alumni.upenn.edu 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

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 rchowdh...@alumni.upenn.edu 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

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 jbass...@cs.gmu.edu 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) =

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 almost

Re: [R] cluster analysis: predefined clusters

2010-11-26 Thread Peter Langfelder
On Fri, Nov 26, 2010 at 6:55 AM, Derik Burgert derik2...@yahoo.de 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

[R] Problem (environment?) with R CMD CHECK

2010-09-13 Thread Peter Langfelder
Hi all, I have a package that contains a function foo that calls a function .fooInternal via match.fun('.fooInternal'). This step is necessary because I want to give the user an option to override .fooInternal with a custom function. The .fooInternal function name is not exported. The function

Re: [R] Problem (environment?) with R CMD CHECK

2010-09-14 Thread Peter Langfelder
2010/9/14 Uwe Ligges lig...@statistik.tu-dortmund.de: I do not see any problem, we'd need to look at the package in order to help, I think. I re-checked again and somehow the package now passes all checks, so I must have mistyped something somewhere. Sorry for that. Peter

[R] Lists with NULL entries

2010-09-20 Thread Peter Langfelder
Hello, I encountered a weird problem. Consider the following code that takes a list lst and shifts all elements one index up (for example, to make space for a new first element): lst = list(1,2) ll = length(lst); for (i in ll:1) lst[[i+1]] = lst[[i]]; lst If you run it, you get the expected

Re: [R] Lists with NULL entries

2010-09-20 Thread Peter Langfelder
Hi Joshua, thanks, I came up with that solution myself after a bit of thinking. Normally I wouldn't worry about NULL components of lists, but dimnames is a list and often some components are null and is therefore a bit tricky to manipulate... Peter On Mon, Sep 20, 2010 at 7:39 PM, Joshua Wiley

Re: [R] Please Help_Error:cannot allocate vector of size 400.4Mb

2010-09-21 Thread Peter Langfelder
On Tue, Sep 21, 2010 at 9:50 AM, qcshare qcsh...@gmail.com wrote: Hello, everyone, When I run R, I met: error:cannot allocate vector of size 400Mb, My data is large. What should I do? Thanks, everyone. How big is the RAM in your computer? There are a few things you can try: 1. Before

Re: [R] Length of vector without NA's

2010-09-23 Thread Peter Langfelder
this following code: x-c(1,2,NA) length(x) returns 3, correctly counting numbers as well as NA's. How can I exclude NA's from this count? sum(!is.na(x)) Peter __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help

Re: [R] hcluster with linkage median

2010-09-27 Thread Peter Langfelder
On Mon, Sep 27, 2010 at 8:22 AM, Kennedy henrik.aldb...@gmail.com wrote: Hi, I want to perform a hierarchical clustering using the median as linkage metric. As I understand it the function hcluster in package amap have this option but it does not produce the results that I expect. In the

Re: [R] hcluster with linkage median

2010-09-27 Thread Peter Langfelder
On Mon, Sep 27, 2010 at 8:22 AM, Kennedy henrik.aldb...@gmail.com wrote: Hi, I want to perform a hierarchical clustering using the median as linkage metric. As I understand it the function hcluster in package amap have this option but it does not produce the results that I expect. Also, if

Re: [R] Issue increasing DPI on a png output of a plot

2010-09-27 Thread Peter Langfelder
On Mon, Sep 27, 2010 at 8:48 AM, Justin Fincher finc...@cs.fsu.edu wrote: Howdy,  I have created a set of plots, but I wish to increase the dpi to 300 (instead of the default 72).  From the documentation, I thought that the res parameter to png should accomplish this, but it appears to

Re: [R] calculating mean and s.d. from a two-column table

2010-09-27 Thread Peter Langfelder
On Mon, Sep 27, 2010 at 9:34 AM, Jonas Josefsson jo...@runtimerecords.net wrote: I have a two-column table as follows where age is in the 1st column and the number of individuals is in the 2nd. age;no 1;21 2;31 3;9 4;12 5;6 You can use the following trick: x = rep(age, no) This repeats

Re: [R] break function execution

2010-09-28 Thread Peter Langfelder
On Tue, Sep 28, 2010 at 12:18 PM, Greg Snow greg.s...@imail.org wrote: Ctrl-C works on some platforms, it would help us to help you if we knew which OS you are using, which version of R you are using, and in some cases whether you are using the GUI or Terminal version of R. Hi, I have an

Re: [R] need help with ramdomly sampling some data

2010-09-28 Thread Peter Langfelder
On Tue, Sep 28, 2010 at 6:22 PM, Michael Larkin mlar...@rsmas.miami.edu wrote: I am trying to get R to randomly select values from my dataset (i.e. bootstrapping) with replacement.  However, my attempts at this have been unsuccessful.  Here is a basic example of what I am doing: I have a data

Re: [R] executing loop

2010-09-29 Thread Peter Langfelder
for (j in 1:n) { if (j%%2==0) { iRange = c(n:1) } else iRange = c(1:n) for (i in iRange) { your code } } Peter On Wed, Sep 29, 2010 at 10:40 AM, cassie jones cassiejone...@gmail.com wrote: Dear All, I am trying to define a loop for a m*n matrix, where

Re: [R] How to get a proportion of a Vector Member

2010-09-29 Thread Peter Langfelder
On Wed, Sep 29, 2010 at 6:43 PM, Gundala Viswanath gunda...@gmail.com wrote: I have a vector that looks like this: foo [1] o o o x o o o o o x x o x How can we find the percentage of o and x in that vector in R? table(foo)/length(foo) Peter __

Re: [R] cor() alternative for huge data set

2010-09-29 Thread Peter Langfelder
On Wed, Sep 29, 2010 at 1:27 PM, Jyotasana Gulati jgul...@ice.mpg.de wrote: Hi, I am have a data set of around 43000 probes(rows), and have to calculate correlation matrix. When I run cor function in R, its throwing an error message of RAM shortage which was obvious for such huge number of

Re: [R] print only 2 digits of number

2010-09-29 Thread Peter Langfelder
On Wed, Sep 29, 2010 at 7:18 PM, Christian Schoder schoc...@newschool.edu wrote: hi R-users! does anyone know how I can access/print only the first two digits of a number? if i have the number 23732, i would like to get 23. if i have 355 i would like to get 35. if i have 4 i would like to get

Re: [R] cor() alternative for huge data set

2010-09-30 Thread Peter Langfelder
. Has any one ever used this package--coXpress?? Regards .. Jyotasana - Original Message - From: Peter Langfelder peter.langfel...@gmail.com To: Jyotasana Gulati jgul...@ice.mpg.de Cc: r-help@r-project.org Sent: Thursday, September 30, 2010 4:05:44 AM Subject: Re: [R] cor

Re: [R] cleaning up a vector

2010-10-01 Thread Peter Langfelder
On Fri, Oct 1, 2010 at 10:51 AM, mlar...@rsmas.miami.edu wrote: I calculated a large vector.  Unfortunately, I have some measurement error in my data and some of the values in the vector are erroneous.  I ended up wih some Infs and NaNs in the vector.  I would like to filter out the Inf and

Re: [R] Memory allocation in 64 bit R

2010-10-01 Thread Peter Langfelder
Hi Mete, I think you should look at the help for memory.limit. Try to set a higher one, for example memory.limit(16000) (I think 16GB is what xenon will take). Peter On Fri, Oct 1, 2010 at 6:02 PM, Mete Civelek mcive...@mednet.ucla.edu wrote: Hi Everyone, I am getting the following error

Re: [R] Programmaticly finding number of processors by R code

2010-10-03 Thread Peter Langfelder
If no-one replies with a better way, here's a way: under POSIX-compliant systems, you can write a small C function and wrap it in an R function. The C program would be something like #include unistd.h void nProcessors(int n) { #ifdef _SC_NPROCESSORS_ONLN long nProcessorsOnline =

Re: [R] Create variable by name

2010-10-06 Thread Peter Langfelder
On Wed, Oct 6, 2010 at 9:32 AM, Ralf B ralf.bie...@gmail.com wrote: Can one create a variable through a function by name createVariable - function(name) {        outputVariable = name        name - NULL } after calling createVariable(myVar) I would like to have a variable myVar

Re: [R] Create variable by name

2010-10-06 Thread Peter Langfelder
On Wed, Oct 6, 2010 at 9:32 AM, Ralf B ralf.bie...@gmail.com wrote: Can one create a variable through a function by name createVariable - function(name) {        outputVariable = name        name - NULL } after calling createVariable(myVar) I would like to have a variable myVar

Re: [R] Assigning value to a vector from within a function

2010-10-06 Thread Peter Langfelder
#another simple function to update the value in a vector update-function(index){ test[index]- 20 } update(2) test #The update() function silently fails to accomplish the update Replace the '-' by '-' and you'll be good to go if you call the function from a global environment. More

Re: [R] what does this err mean and how to solve it? Error in file(file, ifelse(append, a, w))

2010-10-06 Thread Peter Langfelder
you should close files that you do not use anymore. the maximum number of open files is likely 4000 or so. Use close(file) before you open the next one. Peter On Wed, Oct 6, 2010 at 4:55 PM, Yong Wang wangyo...@gmail.com wrote: Dear List I am running a loop downloading  web pages and save the

Re: [R] repeating an analysis

2010-10-12 Thread Peter Langfelder
I think you want something like this: optimal.nSplit = rep(NA, 50) # This will hold the result for (run in 1:50) { fit1 = rpart(...) cpTable = fit1$cptable bestRow = which.min(cpTable[, xerror]); optimal.nSplit[run] = cpTable[bestRow, nsplit] } In any case, look at ?rpart ?printcp

Re: [R] Pasting function arguments and strings

2010-10-13 Thread Peter Langfelder
From what I read, you want something like this: myfunction-function(dataset,arg1,arg2) { func = match.fun(arg2) argument = dataset[, match(paste(arg1,_test, sep=), names(dataset))] result=func(argument) return(result) } On Wed, Oct 13, 2010 at 9:28 AM, Manta mantin...@libero.it wrote:

Re: [R] [OT] (slightly) - OpenOffice Calc and text files

2010-10-13 Thread Peter Langfelder
On Wed, Oct 13, 2010 at 10:13 AM, Schwab,Wilhelm K bsch...@anest.ufl.edu wrote: Hello all, I had a very strange looking problem that turned out to be due to unexpected (by me at least) format changes to one of my data files.  We have a small lab study in which each run is represented by a

Re: [R] How to create a dissimilarity object

2010-10-14 Thread Peter Langfelder
On Thu, Oct 14, 2010 at 5:21 PM, Paul Rigor (ucla) pr...@ucla.edu wrote: Hi all, I would like to use the fpc and cluster packages for clustering. However, I would like to create a custom dissimilarity object using a library in python.  Has anyone attempted or know of a work-around for

Re: [R] Impute missing data by regression in R

2010-10-14 Thread Peter Langfelder
I assume you mean regression of x on y... here's the code: missing = is.na(x) predicted = predict(lm(x~y)) x[missing] = predicted[missing]; Should work but please check. Peter On Thu, Oct 14, 2010 at 10:14 PM, Jumlong Vongprasert jumlong.u...@gmail.com wrote:  Dear all I have data (x,y)

[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

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.

Re: [R] list of complex objects?

2010-05-27 Thread Peter Langfelder
) # 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 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

Re: [R] R and ATLAS

2010-05-27 Thread Peter Langfelder
Should illicit a multi-CPU response with R/ATLAS?  If so, any suggestions on how to tweak my install to get it working?  Thanks! --j On Wed, May 26, 2010 at 3:17 PM, Peter Langfelder peter.langfel...@gmail.com wrote: If you didn't specify an external BLAS when you ran R configure script

Re: [R] list of complex objects?

2010-05-27 Thread Peter Langfelder
On Thu, May 27, 2010 at 9:43 AM, William Dunlap wdun...@tibco.com 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'

Re: [R] if negative value, make zero

2010-05-28 Thread Peter Langfelder
temp2 = tempr temp2[temp20] = 0 HTH On Fri, May 28, 2010 at 8:37 AM, ecvet...@uwaterloo.ca 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(tempr0, 0,

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

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 bol...@ufl.edu wrote: Eduardo J. Chica ejchica at 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

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 __

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 mat...@berkeley.edu 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

Re: [R] classification algorithms with distance matrix

2010-06-07 Thread Peter Langfelder
On Mon, Jun 7, 2010 at 9:05 AM, sidahmed BENABDERRAHMANE sidahmed.benabderrahm...@loria.fr 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

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 =

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 cls3...@gmail.com 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: -

Re: [R] Fastest way to merge matrix columns into a comma delimited string?

2010-06-15 Thread Peter Langfelder
apply(test, 1, paste, collapse = ,) On Tue, Jun 15, 2010 at 11:27 AM, Jonathan Greenberg greenb...@ucdavis.edu wrote: Folks: Say I have a matrix: test=matrix(c(1,2,3),nrow=10,ncol=3) I would like to have an output character vector where each line is row's values delimited by commas,

Re: [R] Read code from character string

2010-06-17 Thread Peter Langfelder
eval(parse(text=print(9**2))) On Thu, Jun 17, 2010 at 12:32 PM, Johannes Huesing johan...@huesing.name wrote: Dear expRts, I have a character string, say a - print(9**2). How do I execute the contents of the string, parsed as R code? Do I have to open a connection and use cat(a), and parse it

Re: [R] Same function name

2010-06-21 Thread Peter Langfelder
package::function On Mon, Jun 21, 2010 at 6:29 AM, Filoche pmassico...@hotmail.com wrote: Hi everyone. I want to use 2 different functions (in 2 packages) that have same name. for instance, if I call the function, it will use the one in the last called package.  Is there a way to specify

Re: [R] how to initial a list to store data result?

2010-06-21 Thread Peter Langfelder
On Mon, Jun 21, 2010 at 4:18 PM, song song rprojecth...@gmail.com wrote: May I ask how to initialize a list? usually I will use result=list(0)  to do this. is this right? It works, but it is cleaner to use results=list() The difference is that list(0) will have one component that contains

Re: [R] Plotrix Trick

2010-06-23 Thread Peter Langfelder
On Wed, Jun 23, 2010 at 10:01 AM, Lorenzo Isella lorenzo.ise...@gmail.com wrote: Dear All, I am using the plotrix library to plot some matrices. I have a problem: some of my data are outliers, hence using a linear color scale does not work very well (you would see too many cells having a

Re: [R] how can I evaluate a formula passed as a string?

2010-06-24 Thread Peter Langfelder
On Thu, Jun 24, 2010 at 10:16 AM, Mike Williamson this.is@gmail.com wrote: Hey everyone,    I've been using 'R' long enough that I should have some idea of what the heck either   expression()  or eval()  are really ever useful for.  I come across another instance where I WISH they would

Re: [R] Best way to compute a sum

2010-06-24 Thread Peter Langfelder
On Thu, Jun 24, 2010 at 1:26 PM, Duncan Murdoch murdoch.dun...@gmail.com wrote: On 24/06/2010 4:08 PM, Lasse Kliemann wrote: What is the best way in R to compute a sum while avoiding cancellation effects? Use sum().  If it's not good enough, then do it in C, accumulating in extended

Re: [R] Best way to compute a sum

2010-06-24 Thread Peter Langfelder
On Thu, Jun 24, 2010 at 1:50 PM, Duncan Murdoch murdoch.dun...@gmail.com wrote: On 24/06/2010 4:39 PM, Peter Langfelder wrote: AFAIK the optimal way of summing a large number of positive numbers is to always add the two smallest numbers Isn't that what I said? I understood that you

Re: [R] write a loop for tallies

2010-06-24 Thread Peter Langfelder
On Thu, Jun 24, 2010 at 3:16 PM, john polo jp...@mail.usf.edu wrote: Dear R users, I have a list of numbers such as n [1] 3000 4000 5000 3000 5000 6000 4000 5000 7000 5000 6000 7000 and i'd like to set up a loop that will keep track of the number of occurences of each of the values that

Re: [R] wgcna

2011-07-06 Thread Peter Langfelder
On Wed, Jul 6, 2011 at 8:27 AM, Raquel Martinez Garcia rmartin...@cnio.es wrote: Hi, I'm running a tutorial (Meta-analyses of data from two (or more) microarray data sets), which use wgcna package. I have an error in the function modulePreservation (it is below). I'm using R2.13 Can you

Re: [R] Intransitive DAG

2011-07-11 Thread Peter Langfelder
On Mon, Jul 11, 2011 at 12:28 PM, Thomas S. Dye t...@tsdye.com wrote: Aloha all, I have an adjacency matrix for an acyclic digraph that contains transitive relations, e.g. (u,v), (v,w), (u,w).  I want a DAG with only intransitive relations.  Can someone point me to an R function that will

Re: [R] wgcna

2011-07-12 Thread Peter Langfelder
Hi Meeta, yes, there was a bug in the package. Please install the newest version and try again. Best, Peter On Tue, Jul 12, 2011 at 1:20 PM, mistrm meeta.mis...@gmail.com wrote: Hi Peter and Raquel I am following the same tutorial and seem to have the same error appear and I am using 30

Re: [R] recursive function - finding connections

2011-07-14 Thread Peter Langfelder
Hi Paul, I assume you are using the argument cutoff to specify the p-value below which nodes are considered connected and above which they are not connected. I would use single linkage hierarchical clustering. If you have two groups of nodes and any two nodes between the groups are connected

Re: [R] recursive function - finding connections

2011-07-14 Thread Peter Langfelder
will run much faster. Peter On Thu, Jul 14, 2011 at 4:58 PM, Peter Langfelder peter.langfel...@gmail.com wrote: Hi Paul, I assume you are using the argument cutoff to specify the p-value below which nodes are considered connected and above which they are not connected. I would use single linkage

Re: [R] scaling advice

2011-07-15 Thread Peter Langfelder
On Fri, Jul 15, 2011 at 2:05 PM, Data Analytics Corp. w...@dataanalyticscorp.com wrote:  But then he apparently rescaled this 44x13 matrix so that the rows all sum to zero and the columns all sum to zero.  None of the row and column standard deviations are 1.0.  This I can't see how to do.  

Re: [R] gsub() with unicode and escape character

2011-07-16 Thread Peter Langfelder
Don't know the answer to you first question, but for the \\ see below. On Sat, Jul 16, 2011 at 7:19 PM, Sverre Stausland john...@fas.harvard.edu wrote: Unrelated to that problem, but related to gsub() is that I can't find a way for gsub() to interpret the backslash as a character. In regular

Re: [R] creating a matrix of ranked column data

2011-07-17 Thread Peter Langfelder
On Sun, Jul 17, 2011 at 11:18 AM, christian krahforst ckrahfo...@gmail.com wrote: I have a data frame (gom) or a matrix of trace metal data and some other observations from water column samples taken at sea (e.g., 19 samples (rows), 19 variables) I can calc. the rank individually from each

[R] read.table only reads part of file

2011-07-29 Thread Peter Langfelder
Hi all, I encountered a problem when trying to read in an Illumina chip annotation file. The offending file is large, so I zipped it up and posted it at http://www.genetics.ucla.edu/labs/horvath/CoexpressionNetwork/tmp/ProbeInfo_Expression.txt.bz2 Executing this: annot =

Re: [R] read.table only reads part of file

2011-07-29 Thread Peter Langfelder
On Fri, Jul 29, 2011 at 6:00 PM, Sarah Goslee sarah.gos...@gmail.com wrote: Hi Peter, I'm not going to look at your large file on what for me is Friday evening, but the usual cause of that kind of problem is a single or double quote in the text. bingo! Setting quote = solved the problem.

Re: [R] Is a string all blanks?

2011-08-02 Thread Peter Langfelder
On Tue, Aug 2, 2011 at 5:07 PM, John Sorkin jsor...@grecc.umaryland.edu wrote: windows 7 R 2.12.1 Is there any easy way to determine if a sting contains nothing but blanks? I need to check a series of strings of various length. OneBlank - TwoBlanks -   ThreeBlanks -   NoBlanks -

[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

[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 ch...@trickysolutions.com.au 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.

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

2011-08-09 Thread Peter Langfelder
Assuming you need the full distance matrix at one time (which you do not for hierarchical clustering, itself a highly dubious method for more than a few hundred points). Apologies if this hijacks the thread, but why is hierarchical clustering highly dubious for more than a few hundred points?

Re: [R] Opposite of paste function

2011-08-10 Thread Peter Langfelder
On Wed, Aug 10, 2011 at 11:22 AM, Soyeon Kim yunni0...@gmail.com wrote: Dear All, I have vn variable vn [1] V300 V376 What I want to get is 300 376 as.numeric(substring(vn, 2)) HTH Peter __ R-help@r-project.org mailing list

Re: [R] Clustering Large Applications..sort of

2011-08-10 Thread Peter Langfelder
On Wed, Aug 10, 2011 at 12:07 PM, Ken Hutchison vicvoncas...@gmail.com wrote: Hello all,   I am using the clustering functions in R in order to work with large masses of binary time series data, however the clustering functions do not seem able to fit this size of practical problem. Library

Re: [R] gsub wildcard

2011-08-15 Thread Peter Langfelder
On Mon, Aug 15, 2011 at 10:34 AM, Rebecca Gray atlas...@gmail.com wrote: Hello all, I have what I think is a simple question but I've been unable to solve it. I have the following string: A[states=1]:[rate=2]425, B[states=3]:[rate=5]500 I would like to combine the two expressions in the

Re: [R] Leading zeros

2011-08-19 Thread Peter Langfelder
On Fri, Aug 19, 2011 at 9:19 AM, David Winsemius dwinsem...@comcast.net wrote: Copying list one what was sent in reply. Anybody have a better solution? No sure my solution is better, but it avoids the integer conversion and retains the /. I wrote a function that padds entries of input

Re: [R] gsub for numeric characters in string

2011-08-19 Thread Peter Langfelder
On Fri, Aug 19, 2011 at 11:11 AM, Rebecca Gray atlas...@gmail.com wrote: Dear all, I have what is a bit of a confusing question, so I hope that I can explain clearly. Thank you for your help in advance. I would like to do a replacement procedure on several strings, but the way that I am

Re: [R] display only the top-right half of a correlation matrix?

2011-08-19 Thread Peter Langfelder
On Fri, Aug 19, 2011 at 11:50 AM, Liviu Andronic landronim...@gmail.com wrote: Dear all Is there an easy way to display only one half (top-right or bottom-left) of a correlation matrix? require(Hmisc) rcorr(as.matrix(mtcars[ , 1:4]))       mpg   cyl  disp    hp mpg   1.00 -0.85 -0.85 -0.78

Re: [R] display only the top-right half of a correlation matrix?

2011-08-19 Thread Peter Langfelder
On Fri, Aug 19, 2011 at 12:32 PM, Liviu Andronic landronim...@gmail.com wrote: On Fri, Aug 19, 2011 at 9:02 PM, Peter Langfelder peter.langfel...@gmail.com wrote: Use as.dist: here's an example. Seems promising, but for one issue: I would like to keep the diagonal and thus specify 'diag=T

  1   2   3   4   5   >