Re: [R] .eps files and powerpoint

2013-07-25 Thread Peter Langfelder
On Thu, Jul 25, 2013 at 9:30 AM, Richard M. Heiberger wrote: > On Vista with Powerpoint 2007, file2.eps crashes powerpoint, > Once file.eps displayed, several times it crashed powerpoint. > > My task is now to see if ghostscript can read a pdf or ps or eps and > convert it to png at res=300. > Do

Re: [R] readTiff - Sorry can't handle images with 32-bit samples

2013-07-26 Thread Peter Langfelder
Disclaimer: I haven't seen your tif file and I know nothing about readTiff... but here go some general comments. TIF files can use different bit depths (number of bits to store each pixel (or each color for each pixel). Most common software outputs 8- or 16-bits, but your file probably has a highe

Re: [R] p values for partial correlations

2013-08-08 Thread Peter Langfelder
I am not an expert on shrinkage estimators of partial correlations (such as the one in corpcor), but my sense is that it is difficult to provide a good estimate of a p-value. You could try to email the authors of the package and ask them, but this may be more of a statistics rather than R question.

[R] Avoiding copies in list assignments

2013-08-23 Thread Peter Langfelder
One more question about avoiding copies when modifying lists. I would like to call a function (call it 'f') that does an operation on a large array according to a given index. For example f = function(data, index) sum(data[index]) The idea is to repeatedly call f() with the same 'data' but differ

[R] Solved Re: Garbage collection problem

2013-01-03 Thread Peter Langfelder
:41 PM, Duncan Murdoch wrote: > On 13-01-03 7:01 PM, Peter Langfelder wrote: >> >> Hello all, >> >> I am running into a problem with garbage collection not being able to >> free up all memory. Unfortunately I am unable to provide a minimal >> self-contained

Re: [R] Issue while installing Hmisc package

2013-01-17 Thread Peter Langfelder
On Thu, Jan 17, 2013 at 4:57 AM, vaseem shaikh wrote: > > But still, i am also trying to install the package by locally giving > absolute path with repos= Null and type = "Source", will CRAN have any role > to play here??? To compile a package on Windows, you need to install R tools (Rtools) tha

Re: [R] csv mask order

2013-01-22 Thread Peter Langfelder
Do your lines start with the hash mark #? If so, they are considered comment. Set comment.char="" in your call to read.csv. Another frequent culprit (personal experience) are apostrophes ('). If you have any in your file, use the argument quote = "\"" or, if you are sure the data are not quoted, us

Re: [R] rbind Missing Something: Need New Eyes

2013-01-31 Thread Peter Langfelder
On Thu, Jan 31, 2013 at 3:55 PM, Rich Shepard wrote: > I don't see what's missing in my statements to add rows to a data frame > and someone else will probably see what needs to be added to the statements. > > The data frame has this structure (without any data): > > $ PHYLUM : chr > $

Re: [R] cutreeDynamic error

2013-02-26 Thread Peter Langfelder
On Tue, Feb 26, 2013 at 8:34 AM, Joanna Papakonstantinou wrote: > So I realized I had to convert my dd.daisy to a matrix and used: > ddmatrix.daisy<-as.matrix(dd.daisy) > and then I passed that in as the distM: >> cutreeDynamic(as.hclust(dd.diana), cutHeight = NULL, minClusterSize = 2, > method =

Re: [R] How to transpose it in a fast way?

2013-03-06 Thread Peter Langfelder
On Wed, Mar 6, 2013 at 4:18 PM, Yao He wrote: > Dear all: > > I have a big data file of 6 columns and 6 rows like that: > > AA AC AA AA ...AT > CC CC CT CT...TC > .. > . > > I want to transpose it and the output is a new like that > A

Re: [R] proper way to handle obsolete function names

2013-04-17 Thread Peter Langfelder
On Wed, Apr 17, 2013 at 10:36 AM, R. Michael Weylandt > > It sounds like you want .Deprecate > > ?.Deprecate > Perhaps you meant Deprecated? ?Deprecated Best, Peter __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PL

Re: [R] R not loading

2013-04-22 Thread Peter Langfelder
On Mon, Apr 22, 2013 at 1:15 PM, Barbour, Russell wrote: > I am having a problem with loading R on my 64 bit computer. It used to > load perfectly until I upgraded to R 3.0.0 now it takes about 10 to even > 20 minutes ? Does anyone know how to remedy this problem? Did R-3.0.0 ever loa

Re: [R] Cochran-Mantel-Haenszel test

2012-09-18 Thread Peter Langfelder
Bert is correct that this is a statistics questions, but I'll throw in my 2 cents anyway. The CMH test is formulated for count data and makes certain assumptions on the distribution of the observed values. Since you don't have count data (your data are not integer), chances are that the assumptions

Re: [R] Trap an error from a function

2012-09-18 Thread Peter Langfelder
On Tue, Sep 18, 2012 at 5:35 PM, David Winsemius wrote: > > On Sep 18, 2012, at 5:10 PM, John Sorkin wrote: > >> Window 7 >> R 2.15 >> >> I am writing a simulation which generates sample sized estimates from >> simulated data. When I run the function shown below, >> power.t.test(delta=14.02528,sd

Re: [R] Line over Boxplot

2012-09-20 Thread Peter Langfelder
Enclose the file name tmax.final.text in quotes. Otherwise R is looking for a variable named tmax.final.text, not the file name named "tmax.final.text". HTH Peter On Thu, Sep 20, 2012 at 1:02 PM, gfishel wrote: > Thanks for your help! Unfortunately, I am now getting this: > >> pdf(file="boxplot

Re: [R] passing a matrix from R to C code

2012-09-24 Thread Peter Langfelder
Erin, you seem to confuse R and C syntax a bit, among other things. See below. On Mon, Sep 24, 2012 at 3:03 PM, Erin Hodgess wrote: > Dear R People: > > I'm working on a project that will pass a matrix from an R function to > a C subroutine. > > I tried to write the following: > > #include > #in

Re: [R] Creating tiff with 1200 dpi

2012-10-03 Thread Peter Langfelder
Well, if I read the error message right, your image is too large. I think you should explore alternate formats - does the journal accept figures in a vector format such PS, EPS or PDF? Such figures will be much easier to handle than a humongous tiff with file size of 60+ megabytes. HTH, Peter

Re: [R] Up key is not the previous command

2012-10-08 Thread Peter Langfelder
run capabilities(what="cledit") in your R terminal session. If you get FALSE, your R was compiled without command line editing support which you need for the "up arrow" action. Peter On Mon, Oct 8, 2012 at 8:04 PM, Tjun Kiat Teo wrote: > I am using R on Fedora 17 and the up arrow is not the pr

Re: [R] Error in if (is.na(n) || n > 65536L) stop("size cannot be NA nor exceed 65536") : missing value where TRUE/FALSE needed

2012-10-09 Thread Peter Langfelder
On Tue, Oct 9, 2012 at 4:37 PM, eliza botto wrote: > > Dear useRs, > > i am using NbClust to determine appropriate number of cluster for > hclustering. i am consistently getting the following error > > Error in if (is.na(n) || n > 65536L) stop("size cannot be NA nor exceed > 65536") : > missin

Re: [R] Error in if (is.na(n) || n > 65536L) stop("size cannot be NA nor exceed 65536") : missing value where TRUE/FALSE needed

2012-10-09 Thread Peter Langfelder
Hi Eliza, this is not __reproducible__ code - how am I supposed to know what's wrong when I don't have the input files you use? Please read the help for NbClust carefully and check that all your input variables have the correct dimensions. Some of the input seems strange, for example the z matrix

Re: [R] WGCNA: Combining block-wise dendrograms and modules into a single figure

2012-10-18 Thread Peter Langfelder
arning to use R, so please forgive me if there is an > obvious explanation for the following problem. My goal is to perform WGCNA > on a dataset of 19776 genes, so I opted to follow the block-wise network > construction (Section 2c) in the WGCNA R Tutorial by Peter Langfelder and > Steve

Re: [R] parallel processing with foreach

2012-10-25 Thread Peter Langfelder
It seems you don't quite understand how foreach works. foreach (..) %dopar% { ... } takes the last value from each of the second {...} evaluations and feeds them to the .combine function (in your case rbind()). Since your last call in the %dopar% {...} block is assign(), you are not getting anythin

Re: [R] Memory allocation using .C interface

2014-04-09 Thread Peter Langfelder
On Wed, Apr 9, 2014 at 11:27 AM, Cassiano dos Santos wrote: > I am testing a call to a C function from R, using .C interface. The test > consists in passing a numeric vector to the C function with no entries, > dynamically allocates n positions, makes attributions and return the vector > to R. Wh

Re: [R] about rect.hclust

2014-04-25 Thread Peter Langfelder
On Fri, Apr 25, 2014 at 6:35 PM, chris Jhon wrote: > Hi, > > I am using hclust and cutree to cluster a data frame y and cut it into few > clusters as follows > > y > V1 V2 V3 V4 > A 1 2 3 4 > B 5 6 7 8 > C 9 10 11 12 > D 13 14 15 16 > E 17 18 19 20 >> clu<-hclust(dist(y),method="comple

Re: [R] R Cairo Installation - Cannot find cairo.h!

2014-04-28 Thread Peter Langfelder
Make sure you have cairo-devel installed, and remove the lines export CAIRO_LIBS=${HOME}/usr/local/lib export CAIRO_CFLAGS=${HOME}/usr/local/include from your .bashrc file. If you have cairo-devel installed normally, the headers should be found with default settings of all search paths. The setti

Re: [R] R Cairo Installation - Cannot find cairo.h!

2014-04-28 Thread Peter Langfelder
VE_SYS_WAIT_H 1 > | #define HAVE_SYS_TYPES_H 1 > | #define HAVE_SYS_STAT_H 1 > | #define HAVE_STDLIB_H 1 > | #define HAVE_STRING_H 1 > | #define HAVE_MEMORY_H 1 > | #define HAVE_STRINGS_H 1 > | #define HAVE_INTTYPES_H 1 > | #define HAVE_STDINT_H 1 > | #define HAVE_UNISTD_H 1

Re: [R] Fwd: problem with kmeans

2014-04-28 Thread Peter Langfelder
You are using the wrong algorithm. You want Partitioning around Medoids (PAM, function pam), not k-means. PAM is also known as k-medoids, which is where the confusion may come from. use library(cluster) cl = pam(dis, 4) and see if you get what you want. HTH, Peter On Mon, Apr 28, 2014 at 9

Re: [R] Error during working with wgcna and R

2014-05-09 Thread Peter Langfelder
WGCNA maintainer here. When working with a large data set, you have a few options. 1. Without being snarky, the best option is to get (or get access to) a computer with large-enough RAM. Many universities, departments, and other research institutes have computer clusters with nodes with at least 6

Re: [R] WGCNA on heterogeneous RNA-seq

2014-05-14 Thread Peter Langfelder
Hi Pan, On Wed, May 14, 2014 at 9:14 PM, Panos Bolan wrote: > Dear list, > > Apologies for posting this to both Bioconductor and here. I recently read a > Bioconductor post where the developer of the WGCNA suggested the use of the > package for RNA-seq data analysis after implementing a variance

Re: [R] Identifying one or more TRUE in the middle of an array

2014-06-06 Thread Peter Langfelder
Not sure if this is better than your "brute force" and you may be able to simplify it... notStart = function(x) { n = length(x) i0 = which(x); n0 = length(i0); i0!=c(1:n)[1:n0]; } notStartNorEnd = function(x) { which(x)[notStart(x) & rev(notStart(rev(x)))] } notStartNorEnd(c(F, F, F)) ##

Re: [R] an incredibly trivial question about nls

2014-07-01 Thread Peter Langfelder
On Tue, Jul 1, 2014 at 1:27 PM, Erin Hodgess wrote: > Hello R People: > > I'm having a forest/trees location problem with the output of nls. > > If I save the output to an object, and print the object, it shows, amongst > other things, the residual sum of squares. I would like to get that. > > Ho

Re: [R] odd behavior of seq()

2014-07-03 Thread Peter Langfelder
Precision, precision, precision... > z[2]-0.15 [1] 2.775558e-17 My solution: > z <- signif(seq(.05,.85,by=.1), 5) > z[2] - 0.15 [1] 0 > z[2]==0.15 [1] TRUE Peter On Thu, Jul 3, 2014 at 11:28 AM, Matthew Keller wrote: > Hi all, > > A bit stumped here. > > z <- seq(.05,.85,by=.1) > z==.05 #

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

2014-07-15 Thread Peter Langfelder
Hi Johannes, you mentioned dynamicTreeCut - the dynamic hybrid method works fine on your data. Just supply the dissimilarity matrix as well: I use the function plotDendroAndColors from WGCNA to show the results; if you don't want to use WGCNA, just leave out the last call. library(WGCNA) set.see

Re: [R] subset a defined row plus the aforegoing

2012-11-01 Thread Peter Langfelder
On Thu, Nov 1, 2012 at 10:28 AM, Hermann Norpois wrote: > Hello, > > my data is sorted by start.ens (see below). And now I would like to extract > all rows (so called* defined row*s) with type==Expression - subset (df, > type==Expression) - and the aforegoing type==DNase HS (which is not > necessa

Re: [R] Code works, but not as function.

2012-11-15 Thread Peter Langfelder
On Thu, Nov 15, 2012 at 5:48 PM, Benjamin Ward (ENV) wrote: > Hi, > > I have some values in a list format generated by the following: > Path_Number <- 0010 > ID.Path <- formatC(0001:Path_Number, width=4, flag=0) # Make vector of ID's. > No_of_Effectors <- sample(1:550, length(ID.Path), replace=TRU

Re: [R] what's this character?

2012-11-28 Thread Peter Langfelder
On Wed, Nov 28, 2012 at 4:44 PM, Shi, Tao wrote: > Hi list, > > I've encounter this problem (see below). I know it's particularly R-related > and it's easy to get by but it still bothers me a lot. > > > It looks the last character of "N.C. " is a space to me, but it's clearly > not. Can someon

Re: [R] Fast Normalize by Group

2012-11-29 Thread Peter Langfelder
Not tested but should work: sums = tapply(x, group, sum); sums.ext = sums[ match(group, names(sums))] normalized = x/sums.ext It may be that the tapply is just as slow as your loop though, I'm not sure. HTH, Peter On Thu, Nov 29, 2012 at 10:55 AM, Noah Silverman wrote: > Hi, > > I have a ver

Re: [R] qbinom

2012-11-30 Thread Peter Langfelder
On Fri, Nov 30, 2012 at 9:47 AM, jaybell wrote: > a=c(0.1, 0.2, 0.3, 0.4, 0.5, 0.6, 0.7, 0.8, 0.9) > b=c(0.9, 0.8, 0.7, 0.6, 0.5, 0.4, 0.3, 0.2, 0.1) > cor(a,b)= -1 > > a'=qbinom(a, 1, 0.5) > b'=qbinom(b, 1, 0.5) > why cor(a',b') becomes -0.5 ? On my computer the correlation is -0.8. It is not 1

Re: [R] Different results from random.Forest with test option and using predict function

2012-12-03 Thread Peter Langfelder
On Mon, Dec 3, 2012 at 3:30 PM, tdbuskirk wrote: > > Hello R Gurus, > > I am perplexed by the different results I obtained when I ran code like > this: > set.seed(100) > test1<-randomForest(BinaryY~., data=Xvars, trees=51, mtry=5, seed=200) > predict(test1, newdata=cbind(NewBinaryY, NewXs), type="

Re: [R] Large loops in R

2012-12-04 Thread Peter Langfelder
On Tue, Dec 4, 2012 at 11:27 AM, Charles Novaes de Santana wrote: > Dear Michael, > > Thank you for your answer. > > I have 2 matrices. Each position of the matrices is a weight. And I > need to calculate the following sum of differences: > > Considering: > mat1 and mat2 - two matrices (each of th

Re: [R] What purpose is served by reflexive function assignments?

2013-12-28 Thread Peter Langfelder
On Sat, Dec 28, 2013 at 7:27 PM, Andrew Hoerner wrote: > Let us suppose that we have a function foo(X) which is called inside > another function, bar(). Suppose, moreover, that the name "X" has been > assigned a value when foo is called: > > X <- 2 > bar(X=X){ > foo(X) > } > > I have noticed that

Re: [R] counting matched elements in two vectors

2014-01-23 Thread Peter Langfelder
Here's a solution: # This gives a vector of counts (if z is a data frame, first convert it to a matrix) res = sapply(as.vector(z), function(x) sum(w==x)) # This copies the dimensions of the variable 'z' to 'res': dim(res) = dim(z) Peter On Thu, Jan 23, 2014 at 7:43 AM, wrote: >Hi all, > I

Re: [R] Understanding namespace for plyr / dplyr

2014-01-29 Thread Peter Langfelder
In short, use dplyr::summarize or plyr::summarize to select the one you want. HTH, Peter On Wed, Jan 29, 2014 at 2:19 PM, Trevor Davies wrote: > I think I have a hole in my understanding of how R uses packages (or at > least how it gives functions in packages priority). I thought I would give

Re: [R] Random Forest, Variable Mismatch

2014-02-15 Thread Peter Langfelder
On Sat, Feb 15, 2014 at 8:43 AM, Lorenzo Isella wrote: > Dear All, > I am a bit puzzled. > I am developing a random forest model. > The data is large and it involves hundred of predictors, but the code I have > written is relatively simple. > After training my random forest model, I apply it on so

Re: [R] hclust/dendrogram merging

2013-09-16 Thread Peter Langfelder
Joshua, I'm not sure I understand your aim correctly, but if I do, here's my advice: If you are able to find the clusters according to rows or columns using clustering, you must be using some kind of a distance matrix that encodes whether two antibodies should be in one bin for rows, and a similar

Re: [R] How can I use muliple cores of CPU in Windows or OS X?

2013-11-05 Thread Peter Langfelder
On Tue, Nov 5, 2013 at 3:36 PM, Uwe Ligges wrote: > > > On 06.11.2013 00:26, Simon Pickert wrote: >> >> Mcapply from package 'parallel'. Also see package 'multicore' > > > Not mcapply: it won't work under Windows that the OP asked for. > > But package parallel is the right hint. It also provides o

Re: [R] Chart colors

2013-12-09 Thread Peter Langfelder
On Mon, Dec 9, 2013 at 2:08 PM, Katharine Miller - NOAA Federal wrote: > Hello, > > I am having difficulty obtaining the correct colors in my R charts. > >> colors()[c(552, 254, 26)] > [1] "red" "green" "blue" > > But, if I specify col=552 in my barplot, I get gray bars. Likewise, > col=254 giv

Re: [R] fisher.test - can I use non-integer expected values?

2013-12-10 Thread Peter Langfelder
On Tue, Dec 10, 2013 at 6:55 PM, bakerwl wrote: > Expected values are needed to test a null hypothesis against observed > counts, but if total observed counts are 20 for 3 categories, then a null > hypothesis of a random effect would use expected values = 6.67 in each of > the 3 categories (20/3)

Re: [R] method default for hclust function

2013-12-12 Thread Peter Langfelder
On Thu, Dec 12, 2013 at 3:09 PM, capricy gao wrote: > I could not figure out what was the default when I ran hclust() without > specifying the method. According to help("hclust"), the default method is complete linkage. HTH, Peter __ R-help@r-projec

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 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, e.g.: > > "1,2,3

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 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 at the other

Re: [R] Same function name

2010-06-21 Thread Peter Langfelder
package::function On Mon, Jun 21, 2010 at 6:29 AM, Filoche 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 the package to use f

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 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 the number zero, w

Re: [R] Plotrix Trick

2010-06-23 Thread Peter Langfelder
On Wed, Jun 23, 2010 at 10:01 AM, Lorenzo Isella 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 similar, indistinguishab

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 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 be useful, but I c

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 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 precision (which is w

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

Re: [R] write a loop for tallies

2010-06-24 Thread Peter Langfelder
On Thu, Jun 24, 2010 at 3:16 PM, john polo 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 occur in t

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

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

2010-09-14 Thread Peter Langfelder
2010/9/14 Uwe Ligges : > 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-h

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

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

Re: [R] hcluster with linkage median

2010-09-27 Thread Peter Langfelder
On Mon, Sep 27, 2010 at 8:22 AM, Kennedy 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 example below M is

Re: [R] hcluster with linkage median

2010-09-27 Thread Peter Langfelder
On Mon, Sep 27, 2010 at 8:22 AM, Kennedy 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 you have a large(r)

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 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 > greatly alter the

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 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 age[1] no[1]-ti

Re: [R] break function execution

2010-09-28 Thread Peter Langfelder
On Tue, Sep 28, 2010 at 12:18 PM, Greg Snow 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 R function

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 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 vector of 8 values

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 wrote: > Dear All, > > > I am trying to define a loop for a m*n matrix, where i=1:n and j=1:m. Un

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 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 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 rows.  I am >

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 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 40. It's a stran

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

2010-09-30 Thread Peter Langfelder
ing differently across conditions. > > Has any one ever used this package--coXpress?? > > Regards > .. > Jyotasana > - Original Message - > From: "Peter Langfelder" > To: "Jyotasana Gulati" > Cc: r-help@r-project.org > Sent: Thursday, September

Re: [R] cleaning up a vector

2010-10-01 Thread Peter Langfelder
On Fri, Oct 1, 2010 at 10:51 AM, 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 NaN values and only k

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 wrote: > Hi Everyone, > > I am getting the following error message > > Error: cann

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 void nProcessors(int & n) { #ifdef _SC_NPROCESSORS_ONLN long nProcessorsOnline = sysconf(_SC_NPROCESSO

Re: [R] Create variable by name

2010-10-06 Thread Peter Langfelder
On Wed, Oct 6, 2010 at 9:32 AM, Ralf B 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 initialized w

Re: [R] Create variable by name

2010-10-06 Thread Peter Langfelder
On Wed, Oct 6, 2010 at 9:32 AM, Ralf B 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 initialized w

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.

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 wrote: > Dear List > I am running a loop downloading  web pages and save the html to a > tempor

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

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 wrote: > > Thaks for your q

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 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 row in a tab-delim

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) 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 creating a > diss

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 wrote: >  Dear all > I have data (x,y) with data x is missing i

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

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 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 matrices w

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 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 names as necessar

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 100

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, st

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 co

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 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(15000) for

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 everything

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, it

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 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 > while the mount

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 wrote: > On Mon, Nov 8, 2010 at 5:15 PM, Peter Langfelder > 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 your moun

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. >> > >> >  Similar

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. Exponentiat

<    1   2   3   4   5   >