Re: [R] Remove non-numerical columns from data frame

2008-07-26 Thread Henrik Bengtsson
On Sat, Jul 26, 2008 at 9:35 AM, Peter Dalgaard [EMAIL PROTECTED] wrote: Henrique Dallazuanna wrote: Try this: x - data.frame(A=c(10,20), B = c(a, b), C = c(20,30)) x[sapply(x, is.numeric)] Yes, and read ?Extract to clear up the confusion between data$vol and data[257] and data[[257]]

Re: [R] Flip Matrix form file?

2008-07-23 Thread Henrik Bengtsson
Hi. On Wed, Jul 23, 2008 at 9:23 AM, Chris82 [EMAIL PROTECTED] wrote: Hello, I have a problem to flip a 200x200 matrix, which is imported by a .asc file. I want to flip the matrix like in a created example below: b - matrix(1:9,3,3,byrow=T) b [,1] [,2] [,3] [1,]123

Re: [R] Combining 4th column from 30 files

2008-07-23 Thread Henrik Bengtsson
A few things that will help you, if not now then in the future: 1) Preallocate the result object. This allow you to avoid using cbind()/rbind(), which constantly creates a new large copy in each iteration. That will eventually bite you if you have a lot of data. In your case you know the number

Re: [R] Help with rearranging data

2008-07-22 Thread Henrik Bengtsson
Hi, is your question how you do this in R? Note that this is a mailing list for R. There are probably other lists/groups better suited for Excel-specific problems. Cheers Henrik On Tue, Jul 22, 2008 at 10:59 AM, William Pepe [EMAIL PROTECTED] wrote: In Excel, I have data that looks like

Re: [R] Location of HTML help files

2008-07-16 Thread Henrik Bengtsson
Hi, could be a browser issue. What browser are you using? I see this behavior on Firefox 3.0.1 but not Microsoft IE 7.0(.5730.11). Looking at the source code for the generate search (of 'reshape') you get the relative URL: ../../../library/R.utils/html/wrap.array.html for both browsers. The

Re: [R] counting number of G in TCGGGGGACAATCGGTAACCCGTCT

2008-07-15 Thread Henrik Bengtsson
Seems like you can do: library(matchprobes) # on Bioconductor countbases(TCGACAATCGGTAACCCGTCT)[,G] The catch is that it only counts A, C, G, and T:s and no other symbols. /Henrik On Tue, Jul 15, 2008 at 8:27 AM, Daren Tan [EMAIL PROTECTED] wrote: Any better solution than this ?

Re: [R] Computing row means for sets of 2 columns

2008-07-13 Thread Henrik Bengtsson
m - matrix(1:40, ncol=4); groups - rep(1:2, each=2); uGroups - unique(groups); mMeans - matrix(NA, nrow=nrow(m), ncol=length(uGroups)); for (gg in seq(along=uGroups)) { mMeans[,gg] - rowMeans(m[,groups == uGroups[gg], drop=FALSE]); } (Preallocation of result matrix is more memory efficient than

Re: [R] Change in behaviour of sd()

2008-07-08 Thread Henrik Bengtsson
Hi, FYI, *the* NEWS file containing updates for all R versions is available at http://cran.r-project.org/ - see the link 'new features and bug fixes'. This links to the URL (which I think is rather stable): https://svn.r-project.org/R/trunk/NEWS The NEWS file also comes with your R

Re: [R] S4 pass-by-value work-around?

2008-06-19 Thread Henrik Bengtsson
Quick comment. Use an environment to hold your fields and then pass around the environment variable. Any modification to variables inside the environment done from anywhere (inside/outside functions) will be persistent. Then wrap this up in a class structure, overload, say, '$', '[[', '$-',

Re: [R] Regex for Special Characters under Grep

2008-06-12 Thread Henrik Bengtsson
A regular set is given by [set]. The complementary set is given by [^set] where set is a set of symbols. I don't think you have to escape symbols in set (but I might be wrong). In any case, this does what you want: lines - c(abc, !abc, #abc, ^abc, #abc) pattern - ^[^!#^]; grep(pattern,

Re: [R] pch=. plots much faster

2008-05-13 Thread Henrik Bengtsson
FYI, there is also smoothScatter() in the 'geneplotter' package (part of the Bioconductor.org project). /Henrik On Tue, May 13, 2008 at 5:08 AM, Prof Brian Ripley [EMAIL PROTECTED] wrote: On Tue, 13 May 2008, Charles Plessy wrote: Dear list, I realised by chance when analysing a

Re: [R] checking whether a file is empty

2008-04-30 Thread Henrik Bengtsson
help(file.info). /Henrik On Wed, Apr 30, 2008 at 5:33 PM, Faheem Mitha [EMAIL PROTECTED] wrote: Hi, Is there a way to check whether a file is empty in R. I did the customary searches, but did not find anything. Please cc me on any reply.

Re: [R] How to hide the warnings

2008-04-29 Thread Henrik Bengtsson
See help(warnings) and from there you'll also find help(warning). It is described there. /Henrik On Tue, Apr 29, 2008 at 5:14 PM, Vidhu Choudhary [EMAIL PROTECTED] wrote: Hi All, I want to hide all the system(R) generated warning messages and want only the messages from my script should be

Re: [R] R memory issue for writing out the file

2008-04-15 Thread Henrik Bengtsson
Try to write the data.frame to file in blocks of rows by calling write.table() multiple times - see argument 'append' for write.table(). That will probably require less memory. /Henrik On Tue, Apr 15, 2008 at 6:12 PM, Xiaojing Wang [EMAIL PROTECTED] wrote: Hello, all, First thanks in

Re: [R] vlookup in R

2008-03-24 Thread Henrik Bengtsson
# Setup the translation map transMap - c(A=R, B=R, C=R, D=B, F=B); # The input data v3 - c(A, C, D, F, A, C, B, B, B, B, A, D); # The translated data v4 - transMap[v3]; df2 - data.frame(V3=v3, V4=v4); I recommend you to read 'An Introduction to R' that comes with any R installation. There is

Re: [R] ls() and classes

2008-03-19 Thread Henrik Bengtsson
library(R.oo) example(data.frame) example(matrix) example(iris) ll() member data.class dimension objectSize 1 author character 1120 2 d data.frame c(10,3) 1136 3 d.0 data.framec(0,3)824 4 d0 data.frame c(10,0)320 5 d00

Re: [R] download.file()

2008-03-18 Thread Henrik Bengtsson
On Tue, Mar 18, 2008 at 8:46 AM, Paul Evans [EMAIL PROTECTED] wrote: Hi, I wanted to download a file and did the following: - fileLink - 'ftp://ftp.ncbi.nih.gov/pub/geo/DATA/supplementary/series/GSE1000/GSE1000_RAW.tar'

Re: [R] download.file()

2008-03-18 Thread Henrik Bengtsson
On Tue, Mar 18, 2008 at 8:57 AM, Henrik Bengtsson [EMAIL PROTECTED] wrote: On Tue, Mar 18, 2008 at 8:46 AM, Paul Evans [EMAIL PROTECTED] wrote: Hi, I wanted to download a file and did the following: - fileLink - 'ftp

Re: [R] download.file()

2008-03-18 Thread Henrik Bengtsson
On Tue, Mar 18, 2008 at 9:10 AM, Prof Brian Ripley [EMAIL PROTECTED] wrote: /geodat *is* an absoute path! The second argument of download.file is called 'destfile', so what makes you think it is a desination *directory*? The help file might be the source of confusion: destfile: A character

Re: [R] format numbers into percentages

2008-03-09 Thread Henrik Bengtsson
On Sun, Mar 9, 2008 at 3:36 PM, tom soyer [EMAIL PROTECTED] wrote: Hi, I am currently using the following to formate numbers into percentages: x=0.00112 paste(round(x*100,2),%,sep=) My favorite is sprintf(), which allow you to control number of digits at the same time you control for

Re: [R] Problems installing packages using the inbuilt facility: Error i n gzfile(file, r) : unable to open connection

2008-03-07 Thread Henrik Bengtsson
Works fine for me on the same setup. Try this and compare (especially the size of the downloaded file): url - http://cran.uk.r-project.org/bin/windows/contrib/2.6/ada_2.0-1.zip;; download.file(url, basename(url), mode=wb) # Note wb!!! trying URL

Re: [R] unable to start device PNG and unable to open connection to X11 display

2008-03-03 Thread Henrik Bengtsson
On Mon, Mar 3, 2008 at 1:25 AM, Ng Stanley [EMAIL PROTECTED] wrote: Hi, I consulted ?png, and it uses X11. is there any way to save plots into png, without using X11 ? See See also under help(png) for alternatives. Rule of thumb: If you get a reply from BR that you don't get the first time

Re: [R] Could not install aroma.affymetrix

2008-03-02 Thread Henrik Bengtsson
Hi My, On Sat, Mar 1, 2008 at 8:04 PM, My Coyne [EMAIL PROTECTED] wrote: I don't know if this is the correct forum to ask the following question; however, when I search the aroma.affymetrix discussion group, it suggested that I should posted the question to r-help. Here it goes. I think

Re: [R] Make plots with GNUplot. Have anyone tried that?

2008-03-01 Thread Henrik Bengtsson
On Fri, Feb 29, 2008 at 2:12 PM, Louise Hoffman [EMAIL PROTECTED] wrote: [snip] Seriously. Be specific if you have a problem. (read the posting guide). R can also plot. If you don't like R's plots (which I could not understand) you can export data and import them to gnuplot. So

Re: [R] insert() function

2008-02-21 Thread Henrik Bengtsson
spect2 - insert(spect1, ats=pos, values=as.list(intensities)) str(spect2) num [1:13112] -0.457 -0.457 0.300 1.781 -0.381 ... /Henrik On Thu, Feb 21, 2008 at 9:26 AM, Henrik Bengtsson [EMAIL PROTECTED] wrote: On Thu, Feb 21, 2008 at 4:30 AM, Dani Valverde [EMAIL PROTECTED] wrote: Hello

Re: [R] insert() function

2008-02-21 Thread Henrik Bengtsson
(CIBER-BBN) Grup d'Aplicacions Biomèdiques de la RMN Facultat de Biociències Universitat Autònoma de Barcelona Edifici Cs, Campus UAB 08193 Cerdanyola del Vallès- SPAIN +34 93 5814126 En/na Henrik Bengtsson ha escrit: Hi. On Feb 20, 2008 2:38 AM, Dani Valverde [EMAIL

Re: [R] jpeg() creating empty files with qplot() in a loop

2008-02-21 Thread Henrik Bengtsson
First, please provide us with enough unambiguous information so we don't have to second guess that you are using qplot() in the 'ggplot' package. Report sessionInfo() is recommended. It has nothing to do with jpeg() or any other device driver. You get the same problem with: library(ggplot) x -

Re: [R] jpeg in batch mode

2008-02-21 Thread Henrik Bengtsson
Hi. I think the devices provided in 'Cairo' package solves your problem. [ Alternatively you can use the bitmap() device which utilizes Ghostscript to generate bitmap images. In the 'R.utils' package there are wrappers png2() and jpeg2() calling bitmap() but that imitates the png() and jpeg()

Re: [R] insert() function

2008-02-20 Thread Henrik Bengtsson
Hi. On Feb 20, 2008 2:38 AM, Dani Valverde [EMAIL PROTECTED] wrote: Hello, I am trying to insert a certain number of points into a certain position of a vector with this code: x - seq(1:10909) x1 - c(13112-10909) spect1 - rnorm(13112) interpol - approx(x,spect1,xout=c(seq(from=1,

Re: [R] plotDensity

2008-02-19 Thread Henrik Bengtsson
Is 'plotDensity' a specific function you are referring to? If so, in which package? Then we can give a straight answer... /Henrik On Feb 19, 2008 4:10 AM, [EMAIL PROTECTED] wrote: Hallo, I have a question to plotDensity and do not understand what stand behind. In a density plot the

Re: [R] How to check cy5 and cy3 values were lowess normalized

2008-02-14 Thread Henrik Bengtsson
On Thu, Feb 14, 2008 at 4:57 AM, Ng Stanley [EMAIL PROTECTED] wrote: Hi, I have some microarray data, cy5 and cy3 values are in log2. Is there a way to check they have undergone lowess normalization ? Yes, go back ask the one who you got the data from. Honestly, this is a serious reply,

Re: [R] indices of rows containing one or more elements 0

2008-02-12 Thread Henrik Bengtsson
X - matrix(c(0,2,0,1,0,0,3,5), ncol=2) Informative version: isPositive - (X 0) nbrOfPositives - apply(isPositive, MARGIN=1, FUN=sum) hasPositives - (nbrOfPositives = 1) positiveRows - which(hasPositives) Compact version: positiveRows - which(rowSums(X 0) = 1) If you have an extremely large

Re: [R] image quality

2008-02-11 Thread Henrik Bengtsson
Have a look at the smoothScatter() function in the 'geneplotter' (Bioconductor) package. That might be sufficient for you. Alternatively, generate a bitmap (e.g. PNG) image plot instead (at least pdflatex can import those as is). /Henrik On Feb 11, 2008 2:18 AM, John Lande [EMAIL PROTECTED]

Re: [R] Res: gc() and memory efficiency

2008-02-06 Thread Henrik Bengtsson
Open suggestion/question: If you in each step of an K-step iteration load/allocate a large object, each time of a different size, followed by smaller memory allocations (due to your analysis), you might be better of if you could do the iteration such that the largest object is in the first

Re: [R] help with oop in R - class structure and syntex

2008-02-05 Thread Henrik Bengtsson
On Feb 5, 2008 6:06 AM, Barry Rowlingson [EMAIL PROTECTED] wrote: Duncan Murdoch wrote: Another problem is that there are two different class systems in R: sometimes calls S3 and S4 (because of the versions of S where they were introduced). You were reading about S3. There's three

Re: [R] Integer vs numeric

2008-01-30 Thread Henrik Bengtsson
- as.integer(100*xs); print(ys); [1] 100 101 102 103 104 105 106 107 108 [10] 109 110 111 112 112 114 114 115 117 [19] 118 119 120 121 122 123 124 125 126 [28] 127 128 129 130 Pay attention to elements 13:18(!) - subsetting using doubles is not safe. /H Henrik Bengtsson a écrit : x[1:n] /H

Re: [R] Waiting bar

2008-01-30 Thread Henrik Bengtsson
For text-based progress bars see the ProgressBar class in R.utils, e.g. # A faster progress bar with default step length 1.4. pb - ProgressBar(max=42, stepLength=1.4) reset(pb) while (!isDone(pb)) { x - rnorm(3e4) increase(pb) Sys.sleep(0.02) } cat(\n) Output:

Re: [R] Using the value of a variable as a variable

2008-01-30 Thread Henrik Bengtsson
On Jan 30, 2008 1:15 PM, Ted Harding [EMAIL PROTECTED] wrote: On 30-Jan-08 19:47:55, Ramon Hidalgo wrote: Hello, How can I make the following expressions are equivalent datos$Col1 and datos$var when I define var - Col1? I am trying to get the same result with datos$Col1 [1] 0 1 1

Re: [R] Integer vs numeric

2008-01-29 Thread Henrik Bengtsson
x[1:n] /H On Jan 29, 2008 5:07 AM, [EMAIL PROTECTED] wrote: Seems strange to me to define an operator relatively to a very special case. I have to admit that I do not use 1:1e7 every day :-) Wouldn't it be more appropriate to define a a:b operator numeric (that is preserving the initial

Re: [R] Is there a safe mode?

2008-01-26 Thread Henrik Bengtsson
When and how does this happen? In Rgui or Rterm? How do you launch R? Have you tried the obvious and restarted R? If you share the startup messages, sessionInfo() and everything else you think could be helpful, someone might be able to help you. There is a vanilla options to start R, e.g.

Re: [R] 'matrix' returns integer instead of decimal

2008-01-20 Thread Henrik Bengtsson
Check your getOption(digits). Default is typically 7. Either you or a package/function sets it to a small value. You get that **output** with options(digits=n) where n=1,2,3. /Henrik On Jan 20, 2008 7:13 PM, Thomas Lumley [EMAIL PROTECTED] wrote: On Sun, 20 Jan 2008, Brant Inman wrote:

Re: [R] unload reload a (new version of a) package

2008-01-14 Thread Henrik Bengtsson
On 14/01/2008, hadley wickham [EMAIL PROTECTED] wrote: On Jan 14, 2008 5:48 PM, Harte, Thomas P [EMAIL PROTECTED] wrote: i'm putting the final touches on a package that i'm developing and i noticed that if i detach the package, and then re-build re-install it (using R CMD) then I can't

Re: [R] How to disable output messages (prints or cats) from functions in R?

2008-01-12 Thread Henrik Bengtsson
the returned object without the displaying information showed by the function. Something like suppressWarnings( ) but suppressing the standard output. Miguel Henrik Bengtsson escribió: See capture.output(). /H On 11/01/2008, Miguel Ratón Almansa [EMAIL PROTECTED] wrote: Hi everybody

Re: [R] clipping a large image on R

2008-01-11 Thread Henrik Bengtsson
Try the EBImage package (utilizes ImageMagick and is available via Bioconductor.org) - not sure if it well help though. If not, try to clip the larger image by calling ImageMagick outside R. /HB On 11/01/2008, Milton Cezar Ribeiro [EMAIL PROTECTED] wrote: Dear all, I have a so large image

Re: [R] How to add rowSums into list?

2008-01-11 Thread Henrik Bengtsson
On 11/01/2008, Lauri Nikkinen [EMAIL PROTECTED] wrote: Thanks, one further question: how to order these matrices using these row sums? lapply(a, function(x) order(x[,5])) #produces only indeces ...which you can use as row indices 'idxs' to reorder the rows of matrix 'x' by x[idxs,]. /Henrik

Re: [R] How to disable output messages (prints or cats) from functions in R?

2008-01-11 Thread Henrik Bengtsson
See capture.output(). /H On 11/01/2008, Miguel Ratón Almansa [EMAIL PROTECTED] wrote: Hi everybody, I have to use a function that shows an output message like # nonzero coefficients ... followed with a lot of numbers depending on the input. This is very annoying because I have to run that

Re: [R] Efficient way to find consecutive integers in vector?

2007-12-21 Thread Henrik Bengtsson
In the R.utils package there is seqToIntervals(), e.g. print(seqToIntervals(1:10)) ## from to ## [1,]1 10 print(seqToIntervals(c(1:10, 15:18, 20))) ## from to ## [1,]1 10 ## [2,] 15 18 ## [3,] 20 20 There is also seqToIntervals(), which uses the above, e.g.

Re: [R] Reading through a group of .RData files

2007-12-11 Thread Henrik Bengtsson
Hi, depending on what you do and how (and why) you save objects in RData files in the first place, you might be interested in knowing of the loadObject()/saveObject() methods of R.utils, as well as loadCache()/saveCache() in R.cache. The R.utils methods are basically clever wrappers around

Re: [R] Problems working with large matrix (using package R.huge)

2007-12-09 Thread Henrik Bengtsson
Hi, I'm sorry, but I will most likely withdraw R.huge from CRAN anytime soon. The File***Matrix classes had some problems, which when solved made it too slow. See BufferedMatrix package in Bioconductor instead. /Henrik On 09/12/2007, [EMAIL PROTECTED] [EMAIL PROTECTED] wrote: Hi all,

Re: [R] lm: how to calculate rsquared of the predicted values?

2007-12-08 Thread Henrik Bengtsson
Did you try to install using install.packages()? install.packages(caret) Warning in install.packages(caret) : argument 'lib' is missing: using '/scratch5/hb/R/R_LIBS/linux/library/' trying URL 'http://cran.cnr.Berkeley.edu/src/contrib/caret_3.08.tar.gz' Content type 'application/x-gzip'

Re: [R] Junk or not Junk ???

2007-12-06 Thread Henrik Bengtsson
On 06/12/2007, Loren Engrav [EMAIL PROTECTED] wrote: As for news readers I found R and R.mac and R.Bio on the sites you recommend, thank you very much, they would avoid the individual emails, but then I would have to go look at them, which might be Ok Deluge? Well, there are from R and Bio

Re: [R] How to select rows with identical index from two matrix?

2007-11-21 Thread Henrik Bengtsson
On Nov 20, 2007 7:04 PM, Moshe Olshansky [EMAIL PROTECTED] wrote: You can do the following: set1 - Matrix1[,1] set2 - Matrix2[,1] common - intersect(set1,set2) ind1 - which(set1 %in% common) ind2 - which(set2 %in% common) A1 - Matrix1[ind1,-1] A2 - Matrix2[ind2,-1] Ok, this far. and

Re: [R] sorting dataframe

2007-11-21 Thread Henrik Bengtsson
See order(). -Henrik On 21/11/2007, Rina Oldager Miehs [EMAIL PROTECTED] wrote: Hello We have a problem with sorting our dataframe... i have tried to write x - males[sort(males$index, decreasing=T),] But that just gives me x id sex BVgain BVmeat phenogain phenomeat index NA

Re: [R] R as server application

2007-11-21 Thread Henrik Bengtsson
Hi, tbe R.batch package (http://www.braju.com/R/) was written to run multiple batch jobs on one or more hosts sharing the same file system. It doesn't do everything you want but part of it. For details, see r-help thread 'R.batch (Was: Re: [R] Calling R from R and specifying wait until script is

Re: [R] R and reading matlab compressed files

2007-11-19 Thread Henrik Bengtsson
Hi. On 11/17/07, Prof Leslie Smith [EMAIL PROTECTED] wrote: Is there any way to read these files (standard .mat files, created by matlab version 7 onwards are compressed)? I know that R.matlab doesn't read them (it even says in the file MatlabServer.m Matlab v7 saves compressed files, which

Re: [R] Image analysis and image questions

2007-10-12 Thread Henrik Bengtsson
See the EBImage package on Bioconductor.org. It builds on top of ImageMagick. /Henrik On 10/12/07, Bio7 [EMAIL PROTECTED] wrote: Dear R users, in my application i can transfer images to R with the help of Rserve. The images come from a java application. When i plot a greyscale image

Re: [R] Graphics and LaTeX documents with the same font

2007-09-28 Thread Henrik Bengtsson
On 9/28/07, hadley wickham [EMAIL PROTECTED] wrote: Yes there is harm. But to make bold lines, easy to read titles is fine. See the spar function in http://biostat.mc.vanderbilt.edu/SgraphicsHints for a starter. Also see the setps, ps.slide, and setpdf functions in the Hmisc package.

<    1   2   3   4   5   6