Re: [R] replace NA value with 0

2007-09-14 Thread Gabor Csardi
x[ is.na(x) ] - 0 should work in most cases i think. Gabor On Fri, Sep 14, 2007 at 10:08:19AM +0200, Alfredo Alessandrini wrote: Hi, how can I replace NA value with 0: 1991 217 119 103 109 137 202 283 240 146 NA 1992 270 174 149 144 166 239 278 237 275 NA 1993 146 111 104 89 98

Re: [R] replace NA value with 0

2007-09-14 Thread Gabor Csardi
On Fri, Sep 14, 2007 at 09:46:57AM +0100, S Ellison wrote: Gabor Csardi [EMAIL PROTECTED] 14/09/2007 09:27:03 x[ is.na(x) ] - 0 should work in most cases i think. ... only you probably shouldn't be doing that at all. Words like 'bias' spring to mind... Woudn't it be better

Re: [R] Importing a dataset

2007-09-21 Thread Gabor Csardi
I don't know a way of loading parts of an .RData file either, but another solution is to use the envir argument of load to load the data into a new environment: x - 1 y - rnorm(3) save.image(tmp.RData) rm(x) rm(y) load(tmp.RData, env - new.env()) get(x, env) [1] 1 get(y, env) [1]

Re: [R] Network Construction in R

2007-09-24 Thread Gabor Csardi
Johannes, with the igraph package, this would be something like library(igraph) g - graph.data.frame( data.frame(from=data$acra, to=data$acrb, weight=data$expab)) Gabor On Sun, Sep 23, 2007 at 11:39:40AM -0400, Johannes Urpelainen wrote: Hi, I am trying to construct

Re: [R] Updating packages for R 2.6.0

2007-10-04 Thread Gabor Csardi
You need to install the libc6-dev ubuntu package to be able to compile programs. sudo apt-get install libc6-dev Gabor On Thu, Oct 04, 2007 at 09:54:26AM -0400, Ricardo Pietrobon wrote: I must be making some really basic mistake, since I keep getting an error message when using

Re: [R] igraph and plotting connected components

2007-10-09 Thread Gabor Csardi
in the wine windows (not) emulator, so you can use it on linux, OSX, etc. with some more effort. Gabor -- Csardi Gabor [EMAIL PROTECTED]MTA RMKI, ELTE TTK __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read

Re: [R] graph or svn

2007-10-09 Thread Gabor Csardi
Paul, if you have large graphs the igraph package might help, it works very well with large sparse graphs. To convert an adjacency matrix (A) to an igraph graph object (g) you can simply use library(igraph) g - graph.adjacency(A) and then you can generate layouts with

Re: [R] igraph and plotting connected components

2007-10-09 Thread Gabor Csardi
Dieter, there are a couple of ways to do this in igraph, eg. you can decompose the graph into separate components with g - erdos.renyi.game(100, 1/100) graphs - decompose.graph(g) and then you will have a list of graphs. If you assign some vertex ids as vertex attributes then you can keep

Re: [R] How to make own function load automatically on startup

2007-10-27 Thread Gabor Csardi
Jonas, if you want the function to load really automatically, without running source of anything, read ?Startup Basically you need to create an .Rprofile file (its location depends on your operating system) containing the R code you want to run at startup. Gabor On Sat, Oct 27, 2007 at

Re: [R] how to download pdb structure files?

2007-10-28 Thread Gabor Csardi
On Sun, Oct 28, 2007 at 11:25:06AM -0700, Ben Bolker wrote: Baoqiang Cao-2 wrote: Dear All, I'd like to know if there is anyway to download a certain structure file from http://www.pdb.org/. I tried the following but failed: tmp -

Re: [R] How to deal with character(0)?

2007-11-15 Thread Gabor Csardi
is.character(dd) length(dd) == 0 should do it i think. Gabor On Thu, Nov 15, 2007 at 04:54:45PM -0500, Gang Chen wrote: I want to identify whether a variable is character(0), but get lost. For example, if I have dd-character(0) the following doesn't seem to serve as a good

Re: [R] permutates and/or samples a matrix

2008-01-31 Thread Gabor Csardi
What exactly is the question? Selecting/permuting rows? M[sample(length=nrow(M), count), ] Selecting/permuting columns? M[ , sample(length=ncol(M), count) ] Permuting elements? structure(sample(M), dim=dim(M)) Selecting elements? sample(M, count) Gabor On Thu, Jan 31, 2008 at 09:10:11PM

Re: [R] permutates and/or samples a matrix

2008-01-31 Thread Gabor Csardi
I mean On Thu, Jan 31, 2008 at 02:32:20PM +0100, Gabor Csardi wrote: What exactly is the question? Selecting/permuting rows? M[sample(length=nrow(M), count), ] M[sample(seq(length=nrow(M)), count), ] Selecting/permuting columns? M[ , sample(length=ncol(M), count) ] M[ , sample(seq

Re: [R] [OT] emacs / xemacs for unix without compile

2008-01-31 Thread Gabor Csardi
You don't need root access to compile a program (in mose cases). Just a compiler and enough space. Gabor On Thu, Jan 31, 2008 at 03:45:51PM -0500, Wensui Liu wrote: I think the unix is SunOS. the secret is I don't have root priviledge. ^_^. So is there a possibility? Thanks. On Jan 31,

Re: [R] Saving a big table or matrix

2008-02-01 Thread Gabor Csardi
?save ?load Gabor ps. although i'm not sure what an Rdata-project means, so maybe you need something else On Fri, Feb 01, 2008 at 08:24:32AM +0200, Atte Tenkanen wrote: Dear R-users, How do you save a big table or matrix as an independent object and attach it to your Rdata-project when

Re: [R] re placing values in a matrix

2008-02-01 Thread Gabor Csardi
Actually, you don't need apply. If there are no NA's then it is very easy: m[] - y[ col(m) ] If you want to keep the NA's then it is a bit more tricky: m[] - 0*m + y[ col(m) ] G. On Thu, Jan 31, 2008 at 07:03:51PM -0800, dxc13 wrote: useR's, Consider: y - c(20, 25, 30) m -

Re: [R] re placing values in a matrix

2008-02-01 Thread Gabor Csardi
Derek, the 0*m part zeros out everything in the matrix, expect for the NA's, 0*NA=NA by definition. If we add this to the y[ col(m) ] matrix, then NA+anything=NA, but 0+anything=anything. G. ps. please answer to the list (as well) On Fri, Feb 01, 2008 at 08:52:50AM -0500, Derek Cyr wrote:

Re: [R] counts of each column that are not NA, and/or greater than column means

2008-02-04 Thread Gabor Csardi
On Mon, Feb 04, 2008 at 03:21:10PM +0800, Ng Stanley wrote: Hi, Given a test matrix, test - matrix(c(1,2,3,NA,2,3,NA,NA,2), 3,3) A) How to compute the counts of each column (excluding the NA) i.e., 3, 2, 1 apply(test, 2, function(x) sum(!is.na(x))) B) How to compute the counts of each

Re: [R] extracting rows from dataframe that match a vector

2008-02-05 Thread Gabor Csardi
You almost got it right. THe solution is df[df$ind %in% subgr,] See ?%in% G. On Tue, Feb 05, 2008 at 04:47:02PM +0100, Karin Lagesen wrote: Hi! I have a large dataframe that I want to extract a subset from. This subset has a certain column value that matches elements in a vector I have

Re: [R] revision control software for managing R-code?

2008-02-07 Thread Gabor Csardi
This is a religion question in some sense. Personally, i used CVS and a bit Subversion too, but arch and bazaar look much better. Especially if you're not always in online connection with the central repository, or you don't really want a central repository at all. Gabor On Thu, Feb 07, 2008 at

Re: [R] Loading Data to R

2008-02-08 Thread Gabor Csardi
It is a good idea to start with RSiteSearch(Excel) G. On Fri, Feb 08, 2008 at 03:49:29PM -0500, Christine Lynn wrote: This is the most basic question ever...I haven't used R in a couple years since college so I forget and haven't been able to find what I'm looking for in any of the manuals.

Re: [R] grep etc.

2008-02-10 Thread Gabor Csardi
sub(-, --, v, fixed=TRUE) See ?sub. Gabor On Sun, Feb 10, 2008 at 02:14:48PM -0500, Michael Kubovy wrote: Dear R-helpers, How do I transform v - c('insd-otsd', 'sppr-unsp') into c('insd--otsd', 'sppr--unsp') ? _ Professor Michael Kubovy University of

Re: [R] Conditional rows

2008-02-11 Thread Gabor Csardi
Because you need test = 0.2 | test 0.3 See ?| Gabor On Mon, Feb 11, 2008 at 09:12:57PM +0800, Stanley Ng wrote: That works beautfully. Why using test=0.2 || test 0.3 gives error ? -Original Message- From: Gabor Csardi [mailto:[EMAIL PROTECTED] Sent: Monday, February 11, 2008

Re: [R] Conditional rows

2008-02-11 Thread Gabor Csardi
which(apply(test=0.2, 1, all)) See ?which, ?all, and in particular ?apply. Gabor On Mon, Feb 11, 2008 at 06:22:09PM +0800, Ng Stanley wrote: Hi, Given a simple example, test - matrix(c(0.1, 0.2, 0.1, 0.2, 0.1, 0.1, 0.3, 0.1, 0.1), 3, 3) How to generate row indexes for which their

Re: [R] matching last argument in function

2008-02-12 Thread Gabor Csardi
It should be possible i think. You just supply all the arguments via '...' and then cut off the last one. I don't see why this wouldn't work, but maybe i'm missing something. Gabor On Tue, Feb 12, 2008 at 12:58:25PM -0600, Erik Iverson wrote: Alistair - I don't believe this is possible. The

Re: [R] sort a data frame according to roman characters

2008-02-12 Thread Gabor Csardi
I assume that data$Roman is character. data[order(as.numeric(as.roman(data$Roman))),] should do it. Maybe data[order(as.roman(data$Roman)), ] is enough too. Gabor On Tue, Feb 12, 2008 at 10:36:50AM +, Luis Ridao Cruz wrote: R-help, I have a data frame with one column containing roman

Re: [R] Removing columns that are all NA from a matrix

2008-02-14 Thread Gabor Csardi
data - data[ , !apply(is.na(data), 2, all)] (or something like that) G. On Thu, Feb 14, 2008 at 12:59:46PM +, Martin Waller wrote: Hi, I guess this might be a FAQ or something, and there's probably a nice simple way to do it, but I can't think of it: Given a matrix, I want to

Re: [R] finding source for a function

2008-02-14 Thread Gabor Csardi
RSiteSearch is your friend. E.g.: http://finzi.psych.upenn.edu/R/Rhelp02a/archive/63365.html and then click on 'Next in thread a couple of times Gabor On Thu, Feb 14, 2008 at 03:23:30PM -0600, Edna Bell wrote: Dear R Gurus: How do you get source for functions which say UseMethod when

Re: [R] function similar to str_replace() in php.

2008-02-15 Thread Gabor Csardi
I don't know php very well, but perhaps you need ?sub Gabor On Fri, Feb 15, 2008 at 03:54:19PM +0100, Dong-hyun Oh wrote: Dear expeRt, I would like to know whether a function similar to str_replace() in php exists in R. Looking forward to hearing from you. Best,

Re: [R] library(convert)

2008-02-18 Thread Gabor Csardi
.. (Counting to ten.) The package is called 'convert'. It seems that this package is not on CRAN, however. I think you should ask the person whose code you're running. Gabor On Mon, Feb 18, 2008 at 10:17:41AM +0100, Schmitt, Corinna wrote: Hallo, I am running R-2.6. on Windows. I

Re: [R] library(convert)

2008-02-18 Thread Gabor Csardi
Update: it is a Bioconductor package, so you need to do: source(http://bioconductor.org/biocLite.R;) biocLite(convert) Gabor On Mon, Feb 18, 2008 at 10:17:41AM +0100, Schmitt, Corinna wrote: Hallo, I am running R-2.6. on Windows. I have a code which uses library(convert). Can anyone tell

Re: [R] change NA values

2008-02-19 Thread Gabor Csardi
?RSiteSeach is useful. It gives you this: http://tolstoy.newcastle.edu.au/R/e2/help/07/09/25536.html and then keep clicking on Next in thread. Gabor On Tue, Feb 19, 2008 at 12:33:21PM +0100, Alfonso Pérez Rodríguez wrote: Hello, I'm sure that this question is too simple, but, I'm begining

Re: [R] Building a package and Depends search

2008-02-19 Thread Gabor Csardi
I think you need -l: R CMD check -l your_library your_package Gabor On Tue, Feb 19, 2008 at 02:00:38PM -, john seers (IFR) wrote: [...] I think this is because I install my packages in mylibrary and use R_LIBS=C:/PROGRA~1/R/mylibrary in my Renviron.site file. If I move the package to the

[R] [R-pkgs] igraph package, version 0.5

2008-02-20 Thread Gabor Csardi
igraph is a package for graphs and networks. It has a C core and uses a simple and fast graph representation allowing millions of vertices and edges. NEW FEATURES: - We use the ARPACK library for graph related eigenvalue problems, like Page Rank calculation, Kleinberg's hub and authority

Re: [R] Hiding a function

2008-02-23 Thread Gabor Csardi
It depends what you mean by 'hiding', you can start the function names with a dot and then they are not listed by ls(), so this is kind of hiding. .a - function() TRUE ls() character(0) .a function() TRUE Personally i would not do this though. G. On Sat, Feb 23, 2008 at 11:58:57AM +0100,

Re: [R] Viable Approach to Parallel R?

2008-02-23 Thread Gabor Csardi
Similar experience, with snow MPI (LAM). Actually, plug and play. G. On Sat, Feb 23, 2008 at 10:57:22AM -0700, Eric W Anderson wrote: Hi Dan, I've had pretty good luck using Snow with with Rpvm. It's definitely not what you'd call plug and play, but it does work. I'm using it on a

Re: [R] Newbie: Where is lmFit function?

2008-02-24 Thread Gabor Csardi
It's in the 'limma' Bioconductor package. Next time you can try help.search(lmFit) RSiteSearch(lmFit) Gabor On Sun, Feb 24, 2008 at 01:02:41PM -0800, Keizer_71 wrote: Hi Everyone, I am trying to use lmFit function; however, i cannot find it function anywhere. I have been trying to

Re: [R] cohesive blocks.. again

2008-02-28 Thread Gabor Csardi
Simone, they are currently ignored. Just like edge direction. Gabor On Thu, Feb 28, 2008 at 03:17:24PM +0100, Simone Gabbriellini wrote: hello, I have a last question on cohesive blocks: if there are multiple links between some nodes in the graph, this is taken into account by cohesive

Re: [R] Column sums from a data frame (without the headers)

2008-02-29 Thread Gabor Csardi
colSums gives you exactly what you want, but the vector is *named*. You can use it like a not-named numeric vector, without much trouble. If you still want to get rid of the names see ?unname G. On Fri, Feb 29, 2008 at 12:02:46PM -0500, Jason Horn wrote: Does anyone know how to get a vector of

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

2008-02-29 Thread Gabor Csardi
I believe that R can export all formats that GNUplot can produce, so i don't really see why you want to use GNUplot if you don't know it. If you still want to then read ?write.table, that can export your data into a spreadsheet-like ascii format which can be used from GNUplot easily. Btw,

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

2008-03-01 Thread Gabor Csardi
On Sat, Mar 01, 2008 at 12:54:56AM +0100, Louise Hoffman wrote: If you still want to then read ?write.table, that can export your data into a spreadsheet-like ascii format which can be used from GNUplot easily. Very interesting. So if I e.g. write: ts.sim - arima.sim(list(order =

Re: [R] [OT] normal (as in Guassian)

2008-03-02 Thread Gabor Csardi
I'm not a statistician, but do i remember well that among all distributions with a given mean and variance, the normal distribution has the highest entropy? This is good enough for me to call it normal Gabor On Sun, Mar 02, 2008 at 10:10:21AM -0600, roger koenker wrote: A nice survey of

Re: [R] help for the first poster- a simple question

2008-03-03 Thread Gabor Csardi
R FAQ 7.31. G. On Mon, Mar 03, 2008 at 12:52:43PM -0500, Xuejun Qin wrote: Hi, there, I cannot get accurate value for calculation. for example: ld-sqrt(1*0.05*0.95*0.05*0.95) 0.05*0.95-ld=-6.938894e-18 0.05*0.95-ld==0 is False. I met this problem in my program, how can I handle it.

Re: [R] R-Terminal

2008-03-04 Thread Gabor Csardi
options(width=120) See ?options G. On Tue, Mar 04, 2008 at 12:04:54PM +0100, Martin Kaffanke wrote: Hi there! I use an gnome-terminal for using R. When I resize the termial to the maximum size, R uses only the left side of the window. Can I tell R to use the whole window somehow?

Re: [R] R-Terminal

2008-03-04 Thread Gabor Csardi
On Tue, Mar 04, 2008 at 01:18:43PM +0100, Martin Kaffanke wrote: Am Dienstag, den 04.03.2008, 12:34 +0100 schrieb Peter Dalgaard: Martin Kaffanke wrote: Hi there! I use an gnome-terminal for using R. When I resize the termial to the maximum size, R uses only the left side of the

Re: [R] request if a variable is defined

2008-03-04 Thread Gabor Csardi
Bingo! See ?exists G. On Tue, Mar 04, 2008 at 04:38:31PM +0100, Paul Hammer wrote: hi members, give it a function for requesting if a object, matrix, vector, variable or whatever already exists? e.g. if (*exists*(a) {print(yes) } else { print(no) } thanks paul

Re: [R] vertex labels in igraph from adjacency matrix

2008-03-05 Thread Gabor Csardi
On Wed, Mar 05, 2008 at 02:27:21AM -0500, Charilaos Skiadas wrote: [...] Btw, you will likely want to take the betweenness call out, and call it once and store the result, instead of calling it twice (well, assuming the graph is largish). Or even better, use which.max:

Re: [R] vertex labels in igraph from adjacency matrix

2008-03-05 Thread Gabor Csardi
Mark, graph.adjacency always preserves the order of the vertices, so the vertex at row/column 1 will be vertex #0 in the igraph graph, etc. I'll document this in a minute. This means that you can always do g - graph.adjacency(A) V(g)$name - colnames(A) But i completely agree that this should

Re: [R] R-Logo in \LaTeX

2008-03-07 Thread Gabor Csardi
On Thu, Mar 06, 2008 at 06:54:41PM -0500, Charilaos Skiadas wrote: On Mar 6, 2008, at 1:49 PM, Mag. Ferri Leberl wrote: Dear everybody! Is there a command in \LaTeX to display the R-Logo or has anybody made it up? Thank you in advance. Isn't it just an image? Hence you would

Re: [R] R-Logo in \LaTeX (Mag. Ferri Leberl)

2008-03-07 Thread Gabor Csardi
Jean, this is nice, but 1) the logo is a bitmap, it is ugly if you resize it, 2) you don't need a pdf version for pdflatex, it handles jpg (and maybe also png as well), so you can just use the logos at the R developer site. It would be really nice to have a non-bitmap version, though. If it

Re: [R] R-Logo in \LaTeX

2008-03-07 Thread Gabor Csardi
Jean, On Fri, Mar 07, 2008 at 06:09:35PM +0100, Jean lobry wrote: Gabor, this is nice, but 1) the logo is a bitmap, it is ugly if you resize it Sure, it's a bitmap, but the naked eye resolution is only 100 $\mu$m so that a vectorized solution is overkilling in most common situations

Re: [R] cumsum list..

2008-03-13 Thread Gabor Csardi
cumsum( mapply(function(i,j) sum(a$data[i:j]), x, y) ) Is this what you want? Gabor On Thu, Mar 13, 2008 at 06:02:13AM -0700, yoo wrote: Hi all, i have the following.. a - data.frame(data = seq(1,10)) i have indices: x - c(1, 5, 3, 9) y - c(2, 7, 4, 10) I want the cumsum of

Re: [R] joining matrices, vectors, scalars in one object

2008-03-13 Thread Gabor Csardi
You want to do thing - list()# empty thing for ( i in 1:100 ) { thing[[i]] - ? } But where is ? coming from? If you can index it with an integer then it is exactly coming from the kind of object you want to create. Chicken-egg problem. No? G. On Thu, Mar 13, 2008 at 09:04:11AM

Re: [R] Selecting elements in vector

2008-03-14 Thread Gabor Csardi
Use %in%: x [ x %in% y ] G. On Fri, Mar 14, 2008 at 12:37:45PM +0200, Rainer M Krug wrote: Hi Consider the following code x - rep(1:13, 13) y - 1:3 I want to select all elements in x which are equal to 1, 2 or 3. I know that I could use sel - x==y[1] | x==y[2] | x==y[3]

Re: [R] test individual values in rows

2008-03-14 Thread Gabor Csardi
keep - apply( DATA, 1, min ) = 100 DATA - DATA[ keep, ] See ?apply for more. Gabor On Fri, Mar 14, 2008 at 01:26:49PM +, IAIN GALLAGHER wrote: Hi list. I have a numerical dataset 22,000 rows deep and 43 columns wide. I would like to remove those rows which contain only values less

Re: [R] using nrow to identify one row

2008-03-14 Thread Gabor Csardi
Try temp[1,,drop=FALSE] See ?[ for the explanation. Gabor On Fri, Mar 14, 2008 at 04:46:10PM -0400, Gregory Gentlemen wrote: Hi fellow R-users, I have run into a problem when trying to identify the number of rows in a matrix. Say we have an arbitrary 5 by 5 matrix called temp: temp -

Re: [R] empty array

2008-03-15 Thread Gabor Csardi
On Sat, Mar 15, 2008 at 04:33:32PM +0100, Christophe Genolini wrote: Hi the list Is it possible to create an empty matrix ? I do not mean an matrix with a single value that is NA (which is not empty) but a real empty one, with length=0. Sure: matrix(nrow=0, ncol=5) [,1] [,2] [,3]

Re: [R] How does one do simple string concatenation?

2008-03-17 Thread Gabor Csardi
First 'c' and then 'paste' with 'collapse': paste(collapse=, c(c(a, b, c), d)) See ?paste G. On Mon, Mar 17, 2008 at 04:26:17PM +0530, Ajay Shah wrote: How does one convert objects c(a,b,c) and d into abcd? paste(c(a,b,c), d) of course yields [1] a d b d c d -- Ajay Shah

Re: [R] unsubscribe

2008-03-19 Thread Gabor Csardi
What about reading the very last four lines of any email you get from the list? Like this one. G. On Wed, Mar 19, 2008 at 12:09:29PM -0400, ablukacz wrote: Dear All, Can someone please give me instruction on how to unsubscribe from this list. I do not have the original emial that arrived

Re: [R] R GUI question

2008-03-19 Thread Gabor Csardi
On Wed, Mar 19, 2008 at 12:56:13PM -0700, jeffreya wrote: Hi. I'm looking to create a user-friendly program built around some R methods I've written. The program should be as easy to install and use as possible and will be built around a GUI. This program will be cross-platform; that's

Re: [R] download webpage in R

2008-03-20 Thread Gabor Csardi
If you do help.search(download) you find ?download.file G. On Thu, Mar 20, 2008 at 04:51:22PM -0500, gilbert feng wrote: Hi, everyone I want to download a XML webpage and save it as a file in my local machine. Is there any way to do it in R? Thanks a lot Gilbert

Re: [R] rounding in calculation

2008-03-21 Thread Gabor Csardi
Read R FAQ 7.31 ? http://cran.r-project.org/doc/FAQ/R-FAQ.html#Why-doesn_0027t-R-think-these-numbers-are-equal_003f Gabor On Fri, Mar 21, 2008 at 04:17:28PM +0100, John Lande wrote: dear all, I report a problem very simple, that I does non know how to handle. look at the following code:

Re: [R] Draw Circles

2008-03-23 Thread Gabor Csardi
May i ask what was the problem with symbols()? G. On Sun, Mar 23, 2008 at 04:10:38AM -0700, ermimi wrote: Thank you very much for the help!!! Felix Andrews wrote: help.search(circle) should point you to grid.circle in the grid package, at least in my R version 2.6.1 (grid

Re: [R] mapply

2008-03-23 Thread Gabor Csardi
On Sun, Mar 23, 2008 at 11:06:05AM -0400, Mark Leeds wrote: In an earlier post, a person wanted to divide each of the rows of rawdata by the row vector sens so he did below but didn't like it and asked if there was a better solution. rawdata - data.frame(rbind(c(1,2,2), c(4,5,6)))

Re: [R] highest eigenvalues of a matrix

2008-06-19 Thread Gabor Csardi
Baptiste, the igraph ARPACK interface is quite experimental, and igraph includes only the ARPACK files (converted to C) that it needs to calculate some graph measures on sparse graphs. Btw. the development version of igraph is a bit better in this respect, I can send you a link to the

Re: [R] 3D histogram

2008-06-20 Thread Gabor Csardi
Maybe I'm missing something, but where is the 3D here? My tip is hist3d in package rgl. But there might be others, it might worth to search the archive, I remember seeing this question once. Gabor On Fri, Jun 20, 2008 at 08:55:36AM -0400, Richardson, Patrick wrote: Try ?hist -and-

Re: [R] reset row numbers when extracting a subset of a table

2008-06-24 Thread Gabor Csardi
Nina, these are not row NUMBERS, but row NAMES. Numbers are actually reset, they always start with 1 and they are continuous. Just try doing T[1,] on your table. If you want to reset row names, you can do this: rownames(T) - seq(length=nrow(T)) or you can even remove them: rownames(T) -

Re: [R] running R-code outside of R

2008-06-25 Thread Gabor Csardi
Some clarifications. R's license (GPL v2) is not about money, you can charge anyone as much as you wish. If you create an R program (and don't modify R itself), then you can distribute that program according to any license you wish. If you modify R itself _and_ distribute the modified

Re: [R] selecting values that are unique, instead of selecting unique values

2008-06-25 Thread Gabor Csardi
Hmmm, this is not very good: Vec - c(10:1,1) Vec[ table(Vec) == 1 ] [1] 9 8 7 6 5 4 3 2 1 and these are obviously not the unique values. This one is better: Vec [ ! duplicated(Vec) ! duplicated(Vec, fromLast=TRUE) ] Gabor On Wed, Jun 25, 2008 at 11:29:31AM -0500, Marc Schwartz wrote:

Re: [R] selecting values that are unique, instead of selecting unique values

2008-06-25 Thread Gabor Csardi
I'm sorry to say, but this one is wrong, too. Maybe coffee really helps, I just had one. :) Vec - c(20:30,20) which(table(Vec) == 1) 21 22 23 24 25 26 27 28 29 30 2 3 4 5 6 7 8 9 10 11 You would actually need the names, but that would involve some numberic - character - numeric

Re: [R] selecting values that are unique, instead of selecting unique values

2008-06-25 Thread Gabor Csardi
Wow, that is smart, although is seems to be overkill. I guess 'duplicated' is better than O(n^2), is it really? Gabor On Wed, Jun 25, 2008 at 05:43:30PM +0100, Prof Brian Ripley wrote: On Wed, 25 Jun 2008, Marc Schwartz wrote: on 06/25/2008 11:19 AM Daren Tan wrote: unique(c(1:10,1))

Re: [R] igraph (was Compilation error during package installation)

2008-06-27 Thread Gabor Csardi
Wanding, I'm the maintainer of igraph, but missed your previous email. Yes, currently the released version of igraph fails to compile with gcc 4.3.x. I made the required modifications to fix this, but these are still in the igraph development tree, as there has been no release since that.

Re: [R] Graphs in R

2008-06-30 Thread Gabor Csardi
paste(sep=, graf, 1:250, .jpg) See ?paste, G. On Mon, Jun 30, 2008 at 11:58:51AM -0300, Leandro Marino wrote: Hi list, I want to make a lot of graphics to my end course project. So, i was using this sintax: jpeg(filename = graf01.jpg, width = 1024, height = 1024, units = px,

Re: [R] trivial list question

2008-07-01 Thread Gabor Csardi
I think there are many simple solutions, here is one: lapply(1:92, function(x) c(2*x-1, 2*x)) Gabor On Tue, Jul 01, 2008 at 02:46:07PM +0200, Boks, M.P.M. wrote: Dear experts, For the makeGenotype function I need a list as in the example. However, since my list needs to be 184 long there

Re: [R] Find classes of each column of data.frame()

2008-07-01 Thread Gabor Csardi
A data frame is a special list: d - data.frame( A=numeric(), B=logical(), C=character() ) lapply(d, class) $A [1] numeric $B [1] logical $C [1] factor Gabor On Tue, Jul 01, 2008 at 03:50:18PM +0200, Dong-hyun Oh wrote: Dear UseRs, I would like to know the way to find classes of each

Re: [R] Can R do this ?

2008-07-08 Thread Gabor Csardi
If this is about more than a handful files, then it is really painful to do it with OpenOffice.org or LyX, I guess. You can use imagemagick, this is fairly standard on Linux. Then it is something like this, assuming you have bash: for f in *.png; do convert $f ${f%png}pdf; done for f in *.jpg;

Re: [R] Can R do this ?

2008-07-08 Thread Gabor Csardi
Ooops, please ignore my previous mail, I did not read the question carefully enough. Gabor On Tue, Jul 08, 2008 at 02:27:51AM -0700, Mark Difford wrote: Hi Daren, Can R (out)do Emacs? I think you just need to ?Sweave a little. Mark. Daren Tan wrote: I have a folder

Re: [R] Expression in axis

2008-07-09 Thread Gabor Csardi
E.g. plot(1:10,1:10,xlab=NA) title(xlab=expression(mu*mol/10^6* cells)) Gabor On Wed, Jul 09, 2008 at 11:21:46AM +0200, Dani Valverde wrote: Hello, I am creating a plot and I would like to know how to put this expression to the y axis

Re: [R] Summary Stats (not summary(x))

2008-07-09 Thread Gabor Csardi
Why don't you write it for yourself, it takes less time than writing an email: mysummary - function(x) { require(plotrix) require(e1071) c(Mean=mean(x), Std.Error=std.error(x), Std.Deviation=sd(x), Kurtosis=kurtosis(x)) } Gabor On Wed, Jul 09, 2008 at 08:15:00AM -0700, nmarti wrote:

Re: [R] Turn any vector

2008-07-10 Thread Gabor Csardi
It is called 'rev', see ?rev. rev(1:10) [1] 10 9 8 7 6 5 4 3 2 1 G. On Thu, Jul 10, 2008 at 01:56:58PM +0200, Zroutik Zroutik wrote: Dear R-users, I'd like to turn a vector so it starts with it's end. For better understanding, this set of commands will do what I need: i -

Re: [R] network

2008-07-11 Thread Gabor Csardi
I'm sure this is possible with 'network', but i'm not very familiar with that package. In case you don't get an answer on how to do it with network, here is how to do it with the 'igraph' package: library(igraph) M - matrix(runif(100)*2-1, 10, 10) M[ lower.tri(M, diag=TRUE) ] - 0 M[ abs(M)

Re: [R] network

2008-07-11 Thread Gabor Csardi
the names in the nodes of the graph (currently it just shows the row number)? Your help is much appreciated Kind regards Jonathan -Original Message- From: Gabor Csardi [mailto:[EMAIL PROTECTED] Sent: 11 July 2008 14:33 To: Dry, Jonathan R Cc: r-help@r-project.org Subject: Re: [R

Re: [R] network

2008-07-11 Thread Gabor Csardi
(gdata2)$name Error in `V-`(`*tmp*`, value = 0:9) : invalid indexing gdata2 Vertices: 10 Edges: 4 Directed: FALSE Edges: [0] 1 -- 5 [1] 2 -- 6 [2] 3 -- 7 [3] 4 -- 7 -Original Message- From: Gabor Csardi [mailto:[EMAIL PROTECTED] Sent: 11 July 2008 14:54

Re: [R] rm(l*)

2008-07-14 Thread Gabor Csardi
Maybe there is a simpler way, but this works fine: l1 - 1 l2 -2 m -10 ls() [1] l1 l2 m rm(list=grep(^l.*, ls(), value=TRUE)) ls() [1] m You can supply a regular expression to grep. Gabor On Mon, Jul 14, 2008 at 10:45:13AM +0200, Oehler, Friderike (AGPP) wrote: Dear Rusers, how can

Re: [R] Font quality in base graphics

2008-07-16 Thread Gabor Csardi
Hmmm, I did not follow this thread closely, sorry for that, just want to share my 2c. If it is about quality, then I create EPS files and use the psfrag latex package to replace the PS fonts with TeX's fonts. This has the following advantages: 1) The figures have the same font as the text

Re: [R] Font quality in base graphics

2008-07-16 Thread Gabor Csardi
On Wed, Jul 16, 2008 at 04:48:28AM -0500, Gabor Csardi wrote: [...] I have a little script that automates this for .fig files (this is based on figtex, another script that I found somewhere online and can't find it any more) [...] Ok, it is called figfrag, and it is on CTAN

Re: [R] Calculating Betweenness - Efficiency problem

2008-07-21 Thread Gabor Csardi
Senthil, you can try the 'igraph' package. Export your two-column Excel file as a .csv, use 'read.csv' to read that into R, then 'graph.data.frame' to create an igraph graph from it. Finally, call 'betweenness' on the graph. It is really just three/four lines, something like this: tab -

Re: [R] Calculating Betweenness - Efficiency problem

2008-07-23 Thread Gabor Csardi
-Original Message- From: Gabor Csardi [mailto:[EMAIL PROTECTED] Sent: Monday, July 21, 2008 1:57 AM To: Senthil Purushothaman Cc: jim holtman; r-help@r-project.org Subject: Re: [R] Calculating Betweenness - Efficiency problem Senthil, you can try the 'igraph' package. Export

Re: [R] NAs - NAs are not allowed in subscripted assignments

2008-07-24 Thread Gabor Csardi
is smaller than 2 _AND_ larger than 3, at least if we consider the usual ordering on numbers. Best, Gabor [...] -- Csardi Gabor [EMAIL PROTECTED]UNIL DGM __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do

Re: [R] NAs - NAs are not allowed in subscripted assignments

2008-07-24 Thread Gabor Csardi
On Thu, Jul 24, 2008 at 09:30:54AM -0700, Nordlund, Dan (DSHS/RDA) wrote: [...] a - c(rep(seq(1,4),4),NA,NA) b - c(rep(seq(1,2),7),NA,NA,1,2) Andreas, what is wrong with a[ (a 2 | a 3) b==1 ] - NA ? Isn't this what you want? [...] As I mentioned in my response

Re: [R] NAs - NAs are not allowed in subscripted assignments

2008-07-24 Thread Gabor Csardi
On Thu, Jul 24, 2008 at 10:39:34AM -0700, Nordlund, Dan (DSHS/RDA) wrote: [...] Yes, it does help. I was misunderstanding how logical values are used for indexing. I assumed incorrectly that a value would be returned only if the index expression evaluated as TRUE. It would seem that the

Re: [R] R beginner - how to apply function to more than one matrix / data.array / ...

2008-04-09 Thread Gabor Csardi
Yes, it is exactly 'apply', and its friends. E.g. you can collect the objects into a list and then do sapply(mylist, is.matrix) G. On Wed, Apr 09, 2008 at 11:52:08AM -0400, Mon Mag wrote: I would like to apply a simple function, like is.matrix to more than one data.frame How can I call on

Re: [R] Associative array and How to store a set of objects ?

2008-04-14 Thread Gabor Csardi
On Mon, Apr 14, 2008 at 08:32:55PM +0800, Ng Stanley wrote: Hi, Two questions: A) Assuming OB is an object, how do I store 20 of OB in a vector or list ? replicate(20, OB, simplify=FALSE) B) Does R has something similar associative array to Perl ? For example, %our_friends = ('best',

Re: [R] Initialize many variables to NUL, check whether an object exist

2008-04-14 Thread Gabor Csardi
On Mon, Apr 14, 2008 at 09:47:49PM +0800, Ng Stanley wrote: Hi, Two questions: A) I need to initialize many variables to NULL. So I created variable_names - c(a1, a2). What can I do to variable_names so that variable a1 is NULL and a2 is NULL ? for (n in variable_names) assign(n, NULL)

Re: [R] Initialize many variables to NUL, check whether an object exist

2008-04-14 Thread Gabor Csardi
) Error in RG[[ABC]] - c(a, b) : more elements supplied than there are to replace On Mon, Apr 14, 2008 at 9:53 PM, Gabor Csardi [EMAIL PROTECTED] wrote: On Mon, Apr 14, 2008 at 09:47:49PM +0800, Ng Stanley wrote: Hi, Two questions: A) I need to initialize many variables

Re: [R] = vs. ==?

2008-04-15 Thread Gabor Csardi
I'm sure you'll get a friendlier answer, but... see ?= ?== Introduction to R G. On Tue, Apr 15, 2008 at 05:28:53AM -0700, Linn wrote: Hi Could anyone please explain to me the difference between the = and the ==? I'm quite new to R and I've tried to find out but didn't get any wiser...

Re: [R] Is there any function to skip a loop in a for loop ?

2008-04-18 Thread Gabor Csardi
next break Another 'Introduction to R', or even ?for question G. On Fri, Apr 18, 2008 at 04:55:01PM +0800, Ng Stanley wrote: Hi, Is there any function to skip a loop in a for loop ? Thanks Stanley [[alternative HTML version deleted]]

Re: [R] How to insert a vector or matrix into an existing matrix

2008-04-20 Thread Gabor Csardi
Hmm, my understanding is different, m - matrix(sample(10*10), ncol=10) m2 - rbind( m[1:5,], 1:10, m[6:10,] ) m3 - cbind( m[,1:8], 1:10, m[,9:10] ) G. On Sun, Apr 20, 2008 at 10:21:47AM -0300, Henrique Dallazuanna wrote: If I understand: m - matrix(sample(10*10), ncol=10) m[5:6, 8:9] - 1:4

Re: [R] How to insert a vector or matrix into an existing matrix

2008-04-21 Thread Gabor Csardi
On Sun, Apr 20, 2008 at 08:16:11PM +, David Winsemius wrote: Gabor Csardi [EMAIL PROTECTED] wrote in news:[EMAIL PROTECTED]: Hmm, my understanding is different, m - matrix(sample(10*10), ncol=10) m2 - rbind( m[1:5,], 1:10, m[6:10,] ) m3 - cbind( m[,1:8], 1:10, m[,9:10] ) I

Re: [R] How to insert a vector or matrix into an existing matrix

2008-04-21 Thread Gabor Csardi
On Mon, Apr 21, 2008 at 12:50:08PM +, David Winsemius wrote: [...] Am I correct in assuming that after the creation of m by way of a temporary matrix that the temporary matrix would then be available for garbage collection, whereas if both m and m2 were created, there would be more

  1   2   >