Re: [R] Help with rep

2008-07-25 Thread Gabor Csardi
Jacob, yes, e.g. rep( c(4,3,4,2,3,4,1,2,3,4), 1 ) :) Seriously, your question reminds me of (rather silly) television contents, when one should find _the_ rule in a series of numbers. :) Here is a solution, assuming I've found the "correct" rule: unlist(lapply(4:1, seq, 4)) Best, Gabor On Fri

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] 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? > > [...] > >

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

2008-07-24 Thread Gabor Csardi
cing values that are either smaller than 2 _OR_ larger than 3, no number 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-pr

Re: [R] Calculating Betweenness - Efficiency problem

2008-07-23 Thread Gabor Csardi
I am attaching the Test.csv file for your > experiments. Thank you very much again. > > Best regards, > Senthil > (909) 267-0799 > > -Original Message- > From: Gabor Csardi [mailto:[EMAIL PROTECTED] > Sent: Monday, July 21, 2008 1:57 AM > To: Senthil Purusho

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 <- read.cs

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

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 its

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: > Dea

Re: [R] network

2008-07-11 Thread Gabor Csardi
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] network

2008-07-11 Thread Gabor Csardi
is it possible to show 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:

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] 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] 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] 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] 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 ha

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; d

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 o

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 the

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

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

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

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
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] 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 version,

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) <- N

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

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 developme

Re: [R] Hyper-elegant code to get a text file, transpose it, and write it

2008-06-05 Thread Gabor Csardi
On Thu, Jun 05, 2008 at 10:26:08AM -0200, Alberto Monteiro wrote: > > > > Uwe Ligges wrote: > > > > You probably want > > > > write.table(t(read.table(file.in)), file = file.out, row.names = > > FALSE, col.names = FALSE) > > > Ok, almost there. I forgot to tell (because I didn't know) > that

Re: [R] For Social Network Analysis-Graph Analysis - How to convert 2 mode data to 1 mode data?

2008-05-20 Thread Gabor Csardi
ix > g3 = df.to.nxn(df$actor, df$event) > g4 = graph.adjacency(g3, mode = "undirected", diag = F) > V(g4)$name = row.names(g3) > g4 > ### > > This yields: > > g4 > Vertices: 4 >

Re: [R] For Social Network Analysis-Graph Analysis - How to convert 2 mode data to 1 mode data?

2008-05-14 Thread Gabor Csardi
Please stay on the list. On Tue, May 13, 2008 at 06:05:15PM -0400, Messing, Solomon O. wrote: > Gabor, > > By the way, this seems to work: I'm a bit lost. So now you're converting your data frame to a matrix? Why? Or you're doing the two-mode to one-mode conversion here? It does not seem so to

Re: [R] For Social Network Analysis-Graph Analysis - How to convert 2 mode data to 1 mode data?

2008-05-14 Thread Gabor Csardi
they're assumed to be different types of nodes. Just create the graph, calculate the 'keep' parameter, I assume that you know this from external information, and then call the function. G. > Solomon > > > >-Original Message- > >From: Gabor Csardi [mai

Re: [R] Remove an object by the reference

2008-05-13 Thread Gabor Csardi
> a <- 1 > x <- "a" > rm(list=x) > a Error: object "a" not found See ?rm for details. Gabor On Tue, May 13, 2008 at 05:13:41PM +0530, Shubha Vishwanath Karanth wrote: > Hi R, > > > > A simple question, but don't know the answer... > > > > x="a" > > a=5 > > > > I need to remove the o

Re: [R] Creating Matrix

2008-05-11 Thread Gabor Csardi
See ?cbind and ?matrix. Gabor On Sat, May 10, 2008 at 03:21:26PM -0700, Claire_6700 wrote: > > Hello, > > I have two data. > > x<-c(1, 2, 1, 3, 2) > y<-c(3, 1, 2, 3, 5) > > How do i create matrix from this two. > > what i want is this > > x y > 1 1 3 > 2 2 1 > 3 1 2 > 4 3

Re: [R] For Social Network Analysis-Graph Analysis - How to convert 2 mode data to 1 mode data?

2008-05-10 Thread Gabor Csardi
Solomon, if i understand two-mode networks properly (they're bipartite, right?), then this is not hard to do with igraph. Basically, for each vertex create an order=2 neighborhood, and then create a graph from the adjacency list, it is something like this: two.to.one <- function(g, keep) { neis

Re: [R] efficiency & profiling? (was: Why R is 200 times slower than Matlab ?)

2008-04-30 Thread Gabor Csardi
On Wed, Apr 30, 2008 at 06:59:38PM -0400, esmail bonakdarian wrote: > > This has been an interesting discussion, and brings up two questions > for me: > > Is there a good collection of hints/suggestions for R language idoms in terms > of efficiency? For instance I read not to use for-loops, so I

Re: [R] Why R is 200 times slower than Matlab ?

2008-04-30 Thread Gabor Csardi
But please consider that this benchmark is five years old, and i believe that R has changed quite a lot since version 1.9. Gabor On Wed, Apr 30, 2008 at 04:21:51PM -0400, Wensui Liu wrote: > Hi, ZD, > Your comment about speed is too general. Here is a benchmark > comparison among several langua

Re: [R] Why R is 200 times slower than Matlab ?

2008-04-30 Thread Gabor Csardi
I would rather not comment on matlab (where is your matlab code by the way?), but your function could be simplified a bit: grw.permute <- function(v) { cbind( rep(v, each=length(v)), rep(v, length(v)) ) } > system.time(tmp <- f( 1:300)) user system elapsed 0.020 0.000 0.019 This is

Re: [R] removing zero rows from matrix/table

2008-04-22 Thread Gabor Csardi
See ?apply M2 <- M[ apply(M!=0, 1, any), , drop=FALSE] Gabor On Tue, Apr 22, 2008 at 11:52:08AM +0200, Patrick Zimmermann wrote: > Dear R-community, > I have matrices/tables of different sizes which may contain rows with > only zeros. Now I would like to delete these zero lines or create new > m

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 mor

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:

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]

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] = 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] Initialize many variables to NUL, check whether an object exist

2008-04-14 Thread Gabor Csardi
force the assignment ? > > > RG[["ABC"]] <- c("a", "b") > 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

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

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:52:36PM +0800, Ng Stanley wrote: > Hi, > > Didn't make myself clear on A). The twenty OBs are all different, how to > store them in a vector or list ? bigOB <- list(OB1, OB2, OB3, ..., OB20) G. [...] -- Csardi Gabor <[EMAIL PROTECTED]>UNIL DGM _

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 = ('bes

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

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

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.

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 co

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] 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'

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 arrive

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] "

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

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

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 le

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=

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:11A

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

Re: [R] SORT MATRIX

2008-03-10 Thread Gabor Csardi
M[ order(M[,1]), ] G. On Mon, Mar 10, 2008 at 01:56:45PM -0700, ermimi wrote: > > I have a matrix with 2 columns and n row. I need sort the matrix by the first > column but the second row must be sort in the same order that the first > column. Somebody know how I can sort this matrix. > Thanks v

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 sit

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 e

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 w

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] 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: > > which.max(b

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] 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 le

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] 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 handl

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] 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(lis

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

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] 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 > cohe

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 try

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 >

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

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

Re: [R] Building a package and Depends search

2008-02-19 Thread Gabor Csardi
I think you need "-l": R CMD check -l 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 main library

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 w

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 any

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] 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] 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" wh

Re: [R] data frame question

2008-02-14 Thread Gabor Csardi
df2 = df ? G. On Thu, Feb 14, 2008 at 09:12:23AM -0800, joseph wrote: > > > Hi > > I have a data frame df1 in which I would like to multiply col1 > by 2. > > > The way I did it does not allow me to keep the old data > frame. > > > How can I do this and be able to create a new data frame

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] R equivalent of linux "cut", "paste", and "grep" ?

2008-02-14 Thread Gabor Csardi
Personally, i would go for a pure R solution, except if the files are very large. For that i'm afraid that you need to read the whole file, manipulate it and write it back. Or implement your own 'read' function instead of read.table. Gabor On Thu, Feb 14, 2008 at 09:57:14AM +, Romain Franco

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

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

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 thei

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

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 manual

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 a

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

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 e

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

  1   2   >