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

2008-07-24 Thread Gabor Csardi
On Thu, Jul 24, 2008 at 04:45:14PM +0200, Kunzler, Andreas wrote:
 Hy Richie, thank you for the quick response.
 
 Unfortunately my problems hold on.
 
 Once again: 2 vectors (numeric) including NAs 
 My intention: I want to replace the values of vector a that are smaller
 than 2 and larger than 3 into NAs only in case vector b equals 1
 
 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?

Btw. I assume you mean replacing 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-project.org mailing list
https://stat.ethz.ch/mailman/listinfo/r-help
PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
and provide commented, minimal, self-contained, reproducible code.


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 to this thread, there are some things I don't 
 quite understand with logical indexing.  Using the above example,
 
  a[ (a  2 | a  3)  b==1 ]
 
 returns
 
 [1]  1  1  1  1 NA NA
 
 Where do the NA values come from?

This is not really about logical indexing, just operations on numeric 
and logical vectors, and how they handle NA values. Just keep in mind 
that NA means that we don't know the actual value. All operations 
were desinged (I believe) with this in mind.
Here is some help:

 NA == 1
[1] NA
 class(NA == 1)
[1] logical

This is NA, obviously, as _we don't know_ whether NA is equal to 1 or not.

 TRUE  NA
[1] NA
 FALSE | NA
[1] NA

The same applies here, for the result we would need to know whether 
NA is TRUE or FALSE. However, we have

 FALSE  NA
[1] FALSE
 TRUE | NA
[1] TRUE

In these cases the result can be calculated without knowing what 
actually NA is. 

Logical indexing is simple, for every TRUE value in the logical vector
we choose the corresponding element from the indexed vector. If we 
index with NA, then the chosen element is NA as well.

 (1:5)[ c(T,T,T,T,T) ]
[1] 1 2 3 4 5
 (1:5)[ c(T,T,T,F,T) ]
[1] 1 2 3 5
 (1:5)[ c(T,T,T,F,NA) ]
[1]  1  2  3 NA
 (1:5)[ c(NA,T,T,F,NA) ]
[1] NA  2  3 NA

Does this help? Best,
Gabor

 Dan
 
 Daniel J. Nordlund
 Washington State Department of Social and Health Services
 Planning, Performance, and Accountability
 Research and Data Analysis Division
 Olympia, WA  98504-5204
  
  
 
 __
 R-help@r-project.org mailing list
 https://stat.ethz.ch/mailman/listinfo/r-help
 PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
 and provide commented, minimal, self-contained, reproducible code.

-- 
Csardi Gabor [EMAIL PROTECTED]UNIL DGM

__
R-help@r-project.org mailing list
https://stat.ethz.ch/mailman/listinfo/r-help
PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
and provide commented, minimal, self-contained, reproducible code.


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 philosophy is that not returning a value would imply
 that the expression evaluated to FALSE.  So, indexing with NA must
 return something, and NA is the appropriate value to return since one
 doesn't know what it is. 
 
 Is that a reasonable summary?

Yes, I think so. (But I have to say that I'm not completely aware of
the ideology behind this choice.)

Gabor

 Dan 
 
 Daniel J. Nordlund
 Washington State Department of Social and Health Services
 Planning, Performance, and Accountability
 Research and Data Analysis Division
 Olympia, WA  98504-5204
  
  
 

-- 
Csardi Gabor [EMAIL PROTECTED]UNIL DGM

__
R-help@r-project.org mailing list
https://stat.ethz.ch/mailman/listinfo/r-help
PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
and provide commented, minimal, self-contained, reproducible code.


Re: [R] Calculating Betweenness - Efficiency problem

2008-07-23 Thread Gabor Csardi
Senthil,

sending a 12Mb file to the list is not a good idea. 
I've run the code in my previous email without any problem, so you need
to be a bit more specific about what went wrong for you.

This is what I get:

 library(igraph)
 tab - read.csv(/tmp/Test.csv)
 dim(tab)
[1] 304711  2
 length(unique(tab))
[1] 2
 g - graph.data.frame(tab)
 summary(g)
Vertices: 48072 
Edges: 304711 
Directed: TRUE 
No graph attributes.
Vertex attributes: name.
No edge attributes.
 system.time(bet - betweenness(g))
   user  system elapsed 
661.180   0.098 661.716 
 length(bet)
[1] 48072
 bet - data.frame(city=V(g)$name, betweenness=bet)
 dim(bet)
[1] 48072 2

Best,
Gabor

On Tue, Jul 22, 2008 at 11:58:37AM -0700, Senthil Purushothaman wrote:
 Dear Gabor,
Thank you very much for the insights. I have been using the igraph
 package for my computations. But I did not know about
 graph.data.frame(). Thanks again for that. So I did run my data using
 the steps you had provided. Weirdly, even though the .csv file has
 approximately 300,000 records (remember that the file gets truncated to
 65536 rows when opened in Excel 2003), not all of them are pulled in
 during the operation and the final betweenness list contains only ~1000+
 records but it should be tens of thousands. 
 
 I know that you are a busy person. This problem seems to be a very
 different challenge. 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 Purushothaman
 Cc: jim holtman; r-help@r-project.org
 Subject: Re: [R] Calculating Betweenness - Efficiency problem
 
 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.csv(...)
 g - graph.data.frame(tab)
 bet - betweenness(g)
 bet - data.frame(city=V(g)$name, betweenness=bet)
 
 The last line creates a two column data frame with the betweenness 
 score of each city. 
 
 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 read the posting guide http://www.R-project.org/posting-guide.html
and provide commented, minimal, self-contained, reproducible code.


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.csv(...)
g - graph.data.frame(tab)
bet - betweenness(g)
bet - data.frame(city=V(g)$name, betweenness=bet)

The last line creates a two column data frame with the betweenness 
score of each city. 

Best,
Gabor

On Sat, Jul 19, 2008 at 02:59:07PM -0700, Senthil Purushothaman wrote:
 Hi Jim,
 Thank you for the response. Your suggestion will help me avoid the whole 
 text to number conversion process that I perform using LookUp in excel. I 
 will definitely give it a shot. But it still doesn't address the vector 
 conversion since a graph file is drawn only using the vectors. Assuming that 
 I use 'factor' to convert the characters to numbers, how do I convert these 
 numbers into vectors?
 
 Thanks,
 Senthil
 
 
 
 
 -Original Message-
 From: jim holtman [mailto:[EMAIL PROTECTED]
 Sent: Sat 7/19/2008 4:49 AM
 To: Senthil Purushothaman
 Cc: r-help@r-project.org
 Subject: Re: [R] Calculating Betweenness - Efficiency problem
  
 It would seem that you can output the initial file from EXCEL, read it
 into R with 'read.csv' and then use 'factor' to convert the characters
 for City1 and City2 to the numbers that you want to use.  Have you
 tried this approach?
 
 On Fri, Jul 18, 2008 at 3:51 PM, Senthil Purushothaman
 [EMAIL PROTECTED] wrote:
  Hello,
 
  I am calculating 'Betweenness' of a large network using R. Currently, I 
  have the node-node information (City1-City2) in an excel file, present in 
  two columns where column A has City1 and column B has City2 that city1 is 
  connected to. These are the steps that I go through to calculate 
  betweenness of my network.
 
  a) Convert the City1-City2 (text) into Number1-Number2 in the excel file 
  where every unique city has a unique number.
  b) Paste all the city-city information separated by comma into c(...) in 
  the R GUI to obtain the corresponding vectors. As you can imagine this 
  copy-paste operation takes a long time. Example: c(1,3,1,5,2,4,2,5). Just 
  fyi, I have a text file that contains all nodes separated by comma based on 
  the appropriate link information.
  c) Then, I create a graph file with the above vector.
  d) I use the graph file to calculate betweenness of my network.
 
  I am sure there must be a better, more efficient way to calculate 
  betweenness. Ideally, I would like to just have the City1 - City2 (link) 
  information in two columns in an excel file and calculate the betweenness 
  from that file directly.
 
  Please provide an optimal solution for this problem. I appreciate your time 
  and help.
 
  Thanks,
  Senthil
 
 [[alternative HTML version deleted]]
 
  __
  R-help@r-project.org mailing list
  https://stat.ethz.ch/mailman/listinfo/r-help
  PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
  and provide commented, minimal, self-contained, reproducible code.
 
 
 
 
 -- 
 Jim Holtman
 Cincinnati, OH
 +1 513 646 9390
 
 What is the problem you are trying to solve?
 
 
   [[alternative HTML version deleted]]
 
 __
 R-help@r-project.org mailing list
 https://stat.ethz.ch/mailman/listinfo/r-help
 PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
 and provide commented, minimal, self-contained, reproducible code.

-- 
Csardi Gabor [EMAIL PROTECTED]UNIL DGM

__
R-help@r-project.org mailing list
https://stat.ethz.ch/mailman/listinfo/r-help
PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
and provide commented, minimal, self-contained, reproducible code.


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 itself. The same 
   size as well. If you resize the figure the fonts stay the same!
2) You can write fancy TeX formulae in the figures. 
3) You can have any font TeX supports. 

Disadvantages:
1) The same as before, if you resize the figure the fonts stay the 
   same! This is quite far from WYSIWYG.
2) You cannot use pdfLaTeX.

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), and another one for SVG files. So you save 
the file with xfig() or svg() and then the script does everything,
all you have to do is to include it into the .tex file with a 
small custom macro.

Gabor

On Wed, Jul 16, 2008 at 02:25:52AM -0700, Mark Difford wrote:
 
 Hi willemf,
 
 Glad to hear that it helped.  Years ago (late-90s) I Linuxed, but have since
 been forced into the Windows environment (where, however, I have the great
 pleasure of being able to use MiKTeX and LyX, i.e. TeX/LaTeX). I therefore
 can't help you further, except to say that I have never had a problem
 controlling font sizes c to my admittedly very demanding --- some people
 say excessively demanding --- standards (and that's on Windows!). And I have
 never had a problem with labels c not being where they should be, or of the
 size I want them to be, when I have built the graphic from scratch. And
 only very rarely have I encountered such problems when using canned graph
 types.
 
 In brief, what I am saying is that the problem almost certainly lies with
 the way fonts c are set up on your Linux box. Were this not the case, then
 I can assure you that there would have many and varied sharply worded
 statements on this list relating to the poor quality of R's graphs. And
 there would have been just as many pointed, well-written rebukes, pointing
 that  Yet there aren't. If you search the archives you will find that a
 good many users migrated to R from other systems because of R's excellent
 graphical subsystems. Look at the graphics in any of the many books now
 published on using R, or that use R to elucidate problems Set your mind
 at rest: look at your system setup, and the tools outside R that you are
 using.
 
 Hope it all works out. OpenOffice is now a very good suite of programs, but
 if you want true quality of output then you really should be TeXing. Check
 it out.
 
 Bye, Mark.
 
 
 willemf wrote:
  
  Mark, your suggestion results in about 75% control over the plot. This is
  the best that I have managed to get it at, so thank you very much. In
  Linux you create a X11() device for screen output. Specifying identical
  device characteristics results in a fair degree of similarity between
  screen version and EPS version. However in this case, for instance, some
  labels along the X axis are omitted in the screen version and
  (thankfullly!) included in the Postscript version. Also, the relative
  sizes of caption font size and label font size are not identical in the
  two versions. I have learnt a few things in this exercise, so thanks you
  very much for the advice.
  
  
 
 -- 
 View this message in context: 
 http://www.nabble.com/Font-quality-in-base-graphics-tp18465608p18483719.html
 Sent from the R help mailing list archive at Nabble.com.
 
 __
 R-help@r-project.org mailing list
 https://stat.ethz.ch/mailman/listinfo/r-help
 PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
 and provide commented, minimal, self-contained, reproducible code.

-- 
Csardi Gabor [EMAIL PROTECTED]UNIL DGM

__
R-help@r-project.org mailing list
https://stat.ethz.ch/mailman/listinfo/r-help
PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
and provide commented, minimal, self-contained, reproducible code.


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.

[...]

-- 
Csardi Gabor [EMAIL PROTECTED]UNIL DGM

__
R-help@r-project.org mailing list
https://stat.ethz.ch/mailman/listinfo/r-help
PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
and provide commented, minimal, self-contained, reproducible code.


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 I designate various objects the names of which start (or end) with
 the same letter to remove them all together?
 
 For instance:
  ls()
 a,b,c,l1,l2,x
  rm(list=ls(l*))
  ls()
 a,b,c,x
 
 Is there some parallel to the MySQL query: where col1 like l%
 
 Thanks a lot in advance,
 Friderike
 
 
   [[alternative HTML version deleted]]
 
 __
 R-help@r-project.org mailing list
 https://stat.ethz.ch/mailman/listinfo/r-help
 PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
 and provide commented, minimal, self-contained, reproducible code.

-- 
Csardi Gabor [EMAIL PROTECTED]UNIL DGM

__
R-help@r-project.org mailing list
https://stat.ethz.ch/mailman/listinfo/r-help
PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
and provide commented, minimal, self-contained, reproducible code.


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)  0.5] - 0

g - graph.adjacency(M, weighted=TRUE, mode=upper)
E(g)$color - green
E(g)[ weight0 ]$color - red

g$layout - layout.fruchterman.reingold
plot(g)

Please tell me if something is not clear,
Gabor

On Fri, Jul 11, 2008 at 02:04:54PM +0100, Dry, Jonathan R wrote:
 Hello
 
 I am a relatively new user of R and am struggling to use the 'network' 
 package.  I have a correlation matrix (produced using 'cor'), and want to 
 draw a network where each item showing correlation above a threshold (say 
 0.5) is joined by a green line, and each item showing correlation below a 
 threshold (say -0.5) is joined by a red line.  Does anyone have any hints of 
 how to correctly use functions within the 'network' package to achieve this?
 
 __
 R-help@r-project.org mailing list
 https://stat.ethz.ch/mailman/listinfo/r-help
 PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
 and provide commented, minimal, self-contained, reproducible code.

-- 
Csardi Gabor [EMAIL PROTECTED]UNIL DGM

__
R-help@r-project.org mailing list
https://stat.ethz.ch/mailman/listinfo/r-help
PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
and provide commented, minimal, self-contained, reproducible code.


Re: [R] network

2008-07-11 Thread Gabor Csardi
Jonathan, 

please stay on the list. 

The first query i don't understand, can you send a pdf or explain 
a bit what exactly happens.

As for the names, use them as row or column names in the matrix
(see ?colnames), and then do 

V(g)$label - V(g)$name 

before the plotting.

G.

On Fri, Jul 11, 2008 at 02:47:55PM +0100, Dry, Jonathan R wrote:
 Superb - thanks Gabor
 
 Two minor queries - firstly the network plot does not seem to fit in the 
 window and so only part of it is plotted.  Secondly, the first row and column 
 of my matrix comprise the sample names - 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: 11 July 2008 14:33
 To: Dry, Jonathan R
 Cc: r-help@r-project.org
 Subject: Re: [R] network
 
 
 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)  0.5] - 0
 
 g - graph.adjacency(M, weighted=TRUE, mode=upper)
 E(g)$color - green
 E(g)[ weight0 ]$color - red
 
 g$layout - layout.fruchterman.reingold
 plot(g)
 
 Please tell me if something is not clear,
 Gabor
 
 On Fri, Jul 11, 2008 at 02:04:54PM +0100, Dry, Jonathan R wrote:
  Hello
  
  I am a relatively new user of R and am struggling to use the 'network' 
  package.  I have a correlation matrix (produced using 'cor'), and want to 
  draw a network where each item showing correlation above a threshold (say 
  0.5) is joined by a green line, and each item showing correlation below a 
  threshold (say -0.5) is joined by a red line.  Does anyone have any hints 
  of how to correctly use functions within the 'network' package to achieve 
  this?
  
  __
  R-help@r-project.org mailing list
  https://stat.ethz.ch/mailman/listinfo/r-help
  PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
  and provide commented, minimal, self-contained, reproducible code.
 
 -- 
 Csardi Gabor [EMAIL PROTECTED]UNIL DGM

-- 
Csardi Gabor [EMAIL PROTECTED]UNIL DGM

__
R-help@r-project.org mailing list
https://stat.ethz.ch/mailman/listinfo/r-help
PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
and provide commented, minimal, self-contained, reproducible code.


Re: [R] network

2008-07-11 Thread Gabor Csardi
Hmmm, it seems that the colum/row names are not added properly, 
maybe this works only in the not-yet-released version. 
You can do 

V(gdata2)$label - colnames(data2)

as a workaround.

G.

On Fri, Jul 11, 2008 at 03:32:15PM +0100, Dry, Jonathan R wrote:
 Thnaks
 
 Ignore the forst problem - seems to solve itself!
 
 Trying 'V(g)$label - V(g)$name' I recieve the following error:
   Error in `V-`(`*tmp*`, value = 0:9) : invalid indexing 
 
 The full code used (with matrix shown) is below - any help appreciated:
 
  data2
  G1   G2   G3   G4   G5   G6  G7 G8   G9   G10
 G1000000.000   0.000  0.0000 0
 G200000   -0.356   0.000  0.0000 0
 G3000000.000   0.319  0.0000 0
 G4000000.000   0.000  0.4290 0
 G5000000.000   0.000 -0.4190 0
 G6000000.000   0.000  0.0000 0
 G7000000.000   0.000  0.0000 0
 G8000000.000   0.000  0.0000 0
 G9000000.000   0.000  0.0000 0
 G10   000000.000   0.000  0.0000 0
  gdata2 - graph.adjacency(data2, weighted=TRUE, mode=upper)
  E(gdata2)$color - green
  E(gdata2)[ weight0 ]$color - red
  gdata2$layout - layout.fruchterman.reingold
  V(gdata2)$label - V(data2)$name
 Error in V(data2) : Not a graph object
  V(gdata2)$label - V(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
 To: Dry, Jonathan R
 Cc: R Help list
 Subject: Re: [R] network
 
 
 Jonathan, 
 
 please stay on the list. 
 
 The first query i don't understand, can you send a pdf or explain 
 a bit what exactly happens.
 
 As for the names, use them as row or column names in the matrix
 (see ?colnames), and then do 
 
 V(g)$label - V(g)$name 
 
 before the plotting.
 
 G.
 
 On Fri, Jul 11, 2008 at 02:47:55PM +0100, Dry, Jonathan R wrote:
  Superb - thanks Gabor
  
  Two minor queries - firstly the network plot does not seem to fit in the 
  window and so only part of it is plotted.  Secondly, the first row and 
  column of my matrix comprise the sample names - 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: 11 July 2008 14:33
  To: Dry, Jonathan R
  Cc: r-help@r-project.org
  Subject: Re: [R] network
  
  
  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)  0.5] - 0
  
  g - graph.adjacency(M, weighted=TRUE, mode=upper)
  E(g)$color - green
  E(g)[ weight0 ]$color - red
  
  g$layout - layout.fruchterman.reingold
  plot(g)
  
  Please tell me if something is not clear,
  Gabor
  
  On Fri, Jul 11, 2008 at 02:04:54PM +0100, Dry, Jonathan R wrote:
   Hello
   
   I am a relatively new user of R and am struggling to use the 'network' 
   package.  I have a correlation matrix (produced using 'cor'), and want to 
   draw a network where each item showing correlation above a threshold (say 
   0.5) is joined by a green line, and each item showing correlation below a 
   threshold (say -0.5) is joined by a red line.  Does anyone have any hints 
   of how to correctly use functions within the 'network' package to achieve 
   this?
   
   __
   R-help@r-project.org mailing list
   https://stat.ethz.ch/mailman/listinfo/r-help
   PLEASE do read the posting guide 
   http://www.R-project.org/posting-guide.html
   and provide commented, minimal, self-contained, reproducible code.
  
  -- 
  Csardi Gabor [EMAIL PROTECTED]UNIL DGM
 
 -- 
 Csardi Gabor [EMAIL PROTECTED]UNIL DGM

-- 
Csardi Gabor [EMAIL PROTECTED]UNIL DGM

__
R-help@r-project.org mailing list
https://stat.ethz.ch/mailman/listinfo/r-help
PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
and provide commented, minimal, self-contained, reproducible code.


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 - seq(1:10)
 i_turned - i
 for (j in 1:length(i)) i_turned[j] - i[length(i)-j+1]
 
 now, i_turned is what I call turned. Is there a function which would make a
 script lighter? Thank you upfront for any hint.
 
 Best regards,
 Zroutik
 
   [[alternative HTML version deleted]]
 
 __
 R-help@r-project.org mailing list
 https://stat.ethz.ch/mailman/listinfo/r-help
 PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
 and provide commented, minimal, self-contained, reproducible code.

-- 
Csardi Gabor [EMAIL PROTECTED]UNIL DGM

__
R-help@r-project.org mailing list
https://stat.ethz.ch/mailman/listinfo/r-help
PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
and provide commented, minimal, self-contained, reproducible code.


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
µmol/10^6 cells
 I've tried some combinations using the expression() function, but none  
 of them worked.
 Any idea?

 Best,

 Dani

 -- 
 Daniel Valverde Saubí

 Grup de Biologia Molecular de Llevats
 Facultat de Veterinària de la Universitat Autònoma de Barcelona
 Edifici V, Campus UAB
 08193 Cerdanyola del Vallès- SPAIN

 Centro de Investigación Biomédica en Red
 en Bioingeniería, Biomateriales y
 Nanomedicina (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

 __
 R-help@r-project.org mailing list
 https://stat.ethz.ch/mailman/listinfo/r-help
 PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
 and provide commented, minimal, self-contained, reproducible code.

-- 
Csardi Gabor [EMAIL PROTECTED]UNIL DGM

__
R-help@r-project.org mailing list
https://stat.ethz.ch/mailman/listinfo/r-help
PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
and provide commented, minimal, self-contained, reproducible code.


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:
 
 I'm looking for a function that lists a few summary stats for a column (or
 row) of data.  I'm aware of summary(x), but that does not give me what I'm
 looking for.
 I'm actually looking for something that is very similar to the descriptive
 statistics tool in excel; i.e. Mean, Std. Error, Std. Deviation, Kurtosis.
 I'm positive that I came across a function that did this (possibly in
 Rmetrics), but now I can't find it.  I lost it in the endless mass of R
 functions.
 
 Any help would be appreciated.
 -- 
 View this message in context: 
 http://www.nabble.com/Summary-Stats-%28not-summary%28x%29%29-tp18363275p18363275.html
 Sent from the R help mailing list archive at Nabble.com.
 
 __
 R-help@r-project.org mailing list
 https://stat.ethz.ch/mailman/listinfo/r-help
 PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
 and provide commented, minimal, self-contained, reproducible code.

-- 
Csardi Gabor [EMAIL PROTECTED]UNIL DGM

__
R-help@r-project.org mailing list
https://stat.ethz.ch/mailman/listinfo/r-help
PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
and provide commented, minimal, self-contained, reproducible code.


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; do convert $f ${f%jpg}pdf; done

Of course this does not vectorise the files

Gabor

On Tue, Jul 08, 2008 at 10:05:59AM +0100, Paul Smith wrote:
 On Tue, Jul 8, 2008 at 6:59 AM, Daren Tan [EMAIL PROTECTED] wrote:
 
  I have a folder full of pngs and jpgs, and would like to consolidate them 
  into a pdf with appropriate title and labels. Can this be done via R ?
 
 I do not know whether R can do that. However, you can accomplish that
 easily with LyX or with OpenOffice.
 
 Paul
 
 __
 R-help@r-project.org mailing list
 https://stat.ethz.ch/mailman/listinfo/r-help
 PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
 and provide commented, minimal, self-contained, reproducible code.

-- 
Csardi Gabor [EMAIL PROTECTED]UNIL DGM

__
R-help@r-project.org mailing list
https://stat.ethz.ch/mailman/listinfo/r-help
PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
and provide commented, minimal, self-contained, reproducible code.


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 full of pngs and jpgs, and would like to consolidate them
  into a pdf with appropriate title and labels. Can this be done via R ?
  _
  Easily publish your photos to your Spaces with Photo Gallery.
  
  [[alternative HTML version deleted]]
  
  __
  R-help@r-project.org mailing list
  https://stat.ethz.ch/mailman/listinfo/r-help
  PLEASE do read the posting guide
  http://www.R-project.org/posting-guide.html
  and provide commented, minimal, self-contained, reproducible code.
  
  
 
 -- 
 View this message in context: 
 http://www.nabble.com/Can-R-do-this---tp18332407p18335253.html
 Sent from the R help mailing list archive at Nabble.com.
 
 __
 R-help@r-project.org mailing list
 https://stat.ethz.ch/mailman/listinfo/r-help
 PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
 and provide commented, minimal, self-contained, reproducible code.

-- 
Csardi Gabor [EMAIL PROTECTED]UNIL DGM

__
R-help@r-project.org mailing list
https://stat.ethz.ch/mailman/listinfo/r-help
PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
and provide commented, minimal, self-contained, reproducible code.


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 must be an easy way to make it.
  
 list(1:2,3:4,5:6,7:8)
 [[1]]
 [1] 1 2
  
 [[2]]
 [1] 3 4
  
 [[3]]
 [1] 5 6
  
 [[4]]
 [1] 7 8
 
  I have tried 
 lis-1:184
 dim(lis)=c(92,2,1)
 as.list(lis)
  
 and several other options. Any suggestions?
  
 many thanks
  
 Marco 
 
   [[alternative HTML version deleted]]
 
 __
 R-help@r-project.org mailing list
 https://stat.ethz.ch/mailman/listinfo/r-help
 PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
 and provide commented, minimal, self-contained, reproducible code.

-- 
Csardi Gabor [EMAIL PROTECTED]UNIL DGM

__
R-help@r-project.org mailing list
https://stat.ethz.ch/mailman/listinfo/r-help
PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
and provide commented, minimal, self-contained, reproducible code.


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 column of  
 data.frame().

 Thank you in advance.




 =
 Dong-hyun Oh
 Center of Excellence for Science and Innovation Studies
 Royal Institute or Technology, Sweden
 e-mail: [EMAIL PROTECTED]
 cel: +46 73 563 45 22

 __
 R-help@r-project.org mailing list
 https://stat.ethz.ch/mailman/listinfo/r-help
 PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
 and provide commented, minimal, self-contained, reproducible code.

-- 
Csardi Gabor [EMAIL PROTECTED]UNIL DGM

__
R-help@r-project.org mailing list
https://stat.ethz.ch/mailman/listinfo/r-help
PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
and provide commented, minimal, self-contained, reproducible code.


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, pointsize = 25, quality = 100, bg = grey95,
  res = NA, restoreConsole = TRUE)
 i=1
 par(mfrow=c(4,1),col=grey90,font.lab=2)
 hist(sul[,i+2],nclass=75,xlab=Região
 Sul,ylab=Freqüência,col=antiquewhite4,main=)
 hist(PR[,i+2],nclass=75,xlab=Paraná,ylab=Freqüência,col=antiquewhite4,
 main=)
 hist(SC[,i+2],nclass=75,xlab=Santa
 Catarina,ylab=Freqüência,col=antiquewhite4,main=)
 hist(RS[,i+2],nclass=75,xlab=Rio Grande do
 Sul,ylab=Freqüência,col=antiquewhite4,main=)
 dev.off()
 
 But, I want to know how can I create an for to do that. Like that:
 
 for(i in 1:250){
 jpeg(filename = graf01.jpg, width = 1024, height = 1024,
  units = px, pointsize = 25, quality = 100, bg = grey95,
  res = NA, restoreConsole = TRUE)
 par(mfrow=c(4,1),col=grey90,font.lab=2)
 hist(sul[,i+2],nclass=75,xlab=Região
 Sul,ylab=Freqüência,col=antiquewhite4,main=)
 hist(PR[,i+2],nclass=75,xlab=Paraná,ylab=Freqüência,col=antiquewhite4,
 main=)
 hist(SC[,i+2],nclass=75,xlab=Santa
 Catarina,ylab=Freqüência,col=antiquewhite4,main=)
 hist(RS[,i+2],nclass=75,xlab=Rio Grande do
 Sul,ylab=Freqüência,col=antiquewhite4,main=)
 dev.off()
 }
 
 The problem is the name of the file, I want to do something like grafi.jpg
 where i goes from 1 to 250.
 
 Thanks a lot for the help.
 
 
 Best Regards,
 Leandro Marino
 
 __
 R-help@r-project.org mailing list
 https://stat.ethz.ch/mailman/listinfo/r-help
 PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
 and provide commented, minimal, self-contained, reproducible code.

-- 
Csardi Gabor [EMAIL PROTECTED]UNIL DGM

__
R-help@r-project.org mailing list
https://stat.ethz.ch/mailman/listinfo/r-help
PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
and provide commented, minimal, self-contained, reproducible code.


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.

You can do the one of the following things:
1) You download and install 
   http://cneurocvs.rmki.kfki.hu/igraph/download/igraph_0.5.1.tar.gz
   This is an almost final 0.5.1 version, there will be some more 
   minor updates. 
2) You just wait a week for igraph 0.5.1.
3) You download our development tree and build an R package for yourself.

Probably 1) is easiest.

Best,
Gabor

Btw. there is also an igraph mailing list, see igraph.sf.net - community -
igraph-help

On Fri, Jun 27, 2008 at 11:49:29AM +0100, Prof Brian Ripley wrote:
 Please discuss this with the package maintainer (see the posting guide).

 He will need lots of details you have omitted, including the precise OS  
 and the C++ compiler used.

 BTW, this illustrates a common problem with packages using C++, which  
 people often test only under one compiler, and until recently (4.3.x) g++ 
 has been notoriously lax in reporting non-conformance to ISO C++.  There  
 are about 30 CRAN packages that fail to install under the Sun C++  
 compiler, but igraph did at one point recently (there is now a problem  
 with the use of C headers in C++ code).


 On Thu, 26 Jun 2008, wanding ZHOU wrote:

 Hi,

 I am a Newbie for R. I just installed R-base on my notebook with
 openSuSE 11. However, I always got compilation errors in installing
 add-on packages. For example, when installing igraph I got the
 following error:
 ___
 * Installing *source* package 'igraph' ...
 checking for gcc... gcc
 checking for C compiler default output file name... a.out
 checking whether the C compiler works... yes
 checking whether we are cross compiling... no
 checking for suffix of executables...
 checking for suffix of object files... o
 checking whether we are using the GNU C compiler... yes
 checking whether gcc accepts -g... yes
 checking for gcc option to accept ISO C89... none needed
 checking for g++... g++
 checking whether we are using the GNU C++ compiler... yes
 checking whether g++ accepts -g... yes
 checking for fmemopen... yes
 checking for open_memstream... yes
 checking for rintf... yes
 checking for finite... yes
 checking how to run the C preprocessor... gcc -E
 checking for grep that handles long lines and -e... /usr/bin/grep
 checking for egrep... /usr/bin/grep -E
 checking for ANSI C header files... yes
 checking for sys/types.h... yes
 checking for sys/stat.h... yes
 checking for stdlib.h... yes
 checking for string.h... yes
 checking for memory.h... yes
 checking for strings.h... yes
 checking for inttypes.h... yes
 checking for stdint.h... yes
 checking for unistd.h... yes
 checking sys/times.h usability... yes
 checking sys/times.h presence... yes
 checking for sys/times.h... yes
 checking for xml2-config... none
 checking for __gmpz_add in -lgmp... no
 configure: creating ./config.status
 config.status: creating src/config.h
 config.status: creating R/config.R
 config.status: creating src/Makevars
 ** libs

 gcc -std=gnu99 -I/usr/lib/R/include  -I/usr/local/include   -DUSING_R
 -I.  -g -O2 -DPACKAGE_VERSION=\0.5\ -DINTERNAL_ARPACK
 -DINTERNAL_LAPACK -DINTERNAL_BLAS -fpic  -g -O2 -c adjlist.c -o
 adjlist.o
 igraph.h:435: warning: inline function ‘igraph_es_type’ declared but
 never defined
 igraph.h:233: warning: inline function ‘igraph_vs_type’ declared but
 never defined
 igraph.h:435: warning: inline function ‘igraph_es_type’ declared but
 never defined
 igraph.h:233: warning: inline function ‘igraph_vs_type’ declared but
 never defined
 gcc -std=gnu99 -I/usr/lib/R/include  -I/usr/local/include   -DUSING_R
 -I.  -g -O2 -DPACKAGE_VERSION=\0.5\ -DINTERNAL_ARPACK
 -DINTERNAL_LAPACK -DINTERNAL_BLAS -fpic  -g -O2 -c arpack.c -o arpack.o
 igraph.h:435: warning: inline function ‘igraph_es_type’ declared but
 never defined
 igraph.h:233: warning: inline function ‘igraph_vs_type’ declared but
 never defined
 igraph.h:435: warning: inline function ‘igraph_es_type’ declared but
 never defined
 igraph.h:233: warning: inline function ‘igraph_vs_type’ declared but
 never defined
 gcc -std=gnu99 -I/usr/lib/R/include  -I/usr/local/include   -DUSING_R
 -I.  -g -O2 -DPACKAGE_VERSION=\0.5\ -DINTERNAL_ARPACK
 -DINTERNAL_LAPACK -DINTERNAL_BLAS -fpic  -g -O2 -c array.c -o array.o
 gcc -std=gnu99 -I/usr/lib/R/include  -I/usr/local/include   -DUSING_R
 -I.  -g -O2 -DPACKAGE_VERSION=\0.5\ -DINTERNAL_ARPACK
 -DINTERNAL_LAPACK -DINTERNAL_BLAS -fpic  -g -O2 -c atlas.c -o atlas.o
 igraph.h:435: warning: inline function ‘igraph_es_type’ declared but
 never defined
 igraph.h:233: warning: inline function ‘igraph_vs_type’ declared but
 never defined
 igraph.h:435: warning: inline function ‘igraph_es_type’ declared but
 

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,
then you have to give the source code of the modified version, along with 
the distributed binaries. Again, this is not about money, you _must_ 
publish the sources, even if your new version is for free.

If you create a website and the user uses R and your code 
through that site only, then you don't have to give the source code 
to anyone. Basically, you have no obligations in this case.
Spencer is right that this might be against the 
principles of the license, but legally it is fine.
It might change if R will ever use GPL version 3.

Gabor

On Wed, Jun 25, 2008 at 10:28:09AM -0500, Michael Conklin wrote:
 
 Spencer Graves wrote:
 
   If you want to hide the fact that you are using R -- especially
 if you charge people for your software that uses R clandestinely --
 that's a violation of the license (GPL).  I doubt if anyone associated
 with R would bother with a lawsuit, but a competitor who offers related
 software might. 
 
   Best Wishes,
   Spencer
 
 Do I understand the implication of the license correctly (forgive my
 ignorance here).  
 
 If I analyze a client's data using an R script I created then I can
 charge the client a $20,000 consulting fee, but, if I let the client
 push the button to execute the R script and charge him 10 cents for the
 privilege then I can be sued for violating the GPL?  Or are my
 assumptions on the first part also incorrect and R can only be used for
 the free betterment of mankind?
 
 Mike
 
 __
 R-help@r-project.org mailing list
 https://stat.ethz.ch/mailman/listinfo/r-help
 PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
 and provide commented, minimal, self-contained, reproducible code.

-- 
Csardi Gabor [EMAIL PROTECTED]UNIL DGM

__
R-help@r-project.org mailing list
https://stat.ethz.ch/mailman/listinfo/r-help
PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
and provide commented, minimal, self-contained, reproducible code.


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:
 on 06/25/2008 11:19 AM Daren Tan wrote:

 unique(c(1:10,1)) gives 1:10 (i.e. unique values), is there any
 method to get only 2:10 (i.e. values that are unique) ?


 The easiest might be:

  Vec
  [1]  1  2  3  4  5  6  7  8  9 10  1

  Vec[table(Vec) == 1]
 [1]  2  3  4  5  6  7  8  9 10

 HTH,

 Marc Schwartz

 __
 R-help@r-project.org mailing list
 https://stat.ethz.ch/mailman/listinfo/r-help
 PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
 and provide commented, minimal, self-contained, reproducible code.

-- 
Csardi Gabor [EMAIL PROTECTED]UNIL DGM

__
R-help@r-project.org mailing list
https://stat.ethz.ch/mailman/listinfo/r-help
PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
and provide commented, minimal, self-contained, reproducible code.


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 conversion. 
My previous solution is better in this respect.

Btw. to get rid of names 'unname' is better, the code is
more readable.

Best,
Gabor

On Wed, Jun 25, 2008 at 11:37:12AM -0500, Marc Schwartz wrote:
 on 06/25/2008 11:29 AM Marc Schwartz wrote:
 on 06/25/2008 11:19 AM Daren Tan wrote:

 unique(c(1:10,1)) gives 1:10 (i.e. unique values), is there any
 method to get only 2:10 (i.e. values that are unique) ?


 The easiest might be:

   Vec
  [1]  1  2  3  4  5  6  7  8  9 10  1

   Vec[table(Vec) == 1]
 [1]  2  3  4  5  6  7  8  9 10


 Correction!

 That should be:

  which(table(Vec) == 1)
  2  3  4  5  6  7  8  9 10
  2  3  4  5  6  7  8  9 10

 or if you don't want a named vector:

  as.vector(which(table(Vec) == 1))
 [1]  2  3  4  5  6  7  8  9 10


 My initial solution was incorrect and only worked because of the  
 ordering of the example vector.

 Time for another cup of cawfee...Oy

 Marc

 __
 R-help@r-project.org mailing list
 https://stat.ethz.ch/mailman/listinfo/r-help
 PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
 and provide commented, minimal, self-contained, reproducible code.

-- 
Csardi Gabor [EMAIL PROTECTED]UNIL DGM

__
R-help@r-project.org mailing list
https://stat.ethz.ch/mailman/listinfo/r-help
PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
and provide commented, minimal, self-contained, reproducible code.


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)) gives 1:10 (i.e. unique values), is there any
 method to get only 2:10 (i.e. values that are unique) ?


 The easiest might be:

 Vec
 [1]  1  2  3  4  5  6  7  8  9 10  1

 Vec[table(Vec) == 1]
 [1]  2  3  4  5  6  7  8  9 10

 I don't think that is right: you are relying on recycling indices.  Try

 Vec - c(1,1:10)
 Vec[table(Vec) == 1]

 which should be the same.

 I was about to write

 tab - table(Vec)
 names(tab)[tab==1]

 but that gives a character vector.  Here's a different way:

 Vec[rowSums(outer(Vec, Vec, ==))==1]


 -- 
 Brian D. Ripley,  [EMAIL PROTECTED]
 Professor of Applied Statistics,  http://www.stats.ox.ac.uk/~ripley/
 University of Oxford, Tel:  +44 1865 272861 (self)
 1 South Parks Road, +44 1865 272866 (PA)
 Oxford OX1 3TG, UKFax:  +44 1865 272595

 __
 R-help@r-project.org mailing list
 https://stat.ethz.ch/mailman/listinfo/r-help
 PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
 and provide commented, minimal, self-contained, reproducible code.

-- 
Csardi Gabor [EMAIL PROTECTED]UNIL DGM

__
R-help@r-project.org mailing list
https://stat.ethz.ch/mailman/listinfo/r-help
PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
and provide commented, minimal, self-contained, reproducible code.


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

Best,
Gabor

On Tue, Jun 24, 2008 at 11:23:56AM -0400, [EMAIL PROTECTED] wrote:
 Hi
 
 I created a new table by extracting only certain rows of table, but the row
 numbers in my new table correspond to those from the original table. Is there 
 a
 way to reset the row numbers in my new table so that they start from one? like
 below:
 
 my table:
 COL1   COL2
 17   v  45
 18   b  14
 25   x  98
 
 desired:
COL1   COL2
 1   v  45
 2   b  14
 3   x  98
 
 Thank you!
 -Nina
 
 __
 R-help@r-project.org mailing list
 https://stat.ethz.ch/mailman/listinfo/r-help
 PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
 and provide commented, minimal, self-contained, reproducible code.

-- 
Csardi Gabor [EMAIL PROTECTED]UNIL DGM

__
R-help@r-project.org mailing list
https://stat.ethz.ch/mailman/listinfo/r-help
PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
and provide commented, minimal, self-contained, reproducible code.


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-
 
 ?plot.histogram
 
 You should find what you need there.
 
 Cheers,
 
 Patrick
 
 -Original Message-
 From: [EMAIL PROTECTED] [mailto:[EMAIL PROTECTED] On Behalf Of sumit gupta
 Sent: Friday, June 20, 2008 8:46 AM
 To: r-help@r-project.org
 Subject: [R] 3D histogram
 
 Hii..
 
 Could anyone please tell me how to draw 3D histogram in R
 
 I have a 20X3 matirx. Now I want 2 of the variable on X and Y axis .And
 Height of the bar should denote the value of third variable.
 
 Thanx
 
 
 Sumit
 
 [[alternative HTML version deleted]]
 
 __
 R-help@r-project.org mailing list
 https://stat.ethz.ch/mailman/listinfo/r-help
 PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
 and provide commented, minimal, self-contained, reproducible code.
 This email message, including any attachments, is for ...{{dropped:11}}

__
R-help@r-project.org mailing list
https://stat.ethz.ch/mailman/listinfo/r-help
PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
and provide commented, minimal, self-contained, reproducible code.


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 development version if you think that can help...

Btw. what options would you need? (Sorry, it might have been 
in your previous mails that i haven't read)

Best,
Gabor

On Thu, Jun 19, 2008 at 03:12:50PM +0100, baptiste Auguié wrote:
 Dear all,

 Thank you for the suggestions and pointers. It looks like I'll need to do 
 some interface with Fortran/C code. The igraph package seems to provide 
 an interface with ARPACK, albeit not with the options I need, so it could 
 be a good starting point.

 Best regards,

 baptiste


-- 
Csardi Gabor [EMAIL PROTECTED]UNIL DGM

__
R-help@r-project.org mailing list
https://stat.ethz.ch/mailman/listinfo/r-help
PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
and provide commented, minimal, self-contained, reproducible code.


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 the strings were separated by tabs (I just thought of
 splitting by _any_ space), and that the output would also
 be tab-separated. But there's still a minor feature:
 
 write.table(t(read.table(file.in, sep =\t)), file = file.out, 
   row.names = FALSE, col.names = FALSE, sep = \t) 
 
 writes each output enclosed with quotation marks, like:
 
 1/2/20030.56380.62330.45590.8746
 
 I didn't find in the documentation of write.table a way to
 remove those quotes, because qmethod is either escape or double :-(

What about 'quote=FALSE'? Is it not good enough?

G.

 Alberto Monteiro
 
 __
 R-help@r-project.org mailing list
 https://stat.ethz.ch/mailman/listinfo/r-help
 PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
 and provide commented, minimal, self-contained, reproducible code.

-- 
Csardi Gabor [EMAIL PROTECTED]UNIL DGM

__
R-help@r-project.org mailing list
https://stat.ethz.ch/mailman/listinfo/r-help
PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
and provide commented, minimal, self-contained, reproducible code.


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

2008-05-20 Thread Gabor Csardi
Solomon, sorry for the delay. In igraph vertices are numbered from 0, so you 
need

keep - 0:3

and then the function i've sent seems to work. But i can see that you also have 
a solution
now. 

Gabor

On Sat, May 17, 2008 at 09:32:27AM -0400, Messing, Solomon O. wrote:
 Consider the following two mode-data:
  
 edgelist:
   actor event
 1   Sam a
 2   Sam b
 3   Sam c
 4  Greg a
 5   Tom b
 6   Tom c
 7   Tom d
 8  Mary b
 9  Mary d
  
 Two-Mode Adjacency Matrix:
  a b c d
 Sam  1 1 1 0
 Greg 1 0 0 0
 Tom  0 1 1 1
 Mary 0 1 0 1
  
 To transform two mode to one mode data, we need a function that transforms the
 data like so:
  
 Sam is connected to Greg (via event a)
 Sam is connected to Tom (via event b and c)
 Sam is connected to Mary (via event b)
 Tom is connected to Mary (via event b and d)
  
 OK, now I load my data by executing the following:
 ###
 
 require(igraph)
 df - data.frame(actor = c
 ('Sam','Sam','Sam','Greg','Tom','Tom','Tom','Mary','Mary'),
   event =c('a','b','c','a','b','c','d','b','d') )
 g = graph.data.frame(df, directed=F)  #Coerce data to igraph object 'g'
 
 #Loading Function two.to.one:
 ##two.to.one() transforms 2-mode data to 1-mode
 two.to.one - function(g, keep) {
  neis - neighborhood(g, order=2)
  neis - lapply(seq(neis), function(x) neis[[x]][ neis[[x]] != x-1]) ## drop
 self-loops
  neis - lapply(neis, function(x) x[ x %in% keep ])  ## keep
 only these
  neis - lapply(seq(neis), function(x) t(cbind(x-1, neis[[x]]))) ## create
 edge lists
  neis[-keep-1] - NULL   ## these
 are not needed
  neis - matrix(unlist(neis), byrow=TRUE, nc=2)  ## a
 single edge list
  neis - neis[ neis[,1]  neis[,2], ]## count
 an edge once only
  mode(neis) - character
  g2 - graph.edgelist(neis, dir=FALSE)
  V(g2)$id - V(g2)$name  ## 'id' is used in Pajek
  g2
 }
  
 #Actors are the first 4 verticies, set them to be kept:
 keep = V(g)[1:4]
 #Convert matrix with two.to.one:
 g2 = two.to.one(g, keep)
 g2
 ###
 
 This yields the following output:
  g2
 Vertices: 4
 Edges: 2
 Directed: FALSE
 Edges:
  
 [0] 3 -- 2
 [1] 4 -- 1
 
 But, this can't be right.  Here there are only two edges where there should be
 four, and if I am inturpreting correctly, the output it is reporting that Tom
 is connected to Greg (he is not) and Sam is connected to Mary (which is true).
  
 When I load my function, which is designed to transform a two mode edgelist
 (e.g. two columns of data) into a one-mode adjacency matrix it seems to work:
 ###
 
 #load my function
 df.to.nxn - function( x, y )
 { # x values will be the N
 x N values  
 M - matrix( nrow = length( unique( x ) ), ncol = length( unique( x ) ),
   dimnames = list( unique( x ), unique( x ) ) )
 M[ 1:length( unique( x ) ), 1:length( unique( x ) ) ] -
 0#initialize the values to 0 - this possibly could be
 removed for illustrative purposes   
 for( i in 1:length( x ) )
 {   # iterate through rows of
 data   
 index = which( y == y[i] )   
 M[ as.character( x[ index ] ), as.character( x[ index ] ) ] =
 1   
  }
 M 

 # return M, an N x N matrix
 }
 #Convert matrix
 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
 Edges: 4
 Directed: FALSE
 Edges:

 [0] Sam  -- Greg
 [1] Sam  -- Tom
 [2] Sam  -- Mary
 [3] Tom  -- Mary
  
 Which is what we wanted.  I have not figured out how to weight edges yet (the
 Sam and Tom edge and the Tom and Mary edge should perhaps be weighted at 2
 because 'connected twice' -- connected by two events).
  
 -Solomon
 
 ━━━
 From: Gabor Csardi [mailto:[EMAIL PROTECTED]
 Sent: Wed 5/14/2008 4:01 AM
 To: Messing, Solomon O.
 Cc: R Help list
 Subject: Re: [R] For Social Network Analysis-Graph Analysis - How to convert 2
 mode data to 1 mode data?
 
 
 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 me.
 
 Btw

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

2008-05-14 Thread Gabor Csardi
Hi Solomon,

On Tue, May 13, 2008 at 05:53:44PM -0400, Messing, Solomon O. wrote:
 Hi Gabor,
 
 Thank you for your help, and thanks for making the excellent igraph
 package.  The function below seems not generate an edge list that works
 for my data.  I coerced a my data from a data frame using
 graph.data.frame.  
 
 You asked in your previous post if 2-mode networks are bipartite.  I
 believe the answer is yes.  However, in 
 
 Hanneman, Robert A. and Mark Riddle.  2005.  Introduction to social
 network methods.  Riverside, CA:  University of California, Riverside (
 published in digital form at http://faculty.ucr.edu/~hanneman/ )
 
 I found the following: 
 
 Two-mode data are sometimes stored in a second way, called the
 bipartite matrix.  A bipartite matrix is formed by adding the rows as
 additional columns, and columns as additional rows.
 
 Did I need to convert my data frame to a bipartite matrix before
 applying the two.to.one function?

No. The function i've sent assumes that your network is bipartite, i.e. 
if A and B are connected by an edge, then 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 [mailto:[EMAIL PROTECTED]
 Sent: Saturday, May 10, 2008 1:09 PM
 To: Messing, Solomon O.
 Cc: r-help@r-project.org
 Subject: Re: [R] For Social Network Analysis-Graph Analysis - How to
 convert 2
 mode data to 1 mode data?
 
 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 - neighborhood(g, order=2)
   neis - lapply(seq(neis), function(x) neis[[x]][ neis[[x]] != x-1])
 ## drop
 self-loops
   neis - lapply(neis, function(x) x[ x %in% keep ])
 ## keep
 only these
   neis - lapply(seq(neis), function(x) t(cbind(x-1, neis[[x]])))
 ## create
 edge lists
   neis[-keep-1] - NULL
 ## these
 are not needed
   neis - matrix(unlist(neis), byrow=TRUE, nc=2)
 ## a
 single edge list
   neis - neis[ neis[,1]  neis[,2], ]
 ## count
 an edge once only
   mode(neis) - character
   g2 - graph.edgelist(neis, dir=FALSE)
   V(g2)$id - V(g2)$name
 ## 'id'
 is used in Pajek
   g2
 }
 
 It does not check that the graph is indeed two-mode, and it keeps the
 vertices given in the 'keep' argument. 'keep' is made of igraph vertex
 ids.
 You can use it like this:
 
 g - graph.ring(10)
 keep - seq(0,8,by=2) ## we keep the 'even' vertices
 
 g2 - two.to.one(g, keep)
 write.graph(two.to.one(g, keep), format=pajek, file=/tmp/a.net)
 
 I haven't tested it much. We'll have a better function in the next
 igraph
 version.
 Gabor
 
 On Fri, May 09, 2008 at 03:37:05PM -0400, Messing, Solomon O. wrote:
  Hi,
 
 
 
  Does anyone know of a package in R that has a function to convert
  network data (e.g. an adjacency matrix or ) from 2-mode to 1-mode?  I
 am
  conducting social network analysis.  I know that Pajek has this
 function
  under Net -- Transform -- 2-mode to 1-mode -- Rows.  I have
 searched
  the documentation under packages 'sna', 'network', 'igraph', and
  'dynamicgraph' but I was not able to identify a comparable function.
 
 
 
  I would just export my data to Pajek and import it to R, but I'm
 going
  to have to generate hundreds of these graphs, so it would take quite
 a
  bit of time to do it this way.
 
 
 
  Thanks,
 
 
 
  Solomon
 
 
 
 
 [[alternative HTML version deleted]]
 
  __
  R-help@r-project.org mailing list
  https://stat.ethz.ch/mailman/listinfo/r-help
  PLEASE do read the posting guide
 http://www.R-project.org/posting-guide.html
  and provide commented, minimal, self-contained, reproducible code.
 
 --
 Csardi Gabor [EMAIL PROTECTED]UNIL DGM

-- 
Csardi Gabor [EMAIL PROTECTED]UNIL DGM

__
R-help@r-project.org mailing list
https://stat.ethz.ch/mailman/listinfo/r-help
PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
and provide commented, minimal, self-contained, reproducible code.


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

Btw. there is a get.adjacency function in igraph to convert 
a graph to an adjacency matrix.

G.

 
 df.to.nxn - function( x, y ){
 # x values will be the N x N values   
 M - matrix( nrow = length( unique( x ) ), ncol = length( unique( x
 ) ), 
   dimnames = list( unique( x ), unique( x ) ) )
 M[ 1:length( unique( x ) ), 1:length( unique( x ) ) ] - 0
 # initialize the values to 0 
 for( i in 1:length( x ) ) {
 # iterate through rows of data
 index = which( y == y[i] )
 M[ as.character( x[ index ] ), as.character( x[ index ]
 ) ] = 1
  }
 M
 # return M, an N x N matrix
 }

-- 
Csardi Gabor [EMAIL PROTECTED]UNIL DGM

__
R-help@r-project.org mailing list
https://stat.ethz.ch/mailman/listinfo/r-help
PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
and provide commented, minimal, self-contained, reproducible code.


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 object a by using only x. something like 
 rm(somefunction(x))...Is this possible?
 
  
 
 Shubha Karanth | Amba Research
 
 Ph +91 80 3980 8031 | Mob +91 94 4886 4510 
 
 Bangalore * Colombo * London * New York * San Jos? * Singapore * 
 www.ambaresearch.com
 
  
 
 This e-mail may contain confidential and/or privileged i...{{dropped:13}}
 

 __
 R-help@r-project.org mailing list
 https://stat.ethz.ch/mailman/listinfo/r-help
 PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
 and provide commented, minimal, self-contained, reproducible code.


-- 
Csardi Gabor [EMAIL PROTECTED]UNIL DGM

__
R-help@r-project.org mailing list
https://stat.ethz.ch/mailman/listinfo/r-help
PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
and provide commented, minimal, self-contained, reproducible code.


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   3
 5  2   5
 
 thanks
 Claire
 -- 
 View this message in context: 
 http://www.nabble.com/Creating-Matrix-tp17168173p17168173.html
 Sent from the R help mailing list archive at Nabble.com.
 
 __
 R-help@r-project.org mailing list
 https://stat.ethz.ch/mailman/listinfo/r-help
 PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
 and provide commented, minimal, self-contained, reproducible code.

-- 
Csardi Gabor [EMAIL PROTECTED]UNIL DGM

__
R-help@r-project.org mailing list
https://stat.ethz.ch/mailman/listinfo/r-help
PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
and provide commented, minimal, self-contained, reproducible code.


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 - neighborhood(g, order=2)
  neis - lapply(seq(neis), function(x) neis[[x]][ neis[[x]] != x-1]) ## drop 
self-loops
  neis - lapply(neis, function(x) x[ x %in% keep ])  ## keep 
only these
  neis - lapply(seq(neis), function(x) t(cbind(x-1, neis[[x]]))) ## create 
edge lists
  neis[-keep-1] - NULL   ## these 
are not needed
  neis - matrix(unlist(neis), byrow=TRUE, nc=2)  ## a 
single edge list
  neis - neis[ neis[,1]  neis[,2], ]## count 
an edge once only
  mode(neis) - character
  g2 - graph.edgelist(neis, dir=FALSE)
  V(g2)$id - V(g2)$name  ## 'id' 
is used in Pajek
  g2
}

It does not check that the graph is indeed two-mode, and it keeps the 
vertices given in the 'keep' argument. 'keep' is made of igraph vertex ids.
You can use it like this:

g - graph.ring(10)
keep - seq(0,8,by=2) ## we keep the 'even' vertices

g2 - two.to.one(g, keep)
write.graph(two.to.one(g, keep), format=pajek, file=/tmp/a.net)

I haven't tested it much. We'll have a better function in the next igraph 
version.
Gabor

On Fri, May 09, 2008 at 03:37:05PM -0400, Messing, Solomon O. wrote:
 Hi,
 
  
 
 Does anyone know of a package in R that has a function to convert
 network data (e.g. an adjacency matrix or ) from 2-mode to 1-mode?  I am
 conducting social network analysis.  I know that Pajek has this function
 under Net -- Transform -- 2-mode to 1-mode -- Rows.  I have searched
 the documentation under packages 'sna', 'network', 'igraph', and
 'dynamicgraph' but I was not able to identify a comparable function.  
 
  
 
 I would just export my data to Pajek and import it to R, but I'm going
 to have to generate hundreds of these graphs, so it would take quite a
 bit of time to do it this way.  
 
  
 
 Thanks,
 
  
 
 Solomon
 
  
 
 
   [[alternative HTML version deleted]]
 
 __
 R-help@r-project.org mailing list
 https://stat.ethz.ch/mailman/listinfo/r-help
 PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
 and provide commented, minimal, self-contained, reproducible code.

-- 
Csardi Gabor [EMAIL PROTECTED]UNIL DGM

__
R-help@r-project.org mailing list
https://stat.ethz.ch/mailman/listinfo/r-help
PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
and provide commented, minimal, self-contained, reproducible code.


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 on my quite busy 4 years old laptop

Best,
Gabor

On Wed, Apr 30, 2008 at 04:15:46PM -0400, Zhandong Liu wrote:
 I am switching from Matlab to R, but I found that R is 200 times slower than
 matlab.
 
 Since I am newbie to R, I must be missing some important programming tips.
 
[...]

-- 
Csardi Gabor [EMAIL PROTECTED]UNIL DGM

__
R-help@r-project.org mailing list
https://stat.ethz.ch/mailman/listinfo/r-help
PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
and provide commented, minimal, self-contained, reproducible code.


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 languages and HTH.
 http://www.sciviews.org/benchmark/index.html
 
[...]

-- 
Csardi Gabor [EMAIL PROTECTED]UNIL DGM

__
R-help@r-project.org mailing list
https://stat.ethz.ch/mailman/listinfo/r-help
PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
and provide commented, minimal, self-contained, reproducible code.


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 used apply only 
 to
 later read that apply is internally implemented as a for so nothing gained
 here. Warnings about pitfalls (such as nested loops), hints, suggestions would
 be great.

Personally i like {l,t,}apply better, 1) it is more readable,
2) it takes two minutes to change it to par{L,S,}apply and then 
it runs in parallel.

 The second question - is there some sort of profiling tool available that 
 would
 make it easy to recognize where the script is spending most of its time? Might
 be especially useful for newbies like me.

See ?Rprof

G.

[...]

-- 
Csardi Gabor [EMAIL PROTECTED]UNIL DGM

__
R-help@r-project.org mailing list
https://stat.ethz.ch/mailman/listinfo/r-help
PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
and provide commented, minimal, self-contained, reproducible code.


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
 matrices composed only of the non-zero lines. Columns only containing
 zeros I want to preserve.
 Here an example:
 
 [,1] [,2] [,3] [,4] [,5] [,6] [,7]
 [1,] 1 0 1 1 0 0 0
 [2,] 0 0 0 0 0 0 0
 [3,] 1 0 0 0 0 0 0
 [4,] 1 0 1 1 1 1 1
 [5,] 1 0 1 0 1 0 1
 [6,] 0 0 1 1 1 1 1
 [7,] 0 0 0 0 0 0 0
 
 Rows 2 and 7 shall be deleted, but column 2 shall be maintained.
 I believe this should be a simple operation with basic commands, but
 have no idea how to manage it.
 Looking forward do any help,
 Patrick
 
 __
 R-help@r-project.org mailing list
 https://stat.ethz.ch/mailman/listinfo/r-help
 PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
 and provide commented, minimal, self-contained, reproducible code.

-- 
Csardi Gabor [EMAIL PROTECTED]UNIL DGM

__
R-help@r-project.org mailing list
https://stat.ethz.ch/mailman/listinfo/r-help
PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
and provide commented, minimal, self-contained, reproducible code.


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 read the question the same way and, in response to the part of the 
 question asking for no temporary matrix, offer this refinement on your 
 suggestion:
 
 m - rbind(  m[1:5,], 1:10, m[6:10,] ) # row insertion or ...
 
 # not to be followed by, but rather instead column insertion ..
 m - cbind( m[,1:8], 1:10, m[,9:10] )

There might be something wrong with my eyes, but where is the refinement
here? Your lines are literally the same as mines. There is no temporary 
matrix here, m2 and m3 are the results, he wanted either between row 
5 and 6 _OR_ column 8 and 9. 

Oh, if you mean that we immediately put back the result into 'm',
then 1) it does not really matter, R will create a temporary matrix 
internally anyway, 2) i assumed that the user can figure this 
out him/herself.

G.

 -- 
 David Winsemius
 
  
  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
  
  
  
  
  
  
  On 4/18/08, Ng Stanley [EMAIL PROTECTED] wrote:
   Hi,
  
   Is there any functions to insert a vector or matrix into an
   existing ma 
  trix
   say between row 5 and 6 or column 8 and 9, without creating a
   temporary matrix ?
  
   Thanks
   Stanley
 
 __
 R-help@r-project.org mailing list
 https://stat.ethz.ch/mailman/listinfo/r-help
 PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
 and provide commented, minimal, self-contained, reproducible code.

-- 
Csardi Gabor [EMAIL PROTECTED]UNIL DGM

__
R-help@r-project.org mailing list
https://stat.ethz.ch/mailman/listinfo/r-help
PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
and provide commented, minimal, self-contained, reproducible code.


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 memory occupied by the two objects?

Of course, yes. We just had a different interpretation about 
without a temporary matrix.

G.

 -- 
 David Winsemius
 
 __
 R-help@r-project.org mailing list
 https://stat.ethz.ch/mailman/listinfo/r-help
 PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
 and provide commented, minimal, self-contained, reproducible code.

-- 
Csardi Gabor [EMAIL PROTECTED]UNIL DGM

__
R-help@r-project.org mailing list
https://stat.ethz.ch/mailman/listinfo/r-help
PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
and provide commented, minimal, self-contained, reproducible code.


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
 
 
 
 On 4/18/08, Ng Stanley [EMAIL PROTECTED] wrote:
  Hi,
 
  Is there any functions to insert a vector or matrix into an existing matrix
  say between row 5 and 6 or column 8 and 9, without creating a temporary
  matrix ?
 
  Thanks
  Stanley
 
  [[alternative HTML version deleted]]
 
  __
  R-help@r-project.org mailing list
  https://stat.ethz.ch/mailman/listinfo/r-help
  PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
  and provide commented, minimal, self-contained, reproducible code.
 
 
 
 -- 
 Henrique Dallazuanna
 Curitiba-Paraná-Brasil
 25° 25' 40 S 49° 16' 22 O
 
 __
 R-help@r-project.org mailing list
 https://stat.ethz.ch/mailman/listinfo/r-help
 PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
 and provide commented, minimal, self-contained, reproducible code.

-- 
Csardi Gabor [EMAIL PROTECTED]UNIL DGM

__
R-help@r-project.org mailing list
https://stat.ethz.ch/mailman/listinfo/r-help
PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
and provide commented, minimal, self-contained, reproducible code.


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]]
 
 __
 R-help@r-project.org mailing list
 https://stat.ethz.ch/mailman/listinfo/r-help
 PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
 and provide commented, minimal, self-contained, reproducible code.

-- 
Csardi Gabor [EMAIL PROTECTED]UNIL DGM

__
R-help@r-project.org mailing list
https://stat.ethz.ch/mailman/listinfo/r-help
PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
and provide commented, minimal, self-contained, reproducible code.


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...
 
 Thanks
 -- 
 View this message in context: 
 http://www.nabble.com/%3D-vs.-%3D%3D--tp16700216p16700216.html
 Sent from the R help mailing list archive at Nabble.com.
 
 __
 R-help@r-project.org mailing list
 https://stat.ethz.ch/mailman/listinfo/r-help
 PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
 and provide commented, minimal, self-contained, reproducible code.

-- 
Csardi Gabor [EMAIL PROTECTED]UNIL DGM

__
R-help@r-project.org mailing list
https://stat.ethz.ch/mailman/listinfo/r-help
PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
and provide commented, minimal, self-contained, reproducible code.


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', 'Don', 'good', 'Robert', 'worst', 'Joe');
 $our_friends{'cool'} = Karen;

our.friends - list(best=Don, good=Robert, worst=Joe)
our.friends[[cool]] - Karen

G.

PS. Concerning the second question, what about reading 'Introduction to R'?

 Thanks
 Stanley
 
   [[alternative HTML version deleted]]
 
 __
 R-help@r-project.org mailing list
 https://stat.ethz.ch/mailman/listinfo/r-help
 PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
 and provide commented, minimal, self-contained, reproducible code.

-- 
Csardi Gabor [EMAIL PROTECTED]UNIL DGM

__
R-help@r-project.org mailing list
https://stat.ethz.ch/mailman/listinfo/r-help
PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
and provide commented, minimal, self-contained, reproducible code.


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)

 B) How can I check whether an object exist ?

help.search(exists)

G.

 Thanks
 Stanley
 
   [[alternative HTML version deleted]]
 
 __
 R-help@r-project.org mailing list
 https://stat.ethz.ch/mailman/listinfo/r-help
 PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
 and provide commented, minimal, self-contained, reproducible code.

-- 
Csardi Gabor [EMAIL PROTECTED]UNIL DGM

__
R-help@r-project.org mailing list
https://stat.ethz.ch/mailman/listinfo/r-help
PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
and provide commented, minimal, self-contained, reproducible code.


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

2008-04-14 Thread Gabor Csardi
What is RG? I suspect it is not a list but a vector and 
you operation you wrote does not make sense. Convert it 
to a list if you want to store c(a,b) is RG[[AB]].

G.

On Tue, Apr 15, 2008 at 12:06:14AM +0800, Ng Stanley wrote:
 Hi,
 
 How can I 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 [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 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)
 
   B) How can I check whether an object exist ?
 
  help.search(exists)
 
  G.
 
   Thanks
   Stanley
  
 [[alternative HTML version deleted]]
  
   __
   R-help@r-project.org mailing list
   https://stat.ethz.ch/mailman/listinfo/r-help
   PLEASE do read the posting guide
  http://www.R-project.org/posting-guide.htmlhttp://www.r-project.org/posting-guide.html
   and provide commented, minimal, self-contained, reproducible code.
 
  --
  Csardi Gabor [EMAIL PROTECTED]UNIL DGM
 
 
   [[alternative HTML version deleted]]
 
 __
 R-help@r-project.org mailing list
 https://stat.ethz.ch/mailman/listinfo/r-help
 PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
 and provide commented, minimal, self-contained, reproducible code.

-- 
Csardi Gabor [EMAIL PROTECTED]UNIL DGM

__
R-help@r-project.org mailing list
https://stat.ethz.ch/mailman/listinfo/r-help
PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
and provide commented, minimal, self-contained, reproducible code.


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 more than one data.frame? (are there any wildcards, etc?)
 
 I am a true beginner and have tried to look this up in help files, but
 cannot figure it out.
 
 Thank you.
 
   [[alternative HTML version deleted]]
 
 __
 R-help@r-project.org mailing list
 https://stat.ethz.ch/mailman/listinfo/r-help
 PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
 and provide commented, minimal, self-contained, reproducible code.

-- 
Csardi Gabor [EMAIL PROTECTED]UNIL DGM

__
R-help@r-project.org mailing list
https://stat.ethz.ch/mailman/listinfo/r-help
PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
and provide commented, minimal, self-contained, reproducible 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 package version 2.6.1).
  
  
  On Sun, Mar 23, 2008 at 8:44 AM, Gabor Grothendieck
  [EMAIL PROTECTED] wrote:
  Look at draw.circle and draw.arc in the plotrix package.
 
   On Sat, Mar 22, 2008 at 5:40 PM, ermimi [EMAIL PROTECTED] wrote:
   
Hello!!!
   
I would want to draw a circle but I don´t want use the function
  symbol(..).
Do anybody know other function that allow me draw a circle?
Thank you very much,
Greetings Luismi
 
   __
   R-help@r-project.org mailing list
   https://stat.ethz.ch/mailman/listinfo/r-help
   PLEASE do read the posting guide
  http://www.R-project.org/posting-guide.html
   and provide commented, minimal, self-contained, reproducible code.
 
  
  
  
  -- 
  Felix Andrews / 安福立
  PhD candidate
  Integrated Catchment Assessment and Management Centre
  The Fenner School of Environment and Society
  The Australian National University (Building 48A), ACT 0200
  Beijing Bag, Locked Bag 40, Kingston ACT 2604
  http://www.neurofractal.org/felix/
  3358 543D AAC6 22C2 D336 80D9 360B 72DD 3E4C F5D8
  
  
  __
  R-help@r-project.org mailing list
  https://stat.ethz.ch/mailman/listinfo/r-help
  PLEASE do read the posting guide
  http://www.R-project.org/posting-guide.html
  and provide commented, minimal, self-contained, reproducible code.
  
  
 
 -- 
 View this message in context: 
 http://www.nabble.com/Draw-Circles-tp16227640p16234383.html
 Sent from the R help mailing list archive at Nabble.com.
 
 __
 R-help@r-project.org mailing list
 https://stat.ethz.ch/mailman/listinfo/r-help
 PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
 and provide commented, minimal, self-contained, reproducible code.

-- 
Csardi Gabor [EMAIL PROTECTED]UNIL DGM

__
R-help@r-project.org mailing list
https://stat.ethz.ch/mailman/listinfo/r-help
PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
and provide commented, minimal, self-contained, reproducible code.


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))) sens - c(2,4,6)
 
  
 
 temp - t(rawdata)/sens
 
 temp - t(temp)
 
 print(temp)
 
  
 
 Gabor sent three other solutions and I understood 2 of them but not the one
 below.
 
  
 
 I think I understand mapply a little but what I don't understand how 
 
 it knows to take the rows of rawdata and then I guess recycle sens ?
 
 how did the mapply know not to take the columns of rawdata and do 
 
 something to them ? or maybe mapply does things element by element and it is
 doing more 
 
 complex recycling ? I guess I don't really understand mapply that well but I
 did 
 
 read the help of it.
 
  
 
 Thanks so much for any enlightenment from anyone besides Gabor. I bother him
 enough already
 
 and he does more than enough.
 
  
 
 tempc - data.frame(mapply(/, rawdata, sens))
 
 print(tempc)

Mark, there is no recycling here. rawdata[1] is the first column of the data 
frame, 
rawdata[2] is the second, etc. and the mapply construct is just calculating

rawdata[1] / sens[1]
rawdata[2] / sens[2]
rawdata[3] / sens[3]

data.frame() is only needed because the result of mapply would be a matrix
otherwise.

(the other (?)) Gabor

 
  
 
  Mark
 
  
 
  
 
  
 
  
 
  
 
 
   [[alternative HTML version deleted]]
 
 __
 R-help@r-project.org mailing list
 https://stat.ethz.ch/mailman/listinfo/r-help
 PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
 and provide commented, minimal, self-contained, reproducible code.

-- 
Csardi Gabor [EMAIL PROTECTED]UNIL DGM

__
R-help@r-project.org mailing list
https://stat.ethz.ch/mailman/listinfo/r-help
PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
and provide commented, minimal, self-contained, reproducible code.


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:
 
  a = rep(16.256, 5)
  sum(a[1:5]^2) - (sum(a[1:5])^2/5)
 [1] 2.273737e-13
 
 as you can see i retrieve a non 0 value, when i am expected to. what can I
 do?
 
  sessionInfo()
 R version 2.6.2 (2008-02-08)
 i386-pc-mingw32
 
 locale:
 LC_COLLATE=Italian_Italy.1252;LC_CTYPE=Italian_Italy.1252;LC_MONETARY=Italian_Italy.1252;LC_NUMERIC=C;LC_TIME=Italian_Italy.1252
 
 attached base packages:
 [1] stats graphics  grDevices utils datasets  methods   base
 
 loaded via a namespace (and not attached):
 [1] rcompgen_0.1-17
 
   [[alternative HTML version deleted]]
 
 __
 R-help@r-project.org mailing list
 https://stat.ethz.ch/mailman/listinfo/r-help
 PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
 and provide commented, minimal, self-contained, reproducible code.

-- 
Csardi Gabor [EMAIL PROTECTED]UNIL DGM

__
R-help@r-project.org mailing list
https://stat.ethz.ch/mailman/listinfo/r-help
PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
and provide commented, minimal, self-contained, reproducible code.


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
 
   [[alternative HTML version deleted]]
 
 __
 R-help@r-project.org mailing list
 https://stat.ethz.ch/mailman/listinfo/r-help
 PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
 and provide commented, minimal, self-contained, reproducible code.

-- 
Csardi Gabor [EMAIL PROTECTED]UNIL DGM

__
R-help@r-project.org mailing list
https://stat.ethz.ch/mailman/listinfo/r-help
PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
and provide commented, minimal, self-contained, reproducible code.


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 with the subscription.
 
 Thank you,
 
 Agnes
 
 
 
 On Wed, 19 Mar 2008, Matthias Ganninger wrote:
 
  Has anyone yet implemented or seen an implementation of a Cox (1987) 
  controlled rounding algorithm in R?
  The controlled rounding procedure is described in:
  Cox, L.H. (1987): A Constructive Procedure for Unbiased Controlled 
  Rounding. 
  JASA, Vol. 82, No. 398, pp. 520-524.
 
  Kind regards
  Matthias Ganninger
 
 
  
 
 
 __
 R-help@r-project.org mailing list
 https://stat.ethz.ch/mailman/listinfo/r-help
 PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
 and provide commented, minimal, self-contained, reproducible code.

-- 
Csardi Gabor [EMAIL PROTECTED]UNIL DGM

__
R-help@r-project.org mailing list
https://stat.ethz.ch/mailman/listinfo/r-help
PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
and provide commented, minimal, self-contained, reproducible code.


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
 crucial.
 
 I'm familiar with Java and its GUI packages, I've been looking at the JRI
 package (interfaces R with Java) but I'm a little uneasy about asking my
 users to go through its installation (necessitates mingw, among other
 things, in Windows). Though, once installed, it could work very well.
 
 I have a little exposure to Tcl/TK. Though I'm not as big of a fan of this
 as I am of Java, I could suck it up and use it, but I'm not sure that its
 installation is a whole lot simpler?

Should be. It comes with R. I believe that it is still the only
cross-platform solution that requires nothing, but the base 
R installation.

 What, in your experience, is the easiest way to accomplish something like
 this?
 
 To recapitulate, my criteria are:
 1.) Easy installation

Tcl/Tk wins here, IMHO.

 2.) Ease of use (GUI)

Tcl/Tk is not the most modern GUI, so it might be a little
clumsy. 

 3.) Interface with functions written in R

That's no problem for any of the R GUI options, i believe.

 4.) Cross-platform

Tcl/Tk is.

Furthermore, Tcl/Tk is quite poorly documented, even 
if you can usually use its normal (not R) documentation.
Sometimes it is hard to find the right way of doing things.

Gabor

 I'm willing to learn a new language (scripting or otherwise) if necessary.
 
 Thanks so much.
 -- 
 View this message in context: 
 http://www.nabble.com/R-GUI-question-tp16149624p16149624.html
 Sent from the R help mailing list archive at Nabble.com.
 
 __
 R-help@r-project.org mailing list
 https://stat.ethz.ch/mailman/listinfo/r-help
 PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
 and provide commented, minimal, self-contained, reproducible code.

-- 
Csardi Gabor [EMAIL PROTECTED]UNIL DGM

__
R-help@r-project.org mailing list
https://stat.ethz.ch/mailman/listinfo/r-help
PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
and provide commented, minimal, self-contained, reproducible code.


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  http://www.mayin.org/ajayshah  
 [EMAIL PROTECTED] http://ajayshahblog.blogspot.com
 *(:-? - wizard who doesn't know the answer.
 
 __
 R-help@r-project.org mailing list
 https://stat.ethz.ch/mailman/listinfo/r-help
 PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
 and provide commented, minimal, self-contained, reproducible code.

-- 
Csardi Gabor [EMAIL PROTECTED]UNIL DGM

__
R-help@r-project.org mailing list
https://stat.ethz.ch/mailman/listinfo/r-help
PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
and provide commented, minimal, self-contained, reproducible code.


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] [,4] [,5]
 a - array( dim=c(5,4,0) )
 dim(a)
[1] 5 4 0
 length(a)
[1] 0

 I do not understand why we have length(numeric()), length(factor()) and 
 length(character()) to zero, and length(array()) to one... Any rason for 
 that ?

That i don't know, maybe someone else does.

G.

 Thanks
 
 Christophe
 
 __
 R-help@r-project.org mailing list
 https://stat.ethz.ch/mailman/listinfo/r-help
 PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
 and provide commented, minimal, self-contained, reproducible code.

-- 
Csardi Gabor [EMAIL PROTECTED]UNIL DGM

__
R-help@r-project.org mailing list
https://stat.ethz.ch/mailman/listinfo/r-help
PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
and provide commented, minimal, self-contained, reproducible code.


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]
  x[sel]
 
 to obtain the values, but in my analysis, the y-vector is thousands of
 elements long.
 
 Is there any way, that I can do that easily?
 
 Thanks
 
 Rainer
 -- 
 Rainer M. Krug, Dipl. Phys. (Germany), MSc Conservation Biology (UCT)
 
 Plant Conservation Unit Department of Botany
 University of Cape Town
 Rondebosch 7701
 South Africa
 
 __
 R-help@r-project.org mailing list
 https://stat.ethz.ch/mailman/listinfo/r-help
 PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
 and provide commented, minimal, self-contained, reproducible code.

-- 
Csardi Gabor [EMAIL PROTECTED]UNIL DGM

__
R-help@r-project.org mailing list
https://stat.ethz.ch/mailman/listinfo/r-help
PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
and provide commented, minimal, self-contained, reproducible code.


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 than 100 (ie if any value 
 in the row is greater than 100 the row stays in the dataset). I am unsure how 
 to test each individual value across the rows and then identify the rows 
 which meet my criteria. 
 
 Can anyone help?
 
 Thank you.
 
 Iain
 
   [[alternative HTML version deleted]]
 
 __
 R-help@r-project.org mailing list
 https://stat.ethz.ch/mailman/listinfo/r-help
 PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
 and provide commented, minimal, self-contained, reproducible code.

-- 
Csardi Gabor [EMAIL PROTECTED]UNIL DGM

__
R-help@r-project.org mailing list
https://stat.ethz.ch/mailman/listinfo/r-help
PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
and provide commented, minimal, self-contained, reproducible code.


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 - matrix(norm(25), nrow=5)
 
 The problem is that nrow(temp[1,]) returns NULL. I would like it to return 1 
 because in my larger program I am indexing the rows of large matrices 
 according to another variable and I need to test when the resulting matrices 
 have 0, 1 or more rows.
 
 Thanks in advance for any assistance.
 
 Best regards,
 Gregory Gentlemen
 
 
 

 -
 
   [[alternative HTML version deleted]]
 
 __
 R-help@r-project.org mailing list
 https://stat.ethz.ch/mailman/listinfo/r-help
 PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
 and provide commented, minimal, self-contained, reproducible code.

-- 
Csardi Gabor [EMAIL PROTECTED]UNIL DGM

__
R-help@r-project.org mailing list
https://stat.ethz.ch/mailman/listinfo/r-help
PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
and provide commented, minimal, self-contained, reproducible code.


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 a[1:2], a[5:7], a[3:4]... 
 
 is there an elegant way to do it without any loop? Thanks!
 
 -- 
 View this message in context: 
 http://www.nabble.com/cumsum-list..-tp16025202p16025202.html
 Sent from the R help mailing list archive at Nabble.com.
 
 __
 R-help@r-project.org mailing list
 https://stat.ethz.ch/mailman/listinfo/r-help
 PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
 and provide commented, minimal, self-contained, reproducible code.

-- 
Csardi Gabor [EMAIL PROTECTED]UNIL DGM

__
R-help@r-project.org mailing list
https://stat.ethz.ch/mailman/listinfo/r-help
PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
and provide commented, minimal, self-contained, reproducible code.


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 -0400, Gonçalo Ferraz wrote:
 Hi,
 
 I have:
 
 a - matrix(c(0,1,0,1),nrow=2)
 b - matrix(c(1,1,1,0,0,0),nrow=3)
 c - 1
 d - c(1,0,1)
 
 And I would like to join them in an object 'thing' so that I can  
 access a, b, c, or d through an index in a for loop.
 
 For example:
 thing[4]
 would return
 [1]  1  0  1
 
 Note however, that I have many of these 'thing' components. So many  
 that  a command like
 
 thing - list(a = matrix(c(0,1,0,1),nrow=2), b = matrix(c 
 (1,1,1,0,0,0),nrow=3), c = 1, d = c(1,0,1))
 
 would become long and awkward.
 
 Is there a way of declaring an empty 'thing' of a given length and  
 then assigning its elements from a for loop? I need to allow elements  
 a, b, c... that can be scalars, vectors or matrices with varying  
 dimensions.
 
 Thanks!
 
 Gon?alo
 
 
   [[alternative HTML version deleted]]
 

 __
 R-help@r-project.org mailing list
 https://stat.ethz.ch/mailman/listinfo/r-help
 PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
 and provide commented, minimal, self-contained, reproducible code.


-- 
Csardi Gabor [EMAIL PROTECTED]UNIL DGM

__
R-help@r-project.org mailing list
https://stat.ethz.ch/mailman/listinfo/r-help
PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
and provide commented, minimal, self-contained, reproducible code.


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 include it like one usually  
 includes images. Or do you mean something else?

Yes, it is an image, but it would be nice to have it in a vector-based 
format like EPS or SVG. Anyway, here are some versions (=different sizes):
http://developer.r-project.org/Logo/

Gabor

  Yours, sincerely
  Mag. Ferri Leberl
 
 Haris Skiadas
 Department of Mathematics and Computer Science
 Hanover College
 
 __
 R-help@r-project.org mailing list
 https://stat.ethz.ch/mailman/listinfo/r-help
 PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
 and provide commented, minimal, self-contained, reproducible code.

-- 
Csardi Gabor [EMAIL PROTECTED]UNIL DGM

__
R-help@r-project.org mailing list
https://stat.ethz.ch/mailman/listinfo/r-help
PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
and provide commented, minimal, self-contained, reproducible code.


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

Gabor

On Fri, Mar 07, 2008 at 04:08:21PM +0100, Jean lobry wrote:
 Dear Mag. Ferri Leberl,
 
 I'm using something like:
 
 --- tex.tex ---
 \documentclass{article}
 \usepackage{graphicx}
 \usepackage{fancyvrb}
 \newcommand{\Rlogo}{\protect\includegraphics[height=1.8ex,keepaspectratio]{Rlogo.pdf}}
 \newcommand{\myinput}[1] {\begin{scriptsize}
\VerbatimInput[frame=single,label=#1]{#1}
\end{scriptsize}}
 \title{The R logo, \Rlogo, in \LaTeX}
 \author{J.R. Lobry}
 
 \begin{document}
 \maketitle
 \section{Introduction to \Rlogo:}
 This is about the \Rlogo~sofware suite\footnote{
 \Rlogo~is available at...}.
 % include source in final document
 \myinput{tex.tex}
 \end{document}
 --
 
 with:
 unix$ pdflatex tex.tex
 this is what I get:
 http://pbil.univ-lyon1.fr/members/lobry/tmp/tex.pdf
 
 The PDF version of the R-Logo I'm using is here:
 http://pbil.univ-lyon1.fr/members/lobry/tmp/Rlogo.pdf
 
 HTH,
 
 Jean
 -- 
 Jean R. Lobry([EMAIL PROTECTED])
 Laboratoire BBE-CNRS-UMR-5558, Univ. C. Bernard - LYON I,
 43 Bd 11/11/1918, F-69622 VILLEURBANNE CEDEX, FRANCE
 allo  : +33 472 43 27 56 fax: +33 472 43 13 88
 http://pbil.univ-lyon1.fr/members/lobry/
 
 __
 R-help@r-project.org mailing list
 https://stat.ethz.ch/mailman/listinfo/r-help
 PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
 and provide commented, minimal, self-contained, reproducible code.

-- 
Csardi Gabor [EMAIL PROTECTED]UNIL DGM

__
R-help@r-project.org mailing list
https://stat.ethz.ch/mailman/listinfo/r-help
PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
and provide commented, minimal, self-contained, reproducible code.


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

a vectorized solution can be rendered smoothly at any 
desired size. Furthermore, it can be easily edited and the 
size of the file is (usually) much smaller than the bitmap 
version. No overkill at all, as it is SIMPLER to use the 
vector version.

 I have to zoom by a factor
 1200% to see some pixellization problems on my screen,
 but my eyes are admitedly getting older and older, one more
 instance of fortune(75) issue I guess :-(

Hmmm, i've downloaded your pdf, and it is clearly ugly at 400%.
I'm talking about the Rlogo.pdf file. E.g. i'm not sure that 
it would look good on an A0 poster.

  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.
 
 Not so sure, I had to convert it a long time ago into a PDF
 format for a reason I don't remember. I'm sharing my *.rnw
 on a CVS with colleages working under Linux, Unix, Mac and
 Windows, so the reason could be that there was a problem
 in a given platform. The PDF choice is defensive in the sense
 that we are Sweaving with \SweaveOpts{pdf = T, eps = F},
 so that including PDF is a pre-condition.

Maybe this is different if you use Sweave. pdflatex itself 
handles jpg without problems.

 It would be really nice to have a non-bitmap version, though.
 If it exists.
 
 There was a not so-old thread about this on R-devel:
 http://finzi.psych.upenn.edu/R/R-devel/archive/19448.html

Of which the conclusion is that there is no vector version.

Best,
Gabor

 Best,
 
 Jean
 -- 
 Jean R. Lobry([EMAIL PROTECTED])
 Laboratoire BBE-CNRS-UMR-5558, Univ. C. Bernard - LYON I,
 43 Bd 11/11/1918, F-69622 VILLEURBANNE CEDEX, FRANCE
 allo  : +33 472 43 27 56 fax: +33 472 43 13 88
 http://pbil.univ-lyon1.fr/members/lobry/
 

-- 
Csardi Gabor [EMAIL PROTECTED]UNIL DGM

__
R-help@r-project.org mailing list
https://stat.ethz.ch/mailman/listinfo/r-help
PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
and provide commented, minimal, self-contained, reproducible code.


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(betweenness(graph = my.graph, v=V(my.graph), directed =  
 FALSE))

This is almost good, but there is a catch, in igraph vertices are 
numbered from zero. So if you want an igraph vertex id, then you 
need to subtract one from this, i.e.:

maxb - which.max(betweennness(my.graph, directed=FALSE))-1

You can double check it:

betweenness(my.graph, maxb, directed=FALSE)

Gabor

PS. there is also an igraph mailing list, see the igraph homepage
at igraph.sf.net

 Haris Skiadas
 Department of Mathematics and Computer Science
 Hanover College
 
[...]

-- 
Csardi Gabor [EMAIL PROTECTED]UNIL DGM

__
R-help@r-project.org mailing list
https://stat.ethz.ch/mailman/listinfo/r-help
PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
and provide commented, minimal, self-contained, reproducible code.


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 be done by default,
i'll do that in the near future.

Btw, weighted shortest path calculation (= where the edges have 
weights or capacities) is only implemented in the development 
version of igraph. Just in case you're looking for that.

Best,
Gabor

On Wed, Mar 05, 2008 at 01:39:41AM -0500, Mark W Kimpel wrote:
 I am getting some unexpected results from some functions of igraph and 
 it is possible that I am misinterpreting the vertex numbers. Eg., the 
 max betweenness measure seems to be from a vertex that is not connected 
 to a single other vertex. Below if my code snippet:
 
 require(igraph)
 my.graph - graph.adjacency(adjmatrix = my.adj.matrix, mode=c(undirected))
 
 most.between.vert - colnames(my.adj.matrix)[which(betweenness(graph = 
 my.graph, v=V(my.graph), directed = FALSE) == max(betweenness(graph = 
 my.graph, v=V(my.graph), directed = FALSE))) + 1]
 
 sum(my.adj.matrix[most.between.vertext,])
 0
 
 
 Is there a way to automatically set the vertex name attributes from the 
 row and colnames of the inputted adjacency matrix to graph.adjacency? 
 This would seem like an intuitive feature, but I can't find it 
 documented. In the absence of this feature, how can I make sure that I 
 am setting the vertex name attributes correctly?
 -- 
 
 Mark W. Kimpel MD  ** Neuroinformatics ** Dept. of Psychiatry
 Indiana University School of Medicine
 
 15032 Hunter Court, Westfield, IN  46074
 
 (317) 490-5129 Work,  Mobile  VoiceMail
 (317) 204-4202 Home (no voice mail please)
 
 mwkimpelatgmaildotcom
 
 **

-- 
Csardi Gabor [EMAIL PROTECTED]UNIL DGM

__
R-help@r-project.org mailing list
https://stat.ethz.ch/mailman/listinfo/r-help
PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
and provide commented, minimal, self-contained, reproducible code.


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?
 
 Thanks,
 Martin
 
 -- 
 Ihr Partner für Webdesign, Webapplikationen und Webspace.
 http://www.roomandspace.com/
 Martin Kaffanke +43 650 4514224

[...]

-- 
Csardi Gabor [EMAIL PROTECTED]UNIL DGM

__
R-help@r-project.org mailing list
https://stat.ethz.ch/mailman/listinfo/r-help
PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
and provide commented, minimal, self-contained, reproducible code.


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 window.  Can I tell R to
   use the whole window somehow?
  
 
  This seems to do it:
  
  options(width=Sys.getenv(COLUMNS))
 
 Thats great!  Is there something like an rc file where I can generally
 save this?

See ?Startup

G.

 lg,
 Martin
 
 -- 
 Ihr Partner für Webdesign, Webapplikationen und Webspace.
 http://www.roomandspace.com/
 Martin Kaffanke +43 650 4514224



 __
 R-help@r-project.org mailing list
 https://stat.ethz.ch/mailman/listinfo/r-help
 PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
 and provide commented, minimal, self-contained, reproducible code.


-- 
Csardi Gabor [EMAIL PROTECTED]UNIL DGM

__
R-help@r-project.org mailing list
https://stat.ethz.ch/mailman/listinfo/r-help
PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
and provide commented, minimal, self-contained, reproducible code.


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
 
   [[alternative HTML version deleted]]
 
 __
 R-help@r-project.org mailing list
 https://stat.ethz.ch/mailman/listinfo/r-help
 PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
 and provide commented, minimal, self-contained, reproducible code.

-- 
Csardi Gabor [EMAIL PROTECTED]UNIL DGM

__
R-help@r-project.org mailing list
https://stat.ethz.ch/mailman/listinfo/r-help
PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
and provide commented, minimal, self-contained, reproducible code.


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. Thanks.
 
 
 xj.
 
 __
 R-help@r-project.org mailing list
 https://stat.ethz.ch/mailman/listinfo/r-help
 PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
 and provide commented, minimal, self-contained, reproducible code.

-- 
Csardi Gabor [EMAIL PROTECTED]UNIL DGM

__
R-help@r-project.org mailing list
https://stat.ethz.ch/mailman/listinfo/r-help
PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
and provide commented, minimal, self-contained, reproducible code.


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 this territory is:
 
 http://books.google.com/books?id=TN3_d7ibo30Cpg=PA85lpg=PA85dq=stigler+normal+oxymoronsource=webots=OwGhmnDk3Osig=J7ou_L8-_Mu4L14c3KJAhefrD4Ihl=en
 
 I particularly like the phrase:  [normal] is in this respect
 a rare one-word oxymoron.
 
 url:www.econ.uiuc.edu/~rogerRoger Koenker
 email   [EMAIL PROTECTED]   Department of Economics
 vox:217-333-4558University of Illinois
 fax:217-244-6678Champaign, IL 61820
 
 
 On Mar 2, 2008, at 7:33 AM, (Ted Harding) wrote:
 
  Hi Folks,
  Apologies to anyone who'd prefer not to see this query
  on this list; but I'm asking because it is probably the
  forum where I'm most likely to get a good answer!
 
  I'm interested in the provenance of the name normal
  distribution (for what I'd really prefer to call the
  Gaussian distribution).
 
  According to Wikipedia, The name normal distribution
  was coined independently by Charles S. Peirce, Francis
  Galton and Wilhelm Lexis around 1875.
 
  So be it, if that was the case -- but I would like to
  know why they chose the name normal: what did they
  intend to convey?
 
  As background: I'm reflecting a bit on the usage in
  statistics of everyday language as techincal terms,
  as in significantly different. This, for instance,
  is likely to be misunderstood by the general publidc
  when they encounter statements in the media.
 
  Likewise, normally distributed would probably be
  interpreted as distributed in the way one would
  normally expect or, perhaps, there was nothing
  unusual about the distribution.
 
  Comments welcome!
  With thanks,
  Ted.
 
  
  E-Mail: (Ted Harding) [EMAIL PROTECTED]
  Fax-to-email: +44 (0)870 094 0861
  Date: 02-Mar-08   Time: 13:04:17
  -- XFMail --
 
  __
  R-help@r-project.org mailing list
  https://stat.ethz.ch/mailman/listinfo/r-help
  PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
  and provide commented, minimal, self-contained, reproducible code.
 
 __
 R-help@r-project.org mailing list
 https://stat.ethz.ch/mailman/listinfo/r-help
 PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
 and provide commented, minimal, self-contained, reproducible code.

-- 
Csardi Gabor [EMAIL PROTECTED]UNIL DGM

__
R-help@r-project.org mailing list
https://stat.ethz.ch/mailman/listinfo/r-help
PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
and provide commented, minimal, self-contained, reproducible code.


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 = c(1,1,0), ar = 0.7), n = 200)
 ts.plot(ts.sim)
 
 How do I know the names of the rows to put in the data.frame() command?

??? Which data.frame() command? 
(Btw. now you're trying to plot from R?)

   Btw, comparing the graphics capabilities of GNUplot and R, it is
   something like a three-wheel bicycle and a spaceship. Guess
   which is which.
 
 =) I know that I will most likely spend a lot of time on just making
 the plots, but I atleast (for now =) ) think it could be fun to try.

For you maybe, not for me. I'm lost, and I apologize, but I'll quit
the discussion here.

G.

ps. i take back half of what i've said about GNUplot. It's a nice tool.
Still, IMHO, (in most cases) it makes no sense to export data from R and
plot it with GNUplot. 

-- 
Csardi Gabor [EMAIL PROTECTED]UNIL DGM

__
R-help@r-project.org mailing list
https://stat.ethz.ch/mailman/listinfo/r-help
PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
and provide commented, minimal, self-contained, reproducible code.


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 column sum from a data frame?   
 You can use colSums(), but this gives you a object of type numeric  
 with the column labels in the first row, and the sums in the second  
 row.  I just want a vector of the sums, and I can't figure out a way  
 to index the numeric object.
 
 Thanks!
 
 __
 R-help@r-project.org mailing list
 https://stat.ethz.ch/mailman/listinfo/r-help
 PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
 and provide commented, minimal, self-contained, reproducible code.

-- 
Csardi Gabor [EMAIL PROTECTED]UNIL DGM

__
R-help@r-project.org mailing list
https://stat.ethz.ch/mailman/listinfo/r-help
PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
and provide commented, minimal, self-contained, reproducible code.


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, comparing the graphics capabilities of GNUplot and R, it is 
something like a three-wheel bicycle and a spaceship. Guess 
which is which.

Gabor

On Fri, Feb 29, 2008 at 11:12:50PM +0100, Louise Hoffman 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 what?
 
 Okay, my post was not very good.
 
 The reason (I think) I need GNUplot, is that I would like to include
 the plots from R in a Latex report, where I would like to have all the
 text and equations in the plots with the same font as used in Latex.
 
 So when I read about opening and closing dev for making a pdf I
 figured that the plots that R produces are like the once Matlab makes;
 shows what they ought to, nothing more, nothing less.
 
 So I was wondering if anyone know of an GNUplot friendly format and
 the code that would produce that text file.
 
 I am new to both R and GNUplot, so I am pure ears if someone knows how
 to make such plots in R.
 
 __
 R-help@r-project.org mailing list
 https://stat.ethz.ch/mailman/listinfo/r-help
 PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
 and provide commented, minimal, self-contained, reproducible code.

-- 
Csardi Gabor [EMAIL PROTECTED]UNIL DGM

__
R-help@r-project.org mailing list
https://stat.ethz.ch/mailman/listinfo/r-help
PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
and provide commented, minimal, self-contained, reproducible code.


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 blocks? or the multiple links are simply ignored?
 
 thank you,
 Simone
 
 __
 R-help@r-project.org mailing list
 https://stat.ethz.ch/mailman/listinfo/r-help
 PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
 and provide commented, minimal, self-contained, reproducible code.

-- 
Csardi Gabor [EMAIL PROTECTED]UNIL DGM

__
R-help@r-project.org mailing list
https://stat.ethz.ch/mailman/listinfo/r-help
PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
and provide commented, minimal, self-contained, reproducible code.


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 find the function in Bioconductor and elsewhere. I
 re-install bioconductor source, update package and update R as well. no luck
 
 Is there a command in R where i can just type, and it will download it for
 me?
 -- 
 View this message in context: 
 http://www.nabble.com/Newbie%3A-Where-is-lmFit-function--tp15669332p15669332.html
 Sent from the R help mailing list archive at Nabble.com.
 
 __
 R-help@r-project.org mailing list
 https://stat.ethz.ch/mailman/listinfo/r-help
 PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
 and provide commented, minimal, self-contained, reproducible code.

-- 
Csardi Gabor [EMAIL PROTECTED]UNIL DGM

__
R-help@r-project.org mailing list
https://stat.ethz.ch/mailman/listinfo/r-help
PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
and provide commented, minimal, self-contained, reproducible code.


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, Christophe Genolini wrote:
[...]
 If I understand, it is possible only in a package, not in a programme 
 (unless the other ways), is that it ?
 Ok, thanks.
 
[...]

-- 
Csardi Gabor [EMAIL PROTECTED]UNIL DGM

__
R-help@r-project.org mailing list
https://stat.ethz.ch/mailman/listinfo/r-help
PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
and provide commented, minimal, self-contained, reproducible code.


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 single computer to just take advantage of multiple processors, and it
 does a pretty good job of keeping them busy.  The main gotchas I've
 found with Snow are in data dissemination:  You may have to
 clusterCall(cl, require(foo)) or clusterExport(cl,bar) more things
 than you would have expected.
 
 -Eric
 
 
 -- 
 Eric W. Anderson   University of Colorado
 [EMAIL PROTECTED]  Dept. of Computer Science
 phone: +1-720-984-8864   Systems Research Lab - ECCR 1B54
 
  PGP key fingerprints:
personal: 1BD4 CFCE 8B59 8D6E EA3E  EBD5 4DC9 3E61 656C 462B
academic: D3C5 D6FF EDED 9F1F C36D  53A3 74B7 53A6 3C74 5F12



 __
 R-help@r-project.org mailing list
 https://stat.ethz.ch/mailman/listinfo/r-help
 PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
 and provide commented, minimal, self-contained, reproducible code.


-- 
Csardi Gabor [EMAIL PROTECTED]UNIL DGM

__
R-help@r-project.org mailing list
https://stat.ethz.ch/mailman/listinfo/r-help
PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
and provide commented, minimal, self-contained, reproducible code.


[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 scores,
  eigenvector centrality, etc. There is also a generic interface 
  if someone wants to use ARPACK for a different (not necessarily 
  graph-related) problem.

- We support the BLISS graph isomorphism algorithm, and the 
  implementation of the VF2 algorithm can calculate subgraph isomorphisms
  now.

- We include a collection of famous graphs, these can be created 
  by referring to their name.

- We have a new 'graph.formula' function, for creating small graphs
  using symbolic names, by giving simple R formulae.

- Many functions support weighted graphs now: Page Rank, modularity
  calculation, the fast greedy community finding algorithm, etc.

- We have a new graph layout algorithm called 'graphopt'.

- A bunch of new functions are added: biconnected components and 
  articulation points, dyad and triad census, functions for vertex 
  similarity, functions for estimating closeness, betweenness and 
  edge betweenness, etc.

- igraph can write files in the DOT format now.

- Some graphics improvements, e.g. it is possible to draw 
  graphs on top of each other, etc.

- Many bugs were fixed, the most important one is probably that 
  now memory is always properly deallocated when CTRL+C (ESC) is 
  used to interrupt a computation.

PACKAGE DESCRIPTION:

igraph is originally a C library for graphs, but has interfaces
to high level languages like R, Python and Ruby. The R package 
contains BOTH the C library and its R interface. 

igraph supports:

- graph generators, creating both regular structures like trees,
  lattices, etc. and various random graphs.

- a rich set of functions calculating structural properties of 
  graphs, like vertex centrality (degree, betweenness, closeness,
  page rank, eigenvector centrality, Burt's constraints, etc.),
  shortest paths, dyad and triad census, network motifs, girth, 
  K-core decomposition, etc.

- attributes can be associated with the vertices/edges of the graph,
  or the graph itself. The attributes can be arbitrary R objects.

- graph visualization using regular R devices, interactive visualization
  using Tcl/Tk, 3D visualization using RGL.

- graph layout generators, the standard Kamada-Kawai and 
  Fruchterman-Reingold algorithms are included, plus many more.

- Functions for graph and subgraph isomorphism, the BLISS and the VF2
  algorithms are included.

- Functions for maximal network flows, minimal cuts, vertex and 
  edge connectivity.

- igraph can read and write many popular file formats used for 
  storing graph data: GraphML, Pajek, GML and others.

- igraph contains implementations of many community structure 
  detection algorithms proposed recently.

See more at the igraph homepage:
http://cneurocvs.rmki.kfki.hu/igraph/index.html

-- 
Csardi Gabor [EMAIL PROTECTED]

___
R-packages mailing list
[EMAIL PROTECTED]
https://stat.ethz.ch/mailman/listinfo/r-packages

__
R-help@r-project.org mailing list
https://stat.ethz.ch/mailman/listinfo/r-help
PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
and provide commented, minimal, self-contained, reproducible code.


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 with R 
 and I'm not able to change the NA values in a matrix by 0 values, and it's 
 necessary for my work, how can I do It? Thank you.
 
 
 
 
 Alfonso P?rez Rodr?guez
 Instituto de Investigaciones Marinas
 C/ Eduardo Cabello n? 6 
 C.P. 36208 Vigo (Espa?a)
 Tlf.- 986231930 Extensi?n 241
 e-mail: [EMAIL PROTECTED]
   [[alternative HTML version deleted]]
 

 __
 R-help@r-project.org mailing list
 https://stat.ethz.ch/mailman/listinfo/r-help
 PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
 and provide commented, minimal, self-contained, reproducible code.


-- 
Csardi Gabor [EMAIL PROTECTED]UNIL DGM

__
R-help@r-project.org mailing list
https://stat.ethz.ch/mailman/listinfo/r-help
PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
and provide commented, minimal, self-contained, reproducible code.


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 main library it fixes the problem. But rather defeats
 the intention behind having a separate mylibrary.
 
 Can anybody tell me how to solve this? That is keep my installed
 packages in mylibrary but get the package check/build to work? I guess
 Depends: has a search path but I cannot find it or how to alter it. Can
 anybody point me to some documentation?
[...]

-- 
Csardi Gabor [EMAIL PROTECTED]UNIL DGM

__
R-help@r-project.org mailing list
https://stat.ethz.ch/mailman/listinfo/r-help
PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
and provide commented, minimal, self-contained, reproducible code.


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 have a code which uses
 library(convert). Can anyone tell me which package I need to install to
 run this code. Everytime I receive the error message library (convert)
 not found.
 
 Thanks, Corinna
 
 
 
 
  
 
 __
 R-help@r-project.org mailing list
 https://stat.ethz.ch/mailman/listinfo/r-help
 PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
 and provide commented, minimal, self-contained, reproducible code.

-- 
Csardi Gabor [EMAIL PROTECTED]UNIL DGM

__
R-help@r-project.org mailing list
https://stat.ethz.ch/mailman/listinfo/r-help
PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
and provide commented, minimal, self-contained, reproducible code.


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 me which package I need to install to
 run this code. Everytime I receive the error message library (convert)
 not found.
 
 Thanks, Corinna
 
 
 
 
  
 
 __
 R-help@r-project.org mailing list
 https://stat.ethz.ch/mailman/listinfo/r-help
 PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
 and provide commented, minimal, self-contained, reproducible code.

-- 
Csardi Gabor [EMAIL PROTECTED]UNIL DGM

__
R-help@r-project.org mailing list
https://stat.ethz.ch/mailman/listinfo/r-help
PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
and provide commented, minimal, self-contained, reproducible code.


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,
 
 
 
 =
 Center of Excellence for Science and Innovation Studies,
 Royal Institute of Technology
 Drottning Kristinas väg 30
 100 44 Stockholm, Sweden
 e-mail: [EMAIL PROTECTED], [EMAIL PROTECTED], [EMAIL PROTECTED]
 Office: +46 8 790 67 93
 Fax: +46 8 790 95 17
 Cell phone: +46 73 563 45 22
 =
 
 __
 R-help@r-project.org mailing list
 https://stat.ethz.ch/mailman/listinfo/r-help
 PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
 and provide commented, minimal, self-contained, reproducible code.

-- 
Csardi Gabor [EMAIL PROTECTED]UNIL DGM

__
R-help@r-project.org mailing list
https://stat.ethz.ch/mailman/listinfo/r-help
PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
and provide commented, minimal, self-contained, reproducible code.


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 remove columns that are _entirely_ filled with 
 NAs (partial NAs are fine).
 
 How please?
 
 Thanks,
 
 Martin
 
 __
 R-help@r-project.org mailing list
 https://stat.ethz.ch/mailman/listinfo/r-help
 PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
 and provide commented, minimal, self-contained, reproducible code.

-- 
Csardi Gabor [EMAIL PROTECTED]UNIL DGM

__
R-help@r-project.org mailing list
https://stat.ethz.ch/mailman/listinfo/r-help
PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
and provide commented, minimal, self-contained, reproducible code.


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 you
 type in their names, please?
 
 I've tried getAnywhere and getMethods...I thought that might produce them.
 
 Thanks in advance.
 
 Sincerely,
 Edna
 
 __
 R-help@r-project.org mailing list
 https://stat.ethz.ch/mailman/listinfo/r-help
 PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
 and provide commented, minimal, self-contained, reproducible code.

-- 
Csardi Gabor [EMAIL PROTECTED]UNIL DGM

__
R-help@r-project.org mailing list
https://stat.ethz.ch/mailman/listinfo/r-help
PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
and provide commented, minimal, self-contained, reproducible code.


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 only way formal arguments (like 
 expr) can be matched after a '...' is with *exact* name matching.  Why 
 do you want to avoid explicitly naming the expr argument?
 
 If you always want the expr argument last, you might be able to just use 
 ... as the sole argument to your function, and strip off the last 
 element inside the function as 'expr', and use all but the last element 
 as your list of options.  This requires that expr always be given last 
 though.  Probably best just to explicitly name the expr argument.
 
 Erik Iverson
 
 Alistair Gee wrote:
  I often want to temporarily modify the options() options, e.g.
  
  a - seq(1001, 1001 + 10) # some wide object
  
  with.options - function(..., expr) {
options0 - options(...)
tryCatch(expr, finally=options(options0))
  }
  
  Then I can use:
  
  with.options(width=160, expr = print(a))
  
  But I'd like to avoid explicitly naming the expr argument, as in:
  
  with.options(width=160, print(a))
  
  How can I do this with R's argument matching? (I prefer the expr as
  the last argument since it could be a long code block. Also, I'd like
  with.options to take multiple options.)
  
  TIA
  
  __
  R-help@r-project.org mailing list
  https://stat.ethz.ch/mailman/listinfo/r-help
  PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
  and provide commented, minimal, self-contained, reproducible code.
 
 __
 R-help@r-project.org mailing list
 https://stat.ethz.ch/mailman/listinfo/r-help
 PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
 and provide commented, minimal, self-contained, reproducible code.

-- 
Csardi Gabor [EMAIL PROTECTED]UNIL DGM

__
R-help@r-project.org mailing list
https://stat.ethz.ch/mailman/listinfo/r-help
PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
and provide commented, minimal, self-contained, reproducible code.


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 numbers
 The data are not sorted as : III   III  IV   VVI   VII  VIII IX
   XXI   XII  XIII XIV  XV
 
 Using data[order(data$Roman),] does not do the job.
 
 How can this be done?
 
 Thanks in advance.
 
 __
 R-help@r-project.org mailing list
 https://stat.ethz.ch/mailman/listinfo/r-help
 PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
 and provide commented, minimal, self-contained, reproducible code.

-- 
Csardi Gabor [EMAIL PROTECTED]UNIL DGM

__
R-help@r-project.org mailing list
https://stat.ethz.ch/mailman/listinfo/r-help
PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
and provide commented, minimal, self-contained, reproducible code.


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 18:27
 To: Ng Stanley
 Cc: r-help
 Subject: Re: [R] Conditional rows
 
 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 corresponding row values 
  are less than or equal to 0.2 ? For this example, row 2 and 3 are the 
  correct ones.
  
  Thanks
[...]

-- 
Csardi Gabor [EMAIL PROTECTED]UNIL DGM

__
R-help@r-project.org mailing list
https://stat.ethz.ch/mailman/listinfo/r-help
PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
and provide commented, minimal, self-contained, reproducible code.


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 corresponding row values are
 less than or equal to 0.2 ? For this example, row 2 and 3 are the correct
 ones.
 
 Thanks
 
   [[alternative HTML version deleted]]
 
 __
 R-help@r-project.org mailing list
 https://stat.ethz.ch/mailman/listinfo/r-help
 PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
 and provide commented, minimal, self-contained, reproducible code.

-- 
Csardi Gabor [EMAIL PROTECTED]UNIL DGM

__
R-help@r-project.org mailing list
https://stat.ethz.ch/mailman/listinfo/r-help
PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
and provide commented, minimal, self-contained, reproducible code.


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 Virginia
 Department of Psychology
 USPS: P.O.Box 400400Charlottesville, VA 22904-4400
 Parcels:Room 102Gilmer Hall
  McCormick RoadCharlottesville, VA 22903
 Office:B011+1-434-982-4729
 Lab:B019+1-434-982-4751
 Fax:+1-434-982-4766
 WWW:http://www.people.virginia.edu/~mk9y/
 
 __
 R-help@r-project.org mailing list
 https://stat.ethz.ch/mailman/listinfo/r-help
 PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
 and provide commented, minimal, self-contained, reproducible code.

-- 
Csardi Gabor [EMAIL PROTECTED]UNIL DGM

__
R-help@r-project.org mailing list
https://stat.ethz.ch/mailman/listinfo/r-help
PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
and provide commented, minimal, self-contained, reproducible code.


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.
 
 I just need to figure out how to load a dataset into the program from excel!
 
 Thanks!
 
 CL
 
   [[alternative HTML version deleted]]
 
 __
 R-help@r-project.org mailing list
 https://stat.ethz.ch/mailman/listinfo/r-help
 PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
 and provide commented, minimal, self-contained, reproducible code.

-- 
Csardi Gabor [EMAIL PROTECTED]UNIL DGM

__
R-help@r-project.org mailing list
https://stat.ethz.ch/mailman/listinfo/r-help
PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
and provide commented, minimal, self-contained, reproducible code.


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 08:18:49AM -0800, Thomas Pujol wrote:
 Does anyone use revision control software to manage their R-code?
 Any suggestions?
 
 Ideally, I'm looking for a, effective yet easy to implement/maintain package.
 
 http://en.wikipedia.org/wiki/Revision_control
 http://en.wikipedia.org/wiki/Comparison_of_revision_control_software
 
 

 -
 
   [[alternative HTML version deleted]]
 
 __
 R-help@r-project.org mailing list
 https://stat.ethz.ch/mailman/listinfo/r-help
 PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
 and provide commented, minimal, self-contained, reproducible code.

-- 
Csardi Gabor [EMAIL PROTECTED]UNIL DGM

__
R-help@r-project.org mailing list
https://stat.ethz.ch/mailman/listinfo/r-help
PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
and provide commented, minimal, self-contained, reproducible code.


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 defined. So, my question is how do I get the rows that match one
 of the elements in the vector.
 
 Example:
 
 a = c(1:5)
 b = letters[1:10]
 df = data.frame(ind = a, letrs = b)
 
  df
ind letrs
 11 a
 22 b
 33 c
 44 d
 55 e
 61 f
 72 g
 83 h
 94 i
 10   5 j
 
 
 
 # Now I want to extract all of the rows where ind == 2, 4 or 5.
 # This would be rows 2, 4, 5, 7, 9 and 10 
 
 subgr = c(2,4,6)
 
 My most natural inclination would be to do 
 
 df[df$ind == subgr,]
 
 However, this does not work:
 
 
  df[df$ind == subgr,]
   ind letrs
 7   2 g
 Warning message:
 In df$ind == subgr :
   longer object length is not a multiple of shorter object length
 
 
 So, which part of this is it that I have misunderstood?
 
 Thanks for your help btw!
 
 Karin
 -- 
 Karin Lagesen, PhD student
 [EMAIL PROTECTED]
 http://folk.uio.no/karinlag
 
 __
 R-help@r-project.org mailing list
 https://stat.ethz.ch/mailman/listinfo/r-help
 PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
 and provide commented, minimal, self-contained, reproducible code.

-- 
Csardi Gabor [EMAIL PROTECTED]UNIL DGM

__
R-help@r-project.org mailing list
https://stat.ethz.ch/mailman/listinfo/r-help
PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
and provide commented, minimal, self-contained, reproducible code.


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 column (excluding the NA) that are
 greater than the column means ? i.e., 1, 1, 0

apply(test, 2, function(x) sum(x  mean(x, na.rm=TRUE), na.rm=TRUE))

In general, you need ?apply to calculate something for each row/column
of a matrix.

Gabor

 I could write a for loop, but hope to use better alternative.
 
   [[alternative HTML version deleted]]
 
 __
 R-help@r-project.org mailing list
 https://stat.ethz.ch/mailman/listinfo/r-help
 PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
 and provide commented, minimal, self-contained, reproducible code.

-- 
Csardi Gabor [EMAIL PROTECTED]UNIL DGM

__
R-help@r-project.org mailing list
https://stat.ethz.ch/mailman/listinfo/r-help
PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
and provide commented, minimal, self-contained, reproducible code.


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 needed?
 
 Atte Tenkanen
 University of Turku, Finland
 Department of Musicology
 +023335278
 
 __
 R-help@r-project.org mailing list
 https://stat.ethz.ch/mailman/listinfo/r-help
 PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
 and provide commented, minimal, self-contained, reproducible code.

-- 
Csardi Gabor [EMAIL PROTECTED]UNIL DGM

__
R-help@r-project.org mailing list
https://stat.ethz.ch/mailman/listinfo/r-help
PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
and provide commented, minimal, self-contained, reproducible code.


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 - matrix(c(0.0,1,NA,0.5,1.25,0.75, 0.5, NA,
  NA),byrow=TRUE,nrow=3,ncol=3)
  m
  [,1] [,2] [,3]
 [1,]  0.0 1.00   NA
 [2,]  0.5 1.25 0.75
 [3,]  0.5   NA   NA
 
 For each numeric value, I want to replace them with their corresponding
 y-value.  The result should look like (here, each row represents a variable
 rather than the columns):
   [,1] [,2] [,3]
 [1,]  20   25   NA
 [2,]  20   25   30
 [3,]  20  NA   NA
 
 Does anyone know how I can do this using apply()?  Or is there an easier
 way?  Thanks in advance.
 
 Derek
 -- 
 View this message in context: 
 http://www.nabble.com/replacing-values-in-a-matrix-tp15219764p15219764.html
 Sent from the R help mailing list archive at Nabble.com.
 
 __
 R-help@r-project.org mailing list
 https://stat.ethz.ch/mailman/listinfo/r-help
 PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
 and provide commented, minimal, self-contained, reproducible code.

-- 
Csardi Gabor [EMAIL PROTECTED]UNIL DGM

__
R-help@r-project.org mailing list
https://stat.ethz.ch/mailman/listinfo/r-help
PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
and provide commented, minimal, self-contained, reproducible code.


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:
 
 
 Thank you, that works very nicely.  I am a little curious as to why you
 need to do 0*m and add that to y[col(m)] in the second expression.  It
 works perfectly, but I am just not sure how, lol.  Thanks
 
 D

[...]

 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 - matrix(c(0.0,1,NA,0.5,1.25,0.75, 0.5, NA,
   NA),byrow=TRUE,nrow=3,ncol=3)
   m
   [,1] [,2] [,3]
  [1,]  0.0 1.00   NA
  [2,]  0.5 1.25 0.75
  [3,]  0.5   NA   NA
 
  For each numeric value, I want to replace them with their corresponding
  y-value.  The result should look like (here, each row represents a
 variable
  rather than the columns):
[,1] [,2] [,3]
  [1,]  20   25   NA
  [2,]  20   25   30
  [3,]  20  NA   NA
 
  Does anyone know how I can do this using apply()?  Or is there an easier
  way?  Thanks in advance.
 
  Derek
  --
  View this message in context:
 http://www.nabble.com/replacing-values-in-a-matrix-tp15219764p15219764.html
  Sent from the R help mailing list archive at Nabble.com.
 
  __
  R-help@r-project.org mailing list
  https://stat.ethz.ch/mailman/listinfo/r-help
  PLEASE do read the posting guide
 http://www.R-project.org/posting-guide.html
  and provide commented, minimal, self-contained, reproducible code.
 
 --
 Csardi Gabor [EMAIL PROTECTED]UNIL DGM
 
 
 
 IMPORTANT NOTICE:  This e-mail and any attachments may contain confidential 
 or sensitive information which is, or may be, legally privileged or otherwise 
 protected by law from further disclosure.  It is intended only for the 
 addressee.  If you received this in error or from someone who was not 
 authorized to send it to you, please do not distribute, copy or use it or any 
 attachments.  Please notify the sender immediately by reply e-mail and delete 
 this from your system. Thank you for your cooperation.
 

-- 
Csardi Gabor [EMAIL PROTECTED]UNIL DGM

__
R-help@r-project.org mailing list
https://stat.ethz.ch/mailman/listinfo/r-help
PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
and provide commented, minimal, self-contained, reproducible code.


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 +0800, Ng Stanley wrote:
 Hi,
 
 sample(x) only permutates and/or samples from a vector, which I can't use
 for a matrix. Please help.
 
 Thanks
 Stanley
 
   [[alternative HTML version deleted]]
 
 __
 R-help@r-project.org mailing list
 https://stat.ethz.ch/mailman/listinfo/r-help
 PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
 and provide commented, minimal, self-contained, reproducible code.

-- 
Csardi Gabor [EMAIL PROTECTED]UNIL DGM

__
R-help@r-project.org mailing list
https://stat.ethz.ch/mailman/listinfo/r-help
PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
and provide commented, minimal, self-contained, reproducible code.


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(length=ncol(M)), count) ]

G.

 Permuting elements?
 
 structure(sample(M), dim=dim(M))
 
 Selecting elements?
 
 sample(M, count)
 
 Gabor
 
 On Thu, Jan 31, 2008 at 09:10:11PM +0800, Ng Stanley wrote:
  Hi,
  
  sample(x) only permutates and/or samples from a vector, which I can't use
  for a matrix. Please help.
  
  Thanks
  Stanley
  
  [[alternative HTML version deleted]]
  
  __
  R-help@r-project.org mailing list
  https://stat.ethz.ch/mailman/listinfo/r-help
  PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
  and provide commented, minimal, self-contained, reproducible code.
 
 -- 
 Csardi Gabor [EMAIL PROTECTED]UNIL DGM
 
 __
 R-help@r-project.org mailing list
 https://stat.ethz.ch/mailman/listinfo/r-help
 PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
 and provide commented, minimal, self-contained, reproducible code.

-- 
Csardi Gabor [EMAIL PROTECTED]UNIL DGM

__
R-help@r-project.org mailing list
https://stat.ethz.ch/mailman/listinfo/r-help
PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
and provide commented, minimal, self-contained, reproducible code.


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, 2008 3:35 PM, Wittner, Ben, Ph.D.
 [EMAIL PROTECTED] wrote:
  I don't know what unix you're using, but if it's fedora 8, the command
  yum install emacs
  did the trick for me. You probably need to have root (a.k.a. superuser)
  privileges to do that.
 
  If you like to use ESS with emacs to edit R scripts,
  yum install emacs-ess
 
  My guess is this would work for any Red Hat linux, but I don't know.
 
  -Ben
 
[...]

-- 
Csardi Gabor [EMAIL PROTECTED]UNIL DGM

__
R-help@r-project.org mailing list
https://stat.ethz.ch/mailman/listinfo/r-help
PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
and provide commented, minimal, self-contained, reproducible code.


  1   2   >