[R] replacing a factor value in a data frame

2005-10-28 Thread Federico Calboli
Hi All, I have the following problem, that's driving me mad. I have a dataframe of factors, from a genetic scan of SNPs. I DO have NAs in the dataframe, which would look like: V4 V5 V6 V7 V8 V9 V10 1 TT GG TT AC AG AG TT 2 AT CC TT AA AA AA TT 3 AT CC TT AC AA NA TT 4 TT

[R] natural selection coefficient S

2005-11-16 Thread Federico Calboli
, Federico Calboli -- Federico C. F. Calboli Department of Epidemiology and Public Health Imperial College, St Mary's Campus Norfolk Place, London W2 1PG Tel +44 (0)20 7594 1602 Fax (+44) 020 7594 3193 f.calboli [.a.t] imperial.ac.uk f.calboli [.a.t] gmail.com

[R] pairs matchning

2006-10-26 Thread Federico Calboli
Hi All, I have two numerical matrices of 2 columns and many rows. The two coulumns of matrix (1) form a number of 'pairs' of numbers, e.g: [,1] [,2] [1,]10 [2,]34 [3,]34 [4,]58 [5,]10 [6,]10 [7,]67 Matrix (2) contains the *unique*

[R] memory management

2006-10-30 Thread Federico Calboli
Hi All, just a quick (?) question while I wait my code runs... I'm comparing the identity of the lines of a dataframe, doing all possible pairwise comparisons. In doing so I use identical(), but that's by the way. I'm doing a (not so) quick and dirty check, and subsetting the data as

[R] spss file import

2007-02-07 Thread Federico Calboli
Hi All, does anyone ever import old SPSS files in a sl3 format? read.spss('file.sl3') does not seem to work... it's not recognised as a supported SPSS format at all. Best, Fede -- Federico C. F. Calboli Department of Epidemiology and Public Health Imperial College, St. Mary's Campus Norfolk

Re: [R] spss file import

2007-02-12 Thread Federico Calboli
Ndoye Souleymane wrote: Hi, Let me suggest you to save your spss file in txt and use the read.table function to load your file in R. That is what I use to do. The problem here is that the files are old data that were made with an ancient version of spss and cannot be changed to txt (or

[R] memory management uestion

2007-02-19 Thread Federico Calboli
Hi All, I would like to ask the following. I have an array of data in an objetct, let's say X. I need to use a for loop on the elements of one or more columns of X and I am having a debate with a colleague about the best memory management. I believe that if I do: col1 = X[,1] col2 = X[,2]

Re: [R] memory management uestion

2007-02-19 Thread Federico Calboli
Charles C. Berry wrote: Whoa! You are accessing one ROW at a time. Either way this will tangle up your cache if you have many rows and columns in your orignal data. You might do better to do Y - t( X ) ### use '-' ! for (i in whatever ){ do something using Y[ , i ] } My

Re: [R] memory management uestion [Broadcast]

2007-02-20 Thread Federico Calboli
Liaw, Andy wrote: I don't see why making copies of the columns you need inside the loop is better memory management. If the data are in a matrix, accessing elements is quite fast. If you're worrying about speed of that, do what Charles suggest: work with the transpose so that you are

Re: [R] memory management uestion [Broadcast]

2007-02-20 Thread Federico Calboli
Charles C. Berry wrote: This is a bit different than your original post (where it appeared that you were manipulating one row of a matrix at a time), but the issue is the same. As suggested in my earlier email this looks like a caching issue, and this is not peculiar to R. Viz.

[R] plotting symbol

2007-03-23 Thread Federico Calboli
Hi All, can I have a plot where the symbol for the dots is smaller than pch =20 but bigger than pch = '.'? Best, Fede -- Federico C. F. Calboli Department of Epidemiology and Public Health Imperial College, St. Mary's Campus Norfolk Place, London W2 1PG Tel +44 (0)20 75941602 Fax +44

[R] ESS function highlighting

2007-04-18 Thread Federico Calboli
Hi, is there a way of telling Emacs + ESS to show words that are already a function in R (such as 'length') is a different colour/font? Best, Federico -- Federico C. F. Calboli Department of Epidemiology and Public Health Imperial College, St. Mary's Campus Norfolk Place, London W2 1PG Tel

[R] non permanent change of vector values

2007-06-20 Thread Federico Calboli
Hi All, I have the following problem: I have a vector x = rep(0,15) x[1:2] = 1 x [1] 1 1 0 0 0 0 0 0 0 0 0 0 0 0 0 I need to be able to call that vector 'x' so that if condition 'A' is true, only the first value is kept 'as is' and all the others are put to 0 if(A == T) function(x) with x

[R] working with fractions

2007-06-21 Thread Federico Calboli
Hi All, I am writing a fucntion where I would like to use fractions for all the (numerous) passages. Is there a way of creating an environment *within a fucntion* so that all the numbers/calculations are fractions? Best, Fede -- Federico C. F. Calboli Department of Epidemiology and Public

Re: [R] working with fractions

2007-06-21 Thread Federico Calboli
Muhammad Subianto wrote: library(MASS) as.fractions(c(0, 0.15, 0.827, .06, 0.266)) [1] 0 3/20 62/75 1/15 4/15 Seems to make things a bit too slow, even though I get a good increase in precision. Fede -- Federico C. F. Calboli Department of Epidemiology and Public

[R] fractional calculations

2007-06-25 Thread Federico Calboli
Hi All, is there a function in R that allows me to work with fractions without transforming them to floats (or whatever) in between? Something that would calculate something like: (1/2 + 1/8) * 1/2 = 5/16 without ever transforming to 0.5 and 0.125? Best, Federico -- Federico C. F. Calboli

Re: [R] fractional calculations

2007-06-25 Thread Federico Calboli
Henrique Dallazuanna wrote: require(MASS) ?as.fractions as.fractions(1/2+1/8) I thought that as.fractions did transform the fractions *first* into floats and *then* found the rational approssimation (a passage I'd rather avoid): fractionspackage:MASSR

[R] fisher information matrix

2007-06-26 Thread Federico Calboli
Hi All, a colleague wants to calculate the Fisher information matrix for a model he wrote (not in R). He can easily get the neg-log-likelihood and the best fit parameters at the minimum. He can also get negLLs for other parameter values too. Given these data, is there a way in R to calculate

[R] EM unsupervised clustering

2007-07-18 Thread Federico Calboli
Hi All, I have a n x m matrix. The n rows are individuals, the m columns are variables. The matrix is in itself a collection of 1s (if a variable is observed for an individual), and 0s (is there is no observation). Something like: [,1] [,2] [,3] [,4] [,5] [,6] [1,]1011

Re: [R] EM unsupervised clustering

2007-07-18 Thread Federico Calboli
Dimitris Rizopoulos wrote: you could also have a look at function lca() from package `e1071' that performs a latent class analysis, e.g., fit1 - lca(data, 2) I tried but I got: lca(data, 2) Error in matrix(0, 2^nvar, nvar) : matrix: invalid 'nrow' value (too large or NA) In addition:

[R] rational or float?

2007-08-08 Thread Federico Calboli
Hi All, I am using the function fractions() and cognates from MASS. I would like to be able to tell if some calculations I am doing on some rationals are transformed into floats and then retransformed into rationals. For instance I suspect that as.fractions(1/8) + as.fractions(1/4) does

[R] data formatting: from rows to columns

2007-08-28 Thread Federico Calboli
Hi All, I have some data I need to write as a file from R to use in a different program. My data comes as a numeric matrix of n rows and 2 colums, I need to transform each row as a two rows 1 col output, and separate the output of each row with a blanck line. Foe instance I need to go from

<    1   2