Re: [R] Problem accessing .Rdata objects in a loop

2012-04-18 Thread francy
, not the > character vector) to access the loaded objects instead of get. Use of > the backticks doesn't do what I think you (Francy) think it does here. > > Of course, I think this is all a little easier if one uses saveRDS / > readRDS which can assign directly to an object up

[R] Problem accessing .Rdata objects in a loop

2012-04-17 Thread francy
Hi, I am trying to access many .Rdata objects and do some operations with them using a loop. I can load the files but can't access them. The files' names are stored in a character vector called "names". After loading the objects, I can view each one using ls() and see that two objects are present

Re: [R] Choose between duplicated rows

2012-04-15 Thread francy
I also tried using Jim's code, but it doesn't work as expected with my real dataset. This is what I did: Best.na <- do.call(rbind, lapply(split(x, x$A), function(.grp){ best <- which.min(apply(.grp, 1, function(a) sum(is.na(a .grp[best, ] })) df.split <- split(Best.na, Best.na$

Re: [R] Choose between duplicated rows

2012-04-15 Thread francy
Thank you very much to both your replies. Trinker's solution works great for small dataset, but the 'split' function just hangs when I try to apply it to all my data (around 9,000 rows)…Has anyone encountered this problem before, and do you know what I could try? Thanks again. -- View this mes

[R] Choose between duplicated rows

2012-04-14 Thread francy
Dear r experts, Sorry for this basic question, but I can't seem to find a solution… I have this data frame: df <- data.frame(id = c("id1", "id1", "id1", "id2", "id2", "id2"), A = c(11905, 11907, 11907, 11829, 11829, 11829), v1 = c(NA, 3, NA,1,2,NA), v2 = c(NA,2,NA, 2, NA,NA), v3 = c(NA,1,NA,1,NA,

[R] loop through columns in S4 objects

2011-11-24 Thread francy
Dear experts, I am trying to perform an association using snpStats. I have a snp matrix called 'plink' which contains my genotype data (as a list of $genotypes, $map, $fam), and a phenotype data frame which contains the outcomes (outcome1, outcome2,...) I would like to associate with the genotype.

[R] Permutation or Bootstrap to obtain p-value for one sample

2011-10-08 Thread francy
Hi, I am having trouble understanding how to approach a simulation: I have a sample of n=250 from a population of N=2,000 individuals, and I would like to use either permutation test or bootstrap to test whether this particular sample is significantly different from the values of any other rando

[R] Merge two data frames and find common values and non-matching values

2011-10-03 Thread francy
Hi, I am trying to find a function to match two data frames of different lengths for one field only. So, for example, df1 is: Name Position location francesca A 75 cristina B 36 And df2 is: location Country 75 UK 56 Austria And I would like to match on "Location" and the output to be something

[R] Import in R with White Spaces

2011-10-03 Thread francy
Hi, I have a simple question about importing data, I would be very grateful if you could help me out. I have used read.csv(file name, header=T, sep=",") to bring in a csv file I saved in MS Excel.The problem is I have white spaces in the middle of values (not in the column names), and this messes