similar to: replacing a factor value in a data frame

Displaying 20 results from an estimated 10000 matches similar to: "replacing a factor value in a data frame"

2006 May 04
2
data manipulation docs
Hi All, Is there some document/manual about data manipulation within R that I could use as a reference (obviously, aside the R manuals)? The reason I am asking is that I have a number of data frames/matrices containg genetic data. The data is in a character form, as in: V1 V2 V3 V4 V5 1 AA AG AA GG AG 2 AC AA AA GG AG 3 AA AG AA GG AG 4 AA AA AA GG AG 5 AA AA AA GG AA I need, to chop,
2005 Apr 05
2
cat bailing out in a for loop
Dear All, I am trying to calculate the Hardy-Weinberg Equilibrium p-value for 42 SNPs. I am using the function HWE.exact from the package "genetics". In order not to do a lot of coding "by hand", I have a for loop that goes through each column (each column is one SNP) and gives me the p.value for HWE.exact. Unfortunately some SNP have reached fixation and HWE.exact requires a
2006 Jun 30
3
data extraction
Dear mailing list I have a data that have 20,000 rows and 20 columns. Io wonted to extract the 10th row only. Example the 10th, 20th, 30th 40th…..20000 th. can you please help me how do I do that.Than kyou. Example is below. Inpute: AG GG GG AG CC CC CC CC CT CC CT CT GG GG GG GG CC CC CC CC GG GG GG GG CC CC CC CC GG CG CG GG GG GG GG GG *CC CC CC CC* AA AG AG AA AA AA AA AA GG AG AG GG GG AG AG
2005 Apr 13
1
logistic regression weights problem
Hi All, I have a problem with weighted logistic regression. I have a number of SNPs and a case/control scenario, but not all genotypes are as "guaranteed" as others, so I am using weights to downsample the importance of individuals whose genotype has been heavily "inferred". My data is quite big, but with a dummy example: > status <- c(1,1,1,0,0) > SNPs <-
2006 May 22
1
editing a big file
I have a file that has 90 columns and 20,000 rows and looks like C/G CC GG CG G/T GG TT GT C/T CC TT CT A/G AA GG AG A/C AA CC AC A/T AA TT AT I want to write a code that will read through each row first the first looks at the first column and then replace the three columns with 12 if it is the same as the first column e.g. third column 11 if it is a repeat of the first alphabet like the
2006 Jun 17
2
managing data
Dear mailing list, may some one be kind to help me solve following problem. I am trying to write a code that will combine two tables "x" and "y". The first columns of both tables are unique identification for the rows. The first column of table "X" is a sub set of the first column of "Y". I need to find the matching rows in both tables by looking on their
2012 Sep 26
3
replace string values with numbers
Hi everyone, I have a data frame Gene with SNPs eg. P1 P2 P3 CG CG GG -- -- AC -- AC CC AC -- AC I tried to replace all the GG with a value 3. Gene[Gene=="GG"]<-3 It always give me: Warning in `[<-.factor`(`*tmp*`, thisvar, value = 3) : invalid factor level, NAs generated Does any know if there is anything wrong with my code? Thanks, Zhengyu
2006 Feb 28
4
subsetting a list of matrices
Hi All, I have a list of matrices: > x [,1] [,2] [1,] 1 4 [2,] 2 5 [3,] 3 6 > y [,1] [,2] [,3] [,4] [,5] [,6] [1,] 18 21 24 27 30 33 [2,] 19 22 25 28 31 34 [3,] 20 23 26 29 32 35 > z =list(x,y) I want to create a second list that is has a subset each matrix in the list subsetting so I get the 2nd and 3rd row of each (and
2005 Mar 08
5
removing message: [Previously saved workspace restored]
Dear All, I saved by mistake the environment I was working in after typing q(), and now I get the annoying message: [Previously saved workspace restored] I have already deleted all the objects in the environment, saving it as an empty environment, so it's just a matter of nitpicking I suppose. The message does not appear if I start R from any other place in the directory tree. I am
2006 Sep 26
5
putting stuff into bins...
Hi All, I have a vector of data, a vector of bin breakpoints and I want to put my data in the bins and then extract fanciful informations like the mean value of each bin. I know I can write my own function, but I would have thought that R should have somewhere a function that took as arguments something like (data, breaks, what to do with the data in the bins). I surey could not find it
2005 Jun 20
3
vectorisation suggestion
Hi All, I am counting the number of occurrences of the terms listed in one vector in another vector. My code runs: for( i in 1:length(vector3)){ vector3[i] = sum(1*is.element(vector2, vector1[i])) } where vector1 = vector containing the terms whose occurrences I want to count vector2 = made up of a number of repetitions of all the elements of vector1 vector3 = a vector of NAs that is
2004 Jul 13
3
plotting a table together with graphs
Check out textplot in the gregmisc package ... Federico Calboli <f.calboli@ucl.ac.uk> Sent by: r-help-bounces@stat.math.ethz.ch 07/13/2004 12:06 PM Please respond to f.calboli To: r-help <r-help@stat.math.ethz.ch> cc: Subject: [R] plotting a table together with graphs Dear All, I would like to ask how to add a table to a
2007 Nov 26
4
writing summary() to a text file
Hi All, I would like to output the results of a function into a text file, legible as a such. The function produces a summary quite like: summary(lm(x ~ y + w * z)) [for instance] and I am not clear how to save this summary into a text file 'automagically', because I need to be able to do it in a for() loop. Cheers, Federico -- Federico C. F. Calboli Department of Epidemiology
2009 Nov 13
4
R, NIH and FDA
Dear All, I will soon be working with NIH and possibly FDA. Will I be able to use R or will I be forced to use SAS? Cheers, Federico -- 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 (0)20 75943193 f.calboli [.a.t] imperial.ac.uk f.calboli [.a.t] gmail.com
2004 Jul 15
1
how to upload [forwarded]
[ This was posted to the R-packages list (which I moderate), but definitely doesn't belong there. Martin Maechler ] ------- start of forwarded message ------- From: Federico Calboli <f.calboli at ucl.ac.uk> To: r-packages at stat.math.ethz.ch Subject: how to upload Date: 15 Jul 2004 18:30:26 +0100 Dear All, I just finished a add on lib called Malmig, to calculate Malecot
2006 Mar 28
2
as.matrix and one row
Hi All, I have the following problem: x = c(1,2) x [1] 1 2 as.matrix(x) [,1] [1,] 1 [2,] 2 BUT, if I add: y = c(3,4) as.matrix(rbind(x,y)) [,1] [,2] x 1 2 y 3 4 It does not transpose. Since I will need as.matrix() for a list of data that is in one or more lines, I need as.matrix to behave in a consisten fashions, so I get as.matrix(x, whatever) [,1] [,2] x 1
2011 Jul 08
3
Making a new package: licence
HI All, I have written and succesfully uploaded a new package. The licence it is under is 'GPL' --no version. My assumption is, since all the code is written in R the licence R used for R would affect the code (hence my "GPL" stands for "whatever version of the GPL R is under") I am happy with the licencing I used, but I'd like to ask if there is any transitive
2012 Jan 28
3
logical subsetting, indexes and NAs
Dear All, just a quick example: > x = 1:25 > x[12] = NA > x [1] 1 2 3 4 5 6 7 8 9 10 11 NA 13 14 15 16 17 18 19 20 21 22 23 24 25 > y = x[x<10] > y [1] 1 2 3 4 5 6 7 8 9 NA Is there any way of NOT getting NA for y = x[x<10]? Similarly > y = x[x<15] > y [1] 1 2 3 4 5 6 7 8 9 10 11 NA 13 14 How do I get rid of the NA (not post
2006 Jun 19
3
MLE maximum number of parameters
Hi All, I would like to know, is there a *ballpark* figure for how many parameters the minimisation routines can cope with? I'm asking because I was asked if I knew. Cheers, Federico -- 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 (0)20 75943193 f.calboli [.a.t]
2011 Dec 05
2
barplot ignoring col parameter
Hi All, I'm having a problem with barplot: mydata [1,] 2 108 0 0 0 1 3 0 0 0 0 0 7 18 3 4 8 20 26 20 19 7 1 1 mycol = c(rep('yellow', 2), rep('white', 3), rep('orange',2), rep('white', 5), rep('orange',3), rep('red',9)) barplot(mydata, col = mycol) gives me an uniformly yellow barplot. How do I solve this? bw Federico