similar to: how to substitute missing values (NAs) by the group means

Displaying 20 results from an estimated 2000 matches similar to: "how to substitute missing values (NAs) by the group means"

2009 Jun 09
1
how to use "lapplyBy" function of "doBy" package
Dear Ruser's I want to substitute each "NA" by the group mean of which the "NA" is belonging to. For example, substitute the first record of traits "NA" by the mean of "BSPy01-10" in the dummy dataframe. I have ever tried to solve this problem by using doBy package. But, I failed. I ask for the advice on how to use "lapplyBy" function of
2009 Jun 16
1
How to replace outliers by group median?
Dear R-helpers, Very small amount of outliers can greatly affect the mean and many other statistic of a numeric variable. So, usually we must deal with the outliers properly in the process of data analysis. Here, I want to replace outliers with the group median of the variable. But, I can not construct a good way to do that efficiently, because of I am a newbie to R and programming. Can anybody
2009 Aug 19
2
Why are there small circles in my plot
Dear R-listers, There is my data and my codes to create a plot. I want to know why there are two small circles in the upper right and lower left of the plot respectively. Could you please share your experience or advice with me? # dummy data factor<-rep(c("Alice","Jone","Mike"),each=100) factor<-factor(factor) traits<-c(rnorm(100, mean=1, sd=1), rnorm(100,
2009 Aug 19
2
how to fill the area under the density line with semitransparent colors
Dear R-listers, I have created a plot to display the density lines for the same variable by different entities. Now, I want to fill the area under the density lines with semitransparent colors. Though I have checked that in web-searching and book-reading, I still do not perform that. Could anyone please give me any helps or advice? Thank you in advance. The data and code I used listed below: #
2011 Jan 13
1
how to calculate the consistency of different clusterings
Dear R-listers, I do clustering on tens of individuals by thousands of traits. I have known the assignment of each individual. I want to classify the individuals by randomly resampling different subsets of the traits, for example, randomly resampling 100 traits for 100 times, then 200 traits for 100 times, then 300 traits for 100 times, ,,,,,,. By each subset of traits, I do clustering of the
2010 Jul 08
2
transformation of data.frame
Hello all R users, I have a problems transforming (or maybe better regrouping) a data.frame. I have a big data.frame, which I would like to sum up according to a specific column. This is an example of my matrix: ID gen 0042787 gen2 0016070 gen2 0016070 gen3 0007409 Gen1 0007409 gen3 0006511 gen2 0006417 gen3 0016070 gen4 0006511 gen4 I want to rearrange the matrix
2009 Apr 10
4
split a character variable into several character variable by a character
Dear Mao Jianfeng, "r-help-owner" is not the place for help, but: r-help at r-project.org (CC-ed here) In any case, strsplit() does the job, i.e.: > unlist(strsplit("BCPy01-01", "-")) [1] "BCPy01" "01" You can work with the whole variable, like: splitpop <- strsplit(df1$popcode, "-") then access the first part with >
2010 Jul 09
3
how to plot two histograms overlapped in the same plane coordinate
Dear R-help listers, I am new. I just want to get helps on how to plot two histograms overlapped in the same plane coordinate. What I did is very ugly. Could you please help me to improve it? I want to got a plot with semi- transparent overlapping region. And, I want to know how to specify the filled colors of the different histograms. I also prefer other solutions other than ggplot2. Many
2011 Apr 28
4
how to generate a normal distribution with mean=1, min=0.2, max=0.8
Dear all, This is a simple probability problem. I want to know, How to generate a normal distribution with mean=1, min=0.2 and max=0.8? I know how the generate a normal distribution of mean = 1 and sd = 1 and with 500 data point. rnorm(n=500, m=1, sd=1) But, I am confusing with how to generate a normal distribution with expected min and max. I expect to hear your directions. Thanks in
2009 Apr 09
2
failed when merging two dataframes, why
Hi, R-listers, Failed, when I tried to merge df1 and df2 by "codetot" in df1 and "codetoto" in df2. I want to know the reason and how to merge them together. Data frames and codes I have used were listed as followed. Thanks a lot in advance. df1: popcode codetot p3need BCPy01-01 BCPy01-01-1 100.0000 BCPy01-01 BCPy01-01-2 100.0000 BCPy01-01 BCPy01-01-3 100.0000 BCPy01-02
2009 Feb 23
1
how todefine an variable/column in a dataframe as numeric mode
Hello dear R-users, I have a tricky problem of data manipulation with R. Although it seems very easy, I can not solve it by myselves. The problem is a variable in my dataset is usually be readed as "factor" (variable mode), however I want it be a "numeric" one. I want to know how can I define an variable/column in a dataframe as numeric mode, after I imported a large
2010 May 25
1
how to update R10.0 to R11.0 in Ubuntu linux
Dear R-listers, I am new to R in linux. And, I am now confused by updating R in Ubuntu 9.10 linux system. I would like to seek some advice on that problem. I have done what are listed in CRAN linux installation guide: 1. add an entry like "deb http://cran.cnr.berkeley.edu/bin/linux/ubuntu karmic/" in /etc/apt/sources.list file in my computer. 2. To install the complete R system, use
2010 Apr 12
1
two problems on R in Ubuntu linux
Dear R-helpers I want to express my respect and thankfulness to all of you. I just switch from windows xp to Ubuntu linux platform. I am facing two problems when I run R in Ubuntu. I need your helps and advice, thanks in advance. ----------------------------------------------------------------------------------------------------------------------------------------------------------- 1. JGR()
2012 Aug 07
1
how to write out a tree file with bootstrap from phangorn package
Dear R-helpers and Klaus, I would like to know how to write out a tree file with bootstrap from phangorn package. That tree file could be in newick format or others. I am new for phylogenetic operation in R. Could you please give me any directions on that? Thanks in advance. Best wishes, Jian-Feng, ######## # as a example # I accomplished 1000 bootstrap simulation on a fit object (a maximum
2010 Mar 10
2
ordering columns in a data frame
Dear R users, I have the following data frame: PROCHI date_admission 2 CAO0000713 1999-12-11 4 CAO0000713 1999-10-25 21 CAO0001743 1989-05-04 25 CAO0001743 1996-09-12 26 CAO0001743 1989-05-17 27 CAO0001743 1987-09-17 28 CAO0001743 1987-09-19 29 CAO0001743 1988-01-27 36 CAO0001747 2004-03-21 38 CAO0001747 2004-03-22 39
2011 Apr 13
1
strategy for writing out file with lines header initiated with comment sign
Dear all, I have data.frame object in R. I want to export it in tab-delimited file with several lines of header initiated with comment sign (#). I do not know how to do that in R. Could you please give helps on this problem? Thanks in advance. Best, Jian-Feng, ################################################################## The lines I want to write in the header lines look like, with words
2010 Dec 29
1
helps on upgrading R in Mac OS
Dear R-helpers, I intend to upgrade R in Mac OS with updated R version and updated Mac OS version. I think my Mac notebook is produced with Mac x86_64, darwin9.8.0. I have updated my Mac OS to Mac OS X version 10.6.5. But, when I installed R 2.12.1, the "version" function still gave me information that R is based on old Mac OS. I need to know how can I update R to let it to fit for
2009 Jun 15
1
How to do automatical-plotting
Hi R-listers, I am new to R and programming. I have a large dataframe composed of two grouping variables (species, population, with populations nested in species) and tens of continuously numeric variables. For each numeric variable, I want to make a boxplot with population as the X axis and the boxes filled according to which species it is belonging to. But, that is a definitely tedious work. I
2008 Feb 08
1
reshape question
I know there are a lot of reshape questions on the mailing list, but I haven't been able to find an answer to this particular issue. I am trying to get a datafame structured like this: > sub <- rep(1:5) > ta1 <- rep(1,5) > ta2 <- rep(2,5) > tb1<- rep(3,5) > tb2 <- rep(4,5) > DF <- data.frame(sub,ta1,ta2,tb1,tb2) > DF sub ta1 ta2 tb1 tb2 1
2011 Nov 08
1
from points in Lon/Lat to physical distance in dist class
Dear R-listers, Here, I would like to hearing helps from you. I have GPS data (multiple points in the geographic scale) in longitude/latitude. I intend to calculate distance (in kilometer) among such points and output the distance matrix in dist class. I have gotten some progress, but I still can not get final goal. Could please give me any directions/advice? This email cc. to Mr. Pierre, the