Re: [R] trim NA from concatenate result

2021-06-02 Thread Kai Yang via R-help
Hi Rui, I use the code to fix my problem: try$newcol <- gsub(" NA", "", try$newcol) But, I'll try your solution later. Thank you for your help. Kai On Wednesday, June 2, 2021, 02:08:18 PM PDT, Kai Yang via R-help wrote: Hi List, I use paste function to concatenate  3 character columns

Re: [R] trim NA from concatenate result

2021-06-02 Thread Rui Barradas
Hello, Something like this? df1 <- read.table(text = " NA NA NA NA NA Adenocarcinoma NA Other NA") df1 apply(df1, 1, function(x){ if(all(is.na(x))){ NA_character_ }else{ paste(x[!is.na(x)], collapse = "") } }) And please configure your e-mail client not to post in HTML format.

Re: [ESS] Style: avoid new lines in chains of square brackets [][]

2021-06-02 Thread Jeremie Juste via ESS-help
Hello Vincent, On Wednesday, 2 Jun 2021 at 09:14, Vincent Arel-Bundock via ESS-help wrote: > Hi all, > > Thanks for your awesome work on ESS! > > I use the data.table package with chains of square brackets, and would like > to indent my code as follows: > > library(data.table) > dat =

[R] trim NA from concatenate result

2021-06-02 Thread Kai Yang via R-help
Hi List, I use paste function to concatenate  3 character columns together. when I run table to see that, I found 3 categories. How can I write script to trim NA in 2nd and 3rd group and set the first one as NA? Thanks, Kai NA NA NA  NA NA Adenocarcinoma NA Other NA [[alternative HTML

Re: [R] DBDA2E-utilities.R file download

2021-06-02 Thread John Kane
" In some cases there may be one missing package." That should reae In some cases there may be more than one missing package. On Tue, 1 Jun 2021 at 14:19, John Kane wrote: > > I have added this to the R Help mailing list as it increases your > chances of getting a helpful response. > > That

Re: [R] replace NA into - for specific column

2021-06-02 Thread Kai Yang via R-help
Hello Jim,Your example works well.Thank you for your help,Kai On Tuesday, June 1, 2021, 04:59:09 PM PDT, Kai Yang via R-help wrote: Hi List, I have a column MMR in a data frame proband_crc2. The column contents missing value and + (means positive).  I need to replace all missing value

Re: [R] replace NA into - for specific column

2021-06-02 Thread Jim Lemon
Hi Kai, Maybe this will help: proband_crc2<-data.frame(MMR=rep(c(NA,"+"),3)) proband_crc2 proband_crc2$MMR[is.na(proband_crc2$MMR)]<-"-" proband_crc2 Jim On Wed, Jun 2, 2021 at 9:59 AM Kai Yang via R-help wrote: > > Hi List, > I have a column MMR in a data frame proband_crc2. The column

[R] [R-pkgs] Announcing RweaveExtra

2021-06-02 Thread Vincent Goulet via R-packages
Hi all, A new package is now available on CRAN: RweaveExtra 1.0-0, which provides "Sweave Drivers with Extra Tricks Up their Sleeve". Call me an old timer, but I always stuck to Sweave ever since it introduced me to literate programming. I just prefer the simplicity of the system. Now, I