[R] Change the oder of stacked bar

2020-06-05 Thread Aimin Yan
I want to use the code below this message to make stacked bar plot, my question is : I want the stacked bar and its legend following the order as tr from left to right like the following: "100.0.250ng_CellLine_0" "75.25.250ng_CellLine_0" "50.50.250ng_CellLine_0" "10.90.250ng_CellLine_0" "1.99.25

[R] (no subject)

2020-06-05 Thread Aimin Yan
I want the stacked bar and its legend following the order as tr from left to right like the following: "100.0.250ng_CellLine_0" "75.25.250ng_CellLine_0" "50.50.250ng_CellLine_0" "10.90.250ng_CellLine_0" "1.99.250ng_CellLine_0" "0.100.250ng_CellLine_0" "100.0.500ng_CellLine_0" "75.25.500ng_CellLine

Re: [R] ask help for ggplot

2020-06-05 Thread Aimin Yan
Thank you, it is very helpful. I tried the following way to generate stacked bar plot for trt 'M6' and 'M12' However, the label position of legend in 'M12' is not what I want, actually in the legend I also want to keep "Others" in the bottom(like the gene order in stacked bar) In addition, how t

Re: [R] Cumulative split of value in data frame column

2020-06-05 Thread Bert Gunter
This is a **plain text list **. In future please post in plain text so that your post does not get mangled. Anyway,... I don't know about "efficient, optimized", but here's one simple way to do it using ?strsplit to unsplit and then ?paste to recombine: df <- data.frame(ID=1:3, FOO=c('A_B','A_B_

Re: [R] Error in gee.fit$working.correlation[1, 2] : subscript out of bounds

2020-06-05 Thread William Dunlap via R-help
The usual reason for the 'subscript out of bounds' error is that an array's subscripts exceed the dimensions of the array. In this case gee.fit$working.correlation is a 1 by 1 matrix, so subscripting with [1,2] will cause the error. Here is a self-contained example that you can send the package's

Re: [R] how to add a calculated column into a data frame

2020-06-05 Thread Ravi Jeyaraman
How about something like this? df <- data.frame(ID=1:3, DTVAL=c("2009-03-21","2010-05-11","2020-05-05")) df <- df %>% mutate(YEAR = as.numeric(format(as.Date(DTVAL,'%Y-%m-%d'), '%Y'))) -Original Message- From: R-help [mailto:r-help-boun...@r-project.org] On Behalf Of Charles Thuo Sent:

[R] Cumulative split of value in data frame column

2020-06-05 Thread Ravi Jeyaraman
Assuming, I have a data frame like this .. df <- data.frame(ID=1:3, FOO=c('A_B','A_B_C','A_B_C_D_E')) I want to do a 'cumulative split' of the values in column FOO based on the delimiter '_'. The end result should be like this .. ID FOO FOO_SPLIT1 FOO_SPLIT2 FOO_SPLIT

Re: [R] ask help for ggplot

2020-06-05 Thread Rui Barradas
Hello, Something like this? g <- unique(as.character(df$gene)) i <- which(g == "Others") g <- c(g[i], g[-i]) df$trt <- factor(df$trt,levels=unique(as.character(df$trt))) df$gene <- factor(df$gene,levels = g) ggplot(df, aes(x=trt,y=freq, fill = gene, group = gene)) + geom_bar(stat = "identity

[R] Spatial model for categorical data

2020-06-05 Thread Lena Fehlhaber
I did a regression analysis with categorical data with a glm model approach, which worked fine. I have longitude and latitude coordinates for each observation and I want to add their geographic spillover effect to the model. My sample data is structured: Index DV IVI IVII IVIII IVIV Long Lat 1

[R] Error in gee.fit$working.correlation[1, 2] : subscript out of bounds

2020-06-05 Thread Phat Chau
Hello, I have a dataframe in R that looks like the following cluster id period u_3 timeID startTrt Ijterror y 1: 1 1 0 -1.26 11 0 1.2015 17.809 2: 1 2 0 -1.26 11 0 -1.6577 14.950 3: 1 3 0 -1.26 11 0

Re: [R] Applying a function to dataframe column where the function value depends on the value of another column

2020-06-05 Thread Jeff Newmiller
Press send too soon? This is not actually a question. Do read the Posting Guide... for one thing you need to post in plain text because the automatic text conversion tends to mess up what you send if it is HTML. On June 5, 2020 12:02:44 AM PDT, TJUN KIAT TEO wrote: >Suppose I have a dataframe

[R] Applying a function to dataframe column where the function value depends on the value of another column

2020-06-05 Thread TJUN KIAT TEO
Suppose I have a dataframe in this from a b c g 2 3 h 4 5 i 6 7 I want to apply a function to individual elements of column C where the function value depends on the value of column A [[alternative HTML version deleted]] __ R-help@r-project.o