Re: [R] selecting the COLUMNS in a dataframe function of the numerical values in a ROW

2018-11-01 Thread Bogdan Tanasa
very helpful, thanks a lot ! On Thu, Nov 1, 2018 at 9:59 PM William Michels wrote: > Perhaps one of the following two methods: > > > zgene = data.frame( TTT=c(0,1,0,0), > +TTA=c(0,1,1,0), > + ATA=c(1,0,0,0), > + ATT=c(0,0,0,0), > +

Re: [R] selecting the COLUMNS in a dataframe function of the numerical values in a ROW

2018-11-01 Thread William Michels via R-help
Perhaps one of the following two methods: > zgene = data.frame( TTT=c(0,1,0,0), +TTA=c(0,1,1,0), + ATA=c(1,0,0,0), + ATT=c(0,0,0,0), + row.names=c("gene1", "gene2", "gene3", "gene4")) > zgene TTT TTA ATA ATT gene1 0 0 1

Re: [R] selecting the COLUMNS in a dataframe function of the numerical values in a ROW

2018-11-01 Thread Bogdan Tanasa
Dear Bill, and Bill, many thanks for taking the time to advice, and for your suggestions. I believe that I shall rephrase a bit my question, with a better example : thank you again in advance for your help. Let's assume that we start from a data frame : x = data.frame( TTT=c(0,1,0,0),

Re: [R] selecting the COLUMNS in a dataframe function of the numerical values in a ROW

2018-11-01 Thread William Michels via R-help
Hi Bogdan, Are you saying you want to drop columns that sum to zero? If so, I'm not sure you've given us a good example dataframe, since all your numeric columns give non-zero sums. Otherwise, what you're asking for is trivial. Below is an example dataframe ("ygene") with an example "AGA" column

Re: [R] selecting the COLUMNS in a dataframe function of the numerical values in a ROW

2018-11-01 Thread William Dunlap via R-help
This would be a bit simpler if 'gene' were the rownames of the data.frame. The '-4' is to remove the gene column from the calculations. > x[ x[,"gene"]=="gene2",] TTT TTA ATA gene 2 1 1 0 gene2 > colnames(x)[-4][ 1 == x[ x[,"gene"]=="gene2",-4] ] [1] "TTT" "TTA" > colnames(x)[-4][ 1 == x[

[R] selecting the COLUMNS in a dataframe function of the numerical values in a ROW

2018-11-01 Thread Bogdan Tanasa
Dear all, please may I ask for a suggestion : considering a dataframe that contains the numerical values for gene expression, for example : x = data.frame(TTT=c(0,1,0,0), TTA=c(0,1,1,0), ATA=c(1,0,0,0), gene=c("gene1", "gene2", "gene3", "gene4")) ho

Re: [R] Speeding up R code - Apply a function to each row of a matrix using the dplyr package

2018-11-01 Thread Jeff Newmiller
As Don suggests, looking for ways to do the whole calculation at once is a big efficiency booster. Also, avoiding unnecessary calculations (e.g. mean of 1:n is (n+1)/2 and mean(x+a) where a is a constant is mean(x)+a. Reproducible example: #library(tictoc) library(microben

Re: [R] Different stack barplots - same color legends

2018-11-01 Thread Richard M. Heiberger
## reminder on how the levels= argument to factor works mydata <- matrix(1:8, nrow=4, ncol=2, dimnames=list(letters[1:4], LETTERS[1:2])) dput(mydata) Factor.wrong <- factor(c("mm", "cm", "m", "km")) levels(Factor.wrong) ## alphabetical order, not meaning order Factor.right <- factor(c("mm", "cm

Re: [R] Speeding up R code - Apply a function to each row of a matrix using the dplyr package

2018-11-01 Thread MacQueen, Don via R-help
Without more study, I can only give some general pointers. The as.vector() in X1 <- as.vector(coord[1]) is almost certainly not needed. It will add a little bit to your execution time. Converting the output of func() to a one row matrix is almost certainly not needed. Just return c(res1, res2).

Re: [R] Different stack barplots - same color legends

2018-11-01 Thread Jim Lemon
Say your dataframe is named prb.df: oldnames<-names(prb.df) ncol<-ncols(prb.df) names(prb.df)<-paste0("Q",1:ncol) barplot(...,names.arg=oldnames,...) Jim On Fri, Nov 2, 2018 at 1:56 AM P. Roberto Bakker wrote: > > Yes, that is an good idea, only then I loose the original column lables which >

[R] Speeding up R code - Apply a function to each row of a matrix using the dplyr package

2018-11-01 Thread Nelly Reduan
Hello, I have a input data frame with multiple rows. For each row, I want to apply a function. The input data frame has 1,000,000+ rows. How can I speed up my code ? I would like to keep the function "func". Here is a reproducible example with a simple function: library(tictoc) library

[R] glmulti and plot highlight=

2018-11-01 Thread Bill Poling
Windows sessionInfo() #R version 3.5.1 (2018-07-02) Hi I am following along (using my own data) the processes described by "glmulti: An R Package for Easy Automated Model Selection with ( Generalized ) Linear Models" Journal of Statistical Software May 2010, Volume 34, Issue 12. http://www.js

Re: [R] Different stack barplots - same color legends

2018-11-01 Thread P. Roberto Bakker
Yes, that is an good idea, only then I loose the original column lables which I need in my barplot. Isn't it? Op do 1 nov. 2018 om 11:03 schreef Jim Lemon : > I would use the "names" or "colnames" functions to change them to Q1, > Q2, ... as I did. > > Jim > > On Thu, Nov 1, 2018 at 9:01 PM P. Ro

Re: [R] Plotting error:

2018-11-01 Thread David L Carlson
You should probably contact the packages maintainer about this. maintainer("WaveletComp") # Notice capitalization [1] Angi Roesch David L Carlson Department of Anthropology Texas A&M University College Station, TX 77843-4352 -Original Message-

Re: [R] Plot a matrix

2018-11-01 Thread David L Carlson
It would be much better if you had pasted the original .csv file into your message or read the file in R and used dput() to send us the result. It looks like you have a lower triangular matrix and I had to do a little editing to get it to work. I am showing the steps, but commenting them out sin

Re: [R] Plot a path

2018-11-01 Thread Jan van der Laan
Below a similar example, using sf and leaflet; plotting the trajectory on a background map. library(leaflet) library(sf) library(dplyr) # Generate example data gen_data <- function(id, n) { data.frame( id = id, date = 1:n, lat = runif(10, min = -90, max = 90), lon = runif(10,

[R] Plotting error:

2018-11-01 Thread srinivas kotta
Dear Members, Can anybody help me to solve the errors in R-script. I am plotting wavelet image using waveletcomp library . I am trying define maximum and minimum (range) of the color scale. *command is*: wt.image(my.w, color.key = "interval", n.levels = 250, legend.params = list(lab =

Re: [R] Plot a path

2018-11-01 Thread Rui Barradas
Hello, The following uses ggplot2. First, make up a dataset, since you have not posted one. lat0 <- 38.736946 lon0 <- -9.142685 n <- 10 set.seed(1) Date <- seq(Sys.Date() - n + 1, Sys.Date(), by = "days") Lat <- lat0 + cumsum(c(0, runif(n - 1))) Lon <- lon0 + cumsum(c(0, runif(n - 1))) Place

Re: [R] Different stack barplots - same color legends

2018-11-01 Thread Jim Lemon
I would use the "names" or "colnames" functions to change them to Q1, Q2, ... as I did. Jim On Thu, Nov 1, 2018 at 9:01 PM P. Roberto Bakker wrote: > > Hi Jim, > > Thank you for your quick reply. It is a great procedure. > The response options in my data.frame are (fortunately) similar in all >

Re: [R] Different stack barplots - same color legends

2018-11-01 Thread P. Roberto Bakker
Hi Jim, Thank you for your quick reply. It is a great procedure. The response options in my data.frame are (fortunately) similar in all columns. It would be nice if I could use your procedure in all columns at once instead of each column. My data.frame contains 48 columns, each with long column na

Re: [R] Different stack barplots - same color legends

2018-11-01 Thread Jim Lemon
Hi Roberto, What I suggested is a brute force method of translating response options into ordinal numbers. Fortunately for me, the Barratt Impulsivity Scale has relatively short and constant response options. As I programmed the test myself, I already had the questions in plain text, so I simply ad

Re: [R] Different stack barplots - same color legends

2018-11-01 Thread P. Roberto Bakker
Hi Jim, Thank you. An additional question: as I have many columns to change in numeric, and the columns are long sentences, what is an efficient way to do this? I checked in StackOverflow but could not find the right answer Best Roberto Op do 1 nov. 2018 om 00:25 schreef Jim Lemon : > Hi Robert

Re: [R] OT: R version 1.0.1 is still a success.

2018-11-01 Thread Martin Maechler
> Rui Barradas > on Thu, 1 Nov 2018 07:05:54 + writes: > Hello, This has nothing to do with R-help and I apologize > in advance but this is really, really strange. > A SO user is still using R 1.0.1: > https://stackoverflow.com/questions/53096176/how-do-i-change

Re: [R] Corrupted package?

2018-11-01 Thread Patrick Connolly
On Wed, 31-Oct-2018 at 07:30PM +0100, peter dalgaard wrote: |> Hm, a source install to r-devel gave me |> |> Peter-Dalgaards-MacBook-Air:BUILD pd$ ls -l library/pkgconfig/R/pkgconfig.rdb |> -rw-r--r-- 1 pd staff 4515 Oct 31 19:15 library/pkgconfig/R/pkgconfig.rdb |> Peter-Dalgaards-MacBook-Ai

Re: [R] OT: R version 1.0.1 is still a success.

2018-11-01 Thread Eric Berger
:-) On Thu, Nov 1, 2018 at 9:06 AM Rui Barradas wrote: > Hello, > > This has nothing to do with R-help and I apologize in advance but this > is really, really strange. > > A SO user is still using R 1.0.1: > > > https://stackoverflow.com/questions/53096176/how-do-i-change-the-str-of-my-diff-time

[R] OT: R version 1.0.1 is still a success.

2018-11-01 Thread Rui Barradas
Hello, This has nothing to do with R-help and I apologize in advance but this is really, really strange. A SO user is still using R 1.0.1: https://stackoverflow.com/questions/53096176/how-do-i-change-the-str-of-my-diff-time-from-atomic-to-num#comment93089103_53096176 Imagine if R wasn't for