Re: [R] conditional replacement of elements of matrix with another matrix column

2021-09-01 Thread Mohammad Tanvir Ahamed via R-help
C1 <- A C1[,2][which(B[,1]%in%A[,1])] <- B[,2][which(B[,1]%in%A[,1])] Regards. Tanvir Ahamed On Wednesday, 1 September 2021, 11:00:16 pm GMT+2, Eliza Botto wrote: deaR useRs, I have the matrix "A" and matrix "B" and I want the matrix "C". Is there a way of doing it?

Re: [R] how to get a numeric vector?

2020-10-05 Thread Mohammad Tanvir Ahamed via R-help
Hi,  You can try this.  Example: 1 a <- c(1, 4) b <- c(5, 8) unlist(as.vector(mapply(seq,a,b))) > [1]  1 2 3 4 5 4 5 6 7 8 a <- c(1, 4, 2) b <- c(5, 8, 10) unlist(as.vector(mapply(seq,a,b))) >  [1]  1  2  3  4  5  4  5  6  7  8  2  3  4  5  6  7  8  9 10 Regards. Tanvir Ahamed Sto

Re: [R] data error problem

2020-10-05 Thread Mohammad Tanvir Ahamed via R-help
Hi, In your data file, the first row does not have an equal number of column like the rest of the row.Check your data file. Specially 1st row.   Regards.Tanvir AhamedStockholm, Sweden | mashra...@yahoo.com On Monday, 5 October 2020, 08:11:48 am GMT+2, Mir Md. Abdus Sal

Re: [R] Suppress horizontal mean line in beanplot()

2018-02-13 Thread Mohammad Tanvir Ahamed via R-help
hi,  Check this  beanplot(count ~ spray, data = InsectSprays, what = c(FALSE, TRUE, TRUE, TRUE)) >From R function help :  what :  a vector of four booleans describing what to plot. In the following order, these booleans stand for the total average line, the beans, the bean average, and the bea

Re: [R] How to label a polygon window (spatstat package)

2018-02-09 Thread Mohammad Tanvir Ahamed via R-help
uot;) On Sat, 10 Feb 2018, 16:22 Mohammad Tanvir Ahamed via R-help, wrote: > Hi,  > I want to label a polygon (circle or polygon) inside. > As for example code  > > library(spatstat) > x <- runif(20) > y <- runif(20) > X <- ppp(x, y, window=disc(0.7)) > plot(

[R] How to label a polygon window (spatstat package)

2018-02-09 Thread Mohammad Tanvir Ahamed via R-help
Hi,  I want to label a polygon (circle or polygon) inside. As for example code  library(spatstat) x <- runif(20) y <- runif(20) X <- ppp(x, y, window=disc(0.7)) plot(X) Now I want to label that circle inside . Can some one please help me ?  Thanks.  Regards. Tanvir Ahamed Stockholm,

Re: [R] something weird has happened....!!!!!!!!!!

2017-12-15 Thread Mohammad Tanvir Ahamed via R-help
Dear Akshay, Where is the problem !!Two data set seems identical  except one of them show 10 column and other showing 11 column on r console .   Regards.Tanvir AhamedStockholm, Sweden | mashra...@yahoo.com On Friday, December 15, 2017, 3:49:03 PM GMT+1, akshay kulkarni

[R] Extract all point in a quadrats by spatstat package

2017-11-28 Thread Mohammad Tanvir Ahamed via R-help
Hi, With the following code i can divides window into quadrats and counts the numbers of points in each quadrat. library(spatstat) X <- runifpoint(50) quadratcount(X) quadratcount(X, 4, 5) quadratcount(X, xbreaks=c(0, 0.3, 1), ybreaks=c(0, 0.4, 0.8, 1)) qX <-  quadratcount(X, 4, 5) plot(X) plot(

[R] Merge by Range in R

2017-09-04 Thread Mohammad Tanvir Ahamed via R-help
Hi,  I have two big data set.  data _1 :  > dim(data_1) [1] 15820 5 > head(data_1)    Chromosome  StartEndFeature GroupA_3 1:       chr1 521369  75 chr1-0001    0.170 2:       chr1 750001  80 chr1-0002   -0.086 3:       chr1 8000

[R] Compare output of Violin plot from ggplot2 and vioplot . Need Explanation

2017-07-24 Thread Mohammad Tanvir Ahamed via R-help
Hi,  I have made violin plot with both ggplot2 and vioplot package with same data.  The results and code are as follows.  ###  Loading data  data.melt <- dget("https://gubox.box.com/shared/static/rirth0eym114afwyjxwe128sjzipzdym.txt";) ###  Violin plot by library

Re: [R] Merge selected list element by name

2017-04-13 Thread Mohammad Tanvir Ahamed via R-help
3 4 5 6 7 8 9 10 11 $b [1] 6 7 8 9 10 Hope this helps, Rui Barradas Em 13-04-2017 15:59, Mohammad Tanvir Ahamed via R-help escreveu: > > Hi, > > I have a list like > > kk<- list (a = 1:5, b = 6:10, c = 4:11) > > > Now i want to merger (Union) the list

[R] Merge selected list element by name

2017-04-13 Thread Mohammad Tanvir Ahamed via R-help
Hi, I have a list like kk<- list (a = 1:5, b = 6:10, c = 4:11) Now i want to merger (Union) the list element "a" and "c" by name . My expected outcome is kk1<- list(a_c = 1:11, b = 6:10) I can do it with several lines of code. But can any one have idea to do efficiently/ quickly on a

[R] Merge list element by name

2017-04-13 Thread Mohammad Tanvir Ahamed via R-help
Hi, I have a list like kk<- list (a = 1:5, b = 6:10, c = 4:11) Now i want to merger (Union) the list element "a" and "c" by name . My expected outcome is kk1<- list(a_c = 1:11, b = 6:10) I can do it with several lines of code. But can any one have idea to do efficiently/ quickly on a big da

[R] Unzip multiple layer of compressed (zip/tar) file

2017-03-24 Thread Mohammad Tanvir Ahamed via R-help
Hi, In a folder , there are multiple compressed (zip+tar) files. Each of compressed file can have multiple layer of compression (compressed file inside the compressed file and so on). Can anyone suggest, is there any way to decompress all the files in a single directory ? Tanvir Ahamed

Re: [R] Override/Insert (Change) a value (default value) inside a function

2017-03-11 Thread Mohammad Tanvir Ahamed via R-help
Thanks for reply. as I said , the function in the package is like myplot <- function(x,y) { plot(x,y) } not like myplot <- function(x,y) { plot(x,y,...) } And I cant change the function inside the package!! So , in this case how to solve the problem ? Tanvir Ahamed Göteborg, Sweden | ma

[R] Override/Insert (Change) a value (default value) inside a function

2017-03-11 Thread Mohammad Tanvir Ahamed via R-help
Hi!, Lets I have a function form a package. The function is, as an example, myplot <- function(x,y) { plot(x,y) } Now I can use the function according to function's defined argument. x<- sort(runif(200)) y<- 1:200 myplot(x,y) Now I want to input extra argument or override default value o

[R] Convert a list with NULL to a dataframe with NA

2016-10-02 Thread Mohammad Tanvir Ahamed via R-help
Hi, I have a list like below. OB1 <- structure(list(aa0 = NULL, aa1 = structure("23403", .Names = "BB10"), aa2 = structure("54904", .Names = "BB20"), aa3 = structure("22897", .Names = "BB30"), aa4 = structure("3751", .Names = "BB40"), aa5 = NULL, aa6 = structure("3679", .Names = "BB50"),

Re: [R] Get the location of a numeric element in a list

2016-06-28 Thread Mohammad Tanvir Ahamed via R-help
numeric element in a list On 06/28/2016 03:03 AM, Mohammad Tanvir Ahamed via R-help wrote: > Can any one please help me. I will apply this for a very large list, about > 400k vector in a list and vector size is unequal and large > > Example : > Input: > a <- c(1,3,6,9,25,100

[R] Get the location of a numeric element in a list

2016-06-28 Thread Mohammad Tanvir Ahamed via R-help
Can any one please help me. I will apply this for a very large list, about 400k vector in a list and vector size is unequal and large Example : Input: a <- c(1,3,6,9,25,100) b<-c(10,7,20,2,25) c<-c(1,7,5,15,25,300,1000) d<-list(a,b,c) Expected outcome : # When looking for 1 in d c(1,3) #

Re: [R] [FORGED] Re: Generate list if sequence form two vector element

2016-06-22 Thread Mohammad Tanvir Ahamed via R-help
t; >>>> Hi Tanvir, >>>> Not at all elegant, but: >>>> >>>> make.seq<-function(x) return(seq(x[1],x[2])) >>>> apply(matrix(c(a,b),ncol=2),1,make.seq) >>> >>> >>> Not sure that this is more "elegant" but it&

[R] Generate list if sequence form two vector element

2016-06-22 Thread Mohammad Tanvir Ahamed via R-help
Hi, I want to do the follow thing Input : a <- c(1,3,6,9) b<-c(10,7,20,2) Expected outcome : d<-list(1:10,3:7,6:20,2:9) Thanks !! Tanvir Ahamed Göteborg, Sweden | mashra...@yahoo.com __ R-help@r-project.org mailing list -- To UNSUBS

Re: [R] sample within a loop

2016-03-19 Thread Mohammad Tanvir Ahamed via R-help
Hi, you can try df1<-split(df,df$groups) lapply(df1, function(x) { x<-cbind(x,entry=0) sam <- sample(x$plotno,1) x$entry[which(x$plotno==sam)]<-"CONTROL" x$entry[which(!x$plotno==sam)]<-"TEST" x } ) Tanvir Ahamed Göteborg, Sweden | mashra...@yahoo.com ___

Re: [R] R problem : Error: protect(): protection stack overflow

2016-03-15 Thread Mohammad Tanvir Ahamed via R-help
(): protection stack overflow On 03/14/2016 06:39 PM, Mohammad Tanvir Ahamed via R-help wrote: > Hi, i got an error while i am running a big data. Error has explained > by the following sample sample This is an error in the package, and should be reported to the maintainer. Discover the maintaine

Re: [R] List funtion

2016-03-15 Thread Mohammad Tanvir Ahamed via R-help
> v3<-list(rep(list(v1),2),rep(list(v2),3)) > v3 [[1]] [[1]][[1]] [1] 8 4 9 12 [[1]][[2]] [1] 8 4 9 12 [[2]] [[2]][[1]] [1] 7 8 11 [[2]][[2]] [1] 7 8 11 [[2]][[3]] [1] 7 8 11 if you want to track each list category. Tanvir Ahamed Göteborg, Sweden | mashra...@yah

[R] R problem : Error: protect(): protection stack overflow

2016-03-14 Thread Mohammad Tanvir Ahamed via R-help
Hi, i got an error while i am running a big data. Error has explained by the following sample sample ## Load data mdata <- as.matrix(read.table('https://gubox.box.com/shared/static/qh4spcxe2ba5ymzjs0ynh8n8s08af7m0.txt', header = TRUE, check.names = FALSE, sep = '\t')) ## Install and load

Re: [R] Extract every 2 element for a list which are not equal in length

2016-03-07 Thread Mohammad Tanvir Ahamed via R-help
every 2 element for a list which are not equal in length Dear Mohammad,What's wrong with the result?Best,Jorge.- On Monday, March 7, 2016, Mohammad Tanvir Ahamed via R-help wrote: Hi, a <- c(1:5)b <- c(1:3) c <- 1 d <- 5 e <- list(a,b,c,d) # To extract every 1st ele

Re: [R] Extract every 2 element for a list which are not equal in length

2016-03-07 Thread Mohammad Tanvir Ahamed via R-help
] Extract every 2 element for a list which are not equal in length Hi Tanvir, I think what you want is: lapply(e,"[",1) lapply(e,"[",2) Jim On Tue, Mar 8, 2016 at 11:47 AM, Mohammad Tanvir Ahamed via R-help wrote: > Hi, > > a <- c(1:5)b <- c(1:3) &g

[R] Extract every 2 element for a list which are not equal in length

2016-03-07 Thread Mohammad Tanvir Ahamed via R-help
Hi, a <- c(1:5)b <- c(1:3) c <- 1 d <- 5 e <- list(a,b,c,d) # To extract every 1st element lapply(e,"[[",1) ## Out-put [[1]] [1] 1 [[2]] [1] 1 [[3]] [1] 1 [[4]] [1] 5 #To extract every 2nd element (Need help in this case) lapply(e,"[[",2) ## Expected outcome [[1]] [1] 2 [[2]]

Re: [R] Extract row form a dataframe by row names in another vector and factor . Need explanation

2016-03-03 Thread Mohammad Tanvir Ahamed via R-help
1:10] colnames(dat2) <- paste0("SA", 1:5) dat2[dat1[, "BB"], ] # desired result Hint: You might want to spend some time to carefully learn the different major data types in R and the various modes of indexing. In general, it is not a good default practice to convert matrices

[R] Extract row form a dataframe by row names in another vector and factor . Need explanation

2016-03-02 Thread Mohammad Tanvir Ahamed via R-help
Hi,Here i have written an example to explain my problem ## Data Generationdat<-data.frame(matrix(1:50,ncol=5)) rownames(dat)<-letters[1:10] colnames(dat)<- c("SA1","SA2","SA3","SA4","SA5") dat1<-data.frame(matrix(letters[1:20],ncol=4)) colnames(dat1)<-c("AA","BB","CC","DD") ## Row names v1<-dat1[

[R] Get object name inside lapply

2016-02-25 Thread Mohammad Tanvir Ahamed via R-help
Hello, I want to get object name of a list inside lapply > c<-list(a=seq(1:5),b=seq(10:20)) > lapply(c,names) $a NULL $b NULL Why NULL ? but i am expecting the names of object . Any help will be appreciated . I want to grab the names of object inside lapply for further process. Th

[R] Get object name inside lapply

2016-02-25 Thread Mohammad Tanvir Ahamed via R-help
Hello,  I want to get object name of a list inside lapply > c<-list(a=seq(1:5),b=seq(10:20))> lapply(c,names)$aNULL $bNULL Why NULL ?  but i am expecting the names of object . Any help will be appreciated .  I want to grab the names of object inside lapply for further process.  Thanks .   Tanvir A

[R] Read a file on every 0.5 (or less) second intervall

2015-11-06 Thread Mohammad Tanvir Ahamed via R-help
Hi, i want to read a file on every 0.5 (or less) second. How can i set this time loop to read a file ? Any idea will be appreciated . Thanks .  Tanvir Ahamed Göteborg, Sweden | mashra...@yahoo.com [[alternative HTML version deleted]] __

[R] Progress bar in random forest model

2015-09-23 Thread Mohammad Tanvir Ahamed via R-help
Hi , I am using randomForest model in R . For large number of tree my program takes long time to complete . In "randomForest" function i can use "do.trace=TRUE" to see the real time progress . Sample out put in real time on R console is as follows ntree OOB 1 2 3 4

[R] Help with Package creation

2015-09-18 Thread Mohammad Tanvir Ahamed via R-help
Hello , I am new in R package built.  I want to install one package (randomForest) that will install automatically while my package(myPack) will install. I am using R studio to built.  My Description file is :  Package: myPackType: PackageTitle: What the Package Does (Title Case)Version: 0.1Date:

[R] Combine list element by column name to make a dataframe

2015-04-06 Thread Mohammad Tanvir Ahamed via R-help
Hi ,� I have a example list like follow� lst<-list(setNames(c(1,10,50,60,70,80),c("id","id1","math","phy","che","bio")),setNames(c(2,20,45),c("id","id1","phy")),setNames(c(3,30,75),c("id","id1","bio"))) My expected outcome :� -

[R] Merge List element by name

2015-03-07 Thread Mohammad Tanvir Ahamed via R-help
Hi, I have a list like below :  > gg [[1]]       assembly1 GCA_000257985 [[2]]       assembly1 GCA_17125 [[3]]       assembly1 GCA_16805 [[4]]       assembly1 GCA_000144955 [[5]]       assembly                    isolation.source1 GCA_000507725          missing [[6]]       assembly