Re: [R] Finding unique terms

2018-10-12 Thread Tóth Dénes
data.frame", row.names = c(NA, -11L)) # I assume you would like to add up the values with na.rm = TRUE meanFn <- function(x) mean(x, na.rm = TRUE) # see ?aggregate aggregate(dat[, c("PO1M", "PO1T", "PO2M")], by = dat["STUDENT_ID"],

Re: [R] Converting a list to a data frame

2018-05-03 Thread Tóth Dénes
2, 2018 1:30:37 PM MDT, "Tóth Dénes" wrote: On 05/02/2018 07:11 PM, Kevin E. Thorpe wrote: I suspect this is pretty easy, but I'm having trouble figuring it out. Basically, I have a list of data frames such as the following example: list(A=data.frame(x=1:2, y=3:4),B=data.fr

Re: [R] Converting a list to a data frame

2018-05-02 Thread Tóth Dénes
On 05/02/2018 07:11 PM, Kevin E. Thorpe wrote: I suspect this is pretty easy, but I'm having trouble figuring it out. Basically, I have a list of data frames such as the following example: list(A=data.frame(x=1:2, y=3:4),B=data.frame(x=5:6,y=7:8)) I would like to turn this into data frame w

Re: [R] dplyr - add/expand rows

2017-11-29 Thread Tóth Dénes
Hi Martin, On 11/29/2017 10:46 PM, Martin Morgan wrote: On 11/29/2017 04:15 PM, Tóth Dénes wrote: Hi, A benchmarking study with an additional (data.table-based) solution. I don't think speed is the right benchmark (I do agree that correctness is!). Well, agree, and sorry for the wo

Re: [R] dplyr - add/expand rows

2017-11-29 Thread Tóth Dénes
lp@r-project.org mailing list -- To UNSUBSCRIBE and more, see https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posti ng-guide.html and provide commented, minimal, self-contained, reproducible code. [[alternative HTML version deleted]] ___

Re: [R] Searching for Enumerated Items using str_count() from the stringr package

2017-09-28 Thread Tóth Dénes
On 09/29/2017 12:02 AM, Tóth Dénes wrote: On 09/28/2017 10:25 PM, Dan Abner wrote: Hi all, I have a large number of text strings to search for enumerated items. However, I am receiving this error message even though I thought that I properly escaped the special character closed parenthesis

Re: [R] Searching for Enumerated Items using str_count() from the stringr package

2017-09-28 Thread Tóth Dénes
ttps://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code. -- Dr. Tóth Dénes ügyvezető Kogentum Kft. Tel.: 06-30-2583723 Web: www.kogentum.hu _

Re: [R] how to not match partial names

2011-05-07 Thread Tóth Dénes
> Dear friends, > > How do I stop partial matching of list names? > > e.g., > > x <- list(="a", B="b") > is.null(x$A) #returns FALSE even though there is no element A. > > if(is.null(x$A)) {result <- x$} else {result <- x$A} > result #is even though there is no x$A e

Re: [R] Creating a dataframe from a vector of character strings

2011-04-14 Thread Tóth Dénes
You could use ?unlist: structure(data.frame( matrix(unlist(strsplit(beatles," ")),length(beatles),2,T)), names=c("FirstName","LastName")) Note that this compact code does not guard you against typos, that is names with >2 or <2 elements. Hope that helps, Denes > I have a vector of ch

Re: [R] rtmvt

2011-04-11 Thread Tóth Dénes
Hi there, Since you failed to provide us with data and sessionInfo(), I can only guess that for some reason you call the rtmvt.rejection function instead of rtmvt.gibbs. Just look at the code of rtvmt by typing: rtmvt There you can see that it is a wrapper for rtmvt.rejection or rtmvt.gibbs. You

Re: [R] count number of TRUEs in each row

2011-04-10 Thread Tóth Dénes
Hi Wendy, try this: Z <- matrix(runif(1000)>0.5,10,100) rowSums(Z) HTH, Denes > Hi all, > > I have a huge matrix of TRUE/FALSE table like following, and I want to > count > the number of TRUEs in each row. Instead of looping through each row and > do > length(Z[Z==TRUE]), I am wondering if t

Re: [R] In need of help with correlations

2011-04-09 Thread Tóth Dénes
I do not know the bioconductor packages you mentioned, but the corr.test function in the psych package, or the rcorr function in the Hmisc package should do the work. Also note that the c() in method=c("pearson") is redundant. Just write method="pearson" instead (or nothing, since this is the defa

Re: [R] glm predict on new data

2011-04-06 Thread Tóth Dénes
Dear Dirk, You should avoid indexing in the glm call so that the name of the terms will not contain the indexing part. (Check str(lg) in your example.) A more preferred solution uses predefined data frames in the original calls: n <- 250 x <- rnorm(n) noise <- rnorm(n,0,0.3) y <- round(exp(x+nois

Re: [R] tapply with specific quantile value

2011-03-24 Thread Tóth Dénes
Just have a look at ?quantile and the probs argument. tapply(x, l.c.1, quantile,probs=0.75) Anyway, quantiles and quartiles are not the same. I guess you meant the 3rd quartile. > All - > > I have an example data frame > > x l.c.1 > 43.38812035 085 > 47.55710661 085 > 47.55710661 085

Re: [R] adding vertical segments to an xyplot in lattice

2011-03-22 Thread Tóth Dénes
end to vacillate between lattice and > ggplot2. I should probably settle on one or the other and learn it > better. I'll admit I like the default look of lattice plots better, but > so far custom panel functions still baffle me. > > --Chris > > Tóth Dénes wrote: >>

Re: [R] adding vertical segments to an xyplot in lattice

2011-03-22 Thread Tóth Dénes
You might also consider the Deducer package. You can build up a plot by point and click and then have a look at (and amend) the code and learn the syntax of ggplot2, which is a nice alternative to the lattice package. The website of the Deducer package (www.deducer.org) is a good start. -- An

Re: [R] Stucked with as.numeric function

2011-03-21 Thread Tóth Dénes
> > On Mar 21, 2011, at 2:59 PM, Tóth Dénes wrote: > >> >> Hi, >> >> I guess you have commas as decimals in your data. Replace it to >> decimal >> points. > > If that is true then the easiest fix would be to set the proper > decimal arg

Re: [R] Stucked with as.numeric function

2011-03-21 Thread Tóth Dénes
Hi, I guess you have commas as decimals in your data. Replace it to decimal points. Best, Denes > > On Mar 21, 2011, at 1:57 PM, pat...@gmx.de wrote: > >> Hi list, >> >> I have problems with the as.numeric function. I have imported >> probabilities from external data, but they are classified

Re: [R] GAMLSS Question

2011-03-19 Thread Tóth Dénes
Hi, predictAll should do what you want. See ?predict.gamlss. HTH, Denes > Dear All: > > I have succeeded in fitting a GAMLSS.dist model to growth data I am > working > with it. > > My aim is to create a matrix of predicted percentiles and the > corresponding > the fitted model's sigma mu

Re: [R] Help with plotting a line that is multicoloured based on levels of a factor

2011-03-17 Thread Tóth Dénes
Indeed, I forgot about the segments function. with(d,plot(date,flow,type="n")) with(d,segments(start,start.y,end,end.y,col=colour)) > Hi, > > because each colour is defined on non-consecutive points, you'll > probably need to cut the intervals to define segments around each > point. One approa

Re: [R] Help with plotting a line that is multicoloured based on levels of a factor

2011-03-17 Thread Tóth Dénes
Hi! Not an elegant solution, but seems to work: date <- c(1:300) flow <- sin(2*pi/53*c(1:300)) levels <- factor(rep(c("high","med","low"),100)) data <- cbind.data.frame(date, flow, levels) colours <- as.numeric(levels)+1 # interpolate resolution <- 0.001 appres <- approx(date,flow,seq(min(date

Re: [R] A question about list

2011-03-17 Thread Tóth Dénes
?unlist quantile(unlist(data)) > Hi dear all, > > It may be a simple question, i have a list output with different number of > elements as following; > > [[1]] > [1] 0.86801402 -0.82974691 0.3974 -0.98566707 -4.96576856 > -1.32056754 > [7] -5.54093319 -0.07600462 -1.34457280 -1.04080125

Re: [R] changing the dimensions of a matrix in a real specific way

2011-03-17 Thread Tóth Dénes
t(matrix(a,3,4)) for more complex arrays, see ?aperm > Hi again, > > I'd like to ask you a question again. > > I have a matrix like this: > a <-matrix(c(1,2,3,4,5,6,7,8,9,10,11,12)) > a > > [,1] > [1,]1 > [2,]2 > [3,]3 > [4,]4 > [5,]5 > [6,]6 > [7,]7 >

Re: [R] calculating the occurrences of distinct observations in the subsets of a dataframe

2011-03-17 Thread Tóth Dénes
Hi! Sorry, I made an error in the previous e-mail. So try this: by(df[,-1],df$id,function(x) apply(x,2,tabulate)) This gives you a list. You can rearrange it into a data frame or a 3d array if you wish. Regards, Denes > Hello everybody, > > I have a data frame in R which is similar to the