Re: [R] Replace a dot in a string (".") with a space (" ")

2016-11-18 Thread Bert Gunter
Well of course. See ?regexp where it says: "The period . matches any single character. " (Always a good idea to read man pages, although this *is* a complex one) Setting the fixed argument to TRUE is one way to get what you want (there are others). > sub(".", " ", "c.t",fixed=TRUE) [1] "c t"

Re: [R] Replace a dot in a string (".") with a space (" ")

2016-11-18 Thread Omar André Gonzáles Díaz
Hi, your were close. This is the solution: sub("[.]", " ", "c.t") You need to scape the point, because point has a especial meaning in regular expressions. Read more on regex... 2016-11-18 19:13 GMT-05:00 John : > Hi, > >Is there any function that replaces a dot with a

[R] Replace a dot in a string (".") with a space (" ")

2016-11-18 Thread John
Hi, Is there any function that replaces a dot with a space? I expect "c t" from the output of the second call of function sub, but it did not do so. > sub("a", "b", "cat") [1] "cbt" > sub(".", " ", "c.t") [1] " .t" Thanks! [[alternative HTML version deleted]]

Re: [R] Help

2016-11-18 Thread André Luis Neves
Thank you very much, Sarah! It worked great in my dataset! Andre On Fri, Nov 18, 2016 at 12:31 PM, Sarah Goslee wrote: > Thanks for the useful reproducible example. > > Here's one of the various ways this can be done: > > > lapply(seq_along(mylist),

Re: [R] Help

2016-11-18 Thread Sarah Goslee
Thanks for the useful reproducible example. Here's one of the various ways this can be done: > lapply(seq_along(mylist), function(i)setNames(mylist[[i]], c("CaZyme", > names(mylist)[i]))) [[1]] CaZyme A 1 1 3 2 2 3 [[2]] CaZyme B 1 1 3 2 2 3 [[3]] CaZyme C 1 1 4

Re: [R] Presenting Hazard ratios for interacting variables in a Cox model

2016-11-18 Thread David Winsemius
> On Nov 18, 2016, at 6:56 AM, Stuart Patterson via R-help > wrote: > > I have a time-dependent cox model with three variables, each of which > interacts with the other two. So my final model is: > > fit12<-coxph(formula = Surv(data$TimeIn, data$Timeout, data$Status) ~

[R] Help

2016-11-18 Thread André Luis Neves
Dear, I have the following list (mylist), in which I need to pass to the column 2 the name of the list itself. So, running the follwing commands: A= data.frame(1:2,3) B= data.frame(1:4,3) C= data.frame(c(1:2),c(4:5)) mylist=list(A=A,B=A,C=C) lapply(mylist, setNames, paste(c("CaZyme"))) The

[R] numerical approximation of survival function

2016-11-18 Thread Carlo Giovanni Camarda
Dear R-users, my question concerns numerical approximation and, somehow, survival analysis. Let’s assume we have a density function and we aim to numerically compute the hazard, which is, in theory, the ratio between density and survival. In the following example, I take a pdf from a

Re: [R] summing up a matrix

2016-11-18 Thread Christian Brandstätter
Hi, that should do: mat <- rbind(c(20,200,100,50,100,30), c(100,200,100,50,100,30), c(50,200,100,50,100,30)) rownames(mat) <- c("2016-11","2016-12","2017-01") t(apply(mat,1,cumsum)) Best, Christian Am 18.11.2016 um 16:16 schrieb Matthias Weber: Hello together, is it possible, to summing up

Re: [R] summing up a matrix

2016-11-18 Thread David L Carlson
You should read some of the free tutorials about R. Also use dput() to send your data and plain text (no html) emails. > dput(mtx) structure(c(20L, 100L, 50L, 200L, 200L, 200L, 100L, 100L, 100L, 50L, 50L, 50L, 100L, 100L, 100L, 30L, 30L, 30L), .Dim = c(3L, 6L), .Dimnames = list(c("2016-11",

Re: [R] summing up a matrix

2016-11-18 Thread Michael Dewey
Dear Matthias It is rather hard to read that since you posted in HTML which scrambles things but I think ?cumsum may help and possibly ?apply as you seem to want to work by rows. On 18/11/2016 15:16, Matthias Weber wrote: Hello together, is it possible, to summing up a matrix? I have

Re: [R] Multi-level Meta-Regression using metafor

2016-11-18 Thread Michael Dewey
Dear Janina On 18/11/2016 12:04, Janina Steinert wrote: Hi! I am running a multi-level meta-regression in R using the metafor package. I have specified a univariate multi-level meta-regression as follows: Test_MR <- rma.mv(yi = effectsize_estimates, V = effsize_sd2, data = Test,

[R] Presenting Hazard ratios for interacting variables in a Cox model

2016-11-18 Thread Stuart Patterson via R-help
I have a time-dependent cox model with three variables, each of which interacts with the other two. So my final model is: fit12<-coxph(formula = Surv(data$TimeIn, data$Timeout, data$Status) ~ data$ Year+data$Life_Stg+data$prev.tb +data$prev.tb*data$Life_Stg + data$Year*data $Life_Stg +

[R] Multi-level Meta-Regression using metafor

2016-11-18 Thread Janina Steinert
Hi! I am running a multi-level meta-regression in R using the metafor package. I have specified a univariate multi-level meta-regression as follows: Test_MR <- rma.mv(yi = effectsize_estimates, V = effsize_sd2, data = Test, mods = ~ x, random = list(~ 1 | coeff, ~ 1 | study))

[R] [R-pkgs] Announcing new package horseshoe

2016-11-18 Thread S.L. van der Pas
Dear R users, The first version of the package ‘horseshoe' is now available on CRAN. It contains various functions for implementing the horseshoe prior for sparse linear regression, and faster versions for the special case of the normal means problem. The functions output, among other things,

[R] summing up a matrix

2016-11-18 Thread Matthias Weber
Hello together, is it possible, to summing up a matrix? I have the following matrix at the moment: [,1] [,2] [,3][,4] [,5] [,6] 2016-1120200100 50 100 30

Re: [R] Melt and compute Max, Mean, Min

2016-11-18 Thread Miluji Sb
If I do: as.data.frame(apply(df[,-(1:3)],1, mean, na.rm=T)) is it possible to sequentially name the variables as "mean_1960", "max_1960". "min_1960", "mean_1961", "max_1961". "min_1961", ...? On Fri, Nov 18, 2016 at 3:10 PM, Miluji Sb wrote: > Dear Petr, > > Thank you for

Re: [R] Melt and compute Max, Mean, Min

2016-11-18 Thread Miluji Sb
Dear Petr, Thank you for the code, apologies though as I copied the wrong data, This is precipitation data and not temperature. For the loop, could I do something like this? filelist <- list.files(pattern=".csv") myDTs <- lapply(filelist, function(.file) { apply(temp[,-(1:3)],1, mean,

Re: [R] Melt and compute Max, Mean, Min

2016-11-18 Thread PIKAL Petr
Hi I am not completely sure what you want to do but > apply(temp[,-(1:3)],1, mean, na.rm=T) 12345 NaN NaN 2.159516 1.519914 1.514007 > apply(temp[,-(1:3)],1, max, na.rm=T) 12345 -Inf -Inf 57.36528

Re: [R] Melt and compute Max, Mean, Min

2016-11-18 Thread Stephen Sefick
Milu, I am unsure what you are trying to do. Please provide a minimal reproducible example, and someone will likely be able to help you with the R code. What have you tried so far? kindest regards, Stephen On 11/18/2016 06:49 AM, Miluji Sb wrote: Dear all, I have 51 years of data (1960 -

[R] Melt and compute Max, Mean, Min

2016-11-18 Thread Miluji Sb
Dear all, I have 51 years of data (1960 - 2010) in csv format, where each file represents one year of data. Below is what each file looks like. These are temperature data by coordinates, my goal is to to compute max, min, and mean by year for each of the coordinates and construct a panel

Re: [R] Archer-Lemeshow Goodness of Fit Test for Survey Data with Log. Regression

2016-11-18 Thread Courtney Benjamin
Like I had said, I was concerned with the low p value outcome of this diagnostic test, so I went on to test other interactions that I had not previously tested. I did find an interaction that is significant. Now when I go to run the diagnostic to check for any improvement, I am coming up with

Re: [R] aggregate dataframe by multiple factors

2016-11-18 Thread PIKAL Petr
Hi same result can be achieved by dat.ag<-aggregate(dat[ , c("DCE","DP")], by= list(dat$first.Name, dat$Name, dat$Department) , "I") Sorting according to the first row seems to be quite tricky. You could probably get closer by using some combination of split and order and arranging back

Re: [R] Archer-Lemeshow Goodness of Fit Test for Survey Data with Log. Regression

2016-11-18 Thread Courtney Benjamin
​Thank you; I appreciate your advisement. Courtney Benjamin Broome-Tioga BOCES Automotive Technology II Teacher Located at Gault Toyota Doctoral Candidate-Educational Theory & Practice State University of New York at Binghamton cbenj...@btboces.org

Re: [R] Archer-Lemeshow Goodness of Fit Test for Survey Data with Log. Regression

2016-11-18 Thread Anthony Damico
hi, my code does not subset the survey design on the line that creates the svrepdesign(). subsetting in order to create a variable while your data is still a data.frame is probably okay, so long as you expect the observations outside of the subset to be NAs like they are in this case.

Re: [R] Archer-Lemeshow Goodness of Fit Test for Survey Data with Log. Regression

2016-11-18 Thread Courtney Benjamin
​Thank you, Anthony. Your approach does work; however, I am concerned to some degree about subsetting the data prior to creating the new svrepdesign as I know that it is not recommended to subset the data prior to creating the svrepdesign object. I am not sure if this is a significant concern

Re: [R] aggregate dataframe by multiple factors

2016-11-18 Thread David Winsemius
> On Nov 17, 2016, at 11:27 PM, Karim Mezhoud wrote: > > Dear all, > > the dat has missing values NA, > >first.Name Name Department DCE DP date > 5 Auction VideosYME 0.57 0.56 2013-09-30 > 18 Amish WivesTAS 0.59 0.56 2013-09-30 >