Re: [R] getting numeric [0..6] day of week from POSIXct?

2014-07-07 Thread Miguel Manese
Hi John, The package lubridate is the easiest way to deal with dates. library(lubridate) frame$groupByWeekNumber - wday(frame$dt) - 1 # Sun=1, Sat=7 On Mon, Jul 7, 2014 at 11:54 PM, John McKown john.archie.mck...@gmail.com wrote: I have a column, dt, in a data.frame. It is a list of

Re: [R] if, apply, ifelse

2013-11-28 Thread Miguel Manese
Hi Andrea, A cleaner alternative to Jim's suggestion is something like a.df - as.data.frame(a) group1 - (a.df$col1 == 1) apply(a.df[,c(col2,col3,col4)], 2, function(x) any(x == 1 | is.na(x))) group2 - (a.df$col1 == 1) apply(a.df[,c(col2,col3,col4)], 1, function(x) all(x == 0 | is.na(x)))

Re: [R] compute p/t value from pearson r and n

2013-02-24 Thread Miguel Manese
Hi Martin, See ?cor.test example(cor.test) Regards, - Jon On Mon, Feb 25, 2013 at 5:06 AM, Martin Batholdy batho...@googlemail.com wrote: Hi, is there a predefined function that computes the p- or t-value based on a correlation coefficient and its sample size? thanks!

Re: [R] R script .bat file from Python

2013-02-20 Thread Miguel Manese
Hi Fabio, I cannot reproduce it but this is probably some env var not set, or some problem with the path to your R installation having whitespace in it. See ?.libPaths, if it is empty you might want to hard-code R_HOME somewhere. Regards, On Thu, Feb 14, 2013 at 10:58 PM, Fabio Veronesi

Re: [R] Variables and greek letters in a plot title

2012-08-16 Thread Miguel Manese
Hi Dominik, You can try x - 5 plot(rnorm(50), main=bquote(.(x) * mu * g/m^3 * substance)) Regards, - Jon On Thu, Aug 16, 2012 at 3:37 PM, Dominik Refardt dominik.refa...@gmail.com wrote: Hello This is a problem I encountered repeatedly and I found no answer that made me really happy. I

Re: [R] Printing a variable in a loop

2012-06-28 Thread Miguel Manese
Hi Kat, On Thu, Jun 28, 2012 at 8:22 AM, kat_the_great k...@hotmail.com wrote: Dear R Users: I'm a STATA user converting to R, and I'd like to be to do the following. #Assign var_1 and var_2 a value 10-var1 20-var2 #Now I'd like to print the values of var_1 and var_2 by looping through

Re: [R] If statement - copying a factor variable to a new variable

2012-06-28 Thread Miguel Manese
Hi James, On Thu, Jun 28, 2012 at 12:33 AM, James Holland holland.ag...@gmail.com wrote: I need to look through a dataset with two factor variables, and depending on certain criteria, create a new variable containing the data from one of those other variables. The problem is, R keeps making

Re: [R] If statement - copying a factor variable to a new variable

2012-06-28 Thread Miguel Manese
On Thu, Jun 28, 2012 at 8:47 PM, James Holland holland.ag...@gmail.com wrote: With the multiple if statements I need to check for, I though for statements with the if/else if conditional statement was better than nested ifelse functions. for () gives you a lot of flexibility at the expense of

Re: [R] Date formats

2012-06-19 Thread Miguel Manese
Hi Walt, as.Date(01OCT1928, %d%b%Y) works for me. See also ?strftime Regards, Jon On Tue, Jun 19, 2012 at 8:00 PM, Data Analytics Corp. w...@dataanalyticscorp.com wrote: Hi, I imported an excel table (using read.csv) of Dow Jones monthly average closings where the first variable is a date

Re: [R] triangular matrix

2012-06-18 Thread Miguel Manese
Hi Lucia, On Mon, Jun 18, 2012 at 6:11 PM, lucinka lucia.bohus...@gmail.com wrote: Hello, I got this matrix of gentic distances between my samples. it is 85x85 but only lower half (without diagonal) contains my distances. How can I make a mean and standard deviation on these distances,

Re: [R] interpolation to montly data

2012-06-16 Thread Miguel Manese
Hi Ken, Stef, We can make your script more elegant like below: On Sun, Jun 17, 2012 at 12:52 AM, Ken katak...@bu.edu wrote: stef salvez loggyedy at googlemail.com writes: [snip] #load library library(plyr) # utility function mean.var = function(df, var){ mean(df[[var]], na.rm = T)};

Re: [R] Replication of linear model/autoregressive model

2012-06-16 Thread Miguel Manese
Hi Al, Michael, On Sat, Jun 16, 2012 at 11:01 AM, R. Michael Weylandt michael.weyla...@gmail.com wrote: On Fri, Jun 15, 2012 at 6:56 AM, Al Ehan aehan3...@gmail.com wrote: Hi, I would like to make a replication of 10 of a linear, first order Autoregressive function, with respect to the