[R] Odp: tabulating 2 factors weighting by a third var

2010-12-19 Thread Petr PIKAL
Hi r-help-boun...@r-project.org napsal dne 20.12.2010 07:07:35: > Hi, > > This must be an easy one but so far I haven't find a way out... > > I have a data frame such as: > > $ v1: Factor w/ 5 levels > $ v2: Factor w/ 2 levels > $ v3: Class 'difftime' atomic [1:] > > basical

Re: [R] tabulating 2 factors weighting by a third var

2010-12-19 Thread Gerrit Eichner
Hi, Luca, if V is you data frame, maybe with( V, tapply( v3, list( v1, v2), sum)) does what you want. Hth -- Gerrit On Mon, 20 Dec 2010, Luca Meyer wrote: Hi, This must be an easy one but so far I haven't find a way out... I have a data frame such as: $ v1: Factor w/ 5 levels $ v2

[R] package "arules" - 'transpose' of the transactions

2010-12-19 Thread Kohleth Chia
Suppose this is my list of transactions: set.seed(200) tran=random.transactions(100,3) inspect(tran) itemstransactionID 1 {item80}trans1 2 {item8, item20}trans2 3 {item28}trans3 I want to get the 'transpose' of the data, i.e. transactionID items 1 {trans2

[R] tabulating 2 factors weighting by a third var

2010-12-19 Thread Luca Meyer
Hi, This must be an easy one but so far I haven't find a way out... I have a data frame such as: $ v1: Factor w/ 5 levels $ v2: Factor w/ 2 levels $ v3: Class 'difftime' atomic [1:] basically v1 and v2 are factors, while v3 is a variable containing the duration of certain acti

Re: [R] R.matlab memory use

2010-12-19 Thread Ben Bolker
Stefano Ghirlanda gmail.com> writes: > I am trying to load into R a MATLAB format file (actually, as saved by > octave). The file is about 300kB but R complains with a memory > allocation error: > > > library(Rcompression) > > library(R.matlab) > Loading required package: R.oo > Loading required

Re: [R] Time Series of Histograms

2010-12-19 Thread Enrico R. Crema
Hi Jorge, Yes this was exactly what I was looking for! Many Thanks!!! E. On 20 Dec 2010, at 02:11, Jorge Ivan Velez wrote: > Hi Enrico, > > Is this close to what you want to do? > > http://addictedtor.free.fr/graphiques/RGraphGallery.php?graph=109 > > HTH, > Jorge > > > On Sun, Dec 19, 2010

Re: [R] monthly median in a daily dataset

2010-12-19 Thread Bill.Venables
I find this function useful for digging out months from Date objects Month <- function(date, ...) factor(month.abb[as.POSIXlt(date)$mon + 1], levels = month.abb) For this little data set below this is what it gives > with(data, tapply(value, Month(date), median, na.rm = TRUE)) Jan Feb M

Re: [R] Time Series of Histograms

2010-12-19 Thread Jorge Ivan Velez
Hi Enrico, Is this close to what you want to do? http://addictedtor.free.fr/graphiques/RGraphGallery.php?graph=109 HTH, Jorge On Sun, Dec 19, 2010 at 7:03 PM, Enrico R. Crema <> wrote: > Dear List, > > I have a set of distributions recorded at an equal interval of time and I > would like to p

Re: [R] Time Series of Histograms

2010-12-19 Thread Enrico R. Crema
Many Thanks Dennis, The distributions are simulated ordinal data all bounded in the same upper and lower limit, and I wanted to plot how the distribution changes through time. Since the distributions are often multimodal boxplots were not useful so I made some violinplots... My practical soluti

Re: [R] Time Series of Histograms

2010-12-19 Thread Dennis Murphy
Hi: You can get a violin plot in lattice rather straightforwardly. It's easiest if time is an ordered factor, but you can also do it if time is numeric; in the latter case, the code associated with Figure 10.14 in the Lattice book provides a template to start with: http://lmdvr.r-forge.r-project.o

Re: [R] system/system2 command

2010-12-19 Thread Duncan Murdoch
On 17/12/2010 4:36 PM, Jeff Breiwick wrote: All, I had a simple function call I used to open up a dos shell running R under Win XP: system("cmd.exe", wait=FALSE, invisible=FALSE). This does not work with R 2.12.1 - I get a window that briefly flashes open but then disappears. Does anyone know t

Re: [R] Turning a Variable into String

2010-12-19 Thread Duncan Murdoch
On 19/12/2010 7:21 PM, Paolo Rossi wrote: I would like to know how to turn a variable into a string. I have tried as.symbol and as.name but it doesnt work for what I'd like to do Essentially, I'd like to feed the function below with two variables. This works fine in the bit working out number of

Re: [R] Turning a Variable into String

2010-12-19 Thread Phil Spector
Paolo - One way to make the function do what you want is to replace the line print(sprintf("OK with %s and %s\n", var1, var2)) with cat('OK with',substitute(var1),'and',substitute(var2),'\n') With sprintf, you'd need print(sprintf("OK with %s and %s\n", deparse(substitute(var1)), depa

[R] Turning a Variable into String

2010-12-19 Thread Paolo Rossi
I would like to know how to turn a variable into a string. I have tried as.symbol and as.name but it doesnt work for what I'd like to do Essentially, I'd like to feed the function below with two variables. This works fine in the bit working out number of elements in each variable. In the print(sp

[R] Time Series of Histograms

2010-12-19 Thread Enrico R. Crema
Dear List, I have a set of distributions recorded at an equal interval of time and I would like to plot them as series of horizontal histograms (with the x-axis representing time, and y-axis representing the bins) since the distribution shifts from unimodal to multimodal in several occasions.

Re: [R] monthly median in a daily dataset

2010-12-19 Thread Dennis Murphy
Hi: There is a months() function associated with Date objects, so you should be able to do something like aggregate(value ~ months(date), data = data$flow$daily, FUN = median) Here's a toy example because your data are not in a ready form: df <- data.frame(date = seq(as.Date('2010-01-01'), by =

[R] monthly median in a daily dataset

2010-12-19 Thread HUXTERE
Hello, I have a multi-year dataset (see below) with date, a data value and a flag for the data value. I want to find the monthly median for each month in this dataset and then plot it. If anyone has suggestions they would be greatly apperciated. It should be noted that there are some dates with n

Re: [R] Ifelse stability problems?

2010-12-19 Thread peter dalgaard
On Dec 19, 2010, at 15:01 , Peter Ehlers wrote: > On 2010-12-19 03:50, Luca Meyer wrote: >> I am just wondering why what I am showing below might occur. >> >> First I have an x data.frame: >> >>> str(x) >> 'data.frame': 281 obs. of 2 variables: >> $ x1 : Factor w/ 5 levels "A (50-67%)","B

Re: [R] Hershey fonts and substitute()

2010-12-19 Thread David Winsemius
On Dec 19, 2010, at 3:25 PM, pilchat wrote: Hello R users, I am new to R, so this may be a very stupid question. I need to subscript the dotted circle (Hershey escape sequence "\\SO") to a string. I tried using text(.5,.5,substitute( R[disk] == 5 R["\\SO"] ) ) but it turns out to be

Re: [R] levelplot blocks size

2010-12-19 Thread Duncan Murdoch
On 19/12/2010 2:46 PM, jonathan wrote: Duncan, Thanks for the help. I'm new to R, so I'm not sure how to get R to round the values and "group" them into larger blocks. I have tried the following: xlim=seq(0,2000,100),ylim=seq(0,2000,100) just to see if it would work, but it doesn't... Do y

Re: [R] Layout of mulitpage conditioned lattice plots

2010-12-19 Thread David Winsemius
On Dec 19, 2010, at 1:53 PM, Dieter Menne wrote: David Winsemius wrote: What's not working? I see two pages output with "the same layout". The difference is that in the second case your numbers of groups (subj x comp) is not an even multiple of your layout numbers, so the 13 subj leve

[R] Hershey fonts and substitute()

2010-12-19 Thread pilchat
Hello R users, I am new to R, so this may be a very stupid question. I need to subscript the dotted circle (Hershey escape sequence "\\SO") to a string. I tried using text(.5,.5,substitute( R[disk] == 5 R["\\SO"] ) ) but it turns out to be a syntax error. Do you have any suggestion? Th

Re: [R] levelplot blocks size

2010-12-19 Thread jonathan
Duncan, Thanks for the help. I'm new to R, so I'm not sure how to get R to round the values and "group" them into larger blocks. I have tried the following: xlim=seq(0,2000,100),ylim=seq(0,2000,100) just to see if it would work, but it doesn't... Do you think you might be able to explain how

Re: [R] levelplot blocks size

2010-12-19 Thread Duncan Murdoch
On 19/12/2010 2:10 PM, jonathan wrote: Sorry to bump this up again, but I've been continuing to look for a solution to this including a look into stats.bin but I still can't find any solution to do this within R. See ?levelplot. The number of bins of x and y is equal to the number of unique

[R] R.matlab memory use

2010-12-19 Thread Stefano Ghirlanda
Hi, I am trying to load into R a MATLAB format file (actually, as saved by octave). The file is about 300kB but R complains with a memory allocation error: > library(Rcompression) > library(R.matlab) Loading required package: R.oo Loading required package: R.methodsS3 R.methodsS3 v1.2.0 (2010-03-1

Re: [R] Layout of mulitpage conditioned lattice plots

2010-12-19 Thread Dieter Menne
Here is an example with ggplot2, which can also be used in a similar way with lattice. Again, the last page is the problem: the arrangement is correct here, but the last page (with 1 instead of 5 plots) has a different panel size which makes a comparison difficult. And, since I have much more poi

Re: [R] Replacing the for loop for time series buid-up

2010-12-19 Thread Berend Hasselman
Torch wrote: > > Hi, > is there a function that replaces the following code? > > n=200 > boot.x[1]=odhad+boot.res[1] #(boot.x[0]=1) > > for (j in 1:(n-1)) { > boot.x[j+1]=odhad*boot.x[j]+boot.res[j+1] > } > > This is nested in two other loops, and I am looking for some way

Re: [R] levelplot blocks size

2010-12-19 Thread jonathan
Sorry to bump this up again, but I've been continuing to look for a solution to this including a look into stats.bin but I still can't find any solution to do this within R. Any help would be much appreciated! Thanks, Jonathan -- View this message in context: http://r.789695.n4.nabble.com/lev

Re: [R] Layout of mulitpage conditioned lattice plots

2010-12-19 Thread Dieter Menne
David Winsemius wrote: > > > > What's not working? I see two pages output with "the same layout". The > difference is that in the second case your numbers of groups (subj x > comp) is not an even multiple of your layout numbers, so the 13 subj > levels push 3 of the A's onto the new row

Re: [R] Layout of mulitpage conditioned lattice plots

2010-12-19 Thread Dieter Menne
djmuseR wrote: > > > If I read your intention correctly, you need a third element in layout = . > > df <- data.frame(month = rep(month.abb, each = 20), > time = rep(1:20, 12), > y = rnorm(240)) > xyplot(y ~ time | month, data = df, layout = c(2, 2, 3)) > >

[R] Hclust - Number of branch operations for every element

2010-12-19 Thread Lui
Hello everybody, I need to know how often every element in an hierarchical cluster was "branched" - just imagine a watering pot on the top of the hierarchical tree -> the leafs should get water according to the number of branches that lie before them. For example: a <- list() # initialize e

Re: [R] Change legend position in s.value {ade4}

2010-12-19 Thread Uwe Ligges
Looking at the code shows this is hard coded (function scatterutil.legend.square.grey or friends are used that make use of par("usr")[1] and par("usr")[3]. Hence you will have to rewrite the code or even better provide thwe package maintainer with a patch that allows for arbitrary placemant o

Re: [R] Alternative to extended recode sintax? Bug?

2010-12-19 Thread Uwe Ligges
On 19.12.2010 13:20, David Winsemius wrote: On Dec 19, 2010, at 5:11 AM, Luca Meyer wrote: Something goes wrong with the week function of the lubridate package: x= as.POSIXct(factor(c("2010-12-15 17:28:27", + "2010-12-15 17:32:34", + "2010-12-15 18:48:39", + "2010-12-15 19:25:00", + "2010

Re: [R] Layout of mulitpage conditioned lattice plots

2010-12-19 Thread Thomas Adams
Dennis, Thank you; this helps me, too! Tom On 12/19/10 11:45 AM, Dennis Murphy wrote: Hi Dieter: If I read your intention correctly, you need a third element in layout = . Here's a little example: df<- data.frame(month = rep(month.abb, each = 20), time = rep(1:20, 12),

Re: [R] Layout of mulitpage conditioned lattice plots

2010-12-19 Thread David Winsemius
On Dec 19, 2010, at 11:23 AM, Dieter Menne wrote: Dear latticists, I would like to spread a lattice conditioned plot over multiple pages, keeping the same layout as if I had only one page as shown in the code below. My workaround is to divide the dataframe into subset that fit on one page,

Re: [R] Layout of mulitpage conditioned lattice plots

2010-12-19 Thread Dennis Murphy
Hi Dieter: If I read your intention correctly, you need a third element in layout = . Here's a little example: df <- data.frame(month = rep(month.abb, each = 20), time = rep(1:20, 12), y = rnorm(240)) xyplot(y ~ time | month, data = df, layout = c(2, 2, 3)) Th

[R] Layout of mulitpage conditioned lattice plots

2010-12-19 Thread Dieter Menne
Dear latticists, I would like to spread a lattice conditioned plot over multiple pages, keeping the same layout as if I had only one page as shown in the code below. My workaround is to divide the dataframe into subset that fit on one page, but the code is ugly. Is there a build-in way to achi

Re: [R] barplot: width of label

2010-12-19 Thread David Winsemius
On Dec 19, 2010, at 10:55 AM, Peter Ehlers wrote: On 2010-12-19 07:13, fransiepansiekevertje wrote: Hello, I try to make barplots with rather wide labels. A simplified example of this: x<- c(12, 33, 56, 67, 15, 66) names(x)<- c('Richard with a long surname','Minnie with a long name,'Albert

Re: [R] barplot: width of label

2010-12-19 Thread Peter Ehlers
On 2010-12-19 07:13, fransiepansiekevertje wrote: Hello, I try to make barplots with rather wide labels. A simplified example of this: x<- c(12, 33, 56, 67, 15, 66) names(x)<- c('Richard with a long surname','Minnie with a long name,'Albert','Helen','Joe','Kingston') barplot(x, las = 2) Now the

[R] barplot: width of label

2010-12-19 Thread fransiepansiekevertje
Hello, I try to make barplots with rather wide labels. A simplified example of this: x <- c(12, 33, 56, 67, 15, 66) names(x) <- c('Richard with a long surname','Minnie with a long name,'Albert','Helen','Joe','Kingston') barplot(x, las = 2) Now the label 'Richard with a long surname' is too long t

Re: [R] Replacing the for loop for time series buid-up

2010-12-19 Thread David Winsemius
On Dec 19, 2010, at 8:08 AM, Torch wrote: Hi, is there a function that replaces the following code? n=200 boot.x[1]=odhad+boot.res[1] #(boot.x[0]=1) No. there is no boot.x[0] ... in R anyway. for (j in 1:(n-1)) { boot.x[j+1]=odhad*boot.x[j]+boot.res[j+1] } This is nested

[R] sum with times

2010-12-19 Thread Ronaldo Reis Junior
Hi, Forget, the chron package work with this Thanks Ronaldo -- 8ª lei - Colete seus dados hoje como se você soubesse que seu equipamento vai quebrar amanhã. --Herman, I. P. 2007. Following the law. NATURE, Vol 445, p. 228. > Prof. Ronaldo Reis Júnior | .''`. UNIMONTES/DBG/L

[R] sum with times

2010-12-19 Thread Ronaldo Reis Junior
Hi, I have this vector: > A <- c("00:00:36","00:02:18") > A [1] "00:00:36" "00:02:18" I use as.difftime to convert this to time vector based > B <- as.difftime(A) > B Time differences in secs [1] 36 138 attr(,"tzone") [1] "" Now i try to make a sum > sum(B) Time difference of 174 secs

Re: [R] Ifelse stability problems?

2010-12-19 Thread Peter Ehlers
On 2010-12-19 03:50, Luca Meyer wrote: I am just wondering why what I am showing below might occur. First I have an x data.frame: str(x) 'data.frame': 281 obs. of 2 variables: $ x1 : Factor w/ 5 levels "A (50-67%)","B (10-20%)",..: 1 2 5 1 2 5 1 2 5 1 ... $ x2 : num 33.8 60.2 6 7

[R] Replacing the for loop for time series buid-up

2010-12-19 Thread Torch
Hi, is there a function that replaces the following code? n=200 boot.x[1]=odhad+boot.res[1] #(boot.x[0]=1) for (j in 1:(n-1)) { boot.x[j+1]=odhad*boot.x[j]+boot.res[j+1] } This is nested in two other loops, and I am looking for some way to improve code performance I tried sap

Re: [R] Resource for learning C/R interface

2010-12-19 Thread Mike Marchywka
> Date: Sun, 19 Dec 2010 01:34:28 -0500 > From: mailinglist.honey...@gmail.com > To: cjul...@bu.edu > CC: r-help@r-project.org > Subject: Re: [R] Resource for learning C/R interface > > Hi, > > On Sat, Dec 18, 2010 at 11:29 PM, Julian TszKin Chan wro

Re: [R] Random selection from a subsample

2010-12-19 Thread David Winsemius
On Dec 19, 2010, at 5:31 AM, Tom Wilding wrote: Dear Mailing List I have a data set (data4) consisting of a number of factors and a response variable. I wish to randomly sample from a combination of two of those factors (GIS_station and Distance_code2) and return a new dataframe contain

Re: [R] Alternative to extended recode sintax? Bug?

2010-12-19 Thread David Winsemius
On Dec 19, 2010, at 5:11 AM, Luca Meyer wrote: Something goes wrong with the week function of the lubridate package: x= as.POSIXct(factor(c("2010-12-15 17:28:27", + "2010-12-15 17:32:34", + "2010-12-15 18:48:39", + "2010-12-15 19:25:00", + "2010-12-16 08:00:00", + "2010-1

[R] Ifelse stability problems?

2010-12-19 Thread Luca Meyer
I am just wondering why what I am showing below might occur. First I have an x data.frame: > str(x) 'data.frame': 281 obs. of 2 variables: $ x1 : Factor w/ 5 levels "A (50-67%)","B (10-20%)",..: 1 2 5 1 2 5 1 2 5 1 ... $ x2 : num 33.8 60.2 6 76.8 13.8 9.4 76.9 8 15.1 78.1 ... I need t

[R] Random selection from a subsample

2010-12-19 Thread Tom Wilding
Dear Mailing List I have a data set (data4) consisting of a number of factors and a response variable. I wish to randomly sample from a combination of two of those factors (GIS_station and Distance_code2) and return a new dataframe containing the original data structure (i.e. all the columns)

Re: [R] Alternative to extended recode sintax? Bug?

2010-12-19 Thread Luca Meyer
Something goes wrong with the week function of the lubridate package: > x= as.POSIXct(factor(c("2010-12-15 17:28:27", + "2010-12-15 17:32:34", + "2010-12-15 18:48:39", + "2010-12-15 19:25:00", + "2010-12-16 08:00:00", + "2010-12-16 08:25:49", + "2010-12-16 09:00:00"))) > re

Re: [R] testing with if: what I am doing wrong?

2010-12-19 Thread Duncan Murdoch
On 18/12/2010 8:34 AM, Luca Meyer wrote: I am running this small program: x<- factor(c("A","B","A","C")) y<- c(1,2,3,4) w<-data.frame(x,y) if (w$x=="A"){ w$z=1 } w And I obtain: x y z 1 A 1 1 2 B 2 1 3 A 3 1 4 C 4 1 And not x y z 1 A 1 1 2 B 2 NA 3 A 3 1 4 C 4 NA Like I should

Re: [R] bugs in R windows versie 12 ?

2010-12-19 Thread Duncan Murdoch
On 19/12/2010 3:00 AM, elprama wrote: Dear R-users, When you perform "run line or selection" / "Ctrl + R" in a script window then the cursor of the script window does not go to the next line but at a place further downwards. R windows version 11 does the correct job (= goes to the next line) bu

[R] testing with if: what I am doing wrong?

2010-12-19 Thread Luca Meyer
I am running this small program: x <- factor(c("A","B","A","C")) y <- c(1,2,3,4) w <-data.frame(x,y) if (w$x=="A"){ w$z=1 } w And I obtain: x y z 1 A 1 1 2 B 2 1 3 A 3 1 4 C 4 1 And not x y z 1 A 1 1 2 B 2 NA 3 A 3 1 4 C 4 NA Like I should obtain. What am I doing wrong? Please not

[R] bugs in R windows versie 12 ?

2010-12-19 Thread elprama
Dear R-users, When you perform "run line or selection" / "Ctrl + R" in a script window then the cursor of the script window does not go to the next line but at a place further downwards. R windows version 11 does the correct job (= goes to the next line) but version 12 does not. Is this correct ?

Re: [R] Title for y-axis on right side

2010-12-19 Thread Jim Lemon
On 12/17/2010 10:41 PM, phils_mu...@arcor.de wrote: Hi, I want to have a title for the y-axis on the right side of the plot. I know how to do it on the left side: title(ylab="Title for y-axis") But how can I have the title on the right side? Hi Phil, You probably want to add some margin on