[R] Date object and origin BC

2011-12-08 Thread smu
hi everybody, is this intended behaviour? x - as.Date('0-01-01') as.Date(as.character(x)) [1] 0-01-01 a - x - 365 as.Date(a) [1] -1-01-01 as.Date(as.character(a)) Error in charToDate(x) : character string is not in a standard unambiguous format Is this a bug? I found this, while trying

Re: [R] Error in sink(output.txt) : sink stack is full

2010-02-28 Thread smu
hi, It is a good idea not to reply to existing messages, if you want to open a new subject. On Sun, Feb 28, 2010 at 06:33:00PM +, Amy Hessen wrote: Hi, After some runs to my program, I receive this error message: ?Error in sink(output.txt) : sink stack is full? Could you

Re: [R] ggplot 'annotate problem' again.

2010-02-28 Thread smu
= 0, vjust = 0) regards, Stefan On Sun, Feb 28, 2010 at 01:25:15PM -0800, John Kane wrote: I had a problem annotating a graph last year ( see http://n4.nabble.com/Putting-names-on-a-ggplot-td907158.html#a907158 for the discussion) Stefan (smu) provided a solution using annotate

Re: [R] simple data manipulation question

2009-12-10 Thread smu
for example: d = data.frame(gender=c(m,f,unkown), x=rnorm(300)) tapply(d$x,d$gender,mean) f munkown 0.0787628409 0.0940534765 -0.0005323276 regards, stefan On Wed, Dec 09, 2009 at 04:50:37PM -0800, dolar wrote: Hi there I have a dataframe of a whole

Re: [R] Replace Values in Matrix

2009-11-27 Thread smu
matritz[is.na(matritz)] - 0 On Fri, Nov 27, 2009 at 04:15:45PM -0200, Romildo Martins wrote: Hello, how to replace the NA by number zero? matrizt [,1] [,2] [,3][,4] [1,] 1.000NA NA NA [2,] 0.6717685

Re: [R] Feature request for as.Date() function

2009-11-25 Thread smu
hi, it fails, when the NA is surrounded by double quotes, which is the default way of quoting of the write.table command. x - read.csv(textConnection('date,value + + 2009-01-01,10 + + 2009-02-01,1 + + NA, 3'), colClasses=c(Date, 'integer')) Fehler in fromchar(x) : character string is not in a

Re: [R] Classification

2009-11-20 Thread smu
Hello, x - c(3,5,7,3,9,7) as.numeric(as.factor(x)) [1] 1 2 3 1 4 3 regards, stefan On Fri, Nov 20, 2009 at 12:02:59AM -0800, Chris Li wrote: Hi all, I have got a dataset like the following: 3 5 7 3 9 7 i.e. random numbers with some repeats. I want R to classify them

Re: [R] Sum over indexed value

2009-11-16 Thread smu
P=data.frame(x=c(1,1,2,3,2,1),y=rnorm(6)) tapply(P$y,P$x,sum) regards, stefan On Mon, Nov 16, 2009 at 09:49:17AM -0800, Gunadi wrote: I am sure this is easy but I am not finding a function to do this. I have two columns in a matrix. The first column contains multiple entries of

Re: [R] Writing a data frame in an excel file

2009-11-16 Thread smu
hello, sep=\n will seperate each column by \n which is not what you want. I think a csv would be the best solution. write.table(yourdataframe,sep=,) or use write.csv directly. regards, stefan On Mon, Nov 16, 2009 at 11:49:28AM -0800, anna_l wrote: Hello, I am having trouble by using the

[R] partial cumsum

2009-11-11 Thread smu
Hello, I am searching for a function to calculate partial cumsums. For example it should calculate the cumulative sums until a NA appears, and restart the cumsum calculation after the NA. this: x - c(1, 2, 3, NA, 5, 6, 7, 8, 9, 10) should become this: 1 3 6 NA 5 11 18 26 35 45 any

Re: [R] partial cumsum

2009-11-11 Thread smu
On Wed, Nov 11, 2009 at 08:53:50AM -0800, William Dunlap wrote: Perhaps ave(x, rev(cumsum(rev(is.na(x, FUN=cumsum) [1] 1 3 6 NA 5 11 18 26 35 45 it takes some time to understand how it works, but it's perfect. thank you, stefan

Re: [R] sum two columns with same value

2009-10-17 Thread smu
On Sat, Oct 17, 2009 at 09:36:50AM +0200, Alfredo Alessandrini wrote: Hi, I've two dataframe: snag_totale AREA snag_ha 12 1.628128 23 10.274249 34 2.778503 45 73.764307 57 12.015985 log_totale AREAlog_ha 11 22.29846 22 17.16889 33

Re: [R] Putting names on a ggplot

2009-10-17 Thread smu
hi, On Sat, Oct 17, 2009 at 02:04:43PM -0700, John Kane wrote: Putting names on a ggplot p - p + geom_text(aes(x = namposts + 2.5, y = temprange[2], label = mlabs), data = year, size = 2.5, colour='black', hjust = 0, vjust = 0) you shouldn't use aes in this case since nampost,

Re: [R] Color of graph

2009-10-01 Thread smu
abline(m1, col=red) regards, Stefan On Thu, Oct 01, 2009 at 09:57:11AM -0400, Ashta wrote: I am trying to plot a line graph for 3 or more regression lines abline(m1) abline(m2) abline(m3) Can I change the color of each line? if so how? Thanks in advance Ashta

Re: [R] ggplot2 graphing multiple lines of data

2009-09-14 Thread smu
hey, On Mon, Sep 14, 2009 at 07:51:42AM -0700, John Kane wrote: p - ggplot(bmm, aes(x=age, y=bm, colour=pp, group=pp)) p - p + geom_line() remove the quotes and it will work: ggplot(bmm, aes(x=age, y=bm, colour=pp, group=pp))+geom_line() regards, Stefan

[R] local sequence function

2009-09-14 Thread smu
hey, I can not find a function for the following problem, hopefully you can help me. I have a vactor like this one v = c(NA,NA,TRUE,TRUE,NA,TRUE,NA,TRUE,TRUE,TRUE) and I would like to the TRUE values by the their local sequence number. This means, the result should look thike this:

Re: [R] source compile and problem with Hmisc

2009-07-23 Thread smu
On Thu, Jul 23, 2009 at 12:16:36PM +0200, Stefan wrote: I want to compile R version 2.9.1 on debian stable but the make command stops with this message: ... begin installing recommended package VR Error in library(Hmisc, verbose = FALSE) : there is no package called 'Hmisc' Execution

Re: [R] Question on qplot

2009-07-18 Thread smu
hey, On Sat, Jul 18, 2009 at 01:52:34AM -0700, RON70 wrote: Hi, suppose I have following codes : library(zoo); library(ggplot2) dat - matrix(rnorm(500*2), 500); dat - zooreg(dat, start = as.Date(01/01/01, %m/%d/%y), frequency=1); plot(dat) head(dat); month.no - format(index(dat), %m);