[R] rep for multiple categories

2011-03-28 Thread BORGMANN,Kathi
Hi,
I am R beginner and am trying to figure out how to generate a complete list of 
species for every point, visit, and year. The code below is close but does not 
give me a list of species for every point, visit, and year in my data set.

spplist-unique(sumPtCt$Species)
spplength-length(spplist)
Pointlist-unique(sumPtCt$Point)
Pointlength-length(Pointlist)
Visitlist-unique(sumPtCt$Visit)
Visitlength-length(Visitlist)
Yearlist-unique(sumPtCt$Year)
Yearlength-length(Yearlist)
s-rep(spplist, each=Pointlength, Visitlength, Yearlength)
p-rep(Pointlist, spplength)
v-rep(Visitlist, spplength)
y-rep(Yearlist, spplength)
template-data.frame(Species=s,Point=p, Visit=v, Year=y)

###merge template and data and replace NAs with 0
FinalPtCt-merge(template, sumPtCt, all=T)
FinalPtCt$Number[is.na(FinalPtCt$Number)]-0


Essentially I have data that look like this
 SPP  Point  Visit  Number
BUFF   1  1   5
WEGR   1  1   10
CLGR   1  1   15
WEGU   2  15
RUDU   2  1   15
HOGR   2  15


But I want to generate this
Spp  Point  Visit   Number
BUFF  1   1   5
WEGR  1   1   10
CLGR  1   1   15
WEGU  1   1   0
RUDU  1   1   0
HOGR  1   1   0
WEGU  2   1   5
RUDU  2   1   15
HOGR  2   1   5
BUFF  2   1   0
WEGR  2   1   0
CLGR  2   1   0

__
R-help@r-project.org mailing list
https://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.


Re: [R] Help!

2008-12-16 Thread Kathi
Laura,

Try using a different browser for your download. On MacOS X, Safari quite often 
does weird stuff to files 
I want to download, frequently damaging the files. Downloading the same file 
from the same site using 
FireFox usually works fine.

Hope this helps,

Kathi

--
DropNet AG - Das Unternehmen fuer Ihren Internet-Auftritt!

__
R-help@r-project.org mailing list
https://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.


[R] Troubles with the format of dates

2008-11-27 Thread Kathi
Dear useRs,

I'm struggling again with date-related stuff: I am using R to draw water levels 
at certain measuring 
stations. My data comes as a tab-delimited text file and looks like this:

DATUM   P1  P2
...
2006-11-16  425.21  423.99  
2006-12-15 425.12   423.97  
2007-01-16  425.16  424.06  
...

(measurements started in July 2004 and still continue on a monthly or bi-weekly 
basis)

This is then plotted using this code:

a-read.table(dummy_data.tab, sep=\t, header=TRUE, na.strings=c(0))
x-as.Date(a$DATUM)

plot(x, a$P1, axes=FALSE, xlim=c(as.Date(2004-07-01), as.Date(2009-01-01)), 
ylim=c(423,428), col=red, pch=15, type=o, ylab=Kote [m a.s.l.], 
main=Dummy Plot)
points(x, a$P2, col=red, pch=17, type=o, lty=dotted)
axis(2, at=423:428, tck=1, col=gray60)
axis.Date(1, at=seq(as.Date(2004-07-01), as.Date(2009-01-01), 
by=month), labels=seq(as.Date(2004-07-01), as.Date(2009-01-01), 
by=month), tck=1, col=gray60)

So far, I've been using this type of date format (-mm-dd) because that was 
the only way I could 
get  the whole thing to work when I started using R. However, living in 
Switzerland, I would prefer 
the dates to read 16.11.2006 i.e. dd.mm. or 16. Nov. 2006 (preferably using 
German names for 
the months, if possible). 

I've used the chron package to convert my dates to day mon year (16 Nov 2006, 
with or without 
spaces), i.e. I replaced the second line of code with:

x-format(chron(as.character(a$DATUM), format=y-m-d, out.format=day mon 
year))

but then I can't plot them any more, because as.Date() no longer is the correct 
function and R gives 
me an error saying there is an invalid xlim-value. Can someone please point me 
in the right 
direction?

I could easily change the input data to be in dd.mm. format, if that helps.

Thanks for your help,

Kathi


--
DropNet AG - Das Unternehmen fuer Ihren Internet-Auftritt!

__
R-help@r-project.org mailing list
https://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.


Re: [R] Troubles with the format of dates

2008-11-27 Thread Kathi
Thank you _SO_ much, Petr, you helped me again. That worked like a charm, 
exactly what I needed! 

Cheers,
Kathi 

On Thu, 27 Nov 2008 15:01:29 +0100, Petr PIKAL wrote
 Hi
 
 [EMAIL PROTECTED] napsal dne 27.11.2008 14:20:17:
 
  Dear useRs,
  
  I'm struggling again with date-related stuff: I am using R to draw water
 
  levels at certain measuring 
  stations. My data comes as a tab-delimited text file and looks like 
 this:
  
  DATUM   P1   P2
  ...
  2006-11-16   425.21   423.99 
  2006-12-15 425.12   423.97 
  2007-01-16   425.16   424.06 
  ...
  
  (measurements started in July 2004 and still continue on a monthly or 
 bi-weekly basis)
  
  This is then plotted using this code:
  
  a-read.table(dummy_data.tab, sep=\t, header=TRUE, na.strings=c(0))
  x-as.Date(a$DATUM)
  
  plot(x, a$P1, axes=FALSE, xlim=c(as.Date(2004-07-01), 
 as.Date(2009-01-01)), 
  ylim=c(423,428), col=red, pch=15, type=o, ylab=Kote [m a.s.l.], 
  main=Dummy Plot)
  points(x, a$P2, col=red, pch=17, type=o, lty=dotted)
  axis(2, at=423:428, tck=1, col=gray60)
  axis.Date(1, at=seq(as.Date(2004-07-01), as.Date(2009-01-01), 
  by=month), labels=seq(as.Date(2004-07-01), as.Date(2009-01-01), 
  by=month), tck=1, col=gray60)
  
  So far, I've been using this type of date format (-mm-dd) because 
 that was
  the only way I could 
  get  the whole thing to work when I started using R. However, living in 
  Switzerland, I would prefer 
  the dates to read 16.11.2006 i.e. dd.mm. or 16. Nov. 2006 
 (preferably 
  using German names for 
  the months, if possible). 
  
  I've used the chron package to convert my dates to day mon year (16 Nov 
 2006, 
  with or without 
  spaces), i.e. I replaced the second line of code with:
  
  x-format(chron(as.character(a$DATUM), format=y-m-d, out.format=day 
 mon year))
 
 Although I am not an expert in time/date functions it seems to me 
 that you just want your labels to be in your preferred format. If it 
 is the case
 
 labels = format(seq(as.Date(2004-07-01), as.Date(2009-01-01), 
 by=month), %d.%m.%Y)
 
 in your call to axisDate can help you to achieve it.
 
 Regards
 Petr
 
  
  but then I can't plot them any more, because as.Date() no longer is the 
  correct function and R gives 
  me an error saying there is an invalid xlim-value. Can someone please 
 point me
  in the right 
  direction?
  
  I could easily change the input data to be in dd.mm. format, if that 
 helps.
  
  Thanks for your help,
  
  Kathi
  
  
  --
  DropNet AG - Das Unternehmen fuer Ihren Internet-Auftritt!
  
  __
  R-help@r-project.org mailing list
  https://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.


--
DropNet AG - Das Unternehmen fuer Ihren Internet-Auftritt!

__
R-help@r-project.org mailing list
https://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.


Re: [R] How to sign off this list

2008-10-30 Thread Kathi
Hi John

I had the same problem: signed onto the list, then got flooded by too many 
emails. So I changed my 
personal settings to the digest mode (see link below). That means that once a 
day I get *ONE* email 
which summarizes the help list email traffic of that day. Then I can fly 
through its index to see what's 
going on. There's even an option to turn off delivery of mails from the help 
list temporarily, so your 
mail account doesn't get flooded while you are on holidays etc.

Hope this helps,

Kathi Dubach


 To subscribe or unsubscribe via the World Wide Web, visit
   https://stat.ethz.ch/mailman/listinfo/r-help
 or, via email, send a message with subject or body 'help' to
   [EMAIL PROTECTED]
 


--
DropNet AG - Das Unternehmen fuer Ihren Internet-Auftritt!

__
R-help@r-project.org mailing list
https://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.


[R] newbie needs help plotting time series

2008-06-30 Thread Kathi
Dear R help list

I have recently started using R to visualize time series of water level 
measurements. The code I wrote 
does exactly what I want:

plot(x, a$B112, axes=FALSE, ylim=c(405,410), col=red, pch=15, 
type=o, ylab=metres above sea level, main=Main Plot Title)
axis(2, at=405:410, tck=1, col=gray60)
axis.Date(1, at=seq(as.Date(2004-01-01), as.Date(2008-06-01), 
by=month), labels=seq(as.Date(2004-01-01), as.Date(2008-06-01), 
by=month), tck=1, col=gray60)

Now I wanted to shift the data visualized by 6 months, so I replaced 
2004-01-01 by 2004-07-01 
and 2008-06-01 by 2008-12-01. Instead of the desired plot, I get an error 
message stating 
(forgive the perhaps faulty translation into English, I'm working on a German 
version of R):

mistake in axis(side, at = z, labels = labels, ...) : 
  length of 'at' and 'labels' different, 50 != 54

What have I done wrong? Thank you very much for your help!

Katharina Dubach

__
R-help@r-project.org mailing list
https://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.