[R] which duplicated rows to delete

2006-10-30 Thread Søren Merser
Hi
Say I've this vector with several duplicates
x-c(1,2,3,4,2,6,2,8,2,3)

which(duplicated(x))
[1] 5  7  9 10 11

But what I realy want is somthing like:
List({2,5,7}, {3,10}, ...)

Then from each sublist I can specify which of the duplicate items to drop

res-NULL
for(vec in myDuplicateList) 
res-rbind(res, subset(data[vec,], myCrit))

I'll get some of the way by sorting my original data appropriately, as it's
the second and following rows that are 'marked' as duplicates, but that's
not quite enough

Hope for some hints
Kind regards Søren

__
R-help@stat.math.ethz.ch 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] Variables in RODBC environment

2006-10-05 Thread Søren Merser
hi, use paste:
# a string/number/date
pn -  '39R5238';
sql - paste(select u.unitid from test where part =,  pn)
^^

# an array of strings/numbers/dates
pn=c(1,2,3,4)
sql - paste(select u.unitid from test where part in (,  paste(pn, 
collapse=','), ))
^^
regards soren
obs the use of '=' and in

- Original Message - 
From: Thorsten Muehge [EMAIL PROTECTED]
To: r-help@stat.math.ethz.ch
Sent: Thursday, October 05, 2006 9:35 AM
Subject: [R] Variables in RODBC environment



 Hello Experts,
 how can I use variables in the RODBC environment.

 Example which does not work:

 Thanks for your help.

 Thorsten

 pn -  '39R5238';

 library(RODBC);
 odbcobj - odbcConnect(SQUIT21C,uid=muehge,pwd=xxx);
 sql - select
 u.unitid,
 from test
 where part in ('pn')
 ;
 parameter - sqlQuery(odbcobj,sql);
 odbcClose(odbcobj);

 __
 R-help@stat.math.ethz.ch 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-help@stat.math.ethz.ch 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] using table in R

2006-09-17 Thread Søren Merser
hi, here's a way:
 attr(table(unlist(d)),'dimnames')[[1]]
[1] 1 2 3
 as.numeric(table(unlist(d)))
[1] 1 1 2
soren

- Original Message - 
From: Bingshan Li [EMAIL PROTECTED]
To: jim holtman [EMAIL PROTECTED]
Cc: r-help@stat.math.ethz.ch
Sent: Sunday, September 17, 2006 6:14 AM
Subject: Re: [R] using table in R


 Hi Jim,

 This is the way to get the frequencies. But what I
 want is to store the elements in one vector and their
 frequencies in another vector. My problem is that when
 I call table to return the frequency table, I do not
 know how to extract these two vectors. I tried
 table(...)$dinnames and it did not work. It returned
 NULL.

 Thanks!


 --- jim holtman [EMAIL PROTECTED] wrote:

 Here is one way; you create a vector of the data in
 the dataframe with
 'unlist' and then use table:

  d = as.data.frame(matrix(c(1, 2, 3, 3), 2,2))
  d
   V1 V2
 1  1  3
 2  2  3
  table(unlist(d))

 1 2 3
 1 1 2
 


 On 9/16/06, Bingshan Li [EMAIL PROTECTED]
 wrote:
  Hi there,
 
  I have a dataframe whose elements are numbers or
  characters. I want to extract the frequencies of
 each
  elements in the dataframe. For example,
 
  d = as.data.frame(matrix(c(1, 2, 3, 3), 2,2))
 
  What I want is first what are the elements in the
 data
  (1,2,3 here) and second what are their frequencies
  (1,1,2 respectively). How to use table to
 extract
  these two pieces of information? I played with
 table
  but couldn't extract the information. Please
 assume
  that we do not know how many elements in the
 dataframe
  a priori.
 
  Thanks a lot!
 
  __
  R-help@stat.math.ethz.ch 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.
 


 -- 
 Jim Holtman
 Cincinnati, OH
 +1 513 646 9390

 What is the problem you are trying to solve?


 __
 R-help@stat.math.ethz.ch 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-help@stat.math.ethz.ch 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] survfit, unused argument(s) (error ...)

2006-07-08 Thread Søren Merser
Hi 

It seems that survfit() doesn't accept the argumnet 'error' as below  

survfit(fit, error='greenwood')
Error in survfit.coxph(fit, error = greenwood) : 
unused argument(s) (error ...)

Isn't is allowed to do that for a coxph object?

Regards Soren

Windows XP, SP2
R 2.3.0

__
R-help@stat.math.ethz.ch mailing list
https://stat.ethz.ch/mailman/listinfo/r-help
PLEASE do read the posting guide! http://www.R-project.org/posting-guide.html


[R] R(DCOM) / StatConnector and PHP

2006-05-16 Thread Søren Merser
hi
does anyone have knowledge on how to connected to StatConnector from PHP
I have tried:
 new COM(STATCONNECTORSRVLib.StatConnector) or die(Unable to 
instantiate StatConnector);
with no succes
regards soren

__
R-help@stat.math.ethz.ch mailing list
https://stat.ethz.ch/mailman/listinfo/r-help
PLEASE do read the posting guide! http://www.R-project.org/posting-guide.html


[R] integer vector to a string

2006-05-10 Thread Søren Merser
hi there
is there a way that i can coerce a vector of integers to ONE  string with 
the numbers comma separated like:
1:500  -1,2,3, ..., 500

i've tried deparse, but it divides the result into a vector of string 
(depending on the setting of width with a max of 500)

regards soren

__
R-help@stat.math.ethz.ch mailing list
https://stat.ethz.ch/mailman/listinfo/r-help
PLEASE do read the posting guide! http://www.R-project.org/posting-guide.html


[R] y-axis and resizing window

2005-06-12 Thread Søren Merser
hi
using plot(..., las=1), i.e. horizontal axis labels, the labels on the 
y-axis jams if the heigth of the graphics windov becomes too low
while both x-axis and  y-axis kind of removes superflus lables with las=0 
(default)
is there a way to make plot behave alike with horizontal lables?
regards søren

__
R-help@stat.math.ethz.ch mailing list
https://stat.ethz.ch/mailman/listinfo/r-help
PLEASE do read the posting guide! http://www.R-project.org/posting-guide.html


Re: [R] y-axis and resizing window

2005-06-12 Thread Søren Merser
thanks

with 'jams' i meant messes up, but your term overlap is exactly what i
actually had in mind

though a minor problem, do you think that the code will change to enable
checking for enough height-wise space?

regards søren

- Original Message - 
From: Prof Brian Ripley [EMAIL PROTECTED]
To: Søren Merser [EMAIL PROTECTED]
Cc: R - help r-help@stat.math.ethz.ch
Sent: Sunday, June 12, 2005 12:39 PM
Subject: Re: [R] y-axis and resizing window


On Sun, 12 Jun 2005, Søren Merser wrote:

 using plot(..., las=1), i.e. horizontal axis labels, the labels on the
 y-axis jams if the heigth of the graphics windov becomes too low
 while both x-axis and  y-axis kind of removes superflus lables with las=0
 (default)
 is there a way to make plot behave alike with horizontal lables?

It I understand you correctly (what does `jams' mean?), this is nothing to
do with resizing. The axis labelling code checks for enough width-wise
space for labels, but not for enough height-wise space. Specifically,
do_axis for the y axis contains

  /* Check room for perpendicular labels. */
  if (Rf_gpptr(dd)-las == 1 ||
  Rf_gpptr(dd)-las == 2 ||
  tnew - tlast = gap) {

so y-axis labels are always plotted for las %in% c(1,2) and hence may
overlap.  (Similar code exists for an x-axis.)

-- 
Brian D. Ripley,  [EMAIL PROTECTED]
Professor of Applied Statistics,  http://www.stats.ox.ac.uk/~ripley/
University of Oxford, Tel:  +44 1865 272861 (self)
1 South Parks Road, +44 1865 272866 (PA)
Oxford OX1 3TG, UKFax:  +44 1865 272595





 __
 R-help@stat.math.ethz.ch mailing list
 https://stat.ethz.ch/mailman/listinfo/r-help
 PLEASE do read the posting guide!
 http://www.R-project.org/posting-guide.html

__
R-help@stat.math.ethz.ch mailing list
https://stat.ethz.ch/mailman/listinfo/r-help
PLEASE do read the posting guide! http://www.R-project.org/posting-guide.html


[R] how to make an empty screen

2005-02-05 Thread Søren Merser
Hi

I want to plot control charts for several events grouped by employees.
As every employees doesn't encounter every event, a variable number of
control charts is produced in turn.
Now what I need is a way to get a new empty screen when the printout for one
employee has finished as the title lines is somhow mixed between the
changing of employees

The screen setup: 
par(mfrow=c(4,4))
And I make the title like this:
title(main=event, outer=T)

Regards soren

__
R-help@stat.math.ethz.ch mailing list
https://stat.ethz.ch/mailman/listinfo/r-help
PLEASE do read the posting guide! http://www.R-project.org/posting-guide.html


[R] setting tabstop

2004-12-29 Thread Søren Merser
hi
is it possible to change tabstop (default 8) in the GUI ?
regards soren
i'm using
   winxp sp2
   R ver. 2.0.1
__
R-help@stat.math.ethz.ch mailing list
https://stat.ethz.ch/mailman/listinfo/r-help
PLEASE do read the posting guide! http://www.R-project.org/posting-guide.html


Re: [R] setting tabstop

2004-12-29 Thread Søren Merser
you are quite right, i didn't  read the source - only sought through the 
documentation - since i would like to change tabsize from within a function
i'm printing a table aligning entries with tabs
the output is messed up if the maximum number of characters ina matrix of 
strings is to big, i.e. 8
it might not be the wrong trail, so perhaps i have to use formatC somehow
regards soren

- Original Message - 
From: Prof Brian Ripley [EMAIL PROTECTED]
To: Søren Merser [EMAIL PROTECTED]
Cc: R - help r-help@stat.math.ethz.ch
Sent: Thursday, December 30, 2004 12:34 AM
Subject: Re: [R] setting tabstop

On Wed, 29 Dec 2004, [iso-8859-1] Søren Merser wrote:
is it possible to change tabstop (default 8) in the GUI ?
regards soren
i'm using
  winxp sp2
  R ver. 2.0.1
Yes, it is possible.  Why would you want to do so?
Since you are asking, you presumably haven't explored the source code.
Hint: what do you think TABSIZE might do?
--
Brian D. Ripley,  [EMAIL PROTECTED]
Professor of Applied Statistics,  http://www.stats.ox.ac.uk/~ripley/
University of Oxford, Tel:  +44 1865 272861 (self)
1 South Parks Road, +44 1865 272866 (PA)
Oxford OX1 3TG, UKFax:  +44 1865 272595
__
R-help@stat.math.ethz.ch mailing list
https://stat.ethz.ch/mailman/listinfo/r-help
PLEASE do read the posting guide! http://www.R-project.org/posting-guide.html


Re: [R] hashing

2004-10-17 Thread Søren Merser
named lists will do
regard søren
btw thanks for the link to S Poetry
- Original Message - 
From: Patrick Burns [EMAIL PROTECTED]
To: Søren Merser [EMAIL PROTECTED]
Sent: Saturday, October 16, 2004 5:01 PM
Subject: Re: [R] hashing


As someone has stated, names of vectors are hashed.  More
generally, you can use a named list.  S Poetry mentions this.
Patrick Burns
Burns Statistics
[EMAIL PROTECTED]
+44 (0)20 8525 0696
http://www.burns-stat.com
(home of S Poetry and A Guide for the Unwilling S User)
Søren Merser wrote:
is hashing implemented in R
regards søren
__
[EMAIL PROTECTED] mailing list
https://stat.ethz.ch/mailman/listinfo/r-help
PLEASE do read the posting guide! 
http://www.R-project.org/posting-guide.html




__
[EMAIL PROTECTED] mailing list
https://stat.ethz.ch/mailman/listinfo/r-help
PLEASE do read the posting guide! http://www.R-project.org/posting-guide.html


[R] hashing

2004-10-16 Thread Søren Merser
is hashing implemented in R
regards søren
__
[EMAIL PROTECTED] mailing list
https://stat.ethz.ch/mailman/listinfo/r-help
PLEASE do read the posting guide! http://www.R-project.org/posting-guide.html


Re: [R] table and getting rownames

2004-08-18 Thread Søren Merser
exactly what i needed
thanks a lot
soren

- Original Message - 
From: Peter Dalgaard [EMAIL PROTECTED]
To: [EMAIL PROTECTED]
Cc: R-help [EMAIL PROTECTED]
Sent: Tuesday, August 17, 2004 2:35 PM
Subject: Re: [R] table and getting rownames


 [EMAIL PROTECTED] writes:
 
  hi there
  say that i have this table
  x-table(adoc, oarb)
  x
 oarb
0   1
  adoc
  ab1   0
  am5   1
  ba   14   1
  cc  271   3
  ch   87   2
  dz  362   6
  fl7   0
  fs   84   2
  
  is there an easy way to get the row names or row numbers of rows with
  oarb==0
  i.e. (ab, fl) or (1, 7)
 
 Something like
 
 which(x[,1]==0)
 rownames(x)[x[,1]==0]
 
 -- 
O__   Peter Dalgaard Blegdamsvej 3  
   c/ /'_ --- Dept. of Biostatistics 2200 Cph. N   
  (*) \(*) -- University of Copenhagen   Denmark  Ph: (+45) 35327918
 ~~ - ([EMAIL PROTECTED]) FAX: (+45) 35327907


__
[EMAIL PROTECTED] mailing list
https://stat.ethz.ch/mailman/listinfo/r-help
PLEASE do read the posting guide! http://www.R-project.org/posting-guide.html


[R] table and getting rownames

2004-08-17 Thread merser
hi there
say that i have this table
x-table(adoc, oarb)
x
   oarb
  0   1
adoc
ab1   0
am5   1
ba   14   1
cc  271   3
ch   87   2
dz  362   6
fl7   0
fs   84   2

is there an easy way to get the row names or row numbers of rows with
oarb==0
i.e. (ab, fl) or (1, 7)

regards soren

__
[EMAIL PROTECTED] mailing list
https://stat.ethz.ch/mailman/listinfo/r-help
PLEASE do read the posting guide! http://www.R-project.org/posting-guide.html


Re: [R] subset drop unused levels

2004-06-28 Thread merser
thank you
sorry, but i missed that thread
your solution works (of cause)

hopefully the code and not the documentation will be corrected as the drop
argument comes very convenient or maybe as a new option:  drop.unused.levels=T
 
regards soren

btw 
how do i interpret an assigment to a square bracket?
d2[] - lapply(d2, function(x) if (is.factor(x)) factor(x) else x) 


- Original Message - 
From: Peter Dalgaard [EMAIL PROTECTED]
To: Søren Merser [EMAIL PROTECTED]
Cc: R - help [EMAIL PROTECTED]
Sent: Sunday, June 27, 2004 11:38 AM
Subject: Re: [R] subset drop unused levels


 Søren Merser [EMAIL PROTECTED] writes:
 
  hi there
  
  tried to use subset with drop=TRUE, but all the 'old' levels are preserved,
  i.e. when calling e.g. ftable a lot of zeros are displayed
  
  x-subset(LREG,  (kir=='AA' | kir=='BB')  (type=='t1' | otype=='t2'),
  drop=TRUE, select=c(event, kir, type))
   ftable(x)
  
  i explicit have to call factor like
  ftable(event~factor(kir)+factor(type))
  
  any hints?
 
 Yes, the drop argument is misdocumented. It actually does the same as
 the drop argument to [.data.frame. It was on this very list just
 eleven days ago, see e.g. the below ref., including what to do if you
 really want to get rid of unused levels
 
 http://www.mail-archive.com/[EMAIL PROTECTED]/msg22459.html
 
 (yet another interface to the archives...)
 
 -- 
O__   Peter Dalgaard Blegdamsvej 3  
   c/ /'_ --- Dept. of Biostatistics 2200 Cph. N   
  (*) \(*) -- University of Copenhagen   Denmark  Ph: (+45) 35327918
 ~~ - ([EMAIL PROTECTED]) FAX: (+45) 35327907
 
 __
 [EMAIL PROTECTED] mailing list
 https://www.stat.math.ethz.ch/mailman/listinfo/r-help
 PLEASE do read the posting guide! http://www.R-project.org/posting-guide.html


__
[EMAIL PROTECTED] mailing list
https://www.stat.math.ethz.ch/mailman/listinfo/r-help
PLEASE do read the posting guide! http://www.R-project.org/posting-guide.html


[R] subset drop unused levels

2004-06-27 Thread Søren Merser
hi there

tried to use subset with drop=TRUE, but all the 'old' levels are preserved,
i.e. when calling e.g. ftable a lot of zeros are displayed

x-subset(LREG,  (kir=='AA' | kir=='BB')  (type=='t1' | otype=='t2'),
drop=TRUE, select=c(event, kir, type))
 ftable(x)

i explicit have to call factor like
ftable(event~factor(kir)+factor(type))

any hints?

regards soren

__
[EMAIL PROTECTED] mailing list
https://www.stat.math.ethz.ch/mailman/listinfo/r-help
PLEASE do read the posting guide! http://www.R-project.org/posting-guide.html


[R] logistic regression with temporal correlation

2004-03-18 Thread merser
Hello

We would like to perform a logistic regression analysis weighting the
independent variable in  a temporal fashion, i.e. events occuring most
recent get highest weight. Does anyone know how to do this in R??

Regards
S. Merser and S. Lophaven

__
[EMAIL PROTECTED] mailing list
https://www.stat.math.ethz.ch/mailman/listinfo/r-help
PLEASE do read the posting guide! http://www.R-project.org/posting-guide.html


[R] ftable to LaTeX

2004-01-19 Thread Søren Merser
hi there

is there a way to convert objects of class ftable into LaTex code
preserving the 'look' with row and column infomation?

xtable() {xtable} can't handle such objects and latex() {Hmisc} just texify
the number matrix,
without row/column information

regards soren

__
[EMAIL PROTECTED] mailing list
https://www.stat.math.ethz.ch/mailman/listinfo/r-help
PLEASE do read the posting guide! http://www.R-project.org/posting-guide.html


[R] multiple plot

2004-01-08 Thread merser
hi there
i've got this litle strange problem working with multiple plots i one screen
the title dissapears when more than 4 images comes up
up to 4 plots the title it shows nicely

the display is set up like:

split.screen(figs=c(3,4), erase=TRUE)

some plots

close.screen(all=T)

title(main='TITLE 1')

what am i doing wrong here

regards soren

__
[EMAIL PROTECTED] mailing list
https://www.stat.math.ethz.ch/mailman/listinfo/r-help
PLEASE do read the posting guide! http://www.R-project.org/posting-guide.html


Re: [R] title after split.screen (was multiple plot)

2004-01-08 Thread merser
par(oma=c(0,0,2,0)) and title(main='TITLE 1', outer=T)
solved my problem
i'm much obliged
kind regards soren
btw sorry for the vague subject line

__
[EMAIL PROTECTED] mailing list
https://www.stat.math.ethz.ch/mailman/listinfo/r-help
PLEASE do read the posting guide! http://www.R-project.org/posting-guide.html


[R] rw1062

2003-06-25 Thread Søren Merser
hi
I need  'rw1062.zip' since i can't get excel, R1070 or R1071 to work with the R (D)COM 
Server
everything worked fine in the god rw1062 days
the lapack routines can't be loaded
'unable to load shared library c:\r/moduleslapack.dll, the specified library could not 
be found'
don't know if it's the forward slashes that anoys windows
btw, the libraries are in the correct place
any clues to solve my problem or where to get hold on the zip file??
thanks forsoren

[[alternative HTML version deleted]]

__
[EMAIL PROTECTED] mailing list
https://www.stat.math.ethz.ch/mailman/listinfo/r-help