Re: [R] Bar Plots: Error Bars

2009-12-03 Thread Jeremy Baxter
Brett

Hi

Searching http://www.Rseek.org will return many similar results. You might find 
the following useful in terms of your question re aligning the bars:

http://users.fmg.uva.nl/rgrasman/rpages/2005/09/error-bars-in-plots.html

The discussion on this page also refers to the errbar function in the Hmisc 
package. There are other options, searching Rseek will provide many!

Basically something along the lines of the following will 'fix' your graph:

marks - sample(4:10, size=50, replace=TRUE)
dim(marks) - c(10,5)   
classavg - colMeans (marks, na.rm=FALSE, dims = 1)

thegraph - barplot(classavg, main=Class Average for Quizzes, xlab=Quiz, 
ylab=Average, names = c(1,2,3,4,5), ylim=c(0,12), axis.lty=1)
str(thegraph)
max - apply (marks, 2, max)
min - apply (marks, 2, min) 
arrows(thegraph, min, thegraph, max, code=3, angle=90, length=0.125)  

HTH,
Jeremy

 Hey Everyone,

 I'm pretty new at R and wanted to try and make some graphs with dummy data
 before using it to analyze my own. I successfully made a bar graph and
 error bars, but I can't figure out how to align them properly (currently
 they are not centered on the bars and some of them aren't even close).
 Here's the

 code that I'm using:
  marks - sample(4:10, size=50, replace=TRUE)
  dim(marks) - c(10,5)
  classavg - colMeans (marks, na.rm=FALSE, dims = 1)
  barplot(classavg, main=Class Average for Quizzes, xlab=Quiz,
  ylab=Average, names = c(1,2,3,4,5), ylim=c(0,12), axis.lty=1)

 box()

  max - apply (marks, 2, max)
  min - apply (marks, 2, min)
  arrows(1:5, min, 1:5, max, code=3, angle=90, length=0.125)

 The error bars are simply ranges for now (I wanted to do that before I
 tried standard deviation/error). If anyone could help me align them it
 would be much appreciated!

 brett
---
Jeremy Baxter, Statistics Department, Rhodes University, South Africa.
Views expressed above, no matter how badly spelt, are my own... I think?

[[alternative HTML version deleted]]

__
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] Normal tests disagree?

2009-12-03 Thread GlenB



rkevinburton wrote:
 
 If I have data that I feed into shapio.test and jarque.bera.test yet they
 seem to disagree. What do I use for a decision?
 
 For my data set I have p.value of 0.05496421 returned from the
 shapiro.test and 0.882027 returned from the jarque.bera.test. I have
 included the data set below.
 

The explanation is quite simple - different tests for normality concentrate
on different aspects of nonnormality and so are sensitive to different kinds
of departures from it.

Your sample is distinctly non-normal looking, but in a way that the
jarque-bera test is insensitive to (the sample skewness and kurtosis are
entirely unremarkable, being well within the typical range of values from a
normal sample). However, the shapiro-wilk test is quite sensitive to this
form of departure form normality.

To see what's going on, do:
(i) a density plot of your data via plot(density(x)). In particular note
that second mode in the upper tail.

(ii) a qq-plot. The departure from linearity evident in the upper right is
caused by that mode. shapiro test sees this nonlinearity (the
shapiro-francia, an approximation to the shapiro wilk, is a function of the
squared correlation of the two variables in this plot).

(iii) compute sample skewness and kurtosis and their standard errors (the JB
combines these into a single measure); formulas easily found via google
search. They're both close to the middle of their distribution for sampling
from a normal with n=59. 

Glen
-- 
View this message in context: 
http://n4.nabble.com/Normal-tests-disagree-tp932615p947452.html
Sent from the R help mailing list archive at Nabble.com.

__
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] Replying to Posts Within Same Thread

2009-12-03 Thread Charlotte Maia
On Thu, Dec 3, 2009 at 1:15 AM, Ted Harding
ted.hard...@manchester.ac.uk wrote:
 There is an issue which does not seem to have been raised yet in
 this thread. In her original post, Charlotte Maia said she was
 receiving messages in Digest form.

 There are two Digest options: Get MIME or Plain Text Digests?
 You can choose which one to use, if you opt for Digest format,
 when setting your subscription options in the R-help configuration
 page at

  https://stat.ethz.ch/mailman/options/r-help

 In a plain-text Digest, all the messages are bundled into a single
 message. Therefore when you reply to one of these you have to edit
 out everything except the bit you are replying to; and also the
 Thread-relevant headers of the original messages will heve been
 suppressed -- only headers for the Dugest message will be present,
 and these will have nothing to do with the threads that the separate
 original messages belonged to.

 On the other hand, in a MIME Digest, each of the original messages
 is attached as a separate attachment, along with its original headers.
 A mail agent which is MIME-Digest-aware will allow the user to
 open up each attachment separately, as a single message, and reply
 to that. Then the mail agent *should* incorporate these headers,
 including those which identify the thread.

 So, if you use Digest format, choose MIME Digest, and use a mail
 agent which works properly!

 Ted.

Hi,

I have changed my settings from plain text to MIME (doesn't apply to
this post, which is a response to a regular email, with r-help on the
cc line).

We'll see how things go, if my future posts appear threaded properly
then we can assume this was the issue. If not, then I'll keep playing
around.

Me being the old-school kind of computer geek that I am, naturally go
for plain text...

thanks to all those who responded to this topic
-- 
Charlotte Maia
http://sites.google.com/site/maiagx/home

__
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: barchart() {Lattice}

2009-12-03 Thread Deepayan Sarkar
On Thu, Dec 3, 2009 at 10:02 AM, Felix Andrews fe...@nfrac.org wrote:
 Either
 (1) use the 'alternating' option rather than 'relation' (see
 documentation for 'scales' argument);
 or
 (2) put 'rot' inside the 'y' list if you want it to apply only to the y axis.

Or you can have

scales = list(y = list(at = yScale, tck = c(1, 0)))

All of this is in the documentation; it may be long, but reading it is
still more efficient than trial and error.

-Deepayan




 2009/12/3 Peng Cai pengcaimaill...@gmail.com:
 Hi Felix and Others,

 I just realized, after using relation=free option, my y-axis labels got
 rotated by 90 degree. Previously they were horizontal and now they are
 vertical. I tried using rot= option but it rotates both x and y-axis
 labels at the same time. Any suggestions,

 I'm trying:

 scales = list(relation=free, rot=90, y = list(at = yScale))

 Thanks,
 Peng

 On Wed, Dec 2, 2009 at 6:17 PM, Peng Cai pengcaimaill...@gmail.com wrote:

 Got it thanks, (relation=free worked), more specifically

 scales = list(relation=free, y = list(at = yScale))

 On Wed, Dec 2, 2009 at 6:04 PM, Felix Andrews fe...@nfrac.org wrote:

 2009/12/3 Peng Cai pengcaimaill...@gmail.com:
  Hi Felix,
 
  Thanks for your help. If I'm defining my own y-scales like the one in R
  code
  below, then can I remove right side tick marks?

 Yes. Look at the description of the scales argument in ?xyplot


 
  dta-read.table(data.txt, header=TRUE, row.names=Names)
  library(lattice)
  yScale - seq(-200, 200, 10)
  barchart(data.matrix(dta),
    horizontal=FALSE,
    stack=TRUE,
    par.settings = simpleTheme(col = 3:5),
    auto.key=list(space=right),
    border=NA,
      scales = list(y = list(at = yScale))
  )
 
  Thanks,
  Peng
 
  On Wed, Dec 2, 2009 at 5:44 PM, Felix Andrews fe...@nfrac.org wrote:
 
  2009/12/3 Peng Cai pengcaimaill...@gmail.com:
   Hi R Users,
  
   I'm using following data/code (data is attached also) to produce a
   stacked
   barplot.
  
   # Sample Data:
   Names Col1 Col2 Col3
   Row1 -20 40 -10
   Row2 30 -20 40
   Row3 30 10 -20
   Row4 20 20 -10
  
  
   # R Code:
   dta-read.table(data.txt, header=TRUE, row.names=Names)
   barchart(data.matrix(dta),
       horizontal=FALSE,
       stack=TRUE,
       par.settings = simpleTheme(col = 3:5),
       auto.key=list(space=right),
       border=NA
   )
  
   I need help with:
  
   1. How can I remove the (y-axis) tick marks on the right side of the
   plot.
 
  Since you only have one panel, try scales = free
 
 
   2. While reading in the data, I'm using row.names=Names. Can I
   generalize
   this? What I mean is if for some other data set, the row names
   column
   has some other name (say Names2) or may be just blank. Can I still
   produce a
   similar graph plotting row labels (in this case they are Row1, Row2,
   ...) on
   x-axis.
 
  row.names can be a column number (1)
  See ?read.table
  It also describes the behaviour when the row names column is blank.
 
  
   Any help would be appreciated,
  
   Thanks,
   Peng
  
   __
   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.
  
  
 
 
 
  --
  Felix Andrews / 安福立
  Postdoctoral Fellow
  Integrated Catchment Assessment and Management (iCAM) Centre
  Fenner School of Environment and Society [Bldg 48a]
  The Australian National University
  Canberra ACT 0200 Australia
  M: +61 410 400 963
  T: + 61 2 6125 4670
  E: felix.andr...@anu.edu.au
  CRICOS Provider No. 00120C
  --
  http://www.neurofractal.org/felix/
 
 



 --
 Felix Andrews / 安福立
 Postdoctoral Fellow
 Integrated Catchment Assessment and Management (iCAM) Centre
 Fenner School of Environment and Society [Bldg 48a]
 The Australian National University
 Canberra ACT 0200 Australia
 M: +61 410 400 963
 T: + 61 2 6125 4670
 E: felix.andr...@anu.edu.au
 CRICOS Provider No. 00120C
 --
 http://www.neurofractal.org/felix/






 --
 Felix Andrews / 安福立
 Postdoctoral Fellow
 Integrated Catchment Assessment and Management (iCAM) Centre
 Fenner School of Environment and Society [Bldg 48a]
 The Australian National University
 Canberra ACT 0200 Australia
 M: +61 410 400 963
 T: + 61 2 6125 4670
 E: felix.andr...@anu.edu.au
 CRICOS Provider No. 00120C
 --
 http://www.neurofractal.org/felix/

 __
 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-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, 

Re: [R] Bar Plots: Error Bars

2009-12-03 Thread bshan101

Thanks so much! And those links are really useful :)

brett


Jeremy Baxter wrote:
 
 Brett
 
 Hi
 
 Searching http://www.Rseek.org will return many similar results. You might
 find 
 the following useful in terms of your question re aligning the bars:
 
 http://users.fmg.uva.nl/rgrasman/rpages/2005/09/error-bars-in-plots.html
 
 The discussion on this page also refers to the errbar function in the
 Hmisc 
 package. There are other options, searching Rseek will provide many!
 
 Basically something along the lines of the following will 'fix' your
 graph:
 
 marks - sample(4:10, size=50, replace=TRUE)
 dim(marks) - c(10,5)   
 classavg - colMeans (marks, na.rm=FALSE, dims = 1)
 
 thegraph - barplot(classavg, main=Class Average for Quizzes,
 xlab=Quiz, 
 ylab=Average, names = c(1,2,3,4,5), ylim=c(0,12), axis.lty=1)
 str(thegraph)
 max - apply (marks, 2, max)
 min - apply (marks, 2, min) 
 arrows(thegraph, min, thegraph, max, code=3, angle=90, length=0.125)  
 
 HTH,
 Jeremy
 
 Hey Everyone,

 I'm pretty new at R and wanted to try and make some graphs with dummy
 data
 before using it to analyze my own. I successfully made a bar graph and
 error bars, but I can't figure out how to align them properly (currently
 they are not centered on the bars and some of them aren't even close).
 Here's the

 code that I'm using:
  marks - sample(4:10, size=50, replace=TRUE)
  dim(marks) - c(10,5)
  classavg - colMeans (marks, na.rm=FALSE, dims = 1)
  barplot(classavg, main=Class Average for Quizzes, xlab=Quiz,
  ylab=Average, names = c(1,2,3,4,5), ylim=c(0,12),
 axis.lty=1)

 box()

  max - apply (marks, 2, max)
  min - apply (marks, 2, min)
  arrows(1:5, min, 1:5, max, code=3, angle=90, length=0.125)

 The error bars are simply ranges for now (I wanted to do that before I
 tried standard deviation/error). If anyone could help me align them it
 would be much appreciated!

 brett
 ---
 Jeremy Baxter, Statistics Department, Rhodes University, South Africa.
 Views expressed above, no matter how badly spelt, are my own... I think?
 
   [[alternative HTML version deleted]]
 
 __
 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.
 
 

-- 
View this message in context: 
http://n4.nabble.com/Bar-Plots-Error-Bars-tp947407p947484.html
Sent from the R help mailing list archive at Nabble.com.

__
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] How build hist combining data

2009-12-03 Thread Trafim Vanishek
I would like to ask if there is some simple way for building a hist from the
following data.

mm -c(2,3,0,4,5,0,2,9,0)
mmm - matrix(mm,ncol=3, nrow=3)

x - c(0,1.45,2.9)

in mmm there are frequencies (each column is separate histogram and each row
corresponds to value of x).
So that for the first histogram  we have 2 times interval [0,1.45] and 3
times [1.45,2.90].

Thanks a lot!

[[alternative HTML version deleted]]

__
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] How to check if file is on a drive?

2009-12-03 Thread Sergey Goriatchev
Hello, everyone

How would I check in R if a particular file (Excel file) is in a
particular folder on a particular drive?
I am writing a piece of code around that file, using xls.open() in
xlsReadWritePro to open the file in memory and use it. But before I
try to open the file I want to catch the possibility of the file not
being on the drive.

Thank you in advance!

SG

__
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 check if file is on a drive?

2009-12-03 Thread Romain Francois

?file.exists

On 12/03/2009 11:31 AM, Sergey Goriatchev wrote:


Hello, everyone

How would I check in R if a particular file (Excel file) is in a
particular folder on a particular drive?
I am writing a piece of code around that file, using xls.open() in
xlsReadWritePro to open the file in memory and use it. But before I
try to open the file I want to catch the possibility of the file not
being on the drive.

Thank you in advance!

SG


--
Romain Francois
Professional R Enthusiast
+33(0) 6 28 91 30 30
http://romainfrancois.blog.free.fr
|- http://tr.im/Gq7i : ohloh
|- http://tr.im/FtUu : new package : highlight
`- http://tr.im/EAD5 : LondonR slides

__
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] Avoiding singular fits in rlm

2009-12-03 Thread Peter Ehlers


Matt Crawford wrote:

I keep coming back to this problem of singular fits in rlm (MASS library),
but cannot figure out a good solution.

I am fitting a linear model with a factor variable, like
lm( Y ~ factorVar)
and this works fine. lm knows to construct the contrast matrix the way I
would expect, which puts the first factor as the baseline level.

But when I try
rlm( Y ~ factorVar)
I get the message 'x' is singular: singular fits are not implemented in
rlm.


Could it be that some level(s) of factorVar have no corresponding
Y-values? Check with table().

 -Peter Ehlers



How can I solve this problem so that I can use factor variables in rlm?

I've tried constructing the contrast matrix myself using the various contr
functions, but I always run out of memory. So I must not be doing something
right, because lm has to create some version of the same contrast matrix in
memory. In any case, I don't think that more memory is the solution.

[[alternative HTML version deleted]]

__
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-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] Bar Plots: Error Bars

2009-12-03 Thread Jose Gaspar Macia Vicente
Hi Brett,

have you tried the function errbar, within the library Hmisc?
It works pretty well for barplots. You have to specify the coordinates where
error bars start (x and y), end then the ending points they end
(yminus=y-error and yplus=y+error).

The plotting function barplot2 within the library gplots allows you also
to add error bars intrinsecally.

Hope it helps!

Jose

2009/12/3 bshan101 bshan...@gmail.com


 Hey Everyone,

 I'm pretty new at R and wanted to try and make some graphs with dummy data
 before using it to analyze my own. I successfully made a bar graph and
 error
 bars, but I can't figure out how to align them properly (currently they are
 not centered on the bars and some of them aren't even close). Here's the
 code that I'm using:

  marks - sample(4:10, size=50, replace=TRUE)
  dim(marks) - c(10,5)
  classavg - colMeans (marks, na.rm=FALSE, dims = 1)
  barplot(classavg, main=Class Average for Quizzes, xlab=Quiz,
  ylab=Average, names = c(1,2,3,4,5), ylim=c(0,12), axis.lty=1)
 box()
  max - apply (marks, 2, max)
  min - apply (marks, 2, min)
  arrows(1:5, min, 1:5, max, code=3, angle=90, length=0.125)

 The error bars are simply ranges for now (I wanted to do that before I
 tried
 standard deviation/error). If anyone could help me align them it would be
 much appreciated!

 brett

 --
 View this message in context:
 http://n4.nabble.com/Bar-Plots-Error-Bars-tp947407p947407.html
 Sent from the R help mailing list archive at Nabble.com.

 __
 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.


[[alternative HTML version deleted]]

__
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 check if file is on a drive?

2009-12-03 Thread Sergey Goriatchev
Great! Thank you, Romain!

On Thu, Dec 3, 2009 at 11:33, Romain Francois
romain.franc...@dbmail.com wrote:
 ?file.exists

 On 12/03/2009 11:31 AM, Sergey Goriatchev wrote:

 Hello, everyone

 How would I check in R if a particular file (Excel file) is in a
 particular folder on a particular drive?
 I am writing a piece of code around that file, using xls.open() in
 xlsReadWritePro to open the file in memory and use it. But before I
 try to open the file I want to catch the possibility of the file not
 being on the drive.

 Thank you in advance!

 SG

 --
 Romain Francois
 Professional R Enthusiast
 +33(0) 6 28 91 30 30
 http://romainfrancois.blog.free.fr
 |- http://tr.im/Gq7i : ohloh
 |- http://tr.im/FtUu : new package : highlight
 `- http://tr.im/EAD5 : LondonR slides





-- 
I'm not young enough to know everything. /Oscar Wilde
Experience is one thing you can't get for nothing. /Oscar Wilde
When you are finished changing, you're finished. /Benjamin Franklin
Tell me and I forget, teach me and I remember, involve me and I learn.
/Benjamin Franklin
Luck is where preparation meets opportunity. /George Patten

Kniven skärpes bara mot stenen.

__
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] R help with princomp and pam clustering

2009-12-03 Thread Joris Meys
Hi Tyler,

sorry, I missed your response. Don't know if it's solved already, but
some remarks.
the predict uses a princomp object, so your second command should work.

I guess the problem is either the data format of B (should contain
exactly the same amount of columns, with the same names), or the cor
specification you use.

Try :
Cor - ncol(pamX$data)!=2
Prin - princomp(matrix,cor=Cor)
predict(Prin,B)

It works perfectly well on every test I run.

Cheers
Joris


On Fri, Nov 27, 2009 at 10:14 AM, Tyler82
procaccianti.clau...@gmail.com wrote:

 Hi JorisMeys and thanks!


 JorisMeys wrote:

 On Thu, Nov 26, 2009 at 1:04 AM, Tyler82 procaccianti.clau...@gmail.com
 wrote:

 Hi all!
 I am working with R package cluster and I have a little problem:
 let's say I have two datasets...first one (A) is divided into 4
 clusters
 by means of Pam algorythm.
 Let's say I want to project the second database (B) onto the Comp.1 X
 Comp.2 graph, and see where its elements are placed.
 The two datasets are made of different dim (54x19 and 28x19). I tried to
 extract the $loadings of the A clustering but I can't seem to figure out
 how
 to use them with B :(

 Prin - princomp(A)
 predict(Prin,B)

 in the assumption that the variable names in both dataframes are equal.

 A and B are equal in column names (variables) but different in rownames
 (observations), but still it doesn't work.
 If I use
 A-princomp(matrix, cor=ncol(pamX$data)!=2)$loadings
 and then
 predict(A,B)
 then the answer is that there is no valid method
 (My R version is in Italian...the original message is -Errore in
 UseMethod(predict) : nessun metodo applicabile per predict- )
 If I use
 A-princomp(matrix, cor=ncol(pamX$data)!=2)
 then it says the index is out of limit

 Thank you again!!

 --
 View this message in context: 
 http://old.nabble.com/R-help-with-princomp-and-pam-clustering-tp26522485p26539667.html
 Sent from the R help mailing list archive at Nabble.com.

 __
 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-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] median for time data

2009-12-03 Thread uvilla

Hi again.
I´m sorry to ask again but I cannot do the boxplot coprrectly.

I'm typing:

start.posix=as.POSIXct(skiers[,3])
boxplot(start.posix)


where skiers[,3] is my time data,
and I get this error

I have no idea of what that means.. All the other steps are ready, like the
median of the time data, but Im really stock trying to do the boxplot with
the time data on the y axis to interprete the median 

Thanks again




Jannis v. Buttlar wrote:
 
 
 
 uvilla schrieb:
 When I use strptime() I just get NA NA NA
 I`m new at using R, must finisth this work thoug
 
 I guess Im doing totally wrong, actually everytime i try to use POSIXct
 it
 doesn`t work
 
 
 If you have a look at help(strptime) you find that you have to specify 
 the format in which you time is written.
 
 Try
 
 strptime(08:10:10,%H:%M:%S)
 
 The stuff after the comma in the  is the way to give strptime the
 format.
 
 Now you only have use
 
 strptime(vectorwithyourtime,%H:%M:%S)
 
 and you should get a vector with R format times out of it. It uses 
 todays date though but for your calculations this should work. This 
 POSIXct format is not very handy to use though, so you perhaps better 
 consider using library(chron) as Gabor suggested.
 
 
 
 
 Thanks a lot
 
 
 
 Jannis wrote:
 Hi,


 try to convert this to the R time format POSIXct or POSIXlt via 
 strptime(). Then you can simply substract them. I am not sure whether a 
 median can be calculated though (should be possible as POSIXct stores 
 the value as seconds since 1970)

 Best
 Jannis

 uvilla schrieb:
 Hi everybody

 How do I do to calculate the median and average of a colum of time data
 like
 this: 8:50:10. I also need to plot the time difference between two
 colums
 Thanks a lot
 __
 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-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.
 
 
:-((:-((
-- 
View this message in context: 
http://n4.nabble.com/median-for-time-data-tp932287p947591.html
Sent from the R help mailing list archive at Nabble.com.

__
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] Can we get rid of bar charts with error bars?

2009-12-03 Thread Frank E Harrell Jr
Bar charts with error bars are far inferior to dot charts and other 
types of displays.  One of many problems is demonstrated if you draw a 
bar chart displaying temperature in F then re-draw it on the degrees C 
scale.  See http://biostat.mc.vanderbilt.edu/DynamitePlots for much more 
information.  The error bars lull us into an assumption that symmetric 
confidence intervals are OK, among other things.


Frank

--
Frank E Harrell Jr   Professor and Chair   School of Medicine
 Department of Biostatistics   Vanderbilt University

__
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] data manipulation

2009-12-03 Thread oscar linares
Dear Wiza[R]ds,

I have a data.frame header that looks like this:

v2FfaPre15v2FfaPre10v2FfaPre5v2Ffa2v2Ffa3v2Ffa4

I need it to look like this,

1510523 4

i.e., with v2FfaPre and  v2Ffa stripped off

Any suggestions,

Thanks in advance!

-- 
Oscar
Oscar A. Linares, MD
Translational Medicine Unit
LaPlaisance Bay, Bolles Harbor
Monroe, Michigan 48161

Department of Medicine,
University of Toledo College of Medicine
Toledo, OH 43606-3390

Department of Internal Medicine,
The Detroit Medical Center (DMC)
Harper University Hospital
Wayne State University School of Medicine
Detroit, Michigan 48201

[[alternative HTML version deleted]]

__
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] data manipulation

2009-12-03 Thread jim holtman
try this:

 x - c('v2FfaPre15','v2FfaPre10','v2FfaPre5','v2Ffa2',
 'v2Ffa3','v2Ffa4')
 sub(^.*?([0-9]+)$, \\1, x, perl=TRUE)
[1] 15 10 5  2  3  4



On Thu, Dec 3, 2009 at 9:00 AM, oscar linares wins...@gmail.com wrote:
 Dear Wiza[R]ds,

 I have a data.frame header that looks like this:

 v2FfaPre15    v2FfaPre10    v2FfaPre5    v2Ffa2    v2Ffa3    v2Ffa4

 I need it to look like this,

 15    10    5    2    3     4

 i.e., with v2FfaPre and  v2Ffa stripped off

 Any suggestions,

 Thanks in advance!

 --
 Oscar
 Oscar A. Linares, MD
 Translational Medicine Unit
 LaPlaisance Bay, Bolles Harbor
 Monroe, Michigan 48161

 Department of Medicine,
 University of Toledo College of Medicine
 Toledo, OH 43606-3390

 Department of Internal Medicine,
 The Detroit Medical Center (DMC)
 Harper University Hospital
 Wayne State University School of Medicine
 Detroit, Michigan 48201

        [[alternative HTML version deleted]]

 __
 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.




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

What is the problem that you are trying to solve?

__
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] data manipulation

2009-12-03 Thread Henrique Dallazuanna
Try this:

gsub(.*[^0-9], , header)


On Thu, Dec 3, 2009 at 12:00 PM, oscar linares wins...@gmail.com wrote:
 Dear Wiza[R]ds,

 I have a data.frame header that looks like this:

 v2FfaPre15    v2FfaPre10    v2FfaPre5    v2Ffa2    v2Ffa3    v2Ffa4

 I need it to look like this,

 15    10    5    2    3     4

 i.e., with v2FfaPre and  v2Ffa stripped off

 Any suggestions,

 Thanks in advance!

 --
 Oscar
 Oscar A. Linares, MD
 Translational Medicine Unit
 LaPlaisance Bay, Bolles Harbor
 Monroe, Michigan 48161

 Department of Medicine,
 University of Toledo College of Medicine
 Toledo, OH 43606-3390

 Department of Internal Medicine,
 The Detroit Medical Center (DMC)
 Harper University Hospital
 Wayne State University School of Medicine
 Detroit, Michigan 48201

        [[alternative HTML version deleted]]

 __
 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.




-- 
Henrique Dallazuanna
Curitiba-Paraná-Brasil
25° 25' 40 S 49° 16' 22 O

__
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] XML - ampersand escaped

2009-12-03 Thread Ido M. Tamir
Hi,
I create some DOM with XML and would like to include
cap; in the text of an element. The library automatically
escapses it to amp;cap;.
unescaping \\cap; does not help.

any ideas?
My current plan is to go through the output and replace it
with gsub, but maybe there is a better way?

thanks,
ido

 library(XML)
 xml - xmlTree(tree)
Warning message:
In xmlRoot.XMLInternalDocument(currentNodes[[1]]) : empty XML document
 xml$addNode(test,a cap; b)
 xml$addNode(test,a \\cap; b)


 xml$value()
?xml version=1.0?
tree
  testa amp;cap; b/test
  testa \amp;cap; b/test
/tree

__
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] adding bmp/jpg/gif to an existing plot

2009-12-03 Thread Cézar Freitas
Hi, all. 

I searched a lot at mailing list, installed EBImage and gtk packages, but I 
couldn't make this simple work:

How
to add a image file (jpg or bmp ou gif) to an existing plot window (not
plot over the image), like the code below (pseudo function add.image):




plot(1:10,1:10,main=test)

image = read.X(myimage.jpg)



add.image(image, x.left=2, y.bottom=4, size=40%) #points the left-bottom 
corner and the reative size of image




abline(x=3, col=2, lwd=2) #continues editing the plot window.

text(2,3,labels=example of graphics and image)



Is it possible?



Thanks,

Cezar Freitas


  

Veja quais são os assuntos do momento no Yahoo! +Buscados
http://br.maisbuscados.yahoo.com
[[alternative HTML version deleted]]

__
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] data manipulation

2009-12-03 Thread Gabor Grothendieck
Try this where [0-9]+ matches one or more digits and $ matches the end of
string.  See http://gsubfn.googlecode.com for more.

library(gsubfn)
x - c(v2FfaPre15, v2FfaPre10, v2FfaPre5, v2Ffa2, v2Ffa3,
v2Ffa4)

strapply(x, [0-9]+$, c, simplify = TRUE)


# or if you want a numeric result:
strapply(x, [0-9]+$, as.numeric, simplify = TRUE)

On Thu, Dec 3, 2009 at 9:00 AM, oscar linares wins...@gmail.com wrote:

 Dear Wiza[R]ds,

 I have a data.frame header that looks like this:

 v2FfaPre15v2FfaPre10v2FfaPre5v2Ffa2v2Ffa3v2Ffa4

 I need it to look like this,

 1510523 4

 i.e., with v2FfaPre and  v2Ffa stripped off

 Any suggestions,

 Thanks in advance!

 --
 Oscar
 Oscar A. Linares, MD
 Translational Medicine Unit
 LaPlaisance Bay, Bolles Harbor
 Monroe, Michigan 48161

 Department of Medicine,
 University of Toledo College of Medicine
 Toledo, OH 43606-3390

 Department of Internal Medicine,
 The Detroit Medical Center (DMC)
 Harper University Hospital
 Wayne State University School of Medicine
 Detroit, Michigan 48201

[[alternative HTML version deleted]]

 __
 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.


[[alternative HTML version deleted]]

__
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] Acumulate assign on lapply list

2009-12-03 Thread KENNETH R CABRERA
Hi R users:

f1-function(l1,idx){
  f2-function(i,l1)   l1[[i+1]]-c(l1[[i]],l1[[i+1]][-1])
  lapply(idx,f2,l1)
  return(l1)
}

l-list(c(1,2,3),c(4,5),c(6,7,8))

l2-f1(l,1:(length(l)-1))

l2

I got:

[[1]]
[1] 1 2 3

[[2]]
[1] 1 2 3 5

[[3]]
[1] 4 5 7 8

But what I want in the last position of l2 is the acummualte of the
assignations...

I would like to have:

[[1]]
 [1] 1 2 3
 
 [[2]]
 [1] 1 2 3 5
 
 [[3]]
 [1] 1 2 3 5 7 8
 
How can I do that?

Thank you for your help.

Kenneth



[[alternative HTML version deleted]]

__
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] Can we get rid of bar charts with error bars?

2009-12-03 Thread Heinz Tuechler

Frank,

the example on http://biostat.mc.vanderbilt.edu/DynamitePlots is 
nice, and I agree with you. Just one minor question: would it be 
possible to mention as An article with nice dot plots a paper, 
which is freely available?


Heinz

At 14:56 03.12.2009, Frank E Harrell Jr wrote:
Bar charts with error bars are far inferior to dot charts and other 
types of displays.  One of many problems is demonstrated if you draw 
a bar chart displaying temperature in F then re-draw it on the 
degrees C scale.  See http://biostat.mc.vanderbilt.edu/DynamitePlots 
for much more information.  The error bars lull us into an 
assumption that symmetric confidence intervals are OK, among other things.


Frank

--
Frank E Harrell Jr   Professor and Chair   School of Medicine
 Department of Biostatistics   Vanderbilt University

__
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-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] adding bmp/jpg/gif to an existing plot

2009-12-03 Thread Prof Brian Ripley

Look at the R-devel development version of R

o   The graphics engine now supports rendering of raster (bitmap)
images, though not all graphics devices can provide (full)
support.  Packages providing graphics devices (e.g., Cairo,
RSvgDevice, cairoDevice) will need to be reinstalled.

and

http://developer.r-project.org/Raster/raster-RFC.html

for more details (and older ways to do it less well).


On Thu, 3 Dec 2009, Cézar Freitas wrote:


Hi, all.

I searched a lot at mailing list, installed EBImage and gtk packages, but I 
couldn't make this simple work:

How
to add a image file (jpg or bmp ou gif) to an existing plot window (not
plot over the image), like the code below (pseudo function add.image):




plot(1:10,1:10,main=test)

image = read.X(myimage.jpg)



add.image(image, x.left=2, y.bottom=4, size=40%) #points the left-bottom 
corner and the reative size of image




abline(x=3, col=2, lwd=2) #continues editing the plot window.

text(2,3,labels=example of graphics and image)



Is it possible?



Thanks,

Cezar Freitas


 

Veja quais s?? os assuntos do momento no Yahoo! +Buscados
http://br.maisbuscados.yahoo.com
[[alternative HTML version deleted]]




--
Brian D. Ripley,  rip...@stats.ox.ac.uk
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@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] Formatting of numbers on y axis

2009-12-03 Thread Wells Oliver
Hello all. I have the following:

plot(salaries$yearID, salaries$salary, type='n', xaxt='n', xlab='',
yaxt='n', ylab='')
axis(1, at=unique(salaries$yearID), labels=unique(salaries$yearID), lwd=.25,
tck=-0.05)
axis(2, axTicks(2), format(axTicks(2), scientific = F))

Which nicely creates the Y axis with the raw numbers, which are in the range
of .5 - 7 million.

However, it displays them as 100, and so on- I'd like it to show just
whole numbers 1, 2, 3, through 7, so I can label the Y axis in millions.
Any tips?

Thanks!

-- 
Wells Oliver
we...@submute.net

[[alternative HTML version deleted]]

__
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] online.QTAFI: Online questionnaire environment (R supported)

2009-12-03 Thread bhina patria
 R-help@r-project.orgDear lister,

I am delighted to introduce you to an open souce software to make online
survey/questionnaire. online.QTAFI has been developed by Martin Guist in
INCHER-Kassel since 2003. The questionnaire data are also available to
download in R script.

More about online.QTAFI please visit the documentation site:
 http://www.hochschulforschung.uni-kassel.de/qtafidocs/

Best wishes,
Bhina Patria

[[alternative HTML version deleted]]

__
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] documentation of intersect() on string vector and num vector and on duplicated elements

2009-12-03 Thread Greg Snow
 -Original Message-
 From: r-help-boun...@r-project.org [mailto:r-help-boun...@r-
 project.org] On Behalf Of David Winsemius
 Sent: Wednesday, December 02, 2009 3:25 PM
 To: Peng Yu
 Cc: r-h...@stat.math.ethz.ch
 Subject: Re: [R] documentation of intersect() on string vector and num
 vector and on duplicated elements


I nominate the following as a fortune:

 If you are not going to read the help page, then please stop asking
 for corrections to it.




 
 
 David Winsemius, MD
 Heritage Laboratories
 West Hartford, CT
 

When is the version of the fortunes package on R-Forge going to make it to CRAN?

Thanks,

-- 
Gregory (Greg) L. Snow Ph.D.
Statistical Data Center
Intermountain Healthcare
greg.s...@imail.org
801.408.8111

__
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] Replace values in a vector

2009-12-03 Thread Farida Mostajabi
Hi all,

I have a vector like this:

x- c(0.7, 0.1, 0, 0.2, 0.2, 0, 0, 0 , 0, 0.4, 0, 0.8, 1.8)

I would like  to replace the zero values with the first previous non zero value.

my returning vector should look like this:

y-c( 0.7, 0.1, 0.1,0.2,0.2,0.2,0.2,0.2, 0.4, 0.4, 0.8, 1.8)

How can I do this in R without using for loop?

Thank you

__
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] S4 Classes, nested objects and references

2009-12-03 Thread Joris Meys
Hi all,

I'm currently programming my first complete package in S4. (thanks to
Christophe Genolini for the nice introduction he wrote). I have an
object Data with a number of slots. One of those slots is meteo.
Now Meteo is on itself a class with again a number of slots (like
rainfall, temperature,..., you get the picture).

I defined the slot meteo currently as a character slot, and the
values refer to the names of the Meteo-objects related to that
Data-object. The cleaner way would be to define the slot meteo as a
slot of class Meteo, but I'm not sure how that works internally.

Thing is, I have multiple Data objects that refer to the same Meteo
object. I am a bit afraid that when I define the slot meteo as a slot
of the corresponding class, each Data object will contain a complete
copy of the Meteo object it relates to. This would mean that in the
memory I will end up with multiple copies of exactly the same data.
Although it is cleaner, it is definitely not more efficient.

My question : Am I wrong in my assumption that I will have multiple
copies in the memories? If yes, is it possible to use references in a
more formal way than I do now? Or is there an obvious solution I am
missing here?

Thank you in advance
Cheers
Joris

__
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] Replace values in a vector

2009-12-03 Thread Gabor Grothendieck
na.locf in the zoo package takes the last occurrence and carries it forward
into NAs so replace your zeros with NAs and then apply na.locf like this:

   library(zoo)
   na.locf(replace(x, x==0, NA))


On Thu, Dec 3, 2009 at 11:41 AM, Farida Mostajabi
f0mos...@louisville.eduwrote:

 Hi all,

 I have a vector like this:

 x- c(0.7, 0.1, 0, 0.2, 0.2, 0, 0, 0 , 0, 0.4, 0, 0.8, 1.8)

 I would like  to replace the zero values with the first previous non zero
 value.

 my returning vector should look like this:

 y-c( 0.7, 0.1, 0.1,0.2,0.2,0.2,0.2,0.2, 0.4, 0.4, 0.8, 1.8)

 How can I do this in R without using for loop?

 Thank you

 __
 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.


[[alternative HTML version deleted]]

__
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] (Grouped + Stacked) Barplot

2009-12-03 Thread Greg Snow
A bar graph including both stacked and grouped bars will put lots of pretty 
colors on the page and probably be eyecatching, but is unlikely to be the most 
effective way to convey the actual meaning of the data.  I would recommend that 
you explore other possibilities for doing the plot.  A dot plot may give you 
what you want, see the dotchart2 function in the Hmisc package or the dotplot 
function in the lattice package.

-- 
Gregory (Greg) L. Snow Ph.D.
Statistical Data Center
Intermountain Healthcare
greg.s...@imail.org
801.408.8111


 -Original Message-
 From: r-help-boun...@r-project.org [mailto:r-help-boun...@r-
 project.org] On Behalf Of Xin Ge
 Sent: Wednesday, December 02, 2009 8:25 PM
 To: r-help@r-project.org
 Subject: [R] (Grouped + Stacked) Barplot
 
 Hi All,
 
 I have googled and tried finding if someone has ever tried producing
 (Grouped + Stacked) Barplot. I couldn't find one.
 
 My data needs to be reshaped, but once it is done it would be something
 like
 this:
 
 Factor1Factor2Factor3Value
 AXP10
 AXQ20
 AYP20
 AYQ5
 AZP20
 AZQ10
 BXP20
 BXQ10
 BYP30
 BYQ50
 BZP10
 BZQ20
 
 There are three categorical variables (Factor1, Factor2, and Factor3
 having
 2,3, and 2 levels resp.). I'm trying to plot Factor1 on x axis --
 each
 level of this factor should have three (grouped) bars (one for each
 level of
 Factor2). Which will further be stacked by each level of Factor3.
 
 Can anyone guide me please, thanks,
 ~Xin
 
   [[alternative HTML version deleted]]
 
 __
 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-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] Formatting of numbers on y axis

2009-12-03 Thread Joris Meys
The problem is easily solved by plotting salaries$salary/100

Cheers
Joris

On Thu, Dec 3, 2009 at 5:16 PM, Wells Oliver we...@submute.net wrote:
 Hello all. I have the following:

 plot(salaries$yearID, salaries$salary, type='n', xaxt='n', xlab='',
 yaxt='n', ylab='')
 axis(1, at=unique(salaries$yearID), labels=unique(salaries$yearID), lwd=.25,
 tck=-0.05)
 axis(2, axTicks(2), format(axTicks(2), scientific = F))

 Which nicely creates the Y axis with the raw numbers, which are in the range
 of .5 - 7 million.

 However, it displays them as 100, and so on- I'd like it to show just
 whole numbers 1, 2, 3, through 7, so I can label the Y axis in millions.
 Any tips?

 Thanks!

 --
 Wells Oliver
 we...@submute.net

        [[alternative HTML version deleted]]

 __
 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-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] par() background issue

2009-12-03 Thread Wells Oliver
I have the following:

par(bg='#CC', family='Lucida Grande')
plot(salaries$yearID, salaries$salary/100)

Which creates a graph with the correct offwhite/yellow background. However,
I want the actual plot box to have a white background.

par(bg='#CC', family='Lucida Grande')
plot(salaries$yearID, salaries$salary/100, bg='#FF')

But that does nothing. How can I accomplish this? Thanks!

-- 
Wells Oliver
we...@submute.net

[[alternative HTML version deleted]]

__
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] Replace values in a vector

2009-12-03 Thread Farida Mostajabi
WOW! It worked. Thank you!

 Gabor Grothendieck ggrothendi...@gmail.com 12/03/09 11:46 AM 
na.locf in the zoo package takes the last occurrence and carries it forward
into NAs so replace your zeros with NAs and then apply na.locf like this:

   library(zoo)
   na.locf(replace(x, x==0, NA))


On Thu, Dec 3, 2009 at 11:41 AM, Farida Mostajabi
f0mos...@louisville.eduwrote:

 Hi all,

 I have a vector like this:

 x- c(0.7, 0.1, 0, 0.2, 0.2, 0, 0, 0 , 0, 0.4, 0, 0.8, 1.8)

 I would like  to replace the zero values with the first previous non zero
 value.

 my returning vector should look like this:

 y-c( 0.7, 0.1, 0.1,0.2,0.2,0.2,0.2,0.2, 0.4, 0.4, 0.8, 1.8)

 How can I do this in R without using for loop?

 Thank you

 __
 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-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] Acumulate assign on lapply list

2009-12-03 Thread Charles C. Berry

On Thu, 3 Dec 2009, KENNETH R CABRERA wrote:


Hi R users:

f1-function(l1,idx){
? f2-function(i,l1)?? l1[[i+1]]-c(l1[[i]],l1[[i+1]][-1])
? lapply(idx,f2,l1)
? return(l1)
}

l-list(c(1,2,3),c(4,5),c(6,7,8))

l2-f1(l,1:(length(l)-1))

l2

I got:

[[1]]
[1] 1 2 3

[[2]]
[1] 1 2 3 5

[[3]]
[1] 4 5 7 8

But what I want in the last position of l2 is the acummualte of the
assignations...

I would like to have:

[[1]]
[1] 1 2 3

[[2]]
[1] 1 2 3 5

[[3]]
[1] 1 2 3 5 7 8

How can I do that?



Reduce( function(x,y) c( x, y[-1] ) , l , accumulate=TRUE)

HTH,

Chuck



Thank you for your help.

Kenneth



[[alternative HTML version deleted]]




Charles C. Berry(858) 534-2098
Dept of Family/Preventive Medicine
E mailto:cbe...@tajo.ucsd.edu   UC San Diego
http://famprevmed.ucsd.edu/faculty/cberry/  La Jolla, San Diego 92093-0901

__
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] Replace values in a vector

2009-12-03 Thread William Dunlap
 -Original Message-
 From: r-help-boun...@r-project.org 
 [mailto:r-help-boun...@r-project.org] On Behalf Of Farida Mostajabi
 Sent: Thursday, December 03, 2009 8:41 AM
 To: r-help@r-project.org
 Subject: [R] Replace values in a vector
 
 Hi all,
 
 I have a vector like this:
 
 x- c(0.7, 0.1, 0, 0.2, 0.2, 0, 0, 0 , 0, 0.4, 0, 0.8, 1.8)
 
 I would like  to replace the zero values with the first 
 previous non zero value.
 
 my returning vector should look like this:
 
 y-c( 0.7, 0.1, 0.1,0.2,0.2,0.2,0.2,0.2, 0.4, 0.4, 0.8, 1.8)

y is shorter than x.  Shouldn't there be a run of 6 0.2s,
not 5?
 
 How can I do this in R without using for loop?

One way is
isNotZero - function(x) !is.na(x)  x!=0
f-function(x)x[cummax(seq_along(x) * isNotZero(x))]
f(x)
[1] 0.7 0.1 0.1 0.2 0.2 0.2 0.2 0.2 0.2 0.4 0.4 0.8 1.8
This one drops an initial run of 0's but could be adjusted
to do something with them.

Bill Dunlap
Spotfire, TIBCO Software
wdunlap tibco.com 
 
 Thank you
 
 __
 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-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] adding bmp/jpg/gif to an existing plot

2009-12-03 Thread Greg Snow
Look at the subplot function in the TeachingDemos package.

-- 
Gregory (Greg) L. Snow Ph.D.
Statistical Data Center
Intermountain Healthcare
greg.s...@imail.org
801.408.8111


 -Original Message-
 From: r-help-boun...@r-project.org [mailto:r-help-boun...@r-
 project.org] On Behalf Of Cézar Freitas
 Sent: Thursday, December 03, 2009 7:24 AM
 To: r-help@r-project.org
 Subject: [R] adding bmp/jpg/gif to an existing plot
 
 Hi, all.
 
 I searched a lot at mailing list, installed EBImage and gtk packages,
 but I couldn't make this simple work:
 
 How
 to add a image file (jpg or bmp ou gif) to an existing plot window (not
 plot over the image), like the code below (pseudo function add.image):
 
 
 
 
 plot(1:10,1:10,main=test)
 
 image = read.X(myimage.jpg)
 
 
 
 add.image(image, x.left=2, y.bottom=4, size=40%) #points the left-
 bottom corner and the reative size of image
 
 
 
 
 abline(x=3, col=2, lwd=2) #continues editing the plot window.
 
 text(2,3,labels=example of graphics and image)
 
 
 
 Is it possible?
 
 
 
 Thanks,
 
 Cezar Freitas
 
 
 
 ___
 _
 Veja quais são os assuntos do momento no Yahoo! +Buscados
 http://br.maisbuscados.yahoo.com
   [[alternative HTML version deleted]]

__
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] adding bmp/jpg/gif to an existing plot

2009-12-03 Thread Frank E Harrell Jr

Greg Snow wrote:

Look at the subplot function in the TeachingDemos package.


A copy of subplot is in the Hmisc package thanks to Greg.






--
Frank E Harrell Jr   Professor and Chair   School of Medicine
 Department of Biostatistics   Vanderbilt University

__
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] Replace values in a vector

2009-12-03 Thread Farida Mostajabi
Yes, should be 6  0.2.  The code worked. Thank you!

 William Dunlap wdun...@tibco.com 12/03/09 12:07 PM 
 -Original Message-
 From: r-help-boun...@r-project.org 
 [mailto:r-help-boun...@r-project.org] On Behalf Of Farida Mostajabi
 Sent: Thursday, December 03, 2009 8:41 AM
 To: r-help@r-project.org
 Subject: [R] Replace values in a vector
 
 Hi all,
 
 I have a vector like this:
 
 x- c(0.7, 0.1, 0, 0.2, 0.2, 0, 0, 0 , 0, 0.4, 0, 0.8, 1.8)
 
 I would like  to replace the zero values with the first 
 previous non zero value.
 
 my returning vector should look like this:
 
 y-c( 0.7, 0.1, 0.1,0.2,0.2,0.2,0.2,0.2, 0.4, 0.4, 0.8, 1.8)

y is shorter than x.  Shouldn't there be a run of 6 0.2s,
not 5?
 
 How can I do this in R without using for loop?

One way is
isNotZero - function(x) !is.na(x)  x!=0
f-function(x)x[cummax(seq_along(x) * isNotZero(x))]
f(x)
[1] 0.7 0.1 0.1 0.2 0.2 0.2 0.2 0.2 0.2 0.4 0.4 0.8 1.8
This one drops an initial run of 0's but could be adjusted
to do something with them.

Bill Dunlap
Spotfire, TIBCO Software
wdunlap tibco.com 
 
 Thank you
 
 __
 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-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] median for time data

2009-12-03 Thread Jannis
I fear nobody can really help you as we can not really understandd what 
your problem is. What does the error message read? What values does 
start.posix have? And what skiers?


You should include the code for a reproducable example. include at least 
2 values for skiers[,3] in their correct format and class, so we can run 
the code ourselves and check what is going on.


Then we can (hopefully) help you.

uvilla schrieb:

Hi again.
I´m sorry to ask again but I cannot do the boxplot coprrectly.

I'm typing:

start.posix=as.POSIXct(skiers[,3])
boxplot(start.posix)


where skiers[,3] is my time data,
and I get this error

I have no idea of what that means.. All the other steps are ready, like the
median of the time data, but Im really stock trying to do the boxplot with
the time data on the y axis to interprete the median 


Thanks again




Jannis v. Buttlar wrote:



uvilla schrieb:

When I use strptime() I just get NA NA NA
I`m new at using R, must finisth this work thoug

I guess Im doing totally wrong, actually everytime i try to use POSIXct
it
doesn`t work

If you have a look at help(strptime) you find that you have to specify 
the format in which you time is written.


Try

strptime(08:10:10,%H:%M:%S)

The stuff after the comma in the  is the way to give strptime the
format.

Now you only have use

strptime(vectorwithyourtime,%H:%M:%S)

and you should get a vector with R format times out of it. It uses 
todays date though but for your calculations this should work. This 
POSIXct format is not very handy to use though, so you perhaps better 
consider using library(chron) as Gabor suggested.






Thanks a lot



Jannis wrote:

Hi,


try to convert this to the R time format POSIXct or POSIXlt via 
strptime(). Then you can simply substract them. I am not sure whether a 
median can be calculated though (should be possible as POSIXct stores 
the value as seconds since 1970)


Best
Jannis

uvilla schrieb:

Hi everybody

How do I do to calculate the median and average of a colum of time data
like
this: 8:50:10. I also need to plot the time difference between two
colums
Thanks a lot

__
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-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-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] adding bmp/jpg/gif to an existing plot

2009-12-03 Thread Cézar Freitas
Hi, all.
I searched a lot at mailing list, installed EBImage and gtk packages, but I
couldn't make this simple work:
How to add a image file (jpg or bmp ou gif) to an existing plot window (not
plot over the image), like the code below (pseudo function add.image):

plot(1:10,1:10,main=test)
image = read.X(myimage.jpg)

add.image(image, x.left=2, y.bottom=4, size=40%) #points the left-bottom
corner and the reative size of image

abline(x=3, col=2, lwd=2) #continues editing the plot window.
text(2,3,labels=example of graphics and image)

Is it possible?

Thanks,
Cezar Freitas

[[alternative HTML version deleted]]

__
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] Problem with predict() and factors

2009-12-03 Thread Idgarad
I am working on a script that takes numeric performance indicators and runs
them against a series of regressors (dummy regressors, yes\no stuff via 0
and 1, e.g. Was is Christmas this week 0=no, 1=yes).

The script is as follows (Written as a function):


-- Begin Script --

doEnv - function(HOUR,ENVNAME,REPORTNAME) {
library(RODBC)
library(forecast)
library(geneplotter)
library(forecast)
library(fUtilities)
library(TSA)
require(gplots)
library(robfilter)

SOURCEDATA - paste(Q:/TEST/RSTATS/EPOC ,HOUR, Metrics.xls,sep=)
REGRESSORS - Q:/TEST/RSTATS/eventswithholidays.xls

mypalette=c()
mypalette$background=#FF
mypalette$chart=#FF
mypalette$forecastRegion=#66CCFF
mypalette$confidence=#FF9966
mypalette$limits=#FF
mypalette$major=#00
mypalette$minor=#cc
mypalette$actual=#aa
mypalette$dp1=#9900FF
mypalette$dp2=#00
mypalette$dp3=#CCFF00
mypalette$dp4=#00CCFF
mypalette$dp5=#FF00CC

#Raw Data
channel1 - odbcConnectExcel(SOURCEDATA)
sqlTables(channel1)
sh1 - sqlFetch(channel1, Actuals$)
close(channel1)
channel2 - odbcConnectExcel(REGRESSORS)
sqlTables(channel2)
sh2 - sqlFetch(channel2, data$)
close(channel2)

#Get Raw Data
tsSource-ts(sh1[[ENVNAME]],start=c(2004,1),freq=52)

#Data is now a Time Series
#Prep Out-of-sample test ranges
modLength=length(sh1[[ENVNAME]])
modMax=round((modLength/3)*2)
modEndDate=time(tsSource)[modMax]
modStartDate=time(tsSource)[1]

#RAW SUMAMRY WITH OVERLAY OF OUT OF SAMPLE RANGES
summary(tsSource)
modelSource=window(tsSource,modStartDate,end=modEndDate)
verSource=window(tsSource,time(tsSource)[modMax+1])
pdf(paste(Q:/ReleaseMgmt/Environment
Mgmt/Data/Current/Metrics/Mainframe/Test Environment
Projections/RSTATS/images/,ENVNAME,-,HOUR,-,Raw Metrics with Test
Range.pdf,sep=),width=9, height=6.5)
plot(tsSource,col=grey, main=paste(Raw Data for, REPORTNAME),
xlab=Date, ylab=MiPS Used)
points(modelSource,col=red, pch=20)
points(verSource,col=blue, pch=20)
smartlegend( x=left, y= top, inset=0,
#smartlegend parameters
 legend = c(Actual Data,Data for Model Selection,Data for
In Sample Verification),
   fill=c(mypalette$actual,red,blue),bg = mypalette$background)
print(The Red region is where we are going to develop the model from and
the blue area is where we will evaluate the model (In Sample Testing))

#Ok our ranges are comfirmed we'll get a better graph later

# This Heavy Voodoo™ allows us to have a dynamic number of
#dummy variables we can add\remove from the spreadsheet
forecastDistance - 52
#Grab Existing Regressors (clipping out the data)
cReg - sh2[1:modLength,-1]
mcReg - sh2[1:modMax,-1]
#transform the on\offs into proper factors
for(i in names(cReg)) cReg[[i]] - factor(cReg[[i]])
for(i in names(mcReg)) mcReg[[i]] - factor(mcReg[[i]])
#Grab X Future Regressors equal to the forecastDistance (gotta double check
if I need a +1 on the start point)
fReg - sh2[length(tsSource):(length(tsSource)+forecastDistance),-1]
mfReg -sh2[(modMax+1):modLength,-1]
#fix variable names
names(cReg) - make.names(names(cReg))
names(mcReg) - make.names(names(mcReg))
names(fReg) - make.names(names(fReg))
names(mfReg) - make.names(names(mfReg))
#print(#)
#print(This is the CReg Data)
#print(#)
#print(summary(cReg))
#print(##)
#print(This is the mcReg Data)
#print(##)
#print(summary(mcReg))
#names(mcReg)
for(i in names(fReg)) fReg[[i]] - factor(fReg[[i]])
for(i in names(mfReg)) mfReg[[i]] - factor(mfReg[[i]])
#end heavy voodoo


#
# MODEL VERIFICATION FIRST!
#
# Basic Look at the raw data
hist(modelSource)
plot(density(modelSource,na.rm=TRUE))
plot(sort(modelSource),pch=.)
for(i in names(mcReg)) {
pairs(modelSource ~ .,mcReg[[i]], main=paste(Model - MIPS vs,i))
}
#Build the list to store our results
linearModel - list()
residuals - list()
arima_Fit - list()
arima_AO - list()
arima_IO - list()
newcReg - list()
newfReg - list()
newmcReg - list()
newmfReg - list()
newFit - list()
newForecast - list()
# Following won't work until mcReg contains full variety
linearModel[[1]]=lm(modelSource ~ + UNITBUILD + UNITDB + ITBUILD + ITDB +
UATBUILD + UATDB + HOGANCODE + RCF + ReleaseST1 + ReleaseST2 + ReleaseBLA +
Small.Bank.Acquisitions + HLY.NewYear + HLY.MLK + HLY.PRES + HLY.MEMORIAL +
HLY.J4 + HLY.LABOR + HLY.COLUMBUS + HLY.VETS + HLY.THANKS + HLY.XMAS +
HLY.ELECT + HLY.PATRIOT + EOM,mcReg)
linearModel[[2]]=step(linearModel[[1]], trace=1)
linearModel[[3]]=lm(modelSource ~ + UNITBUILD + UNITDB + ITBUILD + ITDB +
UATBUILD + UATDB + HOGANCODE + RCF + ReleaseST1 + ReleaseST2 + ReleaseBLA +
Small.Bank.Acquisitions + HLY.NewYear + HLY.MLK + HLY.PRES + HLY.MEMORIAL +
HLY.J4 + HLY.LABOR + HLY.COLUMBUS + HLY.VETS + HLY.THANKS + HLY.XMAS +
HLY.ELECT + HLY.PATRIOT + EOM - 1,mcReg)
linearModel[[4]]=step(linearModel[[3]],trace=1)
if(ENVNAME==E081) {linearModel[[5]]=lm(modelSource ~ + UNITBUILD + UNITDB
+ HOGANCODE + RCF + ReleaseST1 + Small.Bank.Acquisitions + HLY.NewYear +
HLY.MLK + HLY.PRES + 

Re: [R] Data frame/read.ftable

2009-12-03 Thread Robinson, David G
David,
Great! 'split' is something I didn't even look at.  Owe you one.
Many thanks,
Dave


On 12/2/09 7:29 PM, David Winsemius dwinsem...@comcast.net wrote:



On Dec 2, 2009, at 7:02 PM, Robinson, David G wrote:

 My apologies for this question but I'm stuck and I'm sure that there
 must be
 an easy answer out there (and hope that someone will have mercy and
 point me
 in the right direction).

 I have a data file that looks like:
 1 77 3
 1 8 1
 1 7 2
 1 1 5
 1 42 7
 1 0 2
 1 23 1
 2 83 9
 2 8 2
 2 6 5
 2 23 3
 3 11 3
 3 8 1
 .
  etc.
 .
 N   3   2


 (FWIW, these are document, word reference, and word frequency
 counts.) I
 want to read the data into data frame, Doc, such that
 Doc[[1]]=
 [,1] [,2] [,3] [,4] [,5] [,6] [,7]
 [1,]7787142023
 [2,]3125 72 1

 Doc[[2]]=
 [,1] [,2] [,3] [,4]
 [1,]838623
 [2,]9253

 Etc.

rd.txt - function(txt, header=TRUE) {read.table(textConnection(txt),
header=header)}

  dta - rd.txt(1 77 3
+ 1 8 1
+ 1 7 2
+ 1 1 5
+ 1 42 7
+ 1 0 2
+ 1 23 1
+ 2 83 9
+ 2 8 2
+ 2 6 5
+ 2 23 3
+ 3 11 3
+ 3 8 1, header=F)
  dta
V1 V2 V3
1   1 77  3
2   1  8  1
3   1  7  2
4   1  1  5
5   1 42  7
6   1  0  2
7   1 23  1
8   2 83  9
9   2  8  2
10  2  6  5
11  2 23  3
12  3 11  3
13  3  8  1


  split(dta[ ,-1], list(dta[,1]))
$`1`
   V2 V3
1 77  3
2  8  1
3  7  2
4  1  5
5 42  7
6  0  2
7 23  1

$`2`
V2 V3
8  83  9
9   8  2
10  6  5
11 23  3

$`3`
V2 V3
12 11  3
13  8  1

  ?split
  lapply(split(dta[ ,-1], list(dta[,1])), t)
$`1`
 1 2 3 4  5 6  7
V2 77 8 7 1 42 0 23
V3  3 1 2 5  7 2  1

$`2`
 8 9 10 11
V2 83 8  6 23
V3  9 2  5  3

$`3`
12 13
V2 11  8
V3  3  1



 It seems like I should be able to do this using a flat contingency
 table
 method such as 'read.ftable' or possibly using 'stack' . However,
 something
 is not clicking and hence my plea for assistance.

 Thanks in advance,
 Dave Robinson
 dro...@sandia.gov

 __
 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.

David Winsemius, MD
Heritage Laboratories
West Hartford, CT




[[alternative HTML version deleted]]

__
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] count number of empty cells in a table/matrix/data.frame

2009-12-03 Thread maiya

Hi everyone!

This is a ridiculously simple problem, I just can't seem to find the
solution!

All I need is something equivalent to 

sum(is.na(x))

but instead of counting missing values, to count empty cells (with a value
of 0).

A naive attempt with is.empty didn't work :)

Thanks!

Maja

Oh, and if the proposed solution would be to make all the empty cells into
missing cells, that is not an option! There are over 20,000,000 cells in my
table, and I don't think my computer is in the mood to store two such
objects!
-- 
View this message in context: 
http://n4.nabble.com/count-number-of-empty-cells-in-a-table-matrix-data-frame-tp947740p947740.html
Sent from the R help mailing list archive at Nabble.com.

__
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 export a function from a package and access it only by specifying the namespace?

2009-12-03 Thread Henric (Nilsson) Winell

On 2009-12-02 16:31, Peng Yu wrote:

On Tue, Dec 1, 2009 at 11:27 PM, Sharpie ch...@sharpsteen.net wrote:


Peng Yu wrote:

Then I try the package 'try.package' in an R session. I'm wondering
why neither 'my_test_f' and 'try.package::my_test_f' work.


The error message you got below clearly explains this-- you did not export
my_test_f in your NAMESPACE file.  To access unexported functions, you must
use the ':::' operator:

 try.package:::my_test_f()



Peng Yu wrote:

Why 'my_test_g' can be accessed with 'try.package::' and without
'try.package::'?


Because you exported it in the NAMESPACE file.



Peng Yu wrote:

Is there a way to make  'my_test_g' accessible only by specifying the
namespace 'try.package::'?


No.

The purpose of the '::' operator is for those cases where multiple packages
are loaded that each export a function with the same name.  This is known as
masking and the last loaded package will contribute the dominant
function-- i.e. the function the gets called when the user types
functionName() and not packageName::functionName().  The :: operator
allows the selection of functions that are masked by the dominant function.

If you really want to conceal a function from user-level code, don't export
it and it will only be accessible via the ::: operator.


Is there a way to list all the functions in a namespace? I tried the
following one, but it is not working.


showMethods(where=getNamespace('try.package'))

No applicable functions


You're almost there, and the above approach *is* working but only for S4 
methods. Try


showMethods(where = e - getNamespace('stats4'))

I don't think there's a direct analogue for S3, but it that case you only do

ls(e)


HTH,
Henric





__
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-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] distance matrices

2009-12-03 Thread Omar Gonzalez Post

i'm working on some distance matrices and i was wondering if there is a way to 
export the matrices from R to excel.
OG
thanks
  
[[alternative HTML version deleted]]

__
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] Three-dimensional (3D) movement using 'R'

2009-12-03 Thread StRose, Suzanne
Hi Everyone,

 

I have a question regarding the construction of 3D graphs in 'R', BUT
these graphs also need to illustrate movement (with time) of the
prostate gland (using radiological techniques).  I am not sure how to do
this in 'R' although I'm sure there is some way of doing it. 

 

Below, I have copied and pasted some of the data with which I'm working
on. The data are for axial images of the prostate for four patients (N1,
N2, N3 and N4) over 20 time points. The numbers represent the average
amplitude of movement by the prostate gland in mm. The signs (positive
and negative) indicate movement away from or toward the baseline,
respectively. So, any deviation away from the baseline is '+' and any
excursion toward baseline is negative (with the baseline indicated by
Time=0). 

 

I would like to plot 3D graphs illustrating movement of the prostate
with time for each of the four patients but do not know how. I am not an
expert in 'R' so any help will be very, very much appreciated.

 

Thanks.

 

Best wishes,

Suzanne

 

 

Time

N1

N2

N3

N4

0

0

0

0

0

1

121.8

-60.6

69.8

-122.6

2

19.9

-101.1

77.2

-142.9

3

19.9

-101.1

77.2

-120.4

4

19.9

-101.1

25.8

-131.1

5

44.2

-111.7

25.8

-128.6

6

44.2

-111.7

25.8

-305.7

7

50.5

-111.7

25.8

-232.4

8

75.8

-111.7

121.1

-201.8

9

63

-111.7

121.1

-201.8

10

3.3

-111.7

121.1

-201.8

11

38.9

-111.7

76.4

-175

12

38.9

-111.7

76.4

-175

13

-1.1

-111.7

76.4

-178.8

14

-103.1

-111.7

76.4

-176.2

15

-49.4

-111.7

76.4

-176.2

16

-80.6

-56.5

76.4

-176.2

17

-12.5

-94.7

-37.9

-171.6

18

-12.5

-94.7

-19.8

-186.4

19

-12.5

-94.7

-19.8

-241.1

20

-12.5

-59.4

9.8

-200

 

 

Suzanne St.Rose (DVM, MSc, PhD)

Statistician

Royal Marsden NHS Foundation Trust

Fulham Road

London SW3 6JJ

 

Telephone: 0207 808 2186

Email: suzanne.str...@rmh.nhs.uk

 

 


#
Attention:\ This e-mail and any attachment is for author...{{dropped:19}}

__
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] GLM Question

2009-12-03 Thread Knut Krueger

Hi to all

I think this is more an general question to GLMs.

The result was better in all prior GLMs when I admitted the non
significant factors, but this is the first time that the result is worse
than before. What could be the reason for that?

glm(data1~data2+data3+data4+data5+data6,family=gaussian)
The result:

Coefficients:
Estimate  Std. Error t value Pr(|t|)
(Intercept)3.3670852  0.8978306   3.750 0.000445 ***
data2  0.0002623  0.0001168   2.245 0.029024 *
data3 -0.9742336  0.5032712  -1.936 0.058337 .
data4  0.0628245  0.1503066   0.418 0.677686
data5 -0.0438871  0.0740210  -0.593 0.555818
data6$-0.0012216  0.0187702  -0.065 0.948357



if I test only or  lm() of course
glm(data1~data2,family=gaussian)

Coefficients:
   Estimate Std. Error t value Pr(|t|)
(Intercept)   2.473e+00  2.787e-01   8.876 2.86e-12 ***
data2 7.289e-05  7.485e-05   0.9740.334



Kind regards Knut

__
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] distance matrices

2009-12-03 Thread Gavin Simpson
On Thu, 2009-12-03 at 11:06 -0700, Omar Gonzalez Post wrote:
 i'm working on some distance matrices and i was wondering if there is
 a way to export the matrices from R to excel.
 OG
 thanks

If 'dij' is your dissimilarity matrix as a 'dist' object (special lower
triangular representation) then this will write it out for you: 

write.csv(as.matrix(dij), file = foo.csv)

If 'dij' is a square matrix, then

write.csv(dij, file = foo.csv)

will do it.

I haven't used Excel for a while, but when I did, it had a restriction
of 256 columns. If this restriction is still in place, the above file
won't fit into Excel if you have more than 255 samples.

HTH

G

 
   [[alternative HTML version deleted]]
 
 __
 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.
-- 
%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%
 Dr. Gavin Simpson [t] +44 (0)20 7679 0522
 ECRC, UCL Geography,  [f] +44 (0)20 7679 0565
 Pearson Building, [e] gavin.simpsonATNOSPAMucl.ac.uk
 Gower Street, London  [w] http://www.ucl.ac.uk/~ucfagls/
 UK. WC1E 6BT. [w] http://www.freshwaters.org.uk
%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%

__
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] Structural Equation Models(SEM)

2009-12-03 Thread Ralf Finne
Thank you Jeremy for your information.
The world is changing though.  We live in an
increasing economic pressure. One symptom is that
we are forced to use smaller samples for economy.
This explains the interest for research in how the
methods perform on small samples.  The cited 
large simulation study shows GLS is more efficient
for small and badly distributed samples. 
So perhaps it would be worth the effort to make
an addition to sem(sem)

Yours
Ralf Finne
Emeritus
Novia University of Applied Science
Vasa Finland


 Jeremy Miles jeremy.mi...@gmail.com 12/02/09 8:22 PM 
In the world of SEM, GLS has pretty much fallen by the wayside - I
can't recall anything I've seen arguing for it's use in the past 10
years, and I also can't recall anyone using it over ML.   The
recommendations for non-normal distributions tend to be robust-ML, or
robust weighted least squares.  These are more computationally
intensive, and I *think* that John Fox (author of sem) has written
somewhere that it wouldn't be possible to implement them within R,
without using a lower level language - or rather that it might be
possible, but it would be really, really slow.

However, ML and GLS are pretty similar, if you dug around in the
source code, you could probably make the change (see,
http://www2.gsu.edu/~mkteer/discrep.html for example, for the
equations; in fact GLS is somewhat computationally simpler, as you
don't need to invert the implied covariance matrix at each iteration).
 However, the fact that it's not hard to make the change, and that no
one has made the change, is another argument that it's not a change
that needs to be made.

Jeremy



2009/12/2 Ralf Finne ralf.fi...@novia.fi:
 Hi R-colleagues.

 I have been using the sem(sem) function.  It uses
 maximum likelyhood as optimizing. method.
 According to simulation study in Umeå Sweden

(http://www.stat.umu.se/kursweb/vt07/stad04mom3/?download=UlfHolmberg.pdf
 Sorry it is in swedish, except the abstract)
 maximum likelihood is OK for large samples and normal distribution
 the SEM-problem should be optimized by GLS (Generalized Least
Squares).


 So to the question:

 Is there any R-function that solves SEM with GLS?


 Ralf Finne
 Novia University of Applied Science
 Vasa  Finland

 __
 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.




-- 
Jeremy Miles
Psychology Research Methods Wiki: www.researchmethodsinpsychology.com

__
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] count number of empty cells in a table/matrix/data.frame

2009-12-03 Thread Greg Snow
If you only want to count cells that are exactly 0.0 (not slightly different 
due to rounding errors) then try:

 sum( x==0 )

If you want a little wiggle room for rounding error, then you can try something 
like:

 sum( -0.001  x  x  0.001 )

Adjusting the number of 0's as you see fit.

Hope this helps,

-- 
Gregory (Greg) L. Snow Ph.D.
Statistical Data Center
Intermountain Healthcare
greg.s...@imail.org
801.408.8111


 -Original Message-
 From: r-help-boun...@r-project.org [mailto:r-help-boun...@r-
 project.org] On Behalf Of maiya
 Sent: Thursday, December 03, 2009 9:29 AM
 To: r-help@r-project.org
 Subject: [R] count number of empty cells in a table/matrix/data.frame
 
 
 Hi everyone!
 
 This is a ridiculously simple problem, I just can't seem to find the
 solution!
 
 All I need is something equivalent to
 
 sum(is.na(x))
 
 but instead of counting missing values, to count empty cells (with a
 value
 of 0).
 
 A naive attempt with is.empty didn't work :)
 
 Thanks!
 
 Maja
 
 Oh, and if the proposed solution would be to make all the empty cells
 into
 missing cells, that is not an option! There are over 20,000,000 cells
 in my
 table, and I don't think my computer is in the mood to store two such
 objects!
 --
 View this message in context: http://n4.nabble.com/count-number-of-
 empty-cells-in-a-table-matrix-data-frame-tp947740p947740.html
 Sent from the R help mailing list archive at Nabble.com.
 
 __
 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-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] GLM Question

2009-12-03 Thread Peter Flom
Knut Krueger r...@krueger-family.de wrote

I think this is more an general question to GLMs.

The result was better in all prior GLMs when I admitted the non
significant factors, but this is the first time that the result is worse
than before. What could be the reason for that?

glm(data1~data2+data3+data4+data5+data6,family=gaussian)
The result:

Coefficients:
 Estimate  Std. Error t value Pr(|t|)
(Intercept)3.3670852  0.8978306   3.750 0.000445 ***
data2  0.0002623  0.0001168   2.245 0.029024 *
data3 -0.9742336  0.5032712  -1.936 0.058337 .
data4  0.0628245  0.1503066   0.418 0.677686
data5 -0.0438871  0.0740210  -0.593 0.555818
data6$-0.0012216  0.0187702  -0.065 0.948357



if I test only or  lm() of course
glm(data1~data2,family=gaussian)

Coefficients:
Estimate Std. Error t value Pr(|t|)
(Intercept)   2.473e+00  2.787e-01   8.876 2.86e-12 ***
data27.289e-05  7.485e-05   0.9740.334


What do you mean by better?
Do you mean data2 was significant in one model and not the other?  How is this 
better?

The two models ask different questions, so, they get different answers.  

The first, more complex model, asks (re data2) what its relationship to data1 
is, controlling for the other variables.  The second model asks for 
uncontrolled.

Hope this helps

Peter

Peter L. Flom, PhD
Statistical Consultant
Website: www DOT peterflomconsulting DOT com
Writing; http://www.associatedcontent.com/user/582880/peter_flom.html
Twitter:   @peterflom

__
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 R2WinBUGS

2009-12-03 Thread Uwe Ligges



TTsai wrote:

Hello,

I have problem running WinBUGS from R.
The following example works in WinBUGS but it does not work in R through
package R2WinBUGS.


Works for me. What is the error message you get?

Best wishes,
Uwe Ligges





Does anyone know what the problem is?

x - c(0.2, 1.1, 1, 2.2, 2.5, 2.9, 2.9, 3.6, 3.8, 0.6, 1, 2, 2.4, 2.6, 2.8,
3.2, 3.9, 3.5)
y - c(0.5, 1.3, 0.1, 0.7, -0.4, 0.5, -0.9, -0.3, -0.3, 0.6, 0.4, 0.9, -0.1,
-0.4, -0.5, -0.2, 0.3, -1.5)
eco - c(1, 3, 1, 2, 1, 2, 1, 1, 2, 1, 1, 3, 2, 3, 2, 2, 2, 1)

N - length(y)
J - length(unique(eco))

f.data - list(N, y, x, eco, J)
f.inits - function(){
   list(sigma.y=1, beta.0=1, beta.x=1, beta.eco=c(NA, 1, 1))}
f.parameters - c(beta.0, beta.x, sigma.y, beta.eco)

f.ml - bugs (data=f.data, 
   inits=f.inits, 
   parameters.to.save=f.parameters, 
   model.file=oecd1.bug,  
   n.chains=3, 
   n.iter=1000,   
   debug=TRUE)



# This code works in WinBUGS.

model {
  # dummy variable
  for (i in 1:N){ 
  D.eco2[i] - equals(eco[i],2)  
  D.eco3[i] - equals(eco[i],3)
  }  
  # model's likelihood
  for (i in 1:N){  
y[i] ~ dnorm (mu[i], tau.y)  
mu[i] - beta.0 + beta.x*x[i] + beta.eco[2]*D.eco2[i] +
beta.eco[3]*D.eco3[i]  
  }
  # 
  beta.eco[1] - 0
  
  # priors

   beta.0 ~ dnorm (0, 0.0001)
   beta.x ~ dnorm (0, 0.0001)
   
   for (j in 2:J){ 
   beta.eco[j] ~ dnorm (0, 0.0001)  
   }
   
   tau.y - pow(sigma.y, -2) 
   sigma.y ~ dunif (0, 100)   
} 



DATA 
list(N=18, J=3,

x = c(0.2, 1.1, 1, 2.2, 2.5, 2.9, 2.9, 3.6, 3.8, 0.6, 1, 2, 2.4, 2.6, 2.8,
3.2, 3.9, 3.5),
y = c(0.5, 1.3, 0.1, 0.7, -0.4, 0.5, -0.9, -0.3, -0.3, 0.6, 0.4, 0.9, -0.1,
-0.4, -0.5, -0.2, 0.3, -1.5),
eco = c(1, 3, 1, 2, 1, 2, 1, 1, 2, 1, 1, 3, 2, 3, 2, 2, 2, 1)
)

INITIAL VALUES 
list(sigma.y=1, beta.0=1, beta.x=1, beta.eco=c(NA, 1, 1))


__
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] Three-dimensional (3D) movement using 'R'

2009-12-03 Thread David Winsemius


On Dec 3, 2009, at 7:59 AM, StRose, Suzanne wrote:


Hi Everyone,

I have a question regarding the construction of 3D graphs in 'R', BUT
these graphs also need to illustrate movement (with time) of the
prostate gland (using radiological techniques).  I am not sure how  
to do

this in 'R' although I'm sure there is some way of doing it.



Below, I have copied and pasted some of the data with which I'm  
working

on.


From an unspecified software format?


The data are for axial images of the prostate for four patients (N1,
N2, N3 and N4) over 20 time points.


You (and we readers) would be better served with the output of dput on  
the R object. That way you would not deliver an impossible-to-decode- 
list-of-solitary-numbers, which are now showing up along the left  
margin of the email that gets sent out from the list-server.


--
David.


The numbers represent the average
amplitude of movement by the prostate gland in mm. The signs (positive
and negative) indicate movement away from or toward the baseline,
respectively. So, any deviation away from the baseline is '+' and any
excursion toward baseline is negative (with the baseline indicated by
Time=0).



I would like to plot 3D graphs illustrating movement of the prostate
with time for each of the four patients but do not know how. I am  
not an

expert in 'R' so any help will be very, very much appreciated.



Thanks.



Best wishes,

Suzanne





Time

N1

N2

N3

N4

0

0

0

0

0

1

121.8

-60.6

69.8

-122.6

2

19.9

-101.1

77.2

-142.9

3

19.9

-101.1

77.2

-120.4

4

19.9

-101.1

25.8

-131.1

5

44.2

-111.7

25.8

-128.6

6

44.2

-111.7

25.8

-305.7

7

50.5

-111.7

25.8

-232.4

8

75.8

-111.7

121.1

-201.8

9

63

-111.7

121.1

-201.8

10

3.3

-111.7

121.1

-201.8

11

38.9

-111.7

76.4

-175

12

38.9

-111.7

76.4

-175

13

-1.1

-111.7

76.4

-178.8

14

-103.1

-111.7

76.4

-176.2

15

-49.4

-111.7

76.4

-176.2

16

-80.6

-56.5

76.4

-176.2

17

-12.5

-94.7

-37.9

-171.6

18

-12.5

-94.7

-19.8

-186.4

19

-12.5

-94.7

-19.8

-241.1

20

-12.5

-59.4

9.8

-200





Suzanne St.Rose (DVM, MSc, PhD)

Statistician

Royal Marsden NHS Foundation Trust

Fulham Road

London SW3 6JJ



Telephone: 0207 808 2186

Email: suzanne.str...@rmh.nhs.uk






#
Attention:\ This e-mail and any attachment is for author...{{dropped: 
19}}


__
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.


David Winsemius, MD
Heritage Laboratories
West Hartford, CT

__
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] Three-dimensional (3D) movement using 'R'

2009-12-03 Thread Duncan Murdoch

On 03/12/2009 7:59 AM, StRose, Suzanne wrote:

Hi Everyone,

 


I have a question regarding the construction of 3D graphs in 'R', BUT
these graphs also need to illustrate movement (with time) of the
prostate gland (using radiological techniques).  I am not sure how to do
this in 'R' although I'm sure there is some way of doing it. 

 


Below, I have copied and pasted some of the data with which I'm working
on. The data are for axial images of the prostate for four patients (N1,
N2, N3 and N4) over 20 time points. The numbers represent the average
amplitude of movement by the prostate gland in mm. The signs (positive
and negative) indicate movement away from or toward the baseline,
respectively. So, any deviation away from the baseline is '+' and any
excursion toward baseline is negative (with the baseline indicated by
Time=0). 

 


I would like to plot 3D graphs illustrating movement of the prostate
with time for each of the four patients but do not know how. I am not an
expert in 'R' so any help will be very, very much appreciated.
  


The rgl package allows you to put together 3D graphs, but the big issue 
is designing them.  Do you know what you want it to look like?


Duncan Murdoch

 


Thanks.

 


Best wishes,

Suzanne

 

 


Time

N1

N2

N3

N4

0

0

0

0

0

1

121.8

-60.6

69.8

-122.6

2

19.9

-101.1

77.2

-142.9

3

19.9

-101.1

77.2

-120.4

4

19.9

-101.1

25.8

-131.1

5

44.2

-111.7

25.8

-128.6

6

44.2

-111.7

25.8

-305.7

7

50.5

-111.7

25.8

-232.4

8

75.8

-111.7

121.1

-201.8

9

63

-111.7

121.1

-201.8

10

3.3

-111.7

121.1

-201.8

11

38.9

-111.7

76.4

-175

12

38.9

-111.7

76.4

-175

13

-1.1

-111.7

76.4

-178.8

14

-103.1

-111.7

76.4

-176.2

15

-49.4

-111.7

76.4

-176.2

16

-80.6

-56.5

76.4

-176.2

17

-12.5

-94.7

-37.9

-171.6

18

-12.5

-94.7

-19.8

-186.4

19

-12.5

-94.7

-19.8

-241.1

20

-12.5

-59.4

9.8

-200

 

 


Suzanne St.Rose (DVM, MSc, PhD)

Statistician

Royal Marsden NHS Foundation Trust

Fulham Road

London SW3 6JJ

 


Telephone: 0207 808 2186

Email: suzanne.str...@rmh.nhs.uk

 

 



#
Attention:\ This e-mail and any attachment is for author...{{dropped:19}}

__
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-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] Two-way/Three-way sum.

2009-12-03 Thread Peng Cai
Hi R Users,

I'm wondering how can I calculate two (or three) way sum of a variable. A
sample data is:

State Month Year Value
NC Jan 1996 1
NC Jan 1996 2
NC Feb 1997 2
NC Feb 1997 3
NC Mar 1998 3
NC Mar 1998 4
NY Jan 1996 4
NY Jan 1996 5
NY Feb 1997 5
NY Feb 1997 6
NY Mar 1998 6
NY Mar 1998 7

I'm trying to sum up value column by State*Month and by State*Month*Year.
Also, I may need to calculate mean value along with sum.

Any help would be greatly appreciated,

Thanks,
Peng

[[alternative HTML version deleted]]

__
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] Two-way/Three-way sum.

2009-12-03 Thread Greg Snow
?tapply

-- 
Gregory (Greg) L. Snow Ph.D.
Statistical Data Center
Intermountain Healthcare
greg.s...@imail.org
801.408.8111


 -Original Message-
 From: r-help-boun...@r-project.org [mailto:r-help-boun...@r-
 project.org] On Behalf Of Peng Cai
 Sent: Thursday, December 03, 2009 11:50 AM
 To: r-help@r-project.org
 Subject: [R] Two-way/Three-way sum.
 
 Hi R Users,
 
 I'm wondering how can I calculate two (or three) way sum of a variable.
 A
 sample data is:
 
 State Month Year Value
 NC Jan 1996 1
 NC Jan 1996 2
 NC Feb 1997 2
 NC Feb 1997 3
 NC Mar 1998 3
 NC Mar 1998 4
 NY Jan 1996 4
 NY Jan 1996 5
 NY Feb 1997 5
 NY Feb 1997 6
 NY Mar 1998 6
 NY Mar 1998 7
 
 I'm trying to sum up value column by State*Month and by
 State*Month*Year.
 Also, I may need to calculate mean value along with sum.
 
 Any help would be greatly appreciated,
 
 Thanks,
 Peng
 
   [[alternative HTML version deleted]]
 
 __
 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-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] Two-way/Three-way sum.

2009-12-03 Thread jim holtman
try this:

 x
   State Month Year Value
1 NC   Jan 1996 1
2 NC   Jan 1996 2
3 NC   Feb 1997 2
4 NC   Feb 1997 3
5 NC   Mar 1998 3
6 NC   Mar 1998 4
7 NY   Jan 1996 4
8 NY   Jan 1996 5
9 NY   Feb 1997 5
10NY   Feb 1997 6
11NY   Mar 1998 6
12NY   Mar 1998 7
 tapply(x$Value, list(x$State, x$Year), sum)
   1996 1997 1998
NC357
NY9   11   13

 tapply(x$Value, list(x$State, x$Year, x$Month), sum)
, , Feb
   1996 1997 1998
NC   NA5   NA
NY   NA   11   NA
, , Jan
   1996 1997 1998
NC3   NA   NA
NY9   NA   NA
, , Mar
   1996 1997 1998
NC   NA   NA7
NY   NA   NA   13




On Thu, Dec 3, 2009 at 1:50 PM, Peng Cai pengcaimaill...@gmail.com wrote:

 Hi R Users,

 I'm wondering how can I calculate two (or three) way sum of a variable. A
 sample data is:

 State Month Year Value
 NC Jan 1996 1
 NC Jan 1996 2
 NC Feb 1997 2
 NC Feb 1997 3
 NC Mar 1998 3
 NC Mar 1998 4
 NY Jan 1996 4
 NY Jan 1996 5
 NY Feb 1997 5
 NY Feb 1997 6
 NY Mar 1998 6
 NY Mar 1998 7

 I'm trying to sum up value column by State*Month and by State*Month*Year.
 Also, I may need to calculate mean value along with sum.

 Any help would be greatly appreciated,

 Thanks,
 Peng

[[alternative HTML version deleted]]

 __
 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.htmlhttp://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 that you are trying to solve?

[[alternative HTML version deleted]]

__
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] Two-way/Three-way sum.

2009-12-03 Thread Jorge Ivan Velez
Hi Peng,

Here is a suggestion using tapply:

R with(x, tapply(Value, list(State, Month), FUN = sum))
R with(x, tapply(Value, list(State, Year), FUN = sum))
R with(x, tapply(Value, list(State, Year, Month), FUN = sum))

with 'x' your data set.  Please take a look at ?tapply for more information.
Another useful functions might be ?ave and ?aggregate.

Best,
Jorge

On Thu, Dec 3, 2009 at 1:50 PM, Peng Cai  wrote:

 Hi R Users,

 I'm wondering how can I calculate two (or three) way sum of a variable. A
 sample data is:

 State Month Year Value
 NC Jan 1996 1
 NC Jan 1996 2
 NC Feb 1997 2
 NC Feb 1997 3
 NC Mar 1998 3
 NC Mar 1998 4
 NY Jan 1996 4
 NY Jan 1996 5
 NY Feb 1997 5
 NY Feb 1997 6
 NY Mar 1998 6
 NY Mar 1998 7

 I'm trying to sum up value column by State*Month and by State*Month*Year.
 Also, I may need to calculate mean value along with sum.

 Any help would be greatly appreciated,

 Thanks,
 Peng

[[alternative HTML version deleted]]

 __
 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.


[[alternative HTML version deleted]]

__
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] Two-way/Three-way sum.

2009-12-03 Thread Peng Cai
Thanks Greg, Jorge, and Jim for your help.

Peng

On Thu, Dec 3, 2009 at 1:58 PM, jim holtman jholt...@gmail.com wrote:

 try this:

  x
State Month Year Value
 1 NC   Jan 1996 1
 2 NC   Jan 1996 2
 3 NC   Feb 1997 2
 4 NC   Feb 1997 3
 5 NC   Mar 1998 3
 6 NC   Mar 1998 4
 7 NY   Jan 1996 4
 8 NY   Jan 1996 5
 9 NY   Feb 1997 5
 10NY   Feb 1997 6
 11NY   Mar 1998 6
 12NY   Mar 1998 7
  tapply(x$Value, list(x$State, x$Year), sum)
1996 1997 1998
 NC357
 NY9   11   13
 
  tapply(x$Value, list(x$State, x$Year, x$Month), sum)
 , , Feb
1996 1997 1998
 NC   NA5   NA
 NY   NA   11   NA
 , , Jan
1996 1997 1998
 NC3   NA   NA
 NY9   NA   NA
 , , Mar
1996 1997 1998
 NC   NA   NA7
 NY   NA   NA   13
 



   On Thu, Dec 3, 2009 at 1:50 PM, Peng Cai pengcaimaill...@gmail.comwrote:

  Hi R Users,

 I'm wondering how can I calculate two (or three) way sum of a variable. A
 sample data is:

 State Month Year Value
 NC Jan 1996 1
 NC Jan 1996 2
 NC Feb 1997 2
 NC Feb 1997 3
 NC Mar 1998 3
 NC Mar 1998 4
 NY Jan 1996 4
 NY Jan 1996 5
 NY Feb 1997 5
 NY Feb 1997 6
 NY Mar 1998 6
 NY Mar 1998 7

 I'm trying to sum up value column by State*Month and by
 State*Month*Year.
 Also, I may need to calculate mean value along with sum.

 Any help would be greatly appreciated,

 Thanks,
 Peng

[[alternative HTML version deleted]]

 __
 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.htmlhttp://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 that you are trying to solve?


[[alternative HTML version deleted]]

__
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] Two-way/Three-way sum.

2009-12-03 Thread David Winsemius


On Dec 3, 2009, at 1:50 PM, Peng Cai wrote:


Hi R Users,

I'm wondering how can I calculate two (or three) way sum of a  
variable. A

sample data is:

State Month Year Value
NC Jan 1996 1
NC Jan 1996 2
NC Feb 1997 2
NC Feb 1997 3
NC Mar 1998 3
NC Mar 1998 4
NY Jan 1996 4
NY Jan 1996 5
NY Feb 1997 5
NY Feb 1997 6
NY Mar 1998 6
NY Mar 1998 7

I'm trying to sum up value column by State*Month and by  
State*Month*Year.


?tapply

as in

sum.tbl - with(dftbl, tapply(Value, list(State, Month), sum) )


Also, I may need to calculate mean value along with sum.


Use the mean function in the above formulation to get means, length to  
get counts, or perhaps summary  or one of the several packages  
that offer a describe function. So many functions, so little time.


-- David




Any help would be greatly appreciated,

Thanks,
Peng

[[alternative HTML version deleted]]

__
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.


David Winsemius, MD
Heritage Laboratories
West Hartford, CT

__
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] Two-way/Three-way sum.

2009-12-03 Thread Peng Cai
Thanks David for your suggestions.

On Thu, Dec 3, 2009 at 2:03 PM, David Winsemius dwinsem...@comcast.netwrote:


 On Dec 3, 2009, at 1:50 PM, Peng Cai wrote:

 Hi R Users,

 I'm wondering how can I calculate two (or three) way sum of a variable. A
 sample data is:

 State Month Year Value
 NC Jan 1996 1
 NC Jan 1996 2
 NC Feb 1997 2
 NC Feb 1997 3
 NC Mar 1998 3
 NC Mar 1998 4
 NY Jan 1996 4
 NY Jan 1996 5
 NY Feb 1997 5
 NY Feb 1997 6
 NY Mar 1998 6
 NY Mar 1998 7

 I'm trying to sum up value column by State*Month and by
 State*Month*Year.


 ?tapply

 as in

 sum.tbl - with(dftbl, tapply(Value, list(State, Month), sum) )


 Also, I may need to calculate mean value along with sum.


 Use the mean function in the above formulation to get means, length to get
 counts, or perhaps summary  or one of the several packages that offer a
 describe function. So many functions, so little time.

 -- David



 Any help would be greatly appreciated,

 Thanks,
 Peng

[[alternative HTML version deleted]]

 __
 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.htmlhttp://www.r-project.org/posting-guide.html
 and provide commented, minimal, self-contained, reproducible code.


 David Winsemius, MD
 Heritage Laboratories
 West Hartford, CT



[[alternative HTML version deleted]]

__
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] Two-way/Three-way sum.

2009-12-03 Thread Peng Cai
Also, can I control for number of decimal places printed. Like when I use
mean function. By default it shows upto 7 dec. Thanks!


On Thu, Dec 3, 2009 at 2:08 PM, Peng Cai pengcaimaill...@gmail.com wrote:

 Thanks David for your suggestions.


 On Thu, Dec 3, 2009 at 2:03 PM, David Winsemius dwinsem...@comcast.netwrote:


 On Dec 3, 2009, at 1:50 PM, Peng Cai wrote:

 Hi R Users,

 I'm wondering how can I calculate two (or three) way sum of a variable. A
 sample data is:

 State Month Year Value
 NC Jan 1996 1
 NC Jan 1996 2
 NC Feb 1997 2
 NC Feb 1997 3
 NC Mar 1998 3
 NC Mar 1998 4
 NY Jan 1996 4
 NY Jan 1996 5
 NY Feb 1997 5
 NY Feb 1997 6
 NY Mar 1998 6
 NY Mar 1998 7

 I'm trying to sum up value column by State*Month and by
 State*Month*Year.


 ?tapply

 as in

 sum.tbl - with(dftbl, tapply(Value, list(State, Month), sum) )


 Also, I may need to calculate mean value along with sum.


 Use the mean function in the above formulation to get means, length to get
 counts, or perhaps summary  or one of the several packages that offer a
 describe function. So many functions, so little time.

 -- David



 Any help would be greatly appreciated,

 Thanks,
 Peng

[[alternative HTML version deleted]]

 __
 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.htmlhttp://www.r-project.org/posting-guide.html
 and provide commented, minimal, self-contained, reproducible code.


 David Winsemius, MD
 Heritage Laboratories
 West Hartford, CT




[[alternative HTML version deleted]]

__
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] how to use different ylim scales on a lattice bwplot?

2009-12-03 Thread Steve_Friedman

A colleague is interested in modifying the ylim definition for individual
panels of a common bwplot plotting statement.

Is there an approach to modifying the bwplot function to allow for a
dynamic ylim range given different panel factors ?

He is using R 2.6.2 on a Linux distribution running from a CD.

Thanks for the assistance.





Steve

Steve Friedman Ph. D.
Spatial Statistical Analyst
Everglades and Dry Tortugas National Park
950 N Krome Ave (3rd Floor)
Homestead, Florida 33034

steve_fried...@nps.gov
Office (305) 224 - 4282
Fax (305) 224 - 4147

__
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] Two-way/Three-way sum.

2009-12-03 Thread David Winsemius

On Dec 3, 2009, at 2:14 PM, Peng Cai wrote:

 Also, can I control for number of decimal places printed. Like when  
 I use mean function. By default it shows upto 7 dec. Thanks!

  print(4.567891234, digits=3)
[1] 4.57




 On Thu, Dec 3, 2009 at 2:08 PM, Peng Cai pengcaimaill...@gmail.com  
 wrote:
 Thanks David for your suggestions.


 On Thu, Dec 3, 2009 at 2:03 PM, David Winsemius dwinsem...@comcast.net 
  wrote:

 On Dec 3, 2009, at 1:50 PM, Peng Cai wrote:

 Hi R Users,

 I'm wondering how can I calculate two (or three) way sum of a  
 variable. A
 sample data is:

 State Month Year Value
 NC Jan 1996 1
 NC Jan 1996 2
 NC Feb 1997 2
 NC Feb 1997 3
 NC Mar 1998 3
 NC Mar 1998 4
 NY Jan 1996 4
 NY Jan 1996 5
 NY Feb 1997 5
 NY Feb 1997 6
 NY Mar 1998 6
 NY Mar 1998 7

 I'm trying to sum up value column by State*Month and by  
 State*Month*Year.

 ?tapply

 as in

 sum.tbl - with(dftbl, tapply(Value, list(State, Month), sum) )


 Also, I may need to calculate mean value along with sum.

 Use the mean function in the above formulation to get means, length  
 to get counts, or perhaps summary  or one of the several  
 packages that offer a describe function. So many functions, so  
 little time.

 -- David



 Any help would be greatly appreciated,

 Thanks,
 Peng

[[alternative HTML version deleted]]

 __
 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.

 David Winsemius, MD
 Heritage Laboratories
 West Hartford, CT




David Winsemius, MD
Heritage Laboratories
West Hartford, CT


[[alternative HTML version deleted]]

__
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] Two-way/Three-way sum.

2009-12-03 Thread Peng Cai
Thanks again!

On Thu, Dec 3, 2009 at 2:19 PM, David Winsemius dwinsem...@comcast.netwrote:


  On Dec 3, 2009, at 2:14 PM, Peng Cai wrote:

 Also, can I control for number of decimal places printed. Like when I use
 mean function. By default it shows upto 7 dec. Thanks!


  print(4.567891234, digits=3)
 [1] 4.57




 On Thu, Dec 3, 2009 at 2:08 PM, Peng Cai pengcaimaill...@gmail.comwrote:

 Thanks David for your suggestions.


 On Thu, Dec 3, 2009 at 2:03 PM, David Winsemius 
 dwinsem...@comcast.netwrote:


 On Dec 3, 2009, at 1:50 PM, Peng Cai wrote:

 Hi R Users,

 I'm wondering how can I calculate two (or three) way sum of a variable.
 A
 sample data is:

 State Month Year Value
 NC Jan 1996 1
 NC Jan 1996 2
 NC Feb 1997 2
 NC Feb 1997 3
 NC Mar 1998 3
 NC Mar 1998 4
 NY Jan 1996 4
 NY Jan 1996 5
 NY Feb 1997 5
 NY Feb 1997 6
 NY Mar 1998 6
 NY Mar 1998 7

 I'm trying to sum up value column by State*Month and by
 State*Month*Year.


 ?tapply

 as in

 sum.tbl - with(dftbl, tapply(Value, list(State, Month), sum) )


 Also, I may need to calculate mean value along with sum.


 Use the mean function in the above formulation to get means, length to
 get counts, or perhaps summary  or one of the several packages that
 offer a describe function. So many functions, so little time.

 -- David



 Any help would be greatly appreciated,

 Thanks,
 Peng

[[alternative HTML version deleted]]

 __
 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.htmlhttp://www.r-project.org/posting-guide.html
 and provide commented, minimal, self-contained, reproducible code.


 David Winsemius, MD
 Heritage Laboratories
 West Hartford, CT




  David Winsemius, MD
 Heritage Laboratories
 West Hartford, CT



[[alternative HTML version deleted]]

__
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] R and eclipse

2009-12-03 Thread Gene Leynes
I thought of your email when I ran across this link:
http://romainfrancois.blog.free.fr/index.php?post/2009/09/02/R-capable-version-of-ant

I think that you would have word your question more carefully for a longer
response.

Also, I use StatEt almost everyday.  It works great with R.  I have not used
Eclipse for any other language.

On Wed, Dec 2, 2009 at 12:20 PM, catuxa-2 catuxa...@gmail.com wrote:


   I found the eclipse plugin for R StatEt, hass anyone already worked with
 it?
   It's posible to put inside of java code a R script with it?
   Thank you
 --
 View this message in context:
 http://n4.nabble.com/R-and-eclipse-tp934851p934851.html
 Sent from the R help mailing list archive at Nabble.com.

 __
 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.


[[alternative HTML version deleted]]

__
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] Dataframe help

2009-12-03 Thread Ramya

Hi there

I have two dataframes
Dataframe_1
column_1colum_2
121  12345
145  1675
167   2765

Dataframe_2

column_1 column2
121abc
345lmn
167efg

I want a resulting dataframe

121 12345abc
167  2765 efg

how do i go abt it

Ramya
-- 
View this message in context: 
http://n4.nabble.com/Dataframe-help-tp947934p947934.html
Sent from the R help mailing list archive at Nabble.com.

__
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] Dataframe help

2009-12-03 Thread David Winsemius


On Dec 3, 2009, at 2:47 PM, Ramya wrote:



Hi there

I have two dataframes
Dataframe_1
column_1colum_2
121  12345
145  1675
167   2765

Dataframe_2

column_1 column2
121abc
345lmn
167efg

I want a resulting dataframe

121 12345abc
167  2765 efg

how do i go abt it


?merge



Ramya
--
View this message in context: 
http://n4.nabble.com/Dataframe-help-tp947934p947934.html
Sent from the R help mailing list archive at Nabble.com.

__
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.


David Winsemius, MD
Heritage Laboratories
West Hartford, CT

__
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] matrix data appears corrupted.. appears to be pairs of decimal numbers glommed together

2009-12-03 Thread Stephen Grubb
Hello,

We are occasionally getting matrix results that appear to be corrupted... here 
are the last several rows of an example, copy-pasted out of the R command 
window.  These are supposed to be floating point numbers.

[25015,]  1.820848e-01-3.2090e-06i
[25016,]  2.178046e-01-4.8140e-06i
[25017,]  1.820848e-01-3.2090e-06i
[25018,]  1.820848e-01-3.2090e-06i
[25019,]  1.144594e-01-1.6657e-06i
[25020,]  1.820848e-01-3.2090e-06i
[25021,] -1.293271e-01+4.3889e-06i
[25022,]  1.144594e-01-1.6657e-06i
[25023,]  1.820848e-01-3.2090e-06i
[25024,]  1.820848e-01-3.2090e-06i
[25025,]  1.173487e-01-4.4415e-07i
[25026,]  1.820848e-01-3.2090e-06i
[25027,]  1.375304e-01-3.6167e-06i
[25028,]  1.820848e-01-3.2090e-06i
[25029,] -1.293271e-01+4.3889e-06i
[25030,]  1.820848e-01-3.2090e-06i
[25031,]  1.820848e-01-3.2090e-06i
[25032,]  1.820848e-01-3.2090e-06i
[25033,]  1.820848e-01-3.2090e-06i

Any general idea what may be going on here?

It is a sporadic problem... it occurs maybe 2% or 3% of the time when running 
this particular script on various data.

I apologize for not including a pared-down example that reproduces the 
problem we are using an R script written elsewhere on large data sets.  If 
someone wants more specifics please follow up.

Steve Grubb

__
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] Dataframe help

2009-12-03 Thread Peng Cai
Try this:

both - merge(left, right, by.x=column1, by.y=column1)

left dataset
column1column2
121  12345
145  1675
167   2765

right datset
column1 column3
121abc
345lmn
167efg

HTH,
Peng

On Thu, Dec 3, 2009 at 2:47 PM, Ramya ramya.vict...@gmail.com wrote:


 Hi there

 I have two dataframes
 Dataframe_1
 column_1colum_2
 121  12345
 145  1675
 167   2765

 Dataframe_2

 column_1 column2
 121abc
 345lmn
 167efg

 I want a resulting dataframe

 121 12345abc
 167  2765 efg

 how do i go abt it

 Ramya
 --
 View this message in context:
 http://n4.nabble.com/Dataframe-help-tp947934p947934.html
 Sent from the R help mailing list archive at Nabble.com.

 __
 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.htmlhttp://www.r-project.org/posting-guide.html
 and provide commented, minimal, self-contained, reproducible code.


[[alternative HTML version deleted]]

__
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] matrix data appears corrupted.. appears to be pairs of decimal numbers glommed together

2009-12-03 Thread David Winsemius


On Dec 3, 2009, at 3:02 PM, Stephen Grubb wrote:


Hello,

We are occasionally getting matrix results that appear to be  
corrupted... here are the last several rows of an example, copy- 
pasted out of the R command window.  These are supposed to be  
floating point numbers.


[25015,]  1.820848e-01-3.2090e-06i
[25016,]  2.178046e-01-4.8140e-06i
[25017,]  1.820848e-01-3.2090e-06i
[25018,]  1.820848e-01-3.2090e-06i
[25019,]  1.144594e-01-1.6657e-06i
[25020,]  1.820848e-01-3.2090e-06i
[25021,] -1.293271e-01+4.3889e-06i
[25022,]  1.144594e-01-1.6657e-06i
[25023,]  1.820848e-01-3.2090e-06i
[25024,]  1.820848e-01-3.2090e-06i
[25025,]  1.173487e-01-4.4415e-07i
[25026,]  1.820848e-01-3.2090e-06i
[25027,]  1.375304e-01-3.6167e-06i
[25028,]  1.820848e-01-3.2090e-06i
[25029,] -1.293271e-01+4.3889e-06i
[25030,]  1.820848e-01-3.2090e-06i
[25031,]  1.820848e-01-3.2090e-06i
[25032,]  1.820848e-01-3.2090e-06i
[25033,]  1.820848e-01-3.2090e-06i

Any general idea what may be going on here?


Those are all complex numbers.



It is a sporadic problem... it occurs maybe 2% or 3% of the time  
when running this particular script on various data.


You are most likely solving or inverting something that does not  
have all real roots or eigenvalues  ... or something.




I apologize for not including a pared-down example that reproduces  
the problem we are using an R script written elsewhere on large  
data sets.  If someone wants more specifics please follow up.


Steve Grubb



David Winsemius, MD
Heritage Laboratories
West Hartford, CT

__
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] Dataframe help

2009-12-03 Thread Ramya

Thanks it worked!!! i was trying to use %in% and matching it.

Ramya

On Thu, Dec 3, 2009 at 2:06 PM, Peng Cai [via R] 
ml-node+947950-541874...@n4.nabble.comml-node%2b947950-541874...@n4.nabble.com
 wrote:

 Try this:

 both - merge(left, right, by.x=column1, by.y=column1)

 left dataset
 column1column2
 121  12345
 145  1675
 167   2765

 right datset
 column1 column3
 121abc
 345lmn
 167efg

 HTH,
 Peng

 On Thu, Dec 3, 2009 at 2:47 PM, Ramya [hidden 
 email]http://n4.nabble.com/user/SendEmail.jtp?type=nodenode=947950i=0
 wrote:

 
  Hi there
 
  I have two dataframes
  Dataframe_1
  column_1colum_2
  121  12345
  145  1675
  167   2765
 
  Dataframe_2
 
  column_1 column2
  121abc
  345lmn
  167efg
 
  I want a resulting dataframe
 
  121 12345abc
  167  2765 efg
 
  how do i go abt it
 
  Ramya
  --
  View this message in context:
  http://n4.nabble.com/Dataframe-help-tp947934p947934.html
  Sent from the R help mailing list archive at Nabble.com.
 
  __
  [hidden 
  email]http://n4.nabble.com/user/SendEmail.jtp?type=nodenode=947950i=1mailing
   list
  https://stat.ethz.ch/mailman/listinfo/r-help
  PLEASE do read the posting guide
  http://www.R-project.org/posting-guide.html
 http://www.r-project.org/posting-guide.html
  and provide commented, minimal, self-contained, reproducible code.
 

 [[alternative HTML version deleted]]

 __
 [hidden 
 email]http://n4.nabble.com/user/SendEmail.jtp?type=nodenode=947950i=2mailing
  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.


 --
  View message @ http://n4.nabble.com/Dataframe-help-tp947934p947950.html
 To unsubscribe from Dataframe help, click here (link removed) ==.




-- 
View this message in context: 
http://n4.nabble.com/Dataframe-help-tp947934p947960.html
Sent from the R help mailing list archive at Nabble.com.

[[alternative HTML version deleted]]

__
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] count number of empty cells in a table/matrix/data.frame

2009-12-03 Thread maja zaloznik
Thanks everyone who bothered to reply...

I'm in the middle of a working binge and my brain is clearly fried if I
wasn't able to figure that one out! Time to take a break...

m.

2009/12/3 Greg Snow greg.s...@imail.org

 If you only want to count cells that are exactly 0.0 (not slightly
 different due to rounding errors) then try:

  sum( x==0 )

 If you want a little wiggle room for rounding error, then you can try
 something like:

  sum( -0.001  x  x  0.001 )

 Adjusting the number of 0's as you see fit.

 Hope this helps,

 --
 Gregory (Greg) L. Snow Ph.D.
 Statistical Data Center
 Intermountain Healthcare
 greg.s...@imail.org
 801.408.8111


  -Original Message-
  From: r-help-boun...@r-project.org [mailto:r-help-boun...@r-
  project.org] On Behalf Of maiya
  Sent: Thursday, December 03, 2009 9:29 AM
  To: r-help@r-project.org
  Subject: [R] count number of empty cells in a table/matrix/data.frame
 
 
  Hi everyone!
 
  This is a ridiculously simple problem, I just can't seem to find the
  solution!
 
  All I need is something equivalent to
 
  sum(is.na(x))
 
  but instead of counting missing values, to count empty cells (with a
  value
  of 0).
 
  A naive attempt with is.empty didn't work :)
 
  Thanks!
 
  Maja
 
  Oh, and if the proposed solution would be to make all the empty cells
  into
  missing cells, that is not an option! There are over 20,000,000 cells
  in my
  table, and I don't think my computer is in the mood to store two such
  objects!
  --
  View this message in context: http://n4.nabble.com/count-number-of-
  empty-cells-in-a-table-matrix-data-frame-tp947740p947740.html
  Sent from the R help mailing list archive at Nabble.com.
 
  __
  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.


[[alternative HTML version deleted]]

__
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] S4 Classes, nested objects and references

2009-12-03 Thread Martin Morgan
Joris Meys wrote:
 Hi all,
 
 I'm currently programming my first complete package in S4. (thanks to
 Christophe Genolini for the nice introduction he wrote). I have an
 object Data with a number of slots. One of those slots is meteo.
 Now Meteo is on itself a class with again a number of slots (like
 rainfall, temperature,..., you get the picture).
 
 I defined the slot meteo currently as a character slot, and the
 values refer to the names of the Meteo-objects related to that
 Data-object. The cleaner way would be to define the slot meteo as a
 slot of class Meteo, but I'm not sure how that works internally.
 
 Thing is, I have multiple Data objects that refer to the same Meteo
 object. I am a bit afraid that when I define the slot meteo as a slot
 of the corresponding class, each Data object will contain a complete
 copy of the Meteo object it relates to. This would mean that in the
 memory I will end up with multiple copies of exactly the same data.
 Although it is cleaner, it is definitely not more efficient.
 
 My question : Am I wrong in my assumption that I will have multiple
 copies in the memories? If yes, is it possible to use references in a
 more formal way than I do now? Or is there an obvious solution I am
 missing here?

Hi Joris -- you're second-guessing R's memory management; it could be
that the data are physically replicated, but that may not necessarily be
so. The first thing to do is the obvious, define the slot to contain an
object of class Mateo.

If memory management really is an issue, then round two might define
Mateo to contain a slot that is an environment, in which the big data is
stored.

setClass(Mateo, representation=representation(bigData=environment))

bigData = new.env(parent=emptyenv())
bigData[[myData]] = ...
m = new(Mateo, bigData=bigData)

This really changes the semantics of objects, so you'll want to protect
your end users from unintended consequences, e.g., after n = m, changing
m...@bigdata[[myData]] would also change n. You might use lockEnvironment
in an initialize method to make sure that bigData is really read-only,
or provide accessors that copy bigData when the user wants to make a
change. It is also important to realize that setClass defines a
prototype, the prototype contains an environment, and unless you take
care then all instances derived from the prototype (e.g., calling new()
without a bigData argument) will share the same environment. Probably
not what you want. This extra work really reflects the change in
semantics implied by references; it is only indirectly related to S4.

Martin

 
 Thank you in advance
 Cheers
 Joris
 
 __
 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.


-- 
Martin Morgan
Computational Biology / Fred Hutchinson Cancer Research Center
1100 Fairview Ave. N.
PO Box 19024 Seattle, WA 98109

Location: Arnold Building M1 B861
Phone: (206) 667-2793

__
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] documentation of intersect() on string vector and num vector and on duplicated elements

2009-12-03 Thread Peter Ehlers


Greg Snow wrote:

-Original Message-
From: r-help-boun...@r-project.org [mailto:r-help-boun...@r-
project.org] On Behalf Of David Winsemius
Sent: Wednesday, December 02, 2009 3:25 PM
To: Peng Yu
Cc: r-h...@stat.math.ethz.ch
Subject: Re: [R] documentation of intersect() on string vector and num
vector and on duplicated elements



I nominate the following as a fortune:


If you are not going to read the help page, then please stop asking
for corrections to it.



I'll second that motion.

 -Peter Ehlers







David Winsemius, MD
Heritage Laboratories
West Hartford, CT



When is the version of the fortunes package on R-Forge going to make it to CRAN?

Thanks,



__
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] Data Manipulation Question

2009-12-03 Thread John Filben
Can R support data manipulation programming that is available in the SAS 
datastep?  Specifically, can R support the following:
-          Read multiple dataset one record at a time and compare 
values from each; then base on if-then logic write to multiple output files
-          Load a lookup table and then process a different file; 
based on if-then logic, access and lookup values in the table
-          Support modular “gosub”programming
-          Sort files
-          Date math and conversions
-          Would it be able to support the following type of logic:
o   Start
§  Read Record from File 1
§  Read Record from File 2
§  Match
·         If Key 1  Key 2 and Key 1  Key 2, Write to output file A
·         If Key 1 = Key 2, Write to output file B
·         If Key 1  Key 2 and Key 1  Key 2, Write to output file 
C§  Goto Start until File 1 Done
 John Filben
Cell Phone - 773.401.2822
Email - johnfil...@yahoo.com 


  
[[alternative HTML version deleted]]

__
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] Data Manipulation Question

2009-12-03 Thread hadley wickham
On Thu, Dec 3, 2009 at 3:52 PM, John Filben johnfil...@yahoo.com wrote:
 Can R support data manipulation programming that is available in the SAS 
 datastep?  Specifically, can R support the following:
 -  Read multiple dataset one record at a time and compare values from 
 each; then base on if-then logic write to multiple output files
 -  Load a lookup table and then process a different file; based on 
 if-then logic, access and lookup values in the table
 -  Support modular “gosub”programming
 -  Sort files
 -  Date math and conversions
 -  Would it be able to support the following type of logic:
 o   Start
 §  Read Record from File 1
 §  Read Record from File 2
 §  Match
 · If Key 1  Key 2 and Key 1  Key 2, Write to output file A
 · If Key 1 = Key 2, Write to output file B
 · If Key 1  Key 2 and Key 1  Key 2, Write to output file C§  Goto 
 Start until File 1 Done

Yes.

Hadley


-- 
http://had.co.nz/

__
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] Data Manipulation Question

2009-12-03 Thread Jason Morgan
Please refrain from posting HTML. The results can be incomprehensible:

On 2009.12.03 13:52:09, John Filben wrote:
 Can R support data manipulation programming that is available in the SAS 
 datastep??? Specifically, can R support the following:
 -?? Read multiple dataset one record at a time and compare 
 values from each; then base on if-then logic write to multiple output files
 -?? Load a lookup table and then process a different file; 
 based on if-then logic, access and lookup values in the table
 -?? Support modular ???gosub???programming
 -?? Sort files
 -?? Date math and conversions
 -?? Would it be able to support the following type of logic:
 o Start
  Read Record from File 1
  Read Record from File 2
  Match
 ?? If Key 1  Key 2 and Key 1  Key 2, Write to output file A
 ?? If Key 1 = Key 2, Write to output file B
 ?? If Key 1  Key 2 and Key 1  Key 2, Write to output file 
 C Goto Start until File 1 Done
 ??John Filben
 Cell Phone - 773.401.2822
 Email - johnfil...@yahoo.com 
   
   [[alternative HTML version deleted]]

-- 
Jason W. Morgan
Graduate Student
Department of Political Science
*The Ohio State University*
154 North Oval Mall
Columbus, Ohio 43210

__
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] dataset index

2009-12-03 Thread Lisa

Hello, All,

I have a dataset that looks like this: 
  
x - matrix(c(
0, 0, 0,
0, 0, 0,
0, 1, 0,
0, 1, 0,
0, 1, 0,
1, 2, 1,
1, 2, 1,
1, 3, 1,
1, 3, 1,
1, 3, 1),
ncol = 5, byrow = T, 
dimnames = list(1:10, c(gender, race, disease)))

I want to write a function to produce several matrices including only “TRUE”
and “FALSE” for the different levels of the variables (these matrices may be
thought as index matrices), like

 m1
TRUE TRUE FALSE FALSE FALSE FALSE FALSE FALSE FALSE FALSE

 m2
FALSE FALSE TRUE TRUE TRUE FALSE FALSE FALSE FALSE FALSE

 m3
FALSE FALSE FALSE FALSE FALSE TRUE TRUE FALSE FALSE FALSE

 m4
FALSE FALSE FALSE FALSE FALSE FALSE FALSE TRUE TRUE TRUE

Can anyone please help how to get this done? Your help would be greatly
appreciated. 

Lisa 

-- 
View this message in context: 
http://n4.nabble.com/dataset-index-tp948049p948049.html
Sent from the R help mailing list archive at Nabble.com.

__
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] Question about R Functions

2009-12-03 Thread Stephanie Cooke
Is there a place to find the code for R functions like lsoda? Thanks

__
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] dataset index

2009-12-03 Thread jim holtman
Does this do what you want:

 x - matrix(c(
+ 0, 0, 0,
+ 0, 0, 0,
+ 0, 1, 0,
+ 0, 1, 0,
+ 0, 1, 0,
+ 1, 2, 1,
+ 1, 2, 1,
+ 1, 3, 1,
+ 1, 3, 1,
+ 1, 3, 1),
+ ncol = 3, byrow = T,
+ dimnames = list(1:10, c(gender, race, disease)))
 key - apply(x, 1, paste, collapse=:)
 m.flags - lapply(unique(key), function(.indx){
+ key == .indx
+ })
 # create the keys
 do.call(rbind, m.flags)
 1 2 3 4 5 6 7 8 910
[1,]  TRUE  TRUE FALSE FALSE FALSE FALSE FALSE FALSE FALSE FALSE
[2,] FALSE FALSE  TRUE  TRUE  TRUE FALSE FALSE FALSE FALSE FALSE
[3,] FALSE FALSE FALSE FALSE FALSE  TRUE  TRUE FALSE FALSE FALSE
[4,] FALSE FALSE FALSE FALSE FALSE FALSE FALSE  TRUE  TRUE  TRUE



On Thu, Dec 3, 2009 at 5:07 PM, Lisa lisa...@gmail.com wrote:

 Hello, All,

 I have a dataset that looks like this:

 x - matrix(c(
 0, 0, 0,
 0, 0, 0,
 0, 1, 0,
 0, 1, 0,
 0, 1, 0,
 1, 2, 1,
 1, 2, 1,
 1, 3, 1,
 1, 3, 1,
 1, 3, 1),
 ncol = 5, byrow = T,
 dimnames = list(1:10, c(gender, race, disease)))

 I want to write a function to produce several matrices including only “TRUE”
 and “FALSE” for the different levels of the variables (these matrices may be
 thought as index matrices), like

 m1
 TRUE TRUE FALSE FALSE FALSE FALSE FALSE FALSE FALSE FALSE

 m2
 FALSE FALSE TRUE TRUE TRUE FALSE FALSE FALSE FALSE FALSE

 m3
 FALSE FALSE FALSE FALSE FALSE TRUE TRUE FALSE FALSE FALSE

 m4
 FALSE FALSE FALSE FALSE FALSE FALSE FALSE TRUE TRUE TRUE

 Can anyone please help how to get this done? Your help would be greatly
 appreciated.

 Lisa

 --
 View this message in context: 
 http://n4.nabble.com/dataset-index-tp948049p948049.html
 Sent from the R help mailing list archive at Nabble.com.

 __
 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.




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

What is the problem that you are trying to solve?

__
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] Revolutions blog: November roundup

2009-12-03 Thread David M Smith
I write about R every weekday at the Revolutions blog:
http://blog.revolution-computing.com .

In case you missed them, here are some articles from last month of
particular interest to R users.

http://bit.ly/un680 demonstrated reader Paul Bleicher's code for
visualizing a time series as a heat-map calendar.

http://bit.ly/5fgis0 and http://bit.ly/mepBH showed (with thanks to
Drew Conway) how to use R to perform social network analysis on live
data from Twitter.

http://bit.ly/KKvSA challenged the R community to recreate an
unemployment map created in Python in R. The results
(http://bit.ly/11Qve9) were outstanding, and also inspired a similar
look at unemployment in Germany (http://bit.ly/2Mywrq).

http://bit.ly/4nKQ0w showcased a Brazilian open-government website
created by Eduardo Leoni that relies heavily on R.

Several media outlets this month looked at the impact of R and IBM's
acquisition of SPSS on SAS: Information Management
(http://bit.ly/5Qu5mp and http://bit.ly/8VT03b), the New York Times
(http://bit.ly/5TRQBi), and Business Week (http://bit.ly/54OoNE).

http://bit.ly/8hUr9u related how R graphics were used to illustrate an
analysis of the US healthcare reform politics in the New York Times.

http://bit.ly/3sM5kQ reviewed R's presence at a data-mining
unconference in the Bay Area.

http://bit.ly/3MZn0r showed how easy it is to install ESS on Ubuntu
Linux, for a more productive environment for programming in R.

http://bit.ly/6ajtBu looked at some of the unique features of R's
function-call semantics.

http://bit.ly/7UNSbl was a tongue-in-cheek comparison of Hadoop and R.

http://bit.ly/1uxU3w announced REvolution Computing's R Productivity
Environment, an IDE for R on Windows.

http://bit.ly/1Qxp9P shares the slides from the Introduction to R talk
I have to a Linux User Group in Davis (CA), and some links for R
beginners.

http://bit.ly/uZRtS linked to a simple analysis of scores from the
game Canabalt.

Other non-R-specific stories in the last month covered: floating-point
errors (http://bit.ly/3UU4SJ), Stochasticity on the radio
(http://bit.ly/4NpvRN), breast cancer screening
(http://bit.ly/8Y01rs), the Mythbusters (http://bit.ly/8dd3Uz) and on
the lighter side: the connection between Tufte and Lord of the Rings
(http://bit.ly/5G6o31), a new way of looking at Choose Your Own
Adventure books (http://bit.ly/1unnsO), and the Reimann Hypothesis
(http://bit.ly/87ieTX).

(I've provided short URLs above because many mailers break the long
direct URLs.)

The R Community Calendar has also been updated at:
http://blog.revolution-computing.com/calendar.html

You can find summaries of older postings here:
http://blog.revolution-computing.com/roundups/

As always, thanks for the comments and please keep sending suggestions
to me at da...@revolution-computing.com . Don't forget you can also
follow the blog using an RSS reader like Google Reader, or by
following me on Twitter (I'm @revodavid).

Cheers to all,
# David Smith

--
David M Smith da...@revolution-computing.com
VP of Marketing, REvolution Computing  http://blog.revolution-computing.com
Tel: +1 (206) 577-4778 x3203 (Palo Alto, CA, USA)

Download REvolution R free:
www.revolution-computing.com/downloads/revolution-r.php

__
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] Scraping a web page

2009-12-03 Thread Michael Conklin
I would like to be able to submit a list of URLs of various webpages and 
extract the content i.e. not the mark-up of those pages. I can find plenty of 
examples in the XML library of extracting links from pages but I cannot seem to 
find a way to extract the text.  Any help would be greatly appreciated - I will 
not know the structure of the URLs I would submit in advance.  Any suggestions 
on where to look would be greatly appreciated.

Mike

W. Michael Conklin
Chief Methodologist

MarketTools, Inc. | www.markettools.comhttp://www.markettools.com
6465 Wayzata Blvd | Suite 170 |  St. Louis Park, MN 55426.  PHONE: 952.417.4719 
| CELL: 612.201.8978
This email and attachment(s) may contain confidential and/or proprietary 
information and is intended only for the intended addressee(s) or its 
authorized agent(s). Any disclosure, printing, copying or use of such 
information is strictly prohibited. If this email and/or attachment(s) were 
received in error, please immediately notify the sender and delete all copies


[[alternative HTML version deleted]]

__
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] Question about R Functions

2009-12-03 Thread Ista Zahn
Yep! just do

RSiteSeqarch(lsoda)

-Ista

On Thu, Dec 3, 2009 at 5:26 PM, Stephanie Cooke
cooke.stepha...@gmail.com wrote:
 Is there a place to find the code for R functions like lsoda? Thanks

 __
 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.




-- 
Ista Zahn
Graduate student
University of Rochester
Department of Clinical and Social Psychology
http://yourpsyche.org

__
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] Question about R Functions

2009-12-03 Thread David Winsemius

http://search.r-project.org/cgi-bin/namazu.cgi?query=lsodamax=100result=normalsort=scoreidxname=functionsidxname=Rhelp08idxname=views

On Dec 3, 2009, at 5:26 PM, Stephanie Cooke wrote:


Is there a place to find the code for R functions like lsoda? Thanks

__
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.


David Winsemius, MD
Heritage Laboratories
West Hartford, CT

__
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 use different ylim scales on a lattice bwplot?

2009-12-03 Thread Felix Andrews
You can define a custom prepanel function: see the entry for
'prepanel' in ?xyplot

If you just want to set specified ylims in each panel, you can do that
by passing a list to 'ylim'.


2009/12/4  steve_fried...@nps.gov:
 A colleague is interested in modifying the ylim definition for individual
 panels of a common bwplot plotting statement.

 Is there an approach to modifying the bwplot function to allow for a
 dynamic ylim range given different panel factors ?

 He is using R 2.6.2 on a Linux distribution running from a CD.

 Thanks for the assistance.





 Steve

 Steve Friedman Ph. D.
 Spatial Statistical Analyst
 Everglades and Dry Tortugas National Park
 950 N Krome Ave (3rd Floor)
 Homestead, Florida 33034

 steve_fried...@nps.gov
 Office (305) 224 - 4282
 Fax     (305) 224 - 4147

 __
 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.




-- 
Felix Andrews / 安福立
Postdoctoral Fellow
Integrated Catchment Assessment and Management (iCAM) Centre
Fenner School of Environment and Society [Bldg 48a]
The Australian National University
Canberra ACT 0200 Australia
M: +61 410 400 963
T: + 61 2 6125 4670
E: felix.andr...@anu.edu.au
CRICOS Provider No. 00120C
-- 
http://www.neurofractal.org/felix/

__
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] dataset index

2009-12-03 Thread Charles C. Berry

On Thu, 3 Dec 2009, Lisa wrote:



Hello, All,

I have a dataset that looks like this:

x - matrix(c(
0, 0, 0,
0, 0, 0,
0, 1, 0,
0, 1, 0,
0, 1, 0,
1, 2, 1,
1, 2, 1,
1, 3, 1,
1, 3, 1,
1, 3, 1),
ncol = 5, byrow = T,
dimnames = list(1:10, c(gender, race, disease)))

I want to write a function to produce several matrices including only “TRUE”
and “FALSE” for the different levels of the variables (these matrices may be
thought as index matrices), like


m1

TRUE TRUE FALSE FALSE FALSE FALSE FALSE FALSE FALSE FALSE


m2

FALSE FALSE TRUE TRUE TRUE FALSE FALSE FALSE FALSE FALSE


m3

FALSE FALSE FALSE FALSE FALSE TRUE TRUE FALSE FALSE FALSE


m4

FALSE FALSE FALSE FALSE FALSE FALSE FALSE TRUE TRUE TRUE

Can anyone please help how to get this done? Your help would be greatly
appreciated.



Perhaps

apply(x , 2, function(x) model.matrix(~0+factor(x))==1)

??

Chuck

p.s. ncol = 3, I would think.




Lisa

--
View this message in context: 
http://n4.nabble.com/dataset-index-tp948049p948049.html
Sent from the R help mailing list archive at Nabble.com.

__
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.



Charles C. Berry(858) 534-2098
Dept of Family/Preventive Medicine
E mailto:cbe...@tajo.ucsd.edu   UC San Diego
http://famprevmed.ucsd.edu/faculty/cberry/  La Jolla, San Diego 92093-0901

__
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] Please help with AR(2)

2009-12-03 Thread PeterS

I need help in interpreting AR(2) model which is of a form y=phi2(t-2)+e... I
can't get past the fact that phi1 is missing -does it mean that phi1 = 0?
why would that be a case? Thank you all in advance!
-- 
View this message in context: 
http://n4.nabble.com/Please-help-with-AR-2-tp947912p947912.html
Sent from the R help mailing list archive at Nabble.com.

__
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] Arules - Association Rules

2009-12-03 Thread Alexandre Shimada
Hi
I'm a windows XP user.
My notebook have 1gb ram, 160gb hd, processor amd turion64 1,6gh. For
processing, it takes about 40 minutes.

This is the code i used:

dados=read.csv(C:/Documents and Settings/Administrador/Meus documentos/My
Dropbox/Estatística/Association Rules/Top2009 alterado.csv, header=T,
rep=;)
library(arules)
bin=as(dados, transactions)
rules - apriori(bin, parameter = list(support = 0.01, confidence = 0.6))

Above is a sample os fthe file. I export data as CSV from excel. I have 71
columns (variabels) an 1001 lines (responses)

 1. Churrascaria 2. Supermercado 3. Restaurante Self Service 4. Restaurante
Chinês 5. Buffet 6. Sorvete 7. Frango  Galpão Nelore Super Muffato Não Sabe Jin
Jin Planalto Sávio Big Frango  Vento Sul Super Muffato Não Sabe Não Sabe Não
Sabe Doce Verão Frangão  Gaúcha Super Muffato Não Sabe Não Sabe Não Sabe
Kibon Sadia  Tradição Gaúcha Super Muffato Não Sabe Não Sabe Não Sabe
Nestlé Big
Frango  Não Sabe Super Muffato Não Sabe Não Sabe Estilo Sávio Big
Frango  Rancho
Grill Viscardi Akira Akira Não Sabe Não Sabe Não Sabe


Thank you very for your helping!!!

2009/12/3 Steve Lianoglou mailinglist.honey...@gmail.com

 Hi,

 On Wed, Dec 2, 2009 at 6:57 PM, Alexandre - UEL shima...@gmail.com
 wrote:
  Hello everybody!
  I'm trying some datamining, but i'm having some problems with arule
  package, in the end of processing R had to be closed. I already
  tryied to reinstall the 2.10 version, change the computer and
  realocated more virtual memory.
 
  Does anyone had this problem to?
 
  I had a hiphoteses that i have to prepare the data, somehow i don't
  know.
 
  Thanks for helping!!!

 Can you provide more info here?

 1. I'm assuming since you're talking about reallocating virtual
 memory, or whatever, you're on windows?
 2. What's the exact error you're getting (what's it saying before R
 'had to be closed'?
 3. What's the size of your data? What type of data is it?
 4. How much RAM do you have?
 5. Are you on a 32 or 64 bit system?
 6 What happens if you cut your data in half?
 6. Can you provide a (very small) reproducible example of your data + code?
 ...

 -steve

 --
 Steve Lianoglou
 Graduate Student: Computational Systems Biology
  | Memorial Sloan-Kettering Cancer Center
  | Weill Medical College of Cornell University
 Contact Info: 
 http://cbio.mskcc.org/~lianos/contacthttp://cbio.mskcc.org/%7Elianos/contact




-- 
É inútil e estúpido lastimar o mundo.
Sofrimento e prazer são frutos do que faz
Nissen Shounin

[[alternative HTML version deleted]]

__
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] Arules - Association Rules

2009-12-03 Thread Alexandre - UEL
Hi
I'm a windows XP user.
My notebook have 1gb ram, 160gb hd, processor amd turion64 1,6gh. For
processing, it takes about 40 minutes.

This is the code i used:

dados=read.csv(C:/Documents and Settings/Administrador/Meus
documentos/My Dropbox/Estatística/Association Rules/Top2009
alterado.csv, header=T, sep=;)
library(arules)
bin=as(dados, transactions)
rules - apriori(bin, parameter = list(support = 0.01, confidence =
0.6))

Below is a sample of the file. I export data as CSV from excel. I have
71 columns (variabels) an 1001 lines (responses)

1. Churrascaria 2. Supermercado 3. Restaurante Self Service 
4.
Restaurante Chinês  5. Buffet   6. Sorvete
Galpão Nelore   Super MuffatoNão Sabe
 Jin JinPlanaltoSávio
Vento Sul   Super MuffatoNão Sabe
Não SabeNão SabeDoce Verão
Gaúcha  Super MuffatoNão Sabe
 Não Sabe   Não SabeKibon
Tradição Gaúcha Super MuffatoNão Sabe
 Não Sabe   Não SabeNestlé
Não SabeSuper MuffatoNão Sabe
Não SabeEstilo  Sávio
Rancho GrillViscardi Akira
 Akira Não Sabe Não Sabe



Thank you very for your helping!!!



On 3 dez, 01:46, Steve Lianoglou mailinglist.honey...@gmail.com
wrote:
 Hi,

 On Wed, Dec 2, 2009 at 6:57 PM, Alexandre - UEL shima...@gmail.com wrote:

  Hello everybody!
  I'm trying some datamining, but i'm having some problems with arule
  package, in the end of processing R had to be closed. I already
  tryied to reinstall the 2.10 version, change the computer and
  realocated more virtual memory.

  Does anyone had this problem to?

  I had a hiphoteses that i have to prepare the data, somehow i don't
  know.

  Thanks for helping!!!

 Can you provide more info here?

 1. I'm assuming since you're talking about reallocating virtual
 memory, or whatever, you're on windows?
 2. What's the exact error you're getting (what's it saying before R
 'had to be closed'?
 3. What's the size of your data? What type of data is it?
 4. How much RAM do you have?
 5. Are you on a 32 or 64 bit system?
 6 What happens if you cut your data in half?
 6. Can you provide a (very small) reproducible example of your data + code?
 ...

 -steve

 --
 Steve Lianoglou
 Graduate Student: Computational Systems Biology
  | Memorial Sloan-Kettering Cancer Center
  | Weill Medical College of Cornell University
 Contact Info:http://cbio.mskcc.org/~lianos/contact

 __
 r-h...@r-project.org mailing listhttps://stat.ethz.ch/mailman/listinfo/r-help
 PLEASE do read the posting guidehttp://www.R-project.org/posting-guide.html
 and provide commented, minimal, self-contained, reproducible code.

__
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] Tobit model fluid milk consumption

2009-12-03 Thread mrsilva


Hi all, 

I'm from Brazil. 

I fit a Tobit model to FLUID MILK CONSUMPTION (DEPENDENT VARIABLE) data
using survreg (attached). 

I am confused about the output interpretation and I would like yours
explanations. 

Thanks, Marcio Roberto Silva

Tobit model.pdf
Description: Adobe PDF document
__
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] corrupted matrix data.. sporadic result appears to be pairs of decimal numbers glommed together

2009-12-03 Thread Stephen Grubb
Hello, 

We are occasionally getting matrix results that appear to be corrupted... here 
are the last several rows of an example.  These are supposed to be floating 
point numbers.

[25015,]  1.820848e-01-3.2090e-06i
[25016,]  2.178046e-01-4.8140e-06i
[25017,]  1.820848e-01-3.2090e-06i
[25018,]  1.820848e-01-3.2090e-06i
[25019,]  1.144594e-01-1.6657e-06i
[25020,]  1.820848e-01-3.2090e-06i
[25021,] -1.293271e-01+4.3889e-06i
[25022,]  1.144594e-01-1.6657e-06i
[25023,]  1.820848e-01-3.2090e-06i
[25024,]  1.820848e-01-3.2090e-06i
[25025,]  1.173487e-01-4.4415e-07i
[25026,]  1.820848e-01-3.2090e-06i
[25027,]  1.375304e-01-3.6167e-06i
[25028,]  1.820848e-01-3.2090e-06i
[25029,] -1.293271e-01+4.3889e-06i
[25030,]  1.820848e-01-3.2090e-06i
[25031,]  1.820848e-01-3.2090e-06i
[25032,]  1.820848e-01-3.2090e-06i
[25033,]  1.820848e-01-3.2090e-06i

Any general idea what may be going on here?

It is a sporadic problem... it occurs maybe 2% or 3% of the time when running 
this particular script on various data.

I apologize for not including a pared-down example that reproduces the 
problem we are using an R script written elsewhere on large data sets.  If 
someone wants more specifics please follow up.

Steve Grubb
__
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] Multiple grouping on the X axis.

2009-12-03 Thread Munin

This looks like exactly what I was looking for, except I forgot to mention
that they are looking for box-plots.  Any ideas on a package that can do the
same kind of organization but with box-plots?


Jim Lemon wrote:
 
 Hi Munin,
 Look at hierobarp in the plotrix package. The current version doesn't 
 have the recently programmed option to pass a list of arrays with the 
 values, so if you want this capability, I will email the new code.
 
 Jim
 
 __
 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.
 
 

-- 
View this message in context: 
http://n4.nabble.com/Multiple-grouping-on-the-X-axis-tp932397p948056.html
Sent from the R help mailing list archive at Nabble.com.

__
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] Question about R Functions

2009-12-03 Thread Stephanie Cooke
Is there a place to find the code for R functions like lsoda? Thanks

__
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] dataset index

2009-12-03 Thread Lisa

Thank you for your help. Your script works very well.

Lisa 



jholtman wrote:
 
 Does this do what you want:
 
 x - matrix(c(
 + 0, 0, 0,
 + 0, 0, 0,
 + 0, 1, 0,
 + 0, 1, 0,
 + 0, 1, 0,
 + 1, 2, 1,
 + 1, 2, 1,
 + 1, 3, 1,
 + 1, 3, 1,
 + 1, 3, 1),
 + ncol = 3, byrow = T,
 + dimnames = list(1:10, c(gender, race, disease)))
 key - apply(x, 1, paste, collapse=:)
 m.flags - lapply(unique(key), function(.indx){
 + key == .indx
 + })
 # create the keys
 do.call(rbind, m.flags)
  1 2 3 4 5 6 7 8 910
 [1,]  TRUE  TRUE FALSE FALSE FALSE FALSE FALSE FALSE FALSE FALSE
 [2,] FALSE FALSE  TRUE  TRUE  TRUE FALSE FALSE FALSE FALSE FALSE
 [3,] FALSE FALSE FALSE FALSE FALSE  TRUE  TRUE FALSE FALSE FALSE
 [4,] FALSE FALSE FALSE FALSE FALSE FALSE FALSE  TRUE  TRUE  TRUE

 
 
 On Thu, Dec 3, 2009 at 5:07 PM, Lisa lisa...@gmail.com wrote:

 Hello, All,

 I have a dataset that looks like this:

 x - matrix(c(
 0, 0, 0,
 0, 0, 0,
 0, 1, 0,
 0, 1, 0,
 0, 1, 0,
 1, 2, 1,
 1, 2, 1,
 1, 3, 1,
 1, 3, 1,
 1, 3, 1),
 ncol = 5, byrow = T,
 dimnames = list(1:10, c(gender, race, disease)))

 I want to write a function to produce several matrices including only
 “TRUE”
 and “FALSE” for the different levels of the variables (these matrices may
 be
 thought as index matrices), like

 m1
 TRUE TRUE FALSE FALSE FALSE FALSE FALSE FALSE FALSE FALSE

 m2
 FALSE FALSE TRUE TRUE TRUE FALSE FALSE FALSE FALSE FALSE

 m3
 FALSE FALSE FALSE FALSE FALSE TRUE TRUE FALSE FALSE FALSE

 m4
 FALSE FALSE FALSE FALSE FALSE FALSE FALSE TRUE TRUE TRUE

 Can anyone please help how to get this done? Your help would be greatly
 appreciated.

 Lisa

 --
 View this message in context:
 http://n4.nabble.com/dataset-index-tp948049p948049.html
 Sent from the R help mailing list archive at Nabble.com.

 __
 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.

 
 
 
 -- 
 Jim Holtman
 Cincinnati, OH
 +1 513 646 9390
 
 What is the problem that you are trying to solve?
 
 __
 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.
 
 

-- 
View this message in context: 
http://n4.nabble.com/dataset-index-tp948049p948080.html
Sent from the R help mailing list archive at Nabble.com.

__
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] corrupted matrix data.. sporadic result appears to be pairs of decimal numbers glommed together

2009-12-03 Thread jim holtman
Those appear to be complex numbers; some place in your script you must
be computing something that return a complex number.  Do an str on the
matrix to see what it says; see if it says this:

 x.1
 [,1] [,2]
[1,] 0.1820848-0.032i 0.1820848-0.032i
[2,] 0.1820848-0.032i 0.1820848-0.032i
 str(x.1)
 cplx [1:2, 1:2] 0.182-0i 0.182-0i 0.182-0i ...


If it does, look closely at your script.



On Thu, Dec 3, 2009 at 2:54 PM, Stephen Grubb stephen.gr...@jax.org wrote:
 Hello,

 We are occasionally getting matrix results that appear to be corrupted... 
 here are the last several rows of an example.  These are supposed to be 
 floating point numbers.

 [25015,]  1.820848e-01-3.2090e-06i
 [25016,]  2.178046e-01-4.8140e-06i
 [25017,]  1.820848e-01-3.2090e-06i
 [25018,]  1.820848e-01-3.2090e-06i
 [25019,]  1.144594e-01-1.6657e-06i
 [25020,]  1.820848e-01-3.2090e-06i
 [25021,] -1.293271e-01+4.3889e-06i
 [25022,]  1.144594e-01-1.6657e-06i
 [25023,]  1.820848e-01-3.2090e-06i
 [25024,]  1.820848e-01-3.2090e-06i
 [25025,]  1.173487e-01-4.4415e-07i
 [25026,]  1.820848e-01-3.2090e-06i
 [25027,]  1.375304e-01-3.6167e-06i
 [25028,]  1.820848e-01-3.2090e-06i
 [25029,] -1.293271e-01+4.3889e-06i
 [25030,]  1.820848e-01-3.2090e-06i
 [25031,]  1.820848e-01-3.2090e-06i
 [25032,]  1.820848e-01-3.2090e-06i
 [25033,]  1.820848e-01-3.2090e-06i

 Any general idea what may be going on here?

 It is a sporadic problem... it occurs maybe 2% or 3% of the time when running 
 this particular script on various data.

 I apologize for not including a pared-down example that reproduces the 
 problem we are using an R script written elsewhere on large data sets.  
 If someone wants more specifics please follow up.

 Steve Grubb
 __
 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.




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

What is the problem that you are trying to solve?

__
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] Scraping a web page

2009-12-03 Thread Gabor Grothendieck
If you only need to grab text it can be conveniently done with lynx.  This
example is for Windows but its nearly the same on other platforms:

 out - shell(lynx.bat --dump --nolist http://www.google.com;, intern =
TRUE)
 head(out)
[1] 
[2]Web Images Videos Maps News Books Gmail more »
[3]iGoogle | Search settings | Sign in
[4]
[5]Google
[6]   

On Thu, Dec 3, 2009 at 5:29 PM, Michael Conklin 
michael.conk...@markettools.com wrote:

 I would like to be able to submit a list of URLs of various webpages and
 extract the content i.e. not the mark-up of those pages. I can find plenty
 of examples in the XML library of extracting links from pages but I cannot
 seem to find a way to extract the text.  Any help would be greatly
 appreciated - I will not know the structure of the URLs I would submit in
 advance.  Any suggestions on where to look would be greatly appreciated.

 Mike

 W. Michael Conklin
 Chief Methodologist

 MarketTools, Inc. | www.markettools.comhttp://www.markettools.com
 6465 Wayzata Blvd | Suite 170 |  St. Louis Park, MN 55426.  PHONE:
 952.417.4719 | CELL: 612.201.8978
 This email and attachment(s) may contain confidential and/or proprietary
 information and is intended only for the intended addressee(s) or its
 authorized agent(s). Any disclosure, printing, copying or use of such
 information is strictly prohibited. If this email and/or attachment(s) were
 received in error, please immediately notify the sender and delete all
 copies


[[alternative HTML version deleted]]

 __
 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.


[[alternative HTML version deleted]]

__
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] Off topic - Compendium of distributions

2009-12-03 Thread Francisco J. Zagmutt
This is not an R related posting but I thought it would be interesting 
for readers of this list. Apologies for any cross-posting


Dear all

Our company Vose Software has just made a very comprehensive “Compendium 
of Distributions”  available for free online at 
www.vosesoftware.com/content/ebook.pdf.


The document explains the thinking behind and the uses of 76 
distributions and gives plots of the distributions with different 
parameter values.


It also has a section to give you a more intuitive understanding of 
formulas for things like density, moments, etc. and gives lists of 
possible candidate distributions for different types of problems like 
waiting time, stock price movements, expert estimates, etc.


We hope you will find it useful!

Regards,

Francisco

Francisco J. Zagmutt
Senior Risk Analysis Consultant
Vose Consulting
1643 Spruce St., Boulder
Boulder, CO, 80302
USA
francisco(at)voseconsulting(com)
www.voseconsulting.com

__
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] Scraping a web page

2009-12-03 Thread Sharpie


Michael Conklin wrote:
 
 I would like to be able to submit a list of URLs of various webpages and
 extract the content i.e. not the mark-up of those pages. I can find
 plenty of examples in the XML library of extracting links from pages but I
 cannot seem to find a way to extract the text.  Any help would be greatly
 appreciated - I will not know the structure of the URLs I would submit in
 advance.  Any suggestions on where to look would be greatly appreciated.
 
 Mike
 
 W. Michael Conklin
 Chief Methodologist
 

What kind of content are you after? Tables? Chunks of Text?  For tables
you can use the readHTMLTable() function in the XML package.  There was also
some discussion of alternate ways to extract data from tables in this
thread:

 
http://n4.nabble.com/Downloading-data-from-from-internet-td889838.html#a889845

If you're after text, then it's probably a matter of locating the element
that encloses the data you want-- perhaps by using getNodeSet along with an
XPath[1] that specifies the element you are interest with.  The text can
then be recovered using the xmlValue() function.

Hope this helps!

-Charlie

  [1]:  http://www.w3schools.com/XPath/xpath_syntax.asp

-- 
View this message in context: 
http://n4.nabble.com/Scraping-a-web-page-tp948069p948103.html
Sent from the R help mailing list archive at Nabble.com.

__
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] Passing arguments to gpar

2009-12-03 Thread Sebastien Bihorel

Dear R-users,

I would like to know how to pass arguments to gpar() without hard-coding 
them. I tried to store my arguments in a list and passed this list to 
gpar(), but it did find the way to do it properly. Any help would be 
appreciated.


a- list(fontisze=8,col=3)
gpar(fontsize=8,col=3)
gpar(a)
gpar(unlist(a))

__
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.


  1   2   >