[R] log likelihood and deviance

2010-06-05 Thread Yunteng Lao
Hi Prof Brain Ripley,

If we know the residual of the model, how could we calculate the Log
likelihood?

Thanks for your help,

Yunteng Lao


[[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] tapply help

2010-06-05 Thread Mark Ebbert
That was very clever. Worked perfectly, thanks!

And thanks to everyone else who provided feedback.

On Jun 5, 2010, at 5:46 AM, jim holtman wrote:

> It this what you are looking for:
> 
>> set.seed(1)
>> # create range for each possible class
>> # 'name' the values so you can use them in the 'sapply' function
>> lows<-c(a=1, b=2, c=3, d=4, e=5)
>> highs<-c(a=5, b=6, c=7, d=8, e=9)
>> 
>> # data values
>> vals<-sample(1:10,100,replace=T)
>> 
>> #classes
>> classes<-sample(letters[1:5],100,replace=T)
>> 
>> # split the data so that you retain the 'classes' name
>> x.split <- split(vals, classes)
>> percentage <- sapply(names(x.split), function(.class){
> + # compute the percentage based on 'class'
> + sum((x.split[[.class]] >= lows[.class]) &
> + (x.split[[.class]] <= highs[.class])) /
> length(x.split[[.class]]) * 100
> + })
>> percentage
>   abcde
> 50.0 45.0 62.5 54.54545 55.6
>> 
> 
> 
> On Fri, Jun 4, 2010 at 4:02 PM, Mark Ebbert  wrote:
>> Dear R gurus,
>> 
>> I am trying perform what I believe will be a pretty simple task, but I'm 
>> struggling to figure out how to do it. I have two vectors of the same 
>> length, the first is numeric and the second is factor. I understand that 
>> tapply is perfect for applying a function to the numeric vector by subsets 
>> of the factors in the second vector. My issue is trying to make use of two 
>> other vectors within the custom function I've written for tapply. The two 
>> other vectors are a high and low value for each subset I am breaking my data 
>> into, and I want to calculate the percentage of data points that fall into 
>> each respective range. I will attempt to provide a coherent example:
>> 
>> # create range for each possible class
>> lows<-c(1,2,3,4,5)
>> highs<-c(5,6,7,8,9)
>> 
>> # data values
>> vals<-sample(1:10,100,replace=T)
>> 
>> #classes
>> classes<-sample(letters[1:5],100,replace=T)
>> 
>> # Try to calculate percentage of values that fall
>> # into the respective range for the given class.
>> percentages<-tapply(vals,classes,
>>function(i){
>>length(i[i>=lows[index] & i<=highs[index]])/length(i)  # I 
>> don't know how to actually keep an index count in tapply, but I'm guessing 
>> there's a better way.
>>})
>> 
>> I really appreciate any help.
>> 
>> ME
>> __
>> 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] Onequestion

2010-06-05 Thread Xiongqing Zhang

Dear Mr. or Ms.,
 
I used the R-software to run the zero-inflatoin negative binomial model, but I 
could not get the results. And the error message is 
"solve.default(as.matrix(fit$gaussian)) ". In the model, I introduced 3 dummy 
variables. I do not know the reasons fully.
 
I will be very appreciate if you can help me. Thank you.
 
Best regards,
 
Sincerely,
Xiongqing Zhang


  
[[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 get the closing price from the the GOOGLE FINANCE site for NSEINDIA stocks

2010-06-05 Thread ivan popivanov

Try getSymbols("RCOM.NS", from="1900-01-01") instead.

It looks like google has removed the ability to download csv (not much business 
providing it;)). In any case, Yahoo historical prices go way back than googles. 
For instance, getSymbols("^DJI", from="1900-01-01") ; head(get("DJI")) shows 
the first date as 1928!

Hope this helps,
Ivan

> Date: Sat, 5 Jun 2010 23:46:37 +0530
> From: veepsi...@gmail.com
> To: r-help@r-project.org
> Subject: [R] How to get the closing price from the the GOOGLE FINANCE site
> for NSEINDIA stocks
> 
> Sir,
>  How to get the closing price from this link
> http://www.google.com/finance/historical?q=NSE:RCOM
> 
> I installed quantmod
> getSymbols('NSE:RCOM',src='google')
> 
>   gives me this error**
> 
> Error in download.file(paste(google.URL, "q=", Symbols.name, "&startdate=",  :
>   cannot open URL
> 'http://finance.google.com/finance/historical?q=NSE:RCOM&startdate=Jan+01,+2007&enddate=Jun+05,+2010&output=csv'
> Calls: getSymbols -> do.call -> getSymbols.google -> download.file
> In addition: Warning message:
> In download.file(paste(google.URL, "q=", Symbols.name, "&startdate=",  :
>   cannot open: HTTP status was '404 Not Found'
> 
> Could someone please give me the correct statement.
> 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.
  
_


[[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] spatstat sub-selection

2010-06-05 Thread Tom_R

Fellow Users,

In Spatstat, if you have a ppp object with, say 100 points, how do you
create another ppp containing a random selection, N, of the original?

You can tell the function 'rthin' to make a sub-selection of points, i.e.
"every point is removed with probability 0.5" but you CAN'T set N exactly...

I'm sure this should be easy...

Ta!

Tom
-- 
View this message in context: 
http://r.789695.n4.nabble.com/spatstat-sub-selection-tp2244619p2244619.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] Color scale graphic

2010-06-05 Thread Diogo_Silva

Hello

Recently, I've been dealing with a seemingly simple problem. I have a table
with two columns filled with values from a test I made (say, amount of
precipitation and Months measured). Now, instead of plotting a typical
linear graphic with precipitation on the y-axis and the months in the
x-axys, I would like to "convert" the values of precipitation in a color
gradient, resulting in a vertical gradient throughout the x-axis. In this
way, months with higher precipitation would appear reddish while lower
precipitation would appear blueish, for example. Despite being a simple
problem (basically converting the y-values in a color gradient), I have
failed to find a way of doing this.

If someone knows how to solve this, either using R or other program, please
lend me a hand. 

Thanks for your attention
Diogo
-- 
View this message in context: 
http://r.789695.n4.nabble.com/Color-scale-graphic-tp2244657p2244657.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 to use MCD condition

2010-06-05 Thread arindam fadikar
Dear R users,

I have a matrix and i want to get mahalanobis distance based on covariance
matrix and MCD ( minimun covariance determinant), but I could not find any
such argument 'MCD" in the function 'mahalanobis'. Please help.

-- 
Arindam Fadikar
M.Stat
Indian Statistical Institute.
New Delhi, India

[[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] Robust Asymptotic Statistics (RobASt)

2010-06-05 Thread Alex Weslowski
Hi all,

Other than:
http://www.stamats.de/F2006.r

Are there other good simple examples out there of using the ROptRegTS
package (part of the RobASt project)? I'm hoping to plug it in for
multivariate regression. Or is this not a good idea? Just trying to
find out how it compares to rlm, lts, glm, etc. Hopefully this makes
sense, I'm new to the world of statistics and R.

Thanks!

St0x

__
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] Shapes in barplots

2010-06-05 Thread Greg Snow
My suggestion is to learn to use dotplots rather than trying to add 3d 
chartjunk to barplots.

-- 
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 khush 
> Sent: Friday, June 04, 2010 11:53 PM
> To: r-help@r-project.org
> Subject: Re: [R] Shapes in barplots
> 
> Dear Gregory,
> 
> Well Thanks for your suggestions. I am no more using TeachingDemos for
> the
> same. I am installing rgl for the same, but one thing I want to ask
> like I
> need to make round ended bars instead of normal one I have to look into
> rgl
> for the same, but is there any option which you think suitable for me
> in
> barplots. Whats your suggestions.
> 
> Thank you
> Jeet
> 
> On Fri, Jun 4, 2010 at 11:09 PM, Greg Snow  wrote:
> 
> > The TeachingDemos package does not in any way replace the rgl
> package.
> >  They serve very different purposes (the TeachingDemos package does
> use rgl
> > for a couple of functions).
> >
> > I would be very surprised if there was anything in the TeachingDemos
> > package that would be of help in creating barplots with 3d effects.
> 3d
> > effects distort the information in graphs without adding anything to
> their
> > interpretation.
> >
> > If you want to display information, then use the appropriate graph
> without
> > the extra chartjunk.  If you want something to catch the reader's
> attention,
> > use a picture of a kitten.
> >
> > --
> > 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 khush 
> > > Sent: Friday, June 04, 2010 1:45 AM
> > > To: r-help@r-project.org
> > > Subject: [R] Shapes in barplots
> > >
> > > Hi,
> > >
> > > I am making barplots . I am using the default shape of barplots
> with a
> > > pipe
> > > but I wants to build bars in various 3d shapes. I have install rgl
> > > using
> > > install.packages('rgl') for this purpose, but when I am doing
> > > library(rgl),
> > > it shows
> > >
> > > Error in library(rgl) : there is no package called 'rgl'
> > >
> > > What are the other ways to build such plots of variuos shapes.
> > >
> > > Is that *TeachingDemos *replace it..I am not sure how to use it for
> > > such
> > > task.
> > >
> > > Thanks in advance
> > > Jeet
> > >
> > >   [[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-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] Error Bar Issues

2010-06-05 Thread William Revelle

Dear Beloitstudent;


Although Ben Bolker will have to give you the 
definitive answer, the following will do what I 
think you want to do.



library(plotrix)   #for those of us who don't know where plotCI comes from
#give us the data:

Saline <- structure(list(Time = c(-20L, NA, 30L, 45L, 60L, 80L, 110L, 140L,
200L, 260L, 320L), Average = c(0, NA, 0, 3.227902, 5.04,
6.107491, 6.968231, 7.325713, 7.875194, 6.513927, 4.204342),
SEM = c(0, NA, 0, 0.7462524, 1.1623944, 1.5027762, 1.3799637,
1.2282053, 1.1185175, 0.5386359, 0.6855906)), .Names = c("Time",
"Average", "SEM"), class = "data.frame", row.names = c("1", "2",
"3", "4", "5", "6", "7", "8", "9", "10", "11"))

# First  draw the  points
plotCI(x=Saline [,1],y=Saline [,2], uiw=Saline [,3], err="y",
 pt.bg=par("bg"),pch=21, cex=1.5 ,gap=0, sfrac=0.005,
xlim=c(-20,340),xaxp=c(-20,320,17), xlab="Time (min)", ylim=c(0,12),
 yaxp=c(0,12,12), ylab="Arterial Plasma Acetaminophen (µg/mL)", las=1,
font.lab=2)#draws the points

plotCI(x=Saline [,1],y=Saline [,2], uiw=Saline [,3], err="y",
pt.bg=par("bg"),pch=21, cex=1.5 ,gap=0, sfrac=0.005,
xlim=c(-20,340),xaxp=c(-20,320,17), ylim=c(0,12),
yaxp=c(0,12,12), las=1,
font.lab=2,add=TRUE,type="o")   #puts the lines in and gives a message

You will get a warning message the type is 
obsolete, but at least you have your graph.


Bill





At 3:51 PM -0700 6/5/10, beloitstudent wrote:

Content-Type: text/plain
Content-Disposition: inline
Content-length: 4586


Thanks for the suggestion...but R still doesn't like it.  Now I have 3 error
messages.  It seems to dislike my *err=y* command.  I'm going to continue
trying.  Thanks for your help!  If you happen to spot anything else, please
let me know!

thanks!
beloitstudent


On Sat, Jun 5, 2010 at 5:16 PM, Joris FA Meys [via R] <
ml-node+2244611-1554261936-278...@n4.nabble.com

 wrote:



 you can't refer to an argument within a function call. Try

 uiw <- Saline[,3]

 plotCI(x=Saline [,1],y=Saline [,2], uiw=uiw, liw=uiw, err=y, pch=21,
 pt.bg=par("bg"), cex=1.5, lty=1, type="o", gap=0, sfrac=0.005,
 xlim=c(-21,340),xaxp=c(-20,320,11), xlab="Time (min)", ylim=c(0,12),
 yaxp=c(0,12,11), ylab="Arterial Plasma Acetaminophen (µg/mL)", las=1,
 font.lab=2, add=TRUE)

 Cheers
 Joris

 On Sat, Jun 5, 2010 at 6:09 PM, beloitstudent 
<[hidden 
email]>

 wrote:

 >
 > Hello all,
 >
 > I am an undergraduate student who is having syntax issues trying to get
 > error bars on my graph.
 >
 > This is the data, which I assigned the name "Saline" to.
 >  Time   Average   SEM
 > 1   -20  0.00 0.000
 > 2
 > 330  0.00 0.000
 > 445  3.227902 0.7462524
 > 560  5.04 1.1623944
 > 680  6.107491 1.5027762
 > 7   110 6.968231 1.3799637
 > 8   140 7.325713 1.2282053
 > 9   200 7.875194 1.1185175
 > 10  2606.513927 0.5386359
 > 11  3204.204342 0.6855906
 >
 > This is the command that I typed in to get my error bars.
 >
 > plotCI(x=Saline [,1],y=Saline [,2], uiw=Saline [,3], liw=uiw, err=y,
 pch=21,
 > pt.bg=par("bg"), cex=1.5, lty=1, type="o", gap=0, sfrac=0.005,
 > xlim=c(-21,340),xaxp=c(-20,320,11), xlab="Time (min)", ylim=c(0,12),
 > yaxp=c(0,12,11), ylab="Arterial Plasma Acetaminophen (µg/mL)", las=1,
 > font.lab=2, add=TRUE)
 >
 > And this is the error message I keep getting
 > Error in plotCI(x = Saline[, 1], y = Saline[, 2], uiw = Saline[, 3], liw
 =
 > uiw,  :
 >  object 'uiw' not found
 > In addition: Warning message:
 > In if (err == "y") z <- y else z <- x :
 >  the condition has length > 1 and only the first element will be used
 >
 > Now, to me, the command seems correct.
 > I want the error bars to show up where the points on my graph are...so
 the x
 > coordinates should be my time (aka Saline [1]) and the y coordinates

 > should

 > be my Averages (aka Saline [2])  and my upper and lower limits to my
 > confidence interval should be the SEM from Saline [3], but something is
 > wrong with this and I cannot figure out what it is.  If anyone has
 > suggestions I would be very grateful.  Thanks for your help!
 >
 > beloitstudent
 > --
 > View this message in context:
 http://r.789695.n4.nabble.com/Error-Bar-Issues-tp2244335p2244335.html
 > Sent from the R help mailing list archive at Nabble.com.
 >
 > __
 > [hidden email] 
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.
 >



 --
 Ghent University
 Faculty of Bioscience Engineering
 Department of Applied mathematics, biometrics and process control

 tel : +32 9 264 59 87
 [hidden email] 
 ---
 Disclaimer : http

Re: [R] Wilcoxon test output as a table

2010-06-05 Thread Iurie Malai
Maybe, this will be better:

W <- as.matrix(lapply(Dataset[2:11], function(x) wilcox.test(x ~ GrFac,
alternative="two.sided", data=Dataset)$statistic))
P <- as.matrix(lapply(Dataset[2:11], function(x) wilcox.test(x ~ GrFac,
alternative="two.sided", data=Dataset)$p.value))
out <- rbind(as.numeric(W),as.numeric(P))
rownames(out) <- c("W", "p")
colnames(out) <- paste(colnames(Dataset[2:11]))
out

The output table we can format later in a spreadsheet (Calc, Excel, etc.).


2010/6/6 Iurie Malai 

> Yes, Joris, my code (and output) is not perfect, but right now is
> acceptable for me. Later I will try the options suggested by you.
>
> Thank you very much for your help!
>
> Iurie
>
>
>
> 2010/6/6 Joris Meys 
>
>> Can't reproduce those with your code and your dataset.
>> I also noticed some other unwanted behaviour by using as.numeric : it
>> changes the formatting again. You won't get rid of the "" as that
>> indicates it's a character, and you won't be able to format the
>> numbers as the columns in a dataframe or in a matrix have all the same
>> formatting.
>>
>> If you want to generate output for a function or so, you can play
>> around with cat() (see ?cat ). If it's for a report, think about using
>> latex or HTML and the xtable package. There are other options, but
>> that requires a bit more info.
>>
>> And your code is not very optimal.
>>
>> setwd("c:/Temp")
>> Dataset <- read.table("Dataset.txt",header=T,sep=",")
>>
>> W <- apply(Dataset[2:11],2, function(x) wilcox.test(x ~ GrFac,
>> alternative="two.sided", data=Dataset)$statistic)
>> P <- apply(Dataset[2:11],2, function(x) wilcox.test(x ~ GrFac,
>> alternative="two.sided", data=Dataset)$p.value)
>> W <- format(W, digits = 5, nsmall = 2)
>> P <- format(P, digits = 1, nsmall = 3)
>>
>> out <- rbind(W,P)
>> rownames(out) <- c("W","P")
>> colnames(out) <- colnames(Dataset[2:11])
>>
>>
>> If you know latex, you can use following package to get
>> library(xtable)
>> xtable(out) # latex output
>>
>> #html output
>> outtable <- xtable(out)
>> print(outtable,type="html")
>>
>> On Sat, Jun 5, 2010 at 11:35 PM, Iurie Malai 
>> wrote:
>> > Thank you, Joris!
>> >
>> > I received two identical warnings:
>> >
>> > [14] WARNING: Warning in if (nchar(cmd) <= width) return(cmd) :
>> >  the condition has length > 1 and only the first element will be used
>> > [15] WARNING: Warning in if (nchar(cmd) <= width) return(cmd) :
>> >  the condition has length > 1 and only the first element will be used
>> >
>> > 2010/6/6 Joris Meys 
>> >
>> >> # not tested
>> >> out <- rbind(as.numeric(Wnew),as.numeric(P))
>> >> rownames(out) <- c("Wnew","P")
>> >>
>> >>
>> >
>> >[[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.
>> >
>>
>>
>>
>> --
>> Ghent University
>> Faculty of Bioscience Engineering
>> Department of Applied mathematics, biometrics and process control
>>
>> tel : +32 9 264 59 87
>> joris.m...@ugent.be
>> ---
>> Disclaimer : http://helpdesk.ugent.be/e-maildisclaimer.php
>>
>
>
>
> --
> Iurie Malai, Senior Lecturer
> Department of Psychology
> Faculty of Psychology and Special Education
> Ion Creanga Moldova Pedagogical State University - www.upsm.md
> http://en.wikipedia.org/wiki/Ion_Creang%C4%83_Pedagogical_State_University
>

[[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] The curious special case of "~ (a + b)/c"

2010-06-05 Thread Nathaniel Smith
On Sat, Jun 5, 2010 at 2:01 PM, RICHARD M. HEIBERGER  wrote:
> The "/" is used for nesting and is defined by
> A/B == A + (B %in% A)
>
> thus
> (a+b)/c == (a+b) + c %in% (a+b) == a + b + a:b:c

...I guess I could then ask why %in% is defined that way, but actually
this rephrasing somehow helped me figure it out :-). In case anyone
else with the same confusion finds this thread: the point in either
case is that a variable can't be nested in two other variables
separately, so the user must have meant it was nested in both
together.

-- Nathaniel

__
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] Error Bar Issues

2010-06-05 Thread beloitstudent

Thanks for the suggestion...but R still doesn't like it.  Now I have 3 error
messages.  It seems to dislike my *err=y* command.  I'm going to continue
trying.  Thanks for your help!  If you happen to spot anything else, please
let me know!

thanks!
beloitstudent


On Sat, Jun 5, 2010 at 5:16 PM, Joris FA Meys [via R] <
ml-node+2244611-1554261936-278...@n4.nabble.com
> wrote:

> you can't refer to an argument within a function call. Try
>
> uiw <- Saline[,3]
>
> plotCI(x=Saline [,1],y=Saline [,2], uiw=uiw, liw=uiw, err=y, pch=21,
> pt.bg=par("bg"), cex=1.5, lty=1, type="o", gap=0, sfrac=0.005,
> xlim=c(-21,340),xaxp=c(-20,320,11), xlab="Time (min)", ylim=c(0,12),
> yaxp=c(0,12,11), ylab="Arterial Plasma Acetaminophen (µg/mL)", las=1,
> font.lab=2, add=TRUE)
>
> Cheers
> Joris
>
> On Sat, Jun 5, 2010 at 6:09 PM, beloitstudent <[hidden 
> email]>
> wrote:
>
> >
> > Hello all,
> >
> > I am an undergraduate student who is having syntax issues trying to get
> > error bars on my graph.
> >
> > This is the data, which I assigned the name "Saline" to.
> >  Time   Average   SEM
> > 1   -20  0.00 0.000
> > 2
> > 330  0.00 0.000
> > 445  3.227902 0.7462524
> > 560  5.04 1.1623944
> > 680  6.107491 1.5027762
> > 7   110 6.968231 1.3799637
> > 8   140 7.325713 1.2282053
> > 9   200 7.875194 1.1185175
> > 10  2606.513927 0.5386359
> > 11  3204.204342 0.6855906
> >
> > This is the command that I typed in to get my error bars.
> >
> > plotCI(x=Saline [,1],y=Saline [,2], uiw=Saline [,3], liw=uiw, err=y,
> pch=21,
> > pt.bg=par("bg"), cex=1.5, lty=1, type="o", gap=0, sfrac=0.005,
> > xlim=c(-21,340),xaxp=c(-20,320,11), xlab="Time (min)", ylim=c(0,12),
> > yaxp=c(0,12,11), ylab="Arterial Plasma Acetaminophen (µg/mL)", las=1,
> > font.lab=2, add=TRUE)
> >
> > And this is the error message I keep getting
> > Error in plotCI(x = Saline[, 1], y = Saline[, 2], uiw = Saline[, 3], liw
> =
> > uiw,  :
> >  object 'uiw' not found
> > In addition: Warning message:
> > In if (err == "y") z <- y else z <- x :
> >  the condition has length > 1 and only the first element will be used
> >
> > Now, to me, the command seems correct.
> > I want the error bars to show up where the points on my graph are...so
> the x
> > coordinates should be my time (aka Saline [1]) and the y coordinates
> should
> > be my Averages (aka Saline [2])  and my upper and lower limits to my
> > confidence interval should be the SEM from Saline [3], but something is
> > wrong with this and I cannot figure out what it is.  If anyone has
> > suggestions I would be very grateful.  Thanks for your help!
> >
> > beloitstudent
> > --
> > View this message in context:
> http://r.789695.n4.nabble.com/Error-Bar-Issues-tp2244335p2244335.html
> > Sent from the R help mailing list archive at Nabble.com.
> >
> > __
> > [hidden email] 
> > 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.
> >
>
>
>
> --
> Ghent University
> Faculty of Bioscience Engineering
> Department of Applied mathematics, biometrics and process control
>
> tel : +32 9 264 59 87
> [hidden email] 
> ---
> Disclaimer : http://helpdesk.ugent.be/e-maildisclaimer.php
>
> __
> [hidden email] 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 message @
> http://r.789695.n4.nabble.com/Error-Bar-Issues-tp2244335p2244611.html
> To unsubscribe from Error Bar Issues, click here< (link removed) ==>.
>
>
>

-- 
View this message in context: 
http://r.789695.n4.nabble.com/Error-Bar-Issues-tp2244335p2244627.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] Error Bar Issues

2010-06-05 Thread Joris Meys
you can't refer to an argument within a function call. Try

uiw <- Saline[,3]

plotCI(x=Saline [,1],y=Saline [,2], uiw=uiw, liw=uiw, err=y, pch=21,
pt.bg=par("bg"), cex=1.5, lty=1, type="o", gap=0, sfrac=0.005,
xlim=c(-21,340),xaxp=c(-20,320,11), xlab="Time (min)", ylim=c(0,12),
yaxp=c(0,12,11), ylab="Arterial Plasma Acetaminophen (µg/mL)", las=1,
font.lab=2, add=TRUE)

Cheers
Joris

On Sat, Jun 5, 2010 at 6:09 PM, beloitstudent  wrote:
>
> Hello all,
>
> I am an undergraduate student who is having syntax issues trying to get
> error bars on my graph.
>
> This is the data, which I assigned the name "Saline" to.
>  Time       Average       SEM
> 1   -20      0.00     0.000
> 2
> 3    30      0.00     0.000
> 4    45      3.227902     0.7462524
> 5    60      5.04     1.1623944
> 6    80      6.107491     1.5027762
> 7   110     6.968231     1.3799637
> 8   140     7.325713     1.2282053
> 9   200     7.875194     1.1185175
> 10  260    6.513927     0.5386359
> 11  320    4.204342     0.6855906
>
> This is the command that I typed in to get my error bars.
>
> plotCI(x=Saline [,1],y=Saline [,2], uiw=Saline [,3], liw=uiw, err=y, pch=21,
> pt.bg=par("bg"), cex=1.5, lty=1, type="o", gap=0, sfrac=0.005,
> xlim=c(-21,340),xaxp=c(-20,320,11), xlab="Time (min)", ylim=c(0,12),
> yaxp=c(0,12,11), ylab="Arterial Plasma Acetaminophen (µg/mL)", las=1,
> font.lab=2, add=TRUE)
>
> And this is the error message I keep getting
> Error in plotCI(x = Saline[, 1], y = Saline[, 2], uiw = Saline[, 3], liw =
> uiw,  :
>  object 'uiw' not found
> In addition: Warning message:
> In if (err == "y") z <- y else z <- x :
>  the condition has length > 1 and only the first element will be used
>
> Now, to me, the command seems correct.
> I want the error bars to show up where the points on my graph are...so the x
> coordinates should be my time (aka Saline [1]) and the y coordinates should
> be my Averages (aka Saline [2])  and my upper and lower limits to my
> confidence interval should be the SEM from Saline [3], but something is
> wrong with this and I cannot figure out what it is.  If anyone has
> suggestions I would be very grateful.  Thanks for your help!
>
> beloitstudent
> --
> View this message in context: 
> http://r.789695.n4.nabble.com/Error-Bar-Issues-tp2244335p2244335.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.
>



-- 
Ghent University
Faculty of Bioscience Engineering
Department of Applied mathematics, biometrics and process control

tel : +32 9 264 59 87
joris.m...@ugent.be
---
Disclaimer : http://helpdesk.ugent.be/e-maildisclaimer.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.


Re: [R] Creating a maxtrix from "conditional prints"

2010-06-05 Thread Joris Meys
Use rbind? Not the most optimal solution, but it should get the job done.

# not tested
Code example:

out <- c()
for (x in 1:10) {
for (y in 1:10) {
qui <- ifelse((mac[,1] == x) & (mac[,5] == y) |  (mac[,1] == y) & (mac[,5]
== x), 1, NA)
quo <- cbind(mac,qui)
qua <- subset(quo, qui ==1)
if(nrow(qua) == 2)
print(qua)
out <- rbind(out,qua)
}}


On Fri, Jun 4, 2010 at 9:08 PM, EM  wrote:
> Hi guys :)
>
> I'm dealing with this problem, perhaps conceptually not that complex, but
> still - I'm stuck.
>
> Two columns, values 1 column's index is identical to the second's (and vice versa). If that's
> true, I want to add a further column with value 1 (if true) or NA (if
> false).
> Thus, I obtain 100 matrices (for each columns I will have 1-1, 1-2, 1-3
> etc). Now, I want R to  consider only those matrices whose "new" column has
> value = 1 & whose total number of rows is equal to 2. I can get R to "print"
> this result inside the "for" cycle, yet I can't manage to build a single
> matrix, to store all the results altoghether - which is what I really want.
>
>
> Code example:
>
> for (x in 1:10) {
> for (y in 1:10) {
> qui <- ifelse((mac[,1] == x) & (mac[,5] == y) |  (mac[,1] == y) & (mac[,5]
> == x), 1, NA)
> quo <- cbind(mac,qui)
> qua <- subset(quo, qui ==1)
> if(nrow(qua) == 2)
> print(qua)
> }}
>
> result (wrong, now):
>
>     ricevente genere_r abo_r classieta_r donatore genere_d abo_d
> classieta_d    eta_d mismatch pra comp       mum qui
> [1,]         8        0     1           3        9        1     1
> 4 56.17437        2   1    1 -6.645437   1
> [2,]         9        1     1           2        8        0     1
> 3 48.77579        2   1    1 -5.905579   1
>     ricevente genere_r abo_r classieta_r donatore genere_d abo_d
> classieta_d    eta_d mismatch pra comp       mum qui
> [1,]         8        0     1           3       10        0     0
> 3 48.77579        2   1    1 -5.905579   1
> [2,]        10        0     2           5        8        0     1
> 3 48.77579        1   1    1 -5.391579   1
>     ricevente genere_r abo_r classieta_r donatore genere_d abo_d
> classieta_d    eta_d mismatch pra comp       mum qui
> [1,]         8        0     1           3        9        1     1
> 4 56.17437        2   1    1 -6.645437   1
> [2,]         9        1     1           2        8        0     1
> 3 48.77579        2   1    1 -5.905579   1
>     ricevente genere_r abo_r classieta_r donatore genere_d abo_d
> classieta_d    eta_d mismatch pra comp       mum qui
> [1,]         9        1     1           2       10        0     0
> 3 48.77579        0   1    1 -4.877579   1
> [2,]        10        0     2           5        9        1     1
> 4 56.17437        0   1    1 -5.617437   1
>
> what I'd like to get:
>
>     ricevente genere_r abo_r classieta_r donatore genere_d abo_d
> classieta_d    eta_d mismatch pra comp       mum qui
> [1,]         8        0     1           3        9        1     1
> 4 56.17437        2   1    1 -6.645437   1
> [2,]         9        1     1           2        8        0     1
> 3 48.77579        2   1    1 -5.905579   1
> [3,]         8        0     1           3       10        0     0
> 3 48.77579        2   1    1 -5.905579   1
> [4,]        10        0     2           5        8        0     1
> 3 48.77579        1   1    1 -5.391579   1
> [5,]         8        0     1           3        9        1     1
> 4 56.17437        2   1    1 -6.645437   1
> [6,]         9        1     1           2        8        0     1
> 3 48.77579        2   1    1 -5.905579   1
> [7,]         9        1     1           2       10        0     0
> 3 48.77579        0   1    1 -4.877579   1
> [8,]        10        0     2           5        9        1     1
> 4 56.17437        0   1    1 -5.617437   1
>
> (don't mind the values & names, this is just a small part of a longer
> algorithm)
>
> Thanks for your help, in advance :)
>
>        [[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.
>



-- 
Ghent University
Faculty of Bioscience Engineering
Department of Applied mathematics, biometrics and process control

tel : +32 9 264 59 87
joris.m...@ugent.be
---
Disclaimer : http://helpdesk.ugent.be/e-maildisclaimer.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.


Re: [R] Wilcoxon test output as a table

2010-06-05 Thread Iurie Malai
Sorry, Joris, now is wonderful! Thank you!

Now, this is the code:

W <- as.matrix(lapply(Dataset[2:11], function(x) wilcox.test(x ~ GrFac,
alternative="two.sided", data=Dataset)$statistic))
P <- as.matrix(lapply(Dataset[2:11], function(x) wilcox.test(x ~ GrFac,
alternative="two.sided", data=Dataset)$p.value))
W <- format(W, digits = 5, nsmall = 2)
P <- format(P, digits = 1, nsmall = 3)
out <- rbind(as.numeric(W),as.numeric(P))
rownames(out) <- c("W", "P")
colnames(out) <- paste(colnames(Dataset[2:11]))
out

This is the output:

   X1 X2   X3   X4X5   X6   X7
X8   IA   IV
W 4582.500 4335.5 4610.500 4008.500 6409.5000 6064.500 5126.500 6.8615e+03
4305.500 5769.000
P0.3010.10.3360.0130.00050.0080.756
4.e-060.0890.059

I am happy!


2010/6/6 Iurie Malai 

> Thank you, Joris!
>
> I received two identical warnings:
>
> [14] WARNING: Warning in if (nchar(cmd) <= width) return(cmd) :
>   the condition has length > 1 and only the first element will be used
> [15] WARNING: Warning in if (nchar(cmd) <= width) return(cmd) :
>   the condition has length > 1 and only the first element will be used
>
> 2010/6/6 Joris Meys 
>
> # not tested
>> out <- rbind(as.numeric(Wnew),as.numeric(P))
>> rownames(out) <- c("Wnew","P")
>>
>>
>

[[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] Wilcoxon test output as a table

2010-06-05 Thread Joris Meys
Can't reproduce those with your code and your dataset.
I also noticed some other unwanted behaviour by using as.numeric : it
changes the formatting again. You won't get rid of the "" as that
indicates it's a character, and you won't be able to format the
numbers as the columns in a dataframe or in a matrix have all the same
formatting.

If you want to generate output for a function or so, you can play
around with cat() (see ?cat ). If it's for a report, think about using
latex or HTML and the xtable package. There are other options, but
that requires a bit more info.

And your code is not very optimal.

setwd("c:/Temp")
Dataset <- read.table("Dataset.txt",header=T,sep=",")

W <- apply(Dataset[2:11],2, function(x) wilcox.test(x ~ GrFac,
alternative="two.sided", data=Dataset)$statistic)
P <- apply(Dataset[2:11],2, function(x) wilcox.test(x ~ GrFac,
alternative="two.sided", data=Dataset)$p.value)
W <- format(W, digits = 5, nsmall = 2)
P <- format(P, digits = 1, nsmall = 3)

out <- rbind(W,P)
rownames(out) <- c("W","P")
colnames(out) <- colnames(Dataset[2:11])


If you know latex, you can use following package to get
library(xtable)
xtable(out) # latex output

#html output
outtable <- xtable(out)
print(outtable,type="html")

On Sat, Jun 5, 2010 at 11:35 PM, Iurie Malai  wrote:
> Thank you, Joris!
>
> I received two identical warnings:
>
> [14] WARNING: Warning in if (nchar(cmd) <= width) return(cmd) :
>  the condition has length > 1 and only the first element will be used
> [15] WARNING: Warning in if (nchar(cmd) <= width) return(cmd) :
>  the condition has length > 1 and only the first element will be used
>
> 2010/6/6 Joris Meys 
>
>> # not tested
>> out <- rbind(as.numeric(Wnew),as.numeric(P))
>> rownames(out) <- c("Wnew","P")
>>
>>
>
>        [[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.
>



-- 
Ghent University
Faculty of Bioscience Engineering
Department of Applied mathematics, biometrics and process control

tel : +32 9 264 59 87
joris.m...@ugent.be
---
Disclaimer : http://helpdesk.ugent.be/e-maildisclaimer.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.


Re: [R] R2HTML problem

2010-06-05 Thread Joris Meys
Tinn-R is using the R2HTML package itself for communication with R.
You could ask JC Faria who wrote Tinn-R what exactly is going on
there. You might get more help here :
http://sourceforge.net/projects/tinn-r/support

Personally, I'd just use a different editor in this case. I love
Tinn-R, but it's no use programming in an editor that interacts with
your code.

Cheers
Joris

On Sat, Jun 5, 2010 at 4:57 PM, RGtk2User  wrote:
>
> Im developing an application with R and Gtk+. It's just a simple GUI which
> helps new users to interactuate with R. Thing is, when you do a statistical
> analysis, I also want to provide a HTML report, but HTMLStart doesnt work
> propperly when executing from TinnR. It does create the file but not empty,
> I've tried some examples from different websites, and it's always the same..
> it works if I execute it from the R prompt, but doesnt when it comes to
> execute it from TinnR. So, any ideas? Im trying to divide the internal code
> of the HTMLStart function to find out where it crashes, but I couldnt find
> it yet. Thanks in advance
>
> __
> 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.
>



-- 
Ghent University
Faculty of Bioscience Engineering
Department of Applied mathematics, biometrics and process control

tel : +32 9 264 59 87
joris.m...@ugent.be
---
Disclaimer : http://helpdesk.ugent.be/e-maildisclaimer.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.


Re: [R] Wilcoxon test output as a table

2010-06-05 Thread Iurie Malai
Thank you, Joris!

I received two identical warnings:

[14] WARNING: Warning in if (nchar(cmd) <= width) return(cmd) :
  the condition has length > 1 and only the first element will be used
[15] WARNING: Warning in if (nchar(cmd) <= width) return(cmd) :
  the condition has length > 1 and only the first element will be used

2010/6/6 Joris Meys 

> # not tested
> out <- rbind(as.numeric(Wnew),as.numeric(P))
> rownames(out) <- c("Wnew","P")
>
>

[[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] Error Bar Issues

2010-06-05 Thread beloitstudent

Hello all,

I am an undergraduate student who is having syntax issues trying to get
error bars on my graph.  

This is the data, which I assigned the name "Saline" to. 
 Time   Average   SEM
1   -20  0.00 0.000
2
330  0.00 0.000
445  3.227902 0.7462524
560  5.04 1.1623944
680  6.107491 1.5027762
7   110 6.968231 1.3799637
8   140 7.325713 1.2282053
9   200 7.875194 1.1185175
10  2606.513927 0.5386359
11  3204.204342 0.6855906

This is the command that I typed in to get my error bars.

plotCI(x=Saline [,1],y=Saline [,2], uiw=Saline [,3], liw=uiw, err=y, pch=21,
pt.bg=par("bg"), cex=1.5, lty=1, type="o", gap=0, sfrac=0.005,
xlim=c(-21,340),xaxp=c(-20,320,11), xlab="Time (min)", ylim=c(0,12),
yaxp=c(0,12,11), ylab="Arterial Plasma Acetaminophen (µg/mL)", las=1,
font.lab=2, add=TRUE)

And this is the error message I keep getting
Error in plotCI(x = Saline[, 1], y = Saline[, 2], uiw = Saline[, 3], liw =
uiw,  : 
  object 'uiw' not found
In addition: Warning message:
In if (err == "y") z <- y else z <- x :
  the condition has length > 1 and only the first element will be used

Now, to me, the command seems correct.
I want the error bars to show up where the points on my graph are...so the x
coordinates should be my time (aka Saline [1]) and the y coordinates should
be my Averages (aka Saline [2])  and my upper and lower limits to my
confidence interval should be the SEM from Saline [3], but something is
wrong with this and I cannot figure out what it is.  If anyone has
suggestions I would be very grateful.  Thanks for your help!

beloitstudent
-- 
View this message in context: 
http://r.789695.n4.nabble.com/Error-Bar-Issues-tp2244335p2244335.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] apply min function rowwise

2010-06-05 Thread moleps
Appreciate it...

//M

On 5. juni 2010, at 20.11, Joshua Wiley wrote:

> On Sat, Jun 5, 2010 at 10:22 AM, moleps  wrote:
>> thx.
>> 
>> It was only the first instance that was class date. The rest were factors. 
>> So that explains it.
>> 
>> If I want to change the rest in vec into class date (there are many of 
>> them...)
>> 
>> neither  as.Date(canc[,vec],"%d.%m.%Y") nor 
>> sapply(canc[,vec],FUN=function(x) as.date(x,"%d.%m.%Y")) works
>> 
>> What is the easy solution to this?
> 
> This is the nicest solution that comes to mind:
> 
> as.data.frame(lapply(X=samp.dat, FUN=as.Date, format="%d.%m.%Y"))
> 
> I believe the problem is that sapply() coerces the results (by default
> when simplify=TRUE) using as.vector() leaving you with the number of
> days since the origin.  Anyway, using as.data.frame() on the list
> output from lapply() seems to work.
> 
> Josh
> 
>> 
>> Regards,
>> 
>> //M
>> 
>> 
>> 
>> On 5. juni 2010, at 18.30, Joshua Wiley wrote:
>> 
>>> Hello M,
>>> 
>>> My guess is that it has something to do with the class of the
>>> variables.  Perhaps you could provide a small sample dataframe?  Also
>>> you might try running str() on your data frame and seeing if the
>>> results are what you would expect.  As a side note, it is not
>>> necessary to make an anonymous function here, as you are allowed to
>>> pass arguments to the function applied.
>>> 
>>> apply(canc[,vec],1, min, na.rm=TRUE)
>>> 
>>> Best regards,
>>> 
>>> Josh
>>> 
>>> On Sat, Jun 5, 2010 at 8:30 AM, moleps  wrote:
 I´m trying to tease out the minimum value from a row in a dataframe where 
 all the variables are dates.
 
 apply(canc[,vec],1,function(x)min(x,na.rm=T))
 
 
 However it only returns empty strings for the entire dataframe except for 
 one date value (which is not the minimum date).
 
 I´ve also tried
 
 apply(canc[,vec],1,function(x)max(x,na.rm=T))
 
 which provides values rowwise, but many of them are not in fact the 
 largest in the row.
 
 
 Any advice?
 
 
 Regards,
 
 //M
 
 __
 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.
 
>>> 
>>> 
>>> 
>>> --
>>> Joshua Wiley
>>> Senior in Psychology
>>> University of California, Riverside
>>> http://www.joshuawiley.com/
>> 
>> 
> 
> 
> 
> -- 
> Joshua Wiley
> Senior in Psychology
> University of California, Riverside
> http://www.joshuawiley.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] HTMLStart with TinnR

2010-06-05 Thread RGtk2User

Im developing an application with R and Gtk+. It's just a simple GUI which
helps new users to interactuate with R. Thing is, when you do a statistical
analysis, I also want to provide a HTML report, but HTMLStart doesnt work
propperly when executing from TinnR. It does create the file but not empty,
I've tried some examples from different websites, and it's always the same..
it works if I execute it from the R prompt, but doesnt when it comes to
execute it from TinnR. So, any ideas? Im trying to divide the internal code
of the HTMLStart function to find out where it crashes, but I couldnt find
it yet. Thanks in advance
-- 
View this message in context: 
http://r.789695.n4.nabble.com/HTMLStart-with-TinnR-tp2244467p2244467.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] (no subject)

2010-06-05 Thread Joris Meys
OK, as you're new:

1) this is a list about R, not about statistics.
2) it looks awkwardly much like a homework assignment. People tend to
be not really keen on solving those ones.
3) READ THE POSTING GUIDELINES. Seriously, read them.
http://www.R-project.org/posting-guide.html

As a tip : go through the archives and search on zero inflated
negative binomial or ZINB. You'll find tons of discussions about the
code, including very recent ones.

Cheers
Joris

On Sat, Jun 5, 2010 at 3:19 PM, cahyo kristiono
 wrote:
> Dear Sirs
>
> First herewith I'll introduce myself. My name is Kristiono, I want ask you to 
> help me how to get  ZINB (Zero Inflated Negative Binomial) regression 
> modeling step by step.
> Anyway, I get some trouble to get step by step about
> 1.    How to get the log likelihood function of ZINB (step by step)
> 2.    How to get first derivative, second derifative to get MLE by Newton 
> Raphson (step by step)
> 3.    Syntax program
>
> I want ask you to help me please to solve my trouble above, because I'm very 
> realy need it soon.
>  I will thank you a lot for your help.
>  Sincerely.
> Kristiono
>
>
>        [[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.
>
>



-- 
Ghent University
Faculty of Bioscience Engineering
Department of Applied mathematics, biometrics and process control

tel : +32 9 264 59 87
joris.m...@ugent.be
---
Disclaimer : http://helpdesk.ugent.be/e-maildisclaimer.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.


Re: [R] Wilcoxon test output as a table

2010-06-05 Thread Joris Meys
# not tested
out <- rbind(as.numeric(Wnew),as.numeric(P))
rownames(out) <- c("Wnew","P")

Cheers

On Sat, Jun 5, 2010 at 11:18 PM, Iurie Malai  wrote:
> Hi!
>
> I searched some time ago a way to get the Wilcoxon test results as a table
> more or less formatted. Nobody told me any solution and I found nothing on
> the Internet. Recently I came across this link (
> http://myowelt.blogspot.com/2008/04/beautiful-correlation-tables-in-r.html),
> which helped me to find a solution.
>
> Here's the solution (I'm using R Commander):
>
> W <- as.matrix(lapply(Dataset[2:11], function(x) wilcox.test(x ~ GrFac,
> alternative="two.sided", data=Dataset)$statistic))
> P <- as.matrix(lapply(Dataset[2:11], function(x) wilcox.test(x ~ GrFac,
> alternative="two.sided", data=Dataset)$p.value))
> W <- format(W, digits = 5, nsmall = 2)
> P <- format(P, digits = 1, nsmall = 3)
> Wnew <- matrix(paste(W), ncol=ncol(Dataset[2:11]))
> colnames(Wnew) <- paste(colnames(Dataset[2:11]))
> Wnew
> P
>
> This is the output (excerpt):
>> Wnew
>     X1        X2        X3        X4        X5        X6        X7
> X8        IA        IV
> [1,] "4582.50" "4335.50" "4610.50" "4008.50" "6409.50" "6064.50" "5126.50"
> "6861.50" "4305.50" "5769.00"
>> P
>  [1] "0.301" "0.100" "0.336" "0.013" "5e-04" "0.008" "0.756" "4e-06" "0.089"
> "0.059"
>
> Can anyone share their views? Propose an improvement? For example, how to
> make it appear as a table, not as separate rows? How to remove quotes? How
> to show rows names W and P?
>
> Regards,
> Iurie Malai, Senior Lecturer
> Department of Psychology
> Faculty of Psychology and Special Education
> Ion Creanga Moldova Pedagogical State University - www.upsm.md
> http://en.wikipedia.org/wiki/Ion_Creang%C4%83_Pedagogical_State_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.
>
>



-- 
Ghent University
Faculty of Bioscience Engineering
Department of Applied mathematics, biometrics and process control

tel : +32 9 264 59 87
joris.m...@ugent.be
---
Disclaimer : http://helpdesk.ugent.be/e-maildisclaimer.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.


Re: [R] Ignoring missing elements in data.frame()

2010-06-05 Thread Joris Meys
Hi,

One possible way to get around it is using following idea :
X1 <- rnorm(10)
X2 <- rnorm(10)

Names <- c("X1","X2","X3")
Names <- Names[Names %in% ls()]

n <- length(Names)
p <- 10   #length of each object
output <- matrix(NA,ncol=n,nrow=p)

for(i in 1:n){
output[,i] <- get(Names[i])
}
output <- as.data.frame(output)
names(output) <- Names

You can also use an eval-parse construct like this :
## Alternative
Names <- c("X1","X2","X3")
Names <- Names[Names %in% ls()]
Names <- paste(Names,collapse=",")
expr = paste("output <- data.frame(",Names,")",sep="")
eval(parse(text=expr))

Both are not really the most optimal solution, but do work. It would
be better if you made a list or matrix beforehand and then save the
results of the calculations in that list or matrix whenever the
calculation turns out to give a result.

Cheers
Joris

On Sat, Jun 5, 2010 at 1:23 AM, Scott Chamberlain  wrote:
> Hello, I am trying to make a data frame from many elements after
> running a function which creates many elements, some of which may not
> end up being real elements due to errors or missing data. For example,
> I have the following three elements p1s, p2s, and p3s. p9s did not
> generate the same data as there was an error in the function for some
> reason. I currently have to delete p9s from the data.frame() command
> to get the data.frame to work.  How can I make a data frame by somehow
> ignoring elements (e.g., p9s) that do not exist, without having to
> delete each missing element from data.frame()? The below is an example
> of the code.
>
>> p1s
>  statistic parameter p.value
> [1,] 3.606518  153   0.0004195377
>> p2s
>  statistic parameter p.value
> [1,] -3.412436 8 0.009190015
>> p3s
>  statistic parameter p.value
> [1,] 1.543685  599   0.1231928
>
>> t(data.frame(t(p1s),t(p2s),t(p3s),t(p9s)))
> Error in t(p9s) : object 'p9s' not found
>
>
> Thanks, Scott Chamberlain
> Rice University
> Houston, TX
>
> __
> 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.
>



-- 
Ghent University
Faculty of Bioscience Engineering
Department of Applied mathematics, biometrics and process control

tel : +32 9 264 59 87
joris.m...@ugent.be
---
Disclaimer : http://helpdesk.ugent.be/e-maildisclaimer.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] Wilcoxon test output as a table

2010-06-05 Thread Iurie Malai
Hi!

I searched some time ago a way to get the Wilcoxon test results as a table
more or less formatted. Nobody told me any solution and I found nothing on
the Internet. Recently I came across this link (
http://myowelt.blogspot.com/2008/04/beautiful-correlation-tables-in-r.html),
which helped me to find a solution.

Here's the solution (I'm using R Commander):

W <- as.matrix(lapply(Dataset[2:11], function(x) wilcox.test(x ~ GrFac,
alternative="two.sided", data=Dataset)$statistic))
P <- as.matrix(lapply(Dataset[2:11], function(x) wilcox.test(x ~ GrFac,
alternative="two.sided", data=Dataset)$p.value))
W <- format(W, digits = 5, nsmall = 2)
P <- format(P, digits = 1, nsmall = 3)
Wnew <- matrix(paste(W), ncol=ncol(Dataset[2:11]))
colnames(Wnew) <- paste(colnames(Dataset[2:11]))
Wnew
P

This is the output (excerpt):
> Wnew
 X1X2X3X4X5X6X7
X8IAIV
[1,] "4582.50" "4335.50" "4610.50" "4008.50" "6409.50" "6064.50" "5126.50"
"6861.50" "4305.50" "5769.00"
> P
 [1] "0.301" "0.100" "0.336" "0.013" "5e-04" "0.008" "0.756" "4e-06" "0.089"
"0.059"

Can anyone share their views? Propose an improvement? For example, how to
make it appear as a table, not as separate rows? How to remove quotes? How
to show rows names W and P?

Regards,
Iurie Malai, Senior Lecturer
Department of Psychology
Faculty of Psychology and Special Education
Ion Creanga Moldova Pedagogical State University - www.upsm.md
http://en.wikipedia.org/wiki/Ion_Creang%C4%83_Pedagogical_State_University
"GrFac","X1","X2","X3","X4","X5","X6","X7","X8","IA","IV"
"town",7,5,4,5,5,8,6,8,5.30,7.00
"town",3,5,5,3,2,6,9,5,4.30,7.50
"town",7,5,8,0,3,10,9,5,6.60,9.50
"town",5,6,7,3,6,6,8,5,6.00,7.00
"town",6,7,7,5,5,7,8,8,6.60,7.50
"town",4,7,3,5,3,8,8,5,4.60,8.00
"town",5,5,7,4,5,10,8,8,5.60,9.00
"town",8,5,8,4,5,8,9,5,7.00,8.50
"town",9,7,8,4,5,5,8,3,8.00,6.50
"town",6,4,3,2,4,7,4,8,4.30,5.50
"town",3,5,4,2,6,5,9,7,4.00,7.00
"town",6,6,4,2,4,5,3,8,5.30,4.00
"town",6,6,8,4,6,8,9,7,6.60,8.50
"town",7,8,6,2,4,5,5,6,7.00,5.00
"town",2,6,5,4,6,10,7,9,4.30,8.50
"town",4,3,3,0,3,9,4,7,3.30,6.50
"town",7,6,5,3,3,6,8,4,6.00,7.00
"town",7,6,5,3,6,9,8,7,6.00,8.50
"town",7,5,9,4,4,5,3,4,7.00,4.00
"town",4,4,5,4,4,2,6,7,4.30,4.00
"town",5,3,8,2,4,10,11,7,5.30,10.50
"town",4,5,2,1,3,7,5,5,3.60,6.00
"town",5,6,7,2,5,7,5,7,6.00,6.00
"town",8,3,7,4,8,8,6,7,6.00,7.00
"town",4,2,2,4,2,4,6,6,2.60,5.00
"town",6,6,6,2,5,5,9,8,6.00,7.00
"town",6,6,8,3,7,8,10,6,6.60,9.00
"town",6,4,8,4,5,6,8,8,6.00,7.00
"town",2,2,4,3,3,5,6,2,2.60,5.50
"town",2,4,6,2,3,5,7,7,4.00,6.00
"town",2,4,2,2,2,5,5,7,2.60,5.00
"town",8,5,9,3,2,8,10,2,7.30,9.00
"town",7,6,5,3,3,8,9,4,6.00,8.50
"town",8,8,8,4,7,8,6,8,8.00,7.00
"town",4,3,8,5,7,5,8,3,5.00,6.50
"town",8,8,9,5,6,10,11,8,8.30,10.50
"town",3,3,4,0,1,5,5,4,3.30,5.00
"town",3,4,4,2,4,8,7,5,3.60,7.50
"town",5,5,5,5,4,7,5,2,5.00,6.00
"town",6,7,6,3,5,8,8,8,6.30,8.00
"town",5,3,5,4,5,7,4,8,4.30,5.50
"town",2,2,1,3,2,2,1,3,1.60,1.50
"town",5,6,7,1,5,6,3,4,6.00,4.50
"town",7,3,3,2,4,1,1,4,4.30,1.00
"town",6,1,8,1,6,6,7,5,5.00,6.50
"town",7,5,6,2,7,5,7,4,6.00,6.00
"town",4,6,9,2,4,4,6,5,6.30,5.00
"town",7,5,2,4,4,6,6,7,4.60,6.00
"town",5,3,8,3,5,5,4,2,5.30,4.50
"town",5,4,7,5,4,3,6,1,5.30,4.50
"town",5,6,4,1,6,8,9,7,5.00,8.50
"town",8,7,3,4,7,6,7,8,6.00,6.50
"town",7,4,4,5,4,6,7,4,5.00,6.50
"town",5,5,2,3,4,6,5,6,4.00,5.50
"town",4,1,3,2,2,6,4,8,2.60,5.00
"town",10,6,7,3,7,6,7,8,7.60,6.50
"town",6,3,3,3,4,8,8,4,4.00,8.00
"town",2,6,9,5,6,3,4,8,5.60,3.50
"town",8,4,5,2,4,6,9,4,5.60,7.50
"town",7,3,6,2,4,5,8,5,5.30,6.50
"town",7,5,6,4,4,5,6,1,6.00,5.50
"town",5,2,8,3,6,7,10,8,5.00,8.50
"town",4,5,4,3,5,8,8,7,4.30,8.00
"town",2,2,4,1,6,7,8,8,2.60,7.50
"town",4,4,7,5,2,6,6,6,5.00,6.00
"town",9,8,10,2,7,7,7,8,9.00,7.00
"town",5,6,4,4,2,8,5,5,5.00,6.50
"town",5,5,5,3,1,7,7,6,5.00,7.00
"town",7,3,5,4,6,9,8,7,5.00,8.50
"town",6,5,1,3,5,1,7,9,4.00,4.00
"town",5,5,5,2,1,7,6,6,5.00,6.50
"town",7,2,5,4,5,6,8,6,4.60,7.00
"town",8,8,7,5,4,7,11,6,7.60,9.00
"town",6,5,5,3,1,6,9,5,5.30,7.50
"town",5,6,6,5,4,4,8,2,5.60,6.00
"town",7,5,9,5,7,5,6,9,7.00,5.50
"town",5,7,3,2,3,7,8,8,5.00,7.50
"town",8,8,7,4,7,10,9,8,7.60,9.50
"town",9,6,7,5,7,7,9,6,7.30,8.00
"town",5,4,5,4,4,7,8,8,4.60,7.50
"town",6,3,5,5,7,5,5,5,4.60,5.00
"town",7,6,5,4,3,7,7,4,6.00,7.00
"town",8,6,6,5,1,3,7,7,6.60,5.00
"town",3,3,6,1,6,7,10,8,4.00,8.50
"town",6,4,8,2,5,7,7,6,6.00,7.00
"town",7,8,4,2,7,5,8,4,6.30,6.50
"town",8,7,7,5,7,8,7,9,7.30,7.50
"town",5,4,3,1,4,8,10,6,4.00,9.00
"town",4,4,2,4,4,5,6,5,3.30,5.50
"town",8,5,10,3,7,8,9,8,7.60,8.50
"town",6,1,2,4,3,3,4,5,3.00,3.50
"town",7,5,7,5,2,6,10,6,6.30,8.00
"town",3,5,4,1,3,6,6,5,4.00,6.00
"town",6,5,7,2,6,8,9,5,6.00,8.50
"town",6,5,7,2,4,6,7,7,6.00,6.50
"town",7,4,7,2,6,2,5,5,6.00,3.50
"town",8,3,7,4,4,5,7,7,6.00,6.00
"town",4,8,5,5,4,6,6,5,5.60,6.00
"town",9,8,10,4,8,9,10,7,9.00,9.50
"town",7,6,7,5,6,5,7,5,6.60,6.00
"country",6,8,6,4,7,8,8,9,6.60,8.00
"country",4,5,7,3,4,7,8,8,5.30,7.50
"countr

Re: [R] What is the largest in memory data object you've worked with in R?

2010-06-05 Thread Joris Meys
You have to take some things into account :
- the maximum memory set for R might not be the maximum memory available
- R needs the memory not only for the dataset. Matrix manipulations
require frquently double of the amount of memory taken by the dataset.
- memory allocation is important when dealing with large datasets.
There is plenty of information about that
- R has some packages to get around memory problems with big datasets.

Read this discussione for example :
http://tolstoy.newcastle.edu.au/R/help/05/05/4507.html

and this page of Matthew Keller is a good summary too :
http://www.matthewckeller.com/html/memory.html

Cheers
Joris

On Sat, Jun 5, 2010 at 12:32 AM, Nathan Stephens  wrote:
> For me, I've found that I can easily work with 1 GB datasets.  This includes
> linear models and aggregations.  Working with 5 GB becomes cumbersome.
> Anything over that, and R croaks.  I'm using a dual quad core Dell with 48
> GB of RAM.
>
> I'm wondering if there is anyone out there running jobs in the 100 GB
> range.  If so, what does your hardware look like?
>
> --Nathan
>
>        [[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.
>



-- 
Ghent University
Faculty of Bioscience Engineering
Department of Applied mathematics, biometrics and process control

tel : +32 9 264 59 87
joris.m...@ugent.be
---
Disclaimer : http://helpdesk.ugent.be/e-maildisclaimer.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.


Re: [R] The curious special case of "~ (a + b)/c"

2010-06-05 Thread RICHARD M. HEIBERGER
The "/" is used for nesting and is defined by
A/B == A + (B %in% A)

thus
(a+b)/c == (a+b) + c %in% (a+b) == a + b + a:b:c

Rich

[[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] Help on ARFIMA modeling

2010-06-05 Thread Joris Meys
Read the posting guides please and give us a tiny little bit more information.
http://www.R-project.org/posting-guide.html

Cheers
Joris

On Sat, Jun 5, 2010 at 4:39 PM, ERIC AIDOO  wrote:
> Dear R Users,
> Please I have applied the arfima  procedure in the forecast package
> to my time series data named "x" as shown below but it does not work
> well for me
>
> fit <- arfima(x)
>
>        [[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.
>



-- 
Ghent University
Faculty of Bioscience Engineering
Department of Applied mathematics, biometrics and process control

tel : +32 9 264 59 87
joris.m...@ugent.be
---
Disclaimer : http://helpdesk.ugent.be/e-maildisclaimer.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.


Re: [R] Prediction in discriminant analysis

2010-06-05 Thread Joris Meys
You use the function "predict" for that. You give a data frame with
the new observations, and make sure the variables have exactly the
same name.

# run example
library(MASS)
Class <- as.factor(rep(c("A","B","C"),each=30))

X1 <- c(rnorm(30),rnorm(30,3,2),rnorm(30,-3,1))
X2 <- c(rnorm(30,5,3),rnorm(30,-2,4),rnorm(30,2,2))

result <- lda(Class~X1+X2)

newdat <- data.frame(X1=rnorm(10),X2=rnorm(10,5,3))

predictions <- predict(result,newdat)  #
predictions$class   # gives the class to which the new observation belongs
predictions$posterior # gives the posterior probabilities for each
observation and for all classes
# end example

Cheers
Joris


On Sat, Jun 5, 2010 at 6:37 AM, suman dhara  wrote:
> Sir,
> I am working with multiclass discriminant analysis.(say response variable
> has 3classes).In R, using lda(), I get 2 sets of coefficients for the
> discriminant function.Now, I want to put a new x-vector(vector of
> independent variables) and want to check it corresponds to which class of
> y.Is there any formula for doing this? or how can I do this?
>
>
>
> Regards,
> Suman Dhara
>
>        [[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.
>



-- 
Ghent University
Faculty of Bioscience Engineering
Department of Applied mathematics, biometrics and process control

tel : +32 9 264 59 87
joris.m...@ugent.be
---
Disclaimer : http://helpdesk.ugent.be/e-maildisclaimer.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.


Re: [R] apply min function rowwise

2010-06-05 Thread William Dunlap
> -Original Message-
> From: r-help-boun...@r-project.org 
> [mailto:r-help-boun...@r-project.org] On Behalf Of Joshua Wiley
> Sent: Saturday, June 05, 2010 11:12 AM
> To: moleps
> Cc: r-help@r-project.org
> Subject: Re: [R] apply min function rowwise
> 
> On Sat, Jun 5, 2010 at 10:22 AM, moleps  wrote:
> > thx.
> >
> > It was only the first instance that was class date. The 
> rest were factors. So that explains it.
> >
> > If I want to change the rest in vec into class date (there 
> are many of them...)
> >
> > neither  as.Date(canc[,vec],"%d.%m.%Y") or 
> sapply(canc[,vec],FUN=function(x) as.date(x,"%d.%m.%Y"))
> >
> > What is the easy solution to this?
> 
> This is the nicest solution that comes to mind:
> 
> as.data.frame(lapply(X=samp.dat, FUN=as.Date, format="%d.%m.%Y"))
> 
> I believe the problem is that sapply() coerces the results (by default
> when simplify=TRUE) using as.vector() leaving you with the number of
> days since the origin.  Anyway, using as.data.frame() on the list
> output from lapply() seems to work.
> 
> Josh

Note that once you have changed your input data.frame
to consist entirely of Date columns, the expression
   apply(d, 1, min)
will still not give you a Date as output, but will output
character data instead.  apply() just doesn't work well
with data.frames unless all columns are numeric or you
are satisfied with all columns being coerced to character
data.  apply(X,MARGIN,FUN) calls as.matrix() to convert X
to a matrix, often a character matrix, before doing
anything to its rows or columns and tries to convert the
outputs of FUN(X[...]) to a vector or a matrix on the way out,
often losing track of the class of FUN's output.

To get the row minima for a data frame try pmin ('parallel
minima'):
   do.call(pmin, d)
or, to protect against funny column names like 'na.rm'
   do.call(unname(as.list(d)))
E.g., with the following data.frame of Date columns
   > d <- data.frame(lapply(list(
 One=c("01.02.2010","02.01.2009","03.03.2008"),
 Two=c("03.01.2009","21.12.1937","25.11.2001"),
 Three=c("21.06.1995","10.02.2008","24.12.2010")),
   as.Date, format="%d.%m.%Y"))
   > d
OneTwo  Three
   1 2010-02-01 2009-01-03 1995-06-21
   2 2009-01-02 1937-12-21 2008-02-10
   3 2008-03-03 2001-11-25 2010-12-24
   > str(d)
   'data.frame':   3 obs. of  3 variables:
$ One  :Class 'Date'  num [1:3] 14641 14246 13941
$ Two  :Class 'Date'  num [1:3] 14247 -11699 11651
$ Three:Class 'Date'  num [1:3] 9302 13919 14967
compare the following
   > apply(d, 1, min) # looks ok
   [1] "1995-06-21" "1937-12-21" "2001-11-25"
   > str(.Last.value) # but it produced character data
chr [1:3] "1995-06-21" "1937-12-21" "2001-11-25"
   > do.call(pmin, unname(as.list(d))) # looks ok also
   [1] "1995-06-21" "1937-12-21" "2001-11-25"
   > str(.Last.value) # and it produced Date data
   Class 'Date'  num [1:3] 9302 -11699 11651

For a data.frame with lots of rows pmin will generally
be faster than apply(X,1,min), in addition to giving
the correct answer.

Bill Dunlap
Spotfire, TIBCO Software
wdunlap tibco.com 

> >
> > Regards,
> >
> > //M
> >
> >
> >
> > On 5. juni 2010, at 18.30, Joshua Wiley wrote:
> >
> >> Hello M,
> >>
> >> My guess is that it has something to do with the class of the
> >> variables.  Perhaps you could provide a small sample 
> dataframe?  Also
> >> you might try running str() on your data frame and seeing if the
> >> results are what you would expect.  As a side note, it is not
> >> necessary to make an anonymous function here, as you are allowed to
> >> pass arguments to the function applied.
> >>
> >> apply(canc[,vec],1, min, na.rm=TRUE)
> >>
> >> Best regards,
> >>
> >> Josh
> >>
> >> On Sat, Jun 5, 2010 at 8:30 AM, moleps  wrote:
> >>> I´m trying to tease out the minimum value from a row in a 
> dataframe where all the variables are dates.
> >>>
> >>> apply(canc[,vec],1,function(x)min(x,na.rm=T))
> >>>
> >>>
> >>> However it only returns empty strings for the entire 
> dataframe except for one date value (which is not the minimum date).
> >>>
> >>> I´ve also tried
> >>>
> >>> apply(canc[,vec],1,function(x)max(x,na.rm=T))
> >>>
> >>> which provides values rowwise, but many of them are not 
> in fact the largest in the row.
> >>>
> >>>
> >>> Any advice?
> >>>
> >>>
> >>> Regards,
> >>>
> >>> //M
> >>>
> >>> __
> >>> 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.
> >>>
> >>
> >>
> >>
> >> --
> >> Joshua Wiley
> >> Senior in Psychology
> >> University of California, Riverside
> >> http://www.joshuawiley.com/
> >
> >
> 
> 
> 
> -- 
> Joshua Wiley
> Senior in Psychology
> University of California, Riverside
> http://www.joshuawiley.com/
> 
> _

[R] The curious special case of "~ (a + b)/c"

2010-06-05 Thread Nathaniel Smith
This isn't at all an urgent practical question, but recently while
exploring the details of how R formulas are interpreted, I learned of
this funny special case for how / interacts with +. In all of the
following cases, the multiplication-like operator simply distributes
over addition:
  (a + b):c = a:c + a:c
  a:(b + c) = a:b + a:c
  (a + b)*c = a*c + b*c
  a*(b + c) = a*b + a*c
  a/(b + c) = a/b + a/c

But:
  (a + b)/c = a + b + a:b:c, not a/c + b/c = a + a:c + b + b:c

Chambers and Hastie mention this, but give no explanation (page 29/30,
"Slightly more subtle is...").

So for my own edification, does anyone know/care to speculate about
why (a + b)/c works this way?

-- Nathaniel

__
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 to Vector

2010-06-05 Thread steven mosher
 I bet that is what I did.

On Sat, Jun 5, 2010 at 11:54 AM, John Kane  wrote:

> m<-matrix(seq(1,48),nrow=6,byrow=T)
> as.vector(t(m))
>
> gives me the correct result.
>
> Any chance you may have already transformed m ?
>
> --- On Sat, 6/5/10, steven mosher  wrote:
>
> > From: steven mosher 
> > Subject: Re: [R] Matrix to Vector
> > To: "Henrique Dallazuanna" 
> > Cc: r-help@r-project.org
> > Received: Saturday, June 5, 2010, 2:44 PM
> >  as.vector(t(m))
> >  [1]  1  9 17 25 33 41  2 10 18 26 34
> > 42  3 11 19 27 35 43  4 12 20 28 36 44
> >  5 13 21 29 37 45  6 14 22 30 38 46  7 15 23 31
> > 39 47  8 16 24
> > [46] 32 40 48
> >
> > the result I want is this:
> >
> > [1]  1  2  3  4  5  6
> > 7  8  9 10 11 12 13 14 15 16 17 18 19 20 21 22 23
> > 24
> > 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44
> > 45
> > [46] 46 47 48
> >
> >
> >
> > On Sat, Jun 5, 2010 at 11:17 AM, Henrique Dallazuanna
> > wrote:
> >
> > > Try this:
> > >
> > > as.vector(t(m))
> > >
> > > On Sat, Jun 5, 2010 at 3:12 PM, steven mosher  >wrote:
> > >
> > >> Given a matrix of m*n, I want to reorder it as a
> > vector, using a row major
> > >> transpose.
> > >>
> > >> so:
> > >>
> > >> > m<-matrix(seq(1,48),nrow=6,byrow=T)
> > >> > m
> > >> [,1] [,2] [,3] [,4] [,5]
> > [,6] [,7] [,8]
> > >> [1,]12
> > 3456
> > 78
> > >> [2,]
> > 9   10   11   12   13   14   15   16
> > >>
> > [3,]   17   18   19   20   21   22   23   24
> > >>
> > [4,]   25   26   27   28   29   30   31   32
> > >>
> > [5,]   33   34   35   36   37   38   39   40
> > >>
> > [6,]   41   42   43   44   45   46   47   48
> > >>
> > >> I want to reorder this as a vector copying by row,
> > so that the final
> > >> vector
> > >> has elements ordered thusly: row 1, column 1:N
> > (m[1,1:n]) maps to
> > >> row 1-n, and m[2,1:n] maps to row[n+1:2n] ...
> > >>
> > >> this obviously is not a solution: as the inherent
> > column major storage
> > >> paradigm of a matrix
> > >> defeats the approach.
> > >> > dim(m)<-c(48,1)
> > >> > m
> > >>  [,1]
> > >>  [1,]1
> > >>  [2,]9
> > >>  [3,]   17
> > >>  [4,]   25
> > >>  [5,]   33
> > >>  [6,]   41
> > >>  [7,]2
> > >>  [8,]   10
> > >>  [9,]   18
> > >> [10,]   26
> > >> [11,]   34
> > >> [12,]   42
> > >> [13,]3
> > >> [14,]   11
> > >> [15,]   19
> > >> [16,]   27
> > >> [17,]   35
> > >> [18,]   43
> > >> [19,]4
> > >> [20,]   12
> > >> [21,]   20
> > >> [22,]   28
> > >> [23,]   36
> > >> [24,]   44
> > >> [25,]5
> > >> [26,]   13
> > >> [27,]   21
> > >> [28,]   29
> > >> [29,]   37
> > >> [30,]   45
> > >> [31,]6
> > >> [32,]   14
> > >> [33,]   22
> > >> [34,]   30
> > >> [35,]   38
> > >> [36,]   46
> > >> [37,]7
> > >> [38,]   15
> > >> [39,]   23
> > >> [40,]   31
> > >> [41,]   39
> > >> [42,]   47
> > >> [43,]8
> > >> [44,]   16
> > >> [45,]   24
> > >> [46,]   32
> > >> [47,]   40
> > >> [48,]   48
> > >>
> > >>
> > >> I already have a version that loops through the
> > data ( this is actually a
> > >> portion of a data frame ) to reorder
> > >> this into a vector, but I was hoping there was an
> > elegant way
> > >>
> > >>[[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
> > >
> >
> > [[alternative HTML version deleted]]
> >
> >
> > -Inline Attachment Follows-
> >
> > __
> > 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] Matrix to Vector

2010-06-05 Thread John Kane
m<-matrix(seq(1,48),nrow=6,byrow=T)
as.vector(t(m))

gives me the correct result.  

Any chance you may have already transformed m ?

--- On Sat, 6/5/10, steven mosher  wrote:

> From: steven mosher 
> Subject: Re: [R] Matrix to Vector
> To: "Henrique Dallazuanna" 
> Cc: r-help@r-project.org
> Received: Saturday, June 5, 2010, 2:44 PM
>  as.vector(t(m))
>  [1]  1  9 17 25 33 41  2 10 18 26 34
> 42  3 11 19 27 35 43  4 12 20 28 36 44
>  5 13 21 29 37 45  6 14 22 30 38 46  7 15 23 31
> 39 47  8 16 24
> [46] 32 40 48
> 
> the result I want is this:
> 
> [1]  1  2  3  4  5  6 
> 7  8  9 10 11 12 13 14 15 16 17 18 19 20 21 22 23
> 24
> 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44
> 45
> [46] 46 47 48
> 
> 
> 
> On Sat, Jun 5, 2010 at 11:17 AM, Henrique Dallazuanna
> wrote:
> 
> > Try this:
> >
> > as.vector(t(m))
> >
> > On Sat, Jun 5, 2010 at 3:12 PM, steven mosher wrote:
> >
> >> Given a matrix of m*n, I want to reorder it as a
> vector, using a row major
> >> transpose.
> >>
> >> so:
> >>
> >> > m<-matrix(seq(1,48),nrow=6,byrow=T)
> >> > m
> >>     [,1] [,2] [,3] [,4] [,5]
> [,6] [,7] [,8]
> >> [1,]    1    2   
> 3    4    5    6   
> 7    8
> >> [2,]   
> 9   10   11   12   13   14   15   16
> >>
> [3,]   17   18   19   20   21   22   23   24
> >>
> [4,]   25   26   27   28   29   30   31   32
> >>
> [5,]   33   34   35   36   37   38   39   40
> >>
> [6,]   41   42   43   44   45   46   47   48
> >>
> >> I want to reorder this as a vector copying by row,
> so that the final
> >> vector
> >> has elements ordered thusly: row 1, column 1:N
> (m[1,1:n]) maps to
> >> row 1-n, and m[2,1:n] maps to row[n+1:2n] ...
> >>
> >> this obviously is not a solution: as the inherent
> column major storage
> >> paradigm of a matrix
> >> defeats the approach.
> >> > dim(m)<-c(48,1)
> >> > m
> >>      [,1]
> >>  [1,]    1
> >>  [2,]    9
> >>  [3,]   17
> >>  [4,]   25
> >>  [5,]   33
> >>  [6,]   41
> >>  [7,]    2
> >>  [8,]   10
> >>  [9,]   18
> >> [10,]   26
> >> [11,]   34
> >> [12,]   42
> >> [13,]    3
> >> [14,]   11
> >> [15,]   19
> >> [16,]   27
> >> [17,]   35
> >> [18,]   43
> >> [19,]    4
> >> [20,]   12
> >> [21,]   20
> >> [22,]   28
> >> [23,]   36
> >> [24,]   44
> >> [25,]    5
> >> [26,]   13
> >> [27,]   21
> >> [28,]   29
> >> [29,]   37
> >> [30,]   45
> >> [31,]    6
> >> [32,]   14
> >> [33,]   22
> >> [34,]   30
> >> [35,]   38
> >> [36,]   46
> >> [37,]    7
> >> [38,]   15
> >> [39,]   23
> >> [40,]   31
> >> [41,]   39
> >> [42,]   47
> >> [43,]    8
> >> [44,]   16
> >> [45,]   24
> >> [46,]   32
> >> [47,]   40
> >> [48,]   48
> >>
> >>
> >> I already have a version that loops through the
> data ( this is actually a
> >> portion of a data frame ) to reorder
> >> this into a vector, but I was hoping there was an
> elegant way
> >>
> >>        [[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
> >
> 
>     [[alternative HTML version deleted]]
> 
> 
> -Inline Attachment Follows-
> 
> __
> 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] Matrix to Vector

2010-06-05 Thread steven mosher
 as.vector(t(m))
 [1]  1  9 17 25 33 41  2 10 18 26 34 42  3 11 19 27 35 43  4 12 20 28 36 44
 5 13 21 29 37 45  6 14 22 30 38 46  7 15 23 31 39 47  8 16 24
[46] 32 40 48

the result I want is this:

[1]  1  2  3  4  5  6  7  8  9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24
25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45
[46] 46 47 48



On Sat, Jun 5, 2010 at 11:17 AM, Henrique Dallazuanna wrote:

> Try this:
>
> as.vector(t(m))
>
> On Sat, Jun 5, 2010 at 3:12 PM, steven mosher wrote:
>
>> Given a matrix of m*n, I want to reorder it as a vector, using a row major
>> transpose.
>>
>> so:
>>
>> > m<-matrix(seq(1,48),nrow=6,byrow=T)
>> > m
>> [,1] [,2] [,3] [,4] [,5] [,6] [,7] [,8]
>> [1,]12345678
>> [2,]9   10   11   12   13   14   15   16
>> [3,]   17   18   19   20   21   22   23   24
>> [4,]   25   26   27   28   29   30   31   32
>> [5,]   33   34   35   36   37   38   39   40
>> [6,]   41   42   43   44   45   46   47   48
>>
>> I want to reorder this as a vector copying by row, so that the final
>> vector
>> has elements ordered thusly: row 1, column 1:N (m[1,1:n]) maps to
>> row 1-n, and m[2,1:n] maps to row[n+1:2n] ...
>>
>> this obviously is not a solution: as the inherent column major storage
>> paradigm of a matrix
>> defeats the approach.
>> > dim(m)<-c(48,1)
>> > m
>>  [,1]
>>  [1,]1
>>  [2,]9
>>  [3,]   17
>>  [4,]   25
>>  [5,]   33
>>  [6,]   41
>>  [7,]2
>>  [8,]   10
>>  [9,]   18
>> [10,]   26
>> [11,]   34
>> [12,]   42
>> [13,]3
>> [14,]   11
>> [15,]   19
>> [16,]   27
>> [17,]   35
>> [18,]   43
>> [19,]4
>> [20,]   12
>> [21,]   20
>> [22,]   28
>> [23,]   36
>> [24,]   44
>> [25,]5
>> [26,]   13
>> [27,]   21
>> [28,]   29
>> [29,]   37
>> [30,]   45
>> [31,]6
>> [32,]   14
>> [33,]   22
>> [34,]   30
>> [35,]   38
>> [36,]   46
>> [37,]7
>> [38,]   15
>> [39,]   23
>> [40,]   31
>> [41,]   39
>> [42,]   47
>> [43,]8
>> [44,]   16
>> [45,]   24
>> [46,]   32
>> [47,]   40
>> [48,]   48
>>
>>
>> I already have a version that loops through the data ( this is actually a
>> portion of a data frame ) to reorder
>> this into a vector, but I was hoping there was an elegant way
>>
>>[[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
>

[[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] Matrix to Vector

2010-06-05 Thread Jorge Ivan Velez
Hi Steven,

If I understood correctly, this might do what you want:

c(t(m))

HTH,
Jorge


On Sat, Jun 5, 2010 at 2:12 PM, steven mosher wrote:

> Given a matrix of m*n, I want to reorder it as a vector, using a row major
> transpose.
>
> so:
>
> > m<-matrix(seq(1,48),nrow=6,byrow=T)
> > m
> [,1] [,2] [,3] [,4] [,5] [,6] [,7] [,8]
> [1,]12345678
> [2,]9   10   11   12   13   14   15   16
> [3,]   17   18   19   20   21   22   23   24
> [4,]   25   26   27   28   29   30   31   32
> [5,]   33   34   35   36   37   38   39   40
> [6,]   41   42   43   44   45   46   47   48
>
> I want to reorder this as a vector copying by row, so that the final vector
> has elements ordered thusly: row 1, column 1:N (m[1,1:n]) maps to
> row 1-n, and m[2,1:n] maps to row[n+1:2n] ...
>
> this obviously is not a solution: as the inherent column major storage
> paradigm of a matrix
> defeats the approach.
> > dim(m)<-c(48,1)
> > m
>  [,1]
>  [1,]1
>  [2,]9
>  [3,]   17
>  [4,]   25
>  [5,]   33
>  [6,]   41
>  [7,]2
>  [8,]   10
>  [9,]   18
> [10,]   26
> [11,]   34
> [12,]   42
> [13,]3
> [14,]   11
> [15,]   19
> [16,]   27
> [17,]   35
> [18,]   43
> [19,]4
> [20,]   12
> [21,]   20
> [22,]   28
> [23,]   36
> [24,]   44
> [25,]5
> [26,]   13
> [27,]   21
> [28,]   29
> [29,]   37
> [30,]   45
> [31,]6
> [32,]   14
> [33,]   22
> [34,]   30
> [35,]   38
> [36,]   46
> [37,]7
> [38,]   15
> [39,]   23
> [40,]   31
> [41,]   39
> [42,]   47
> [43,]8
> [44,]   16
> [45,]   24
> [46,]   32
> [47,]   40
> [48,]   48
>
>
> I already have a version that loops through the data ( this is actually a
> portion of a data frame ) to reorder
> this into a vector, but I was hoping there was an elegant way
>
>[[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] Matrix to Vector

2010-06-05 Thread Henrique Dallazuanna
Try this:

as.vector(t(m))

On Sat, Jun 5, 2010 at 3:12 PM, steven mosher wrote:

> Given a matrix of m*n, I want to reorder it as a vector, using a row major
> transpose.
>
> so:
>
> > m<-matrix(seq(1,48),nrow=6,byrow=T)
> > m
> [,1] [,2] [,3] [,4] [,5] [,6] [,7] [,8]
> [1,]12345678
> [2,]9   10   11   12   13   14   15   16
> [3,]   17   18   19   20   21   22   23   24
> [4,]   25   26   27   28   29   30   31   32
> [5,]   33   34   35   36   37   38   39   40
> [6,]   41   42   43   44   45   46   47   48
>
> I want to reorder this as a vector copying by row, so that the final vector
> has elements ordered thusly: row 1, column 1:N (m[1,1:n]) maps to
> row 1-n, and m[2,1:n] maps to row[n+1:2n] ...
>
> this obviously is not a solution: as the inherent column major storage
> paradigm of a matrix
> defeats the approach.
> > dim(m)<-c(48,1)
> > m
>  [,1]
>  [1,]1
>  [2,]9
>  [3,]   17
>  [4,]   25
>  [5,]   33
>  [6,]   41
>  [7,]2
>  [8,]   10
>  [9,]   18
> [10,]   26
> [11,]   34
> [12,]   42
> [13,]3
> [14,]   11
> [15,]   19
> [16,]   27
> [17,]   35
> [18,]   43
> [19,]4
> [20,]   12
> [21,]   20
> [22,]   28
> [23,]   36
> [24,]   44
> [25,]5
> [26,]   13
> [27,]   21
> [28,]   29
> [29,]   37
> [30,]   45
> [31,]6
> [32,]   14
> [33,]   22
> [34,]   30
> [35,]   38
> [36,]   46
> [37,]7
> [38,]   15
> [39,]   23
> [40,]   31
> [41,]   39
> [42,]   47
> [43,]8
> [44,]   16
> [45,]   24
> [46,]   32
> [47,]   40
> [48,]   48
>
>
> I already have a version that loops through the data ( this is actually a
> portion of a data frame ) to reorder
> this into a vector, but I was hoping there was an elegant way
>
>[[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

[[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 get the closing price from the the GOOGLE FINANCE site for NSEINDIA stocks

2010-06-05 Thread Velappan Periasamy
Sir,
 How to get the closing price from this link
http://www.google.com/finance/historical?q=NSE:RCOM

I installed quantmod
getSymbols('NSE:RCOM',src='google')

  gives me this error**

Error in download.file(paste(google.URL, "q=", Symbols.name, "&startdate=",  :
  cannot open URL
'http://finance.google.com/finance/historical?q=NSE:RCOM&startdate=Jan+01,+2007&enddate=Jun+05,+2010&output=csv'
Calls: getSymbols -> do.call -> getSymbols.google -> download.file
In addition: Warning message:
In download.file(paste(google.URL, "q=", Symbols.name, "&startdate=",  :
  cannot open: HTTP status was '404 Not Found'

Could someone please give me the correct statement.
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] variation

2010-06-05 Thread John Kane
?var perhaps

--- On Sat, 6/5/10, Adel ESSAFI  wrote:

> From: Adel ESSAFI 
> Subject: Re: [R] variation
> To: r-help@r-project.org
> Received: Saturday, June 5, 2010, 7:57 AM
> 2010/6/5 Jannis 
> 
> > What exactly do you mean by "variation"? As I
> understand it, this term is a
> > broad term for all kinds of different "spread
> measures" (like quantile range
> > or standard deviation). Do you mean the Coefficient of
> Variation? If you
> > found out how to
> 
> 
> Yes, that what I mean. But I looked for ready 
> function :)
> 
> 
> > compute the mean and the std.dev., it is
> straightforward to calculate
> > it.
> >
> > Adel ESSAFI schrieb:
> >
> >> Hi list
> >> I am a new user of R. I ask for some "beginner"
> question
> >>
> >> I am searching if there is any function that
> computes the variation of
> >> some
> >> discrete values of a vector (mean() and sd()
> exists, but i have not find
> >> variation).
> >>
> >> Thanks in advance
> >>
> >> Adel
> >>
> >>
> >> 
> 
> >>
> >>
> >> __
> >> 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.
> >>
> >>
> >
> >
> 
> 
> -- 
> PhD candidate in Computer Science
> Address
> 3 avenue lamine, cité ezzahra, Sousse 4000
> Tunisia
> tel: +216 97 246 706 (+33640302046 jusqu'au 15/6)
> fax: +216 71 391 166
> 
>     [[alternative HTML version deleted]]
> 
> 
> -Inline Attachment Follows-
> 
> __
> 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] Matrix to Vector

2010-06-05 Thread steven mosher
Given a matrix of m*n, I want to reorder it as a vector, using a row major
transpose.

so:

> m<-matrix(seq(1,48),nrow=6,byrow=T)
> m
 [,1] [,2] [,3] [,4] [,5] [,6] [,7] [,8]
[1,]12345678
[2,]9   10   11   12   13   14   15   16
[3,]   17   18   19   20   21   22   23   24
[4,]   25   26   27   28   29   30   31   32
[5,]   33   34   35   36   37   38   39   40
[6,]   41   42   43   44   45   46   47   48

I want to reorder this as a vector copying by row, so that the final vector
has elements ordered thusly: row 1, column 1:N (m[1,1:n]) maps to
row 1-n, and m[2,1:n] maps to row[n+1:2n] ...

this obviously is not a solution: as the inherent column major storage
paradigm of a matrix
defeats the approach.
> dim(m)<-c(48,1)
> m
  [,1]
 [1,]1
 [2,]9
 [3,]   17
 [4,]   25
 [5,]   33
 [6,]   41
 [7,]2
 [8,]   10
 [9,]   18
[10,]   26
[11,]   34
[12,]   42
[13,]3
[14,]   11
[15,]   19
[16,]   27
[17,]   35
[18,]   43
[19,]4
[20,]   12
[21,]   20
[22,]   28
[23,]   36
[24,]   44
[25,]5
[26,]   13
[27,]   21
[28,]   29
[29,]   37
[30,]   45
[31,]6
[32,]   14
[33,]   22
[34,]   30
[35,]   38
[36,]   46
[37,]7
[38,]   15
[39,]   23
[40,]   31
[41,]   39
[42,]   47
[43,]8
[44,]   16
[45,]   24
[46,]   32
[47,]   40
[48,]   48


I already have a version that loops through the data ( this is actually a
portion of a data frame ) to reorder
this into a vector, but I was hoping there was an elegant way

[[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] apply min function rowwise

2010-06-05 Thread Joshua Wiley
On Sat, Jun 5, 2010 at 10:22 AM, moleps  wrote:
> thx.
>
> It was only the first instance that was class date. The rest were factors. So 
> that explains it.
>
> If I want to change the rest in vec into class date (there are many of 
> them...)
>
> neither  as.Date(canc[,vec],"%d.%m.%Y") or sapply(canc[,vec],FUN=function(x) 
> as.date(x,"%d.%m.%Y"))
>
> What is the easy solution to this?

This is the nicest solution that comes to mind:

as.data.frame(lapply(X=samp.dat, FUN=as.Date, format="%d.%m.%Y"))

I believe the problem is that sapply() coerces the results (by default
when simplify=TRUE) using as.vector() leaving you with the number of
days since the origin.  Anyway, using as.data.frame() on the list
output from lapply() seems to work.

Josh

>
> Regards,
>
> //M
>
>
>
> On 5. juni 2010, at 18.30, Joshua Wiley wrote:
>
>> Hello M,
>>
>> My guess is that it has something to do with the class of the
>> variables.  Perhaps you could provide a small sample dataframe?  Also
>> you might try running str() on your data frame and seeing if the
>> results are what you would expect.  As a side note, it is not
>> necessary to make an anonymous function here, as you are allowed to
>> pass arguments to the function applied.
>>
>> apply(canc[,vec],1, min, na.rm=TRUE)
>>
>> Best regards,
>>
>> Josh
>>
>> On Sat, Jun 5, 2010 at 8:30 AM, moleps  wrote:
>>> I´m trying to tease out the minimum value from a row in a dataframe where 
>>> all the variables are dates.
>>>
>>> apply(canc[,vec],1,function(x)min(x,na.rm=T))
>>>
>>>
>>> However it only returns empty strings for the entire dataframe except for 
>>> one date value (which is not the minimum date).
>>>
>>> I´ve also tried
>>>
>>> apply(canc[,vec],1,function(x)max(x,na.rm=T))
>>>
>>> which provides values rowwise, but many of them are not in fact the largest 
>>> in the row.
>>>
>>>
>>> Any advice?
>>>
>>>
>>> Regards,
>>>
>>> //M
>>>
>>> __
>>> 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.
>>>
>>
>>
>>
>> --
>> Joshua Wiley
>> Senior in Psychology
>> University of California, Riverside
>> http://www.joshuawiley.com/
>
>



-- 
Joshua Wiley
Senior in Psychology
University of California, Riverside
http://www.joshuawiley.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 use 'points' function to plot two curves with errbar

2010-06-05 Thread John Kane
The first thing we need to know is what "errbar" are you using?

There are at least two, on in the Hmisc package and one in sfsmisc.

 PLEASE do read the posting guide http://www.R-project.org/posting-guide.html 
and provide commented, minimal, self-contained,reproducible code.

I'm not sure what you are trying to do here but perhaps looking  at "new" in 
?par  might hrlp you.

Example:
plot(1:10, col="red")
par(new=TRUE)
plot(10:1, col="blue")


 

--- On Sat, 6/5/10, Yogesh Tiwari  wrote:

> From: Yogesh Tiwari 
> Subject: [R] how to use 'points' function to plot two curves with errbar
> To: r-h...@stat.math.ethz.ch
> Received: Saturday, June 5, 2010, 10:06 AM
> Dear R Users,
> I am using R on windows.
> 
> how to use 'points' function to plot two curves with
> errbar
> 
> I am doing like:
> 
> x.val <- as.integer(names(co2mean))
> errbar(x.val, co2mean, co2mean + co2sd, co2mean - co2sd,
> xaxt='n', col=1,
> xlab=NA,ylab=NA)# obs error bar
> lines(x.val, co2mean, col=1, lwd=2)
> 
> errbar(x.val, co2tm3.month.mean, co2tm3.month.mean +
> co2sd.tm3,
> co2tm3.month.mean - co2sd.tm3, xaxt='n', col=2,
> xlab=NA,ylab=NA)# model
> error bar
> lines(x.val, co2tm3.month.mean, col=2, lwd=2)
> 
> Above code replaces first error bar and its line with
> second. Kindly help,
> how to use 'points' function here so both above can get
> over ploted
> 
> Thanks,
> Regards,
> Yogesh

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] SciViews-K / Komodo as editor on the Mac [was: StatET plot problem]

2010-06-05 Thread Philippe Grosjean

Matt,

Yes, I see this problem. Thanks for report. Also ??topic is wrong. Note 
two points:


1) ?topic works with R.app/R64.app. So, just in case you would consider 
using R.app instead of R inside a terminal session,


2) I have not noticed this bug because using ?topic inside SciViews-K / 
Komodo is a little bit silly. There is a much better mechanism: place 
your cursor on a word (the 'topic' in ?topic) and hit Alt-F1, and you 
got the corresponding help page displayed. It is much more natural to 
type the name of your function, then Alt-F1 to see the man page, than to 
type ?myfun, then move back to eliminate '?', move forward and continue 
typing your code, isn't it? Also try Alt-Shift-F1 for a better 
alternative to ??topic from within SciViews-K / Komodo.


Best,

Philippe

..<°}))><
 ) ) ) ) )
( ( ( ( (Prof. Philippe Grosjean
 ) ) ) ) )
( ( ( ( (Numerical Ecology of Aquatic Systems
 ) ) ) ) )   Mons University, Belgium
( ( ( ( (
..

On 05/06/10 18:54, Bunny, lautloscrew.com wrote:

Philippe,

now I  tried to run the SciViews-K / Komodo combo on my Mac. It did work and I 
like it. Thx for your suggestion.
On first sight everything works really well. The only thing that bothers me a little bit, 
is that I was only able to run it with the "directly in terminal" option.
Everytime I start ?whateverhelp  from Komodo R inside the terminal crashes. If 
I run ?myhelp directly from the terminal, everything works just fine. Probably 
I could just live with that, but somehow I want to fix it or at least know why 
this is happening.

Besides, I think the code folding, syntax highlighting and auto-complete / 
command+t stuff is really an advantage over the standard editor on a mac and 
it´s well worth the hustle.

best

matt


On 04.06.2010, at 11:13, Philippe Grosjean wrote:


On 04/06/10 10:37, Bunny, lautloscrew.com wrote:

Dear all,

after trying several suggestions from the list for a nice R-Editor / IDE for 
MacOS X and really trying some of those that needed to be configured a little 
more (such as emacs, aquamacs and StatET / Eclipse), I prefer StatET at the 
moment. I found more experienced like John suggesting this combination 
(http://www.mail-archive.com/r-help@r-project.org/msg38883.html) on Mac OS X.

So far I am really happy with it except for the plotting. I just can´t get 
plots to go. everytime I plot(x) nothing happens. What´s striking is that the 
edit() works and opens up in X11. Is there some configuration option I just 
missed ?

best regards


You haven't try SciViews-K/Komodo, don't you? 
(http://www.sciviews.org/SciViews-K).
Best,

Philippe


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


Re: [R] selecting only specific rows in R

2010-06-05 Thread Charles C. Berry

On Sat, 5 Jun 2010, stephen sefick wrote:


Reproducible dummy example, as to the posting guide.  look at unique-
you want to subset the data frame on all of the non-unique entries in
the species column...

x[x!=unique(x[,"species"]),]

Something like that, maybe.  If I had some data then I could probably
figure it out.  Use dput() or fake data to make a cut and paste-able
example.
HTH,

Stephen


Or use one of the built in datasets - there are several that pertain to 
trees. Try


??tree

But yes, Adrienne, you should (as per Posting Guide) "provide commented, 
minimal, self-contained, reproducible code".


For example:


?Orange # find out about 'Orange' tree dataset
## rows with more than one tree of a given circumference:
subset( Orange, xtabs(~circumference)[ as.character(circumference) ] > 1 

)
   Tree  age circumference
1 1  11830
4 1 1004   115
6 1 1372   142
132 1372   203
142 1582   203
153  11830
193 1231   115
295  11830
335 1231   142





# more detail to suggest why this works:
with( Orange, xtabs(~circumference)[as.character(circumference)] > 1 )

[output deleted]

Chuck






On Sat, Jun 5, 2010 at 10:00 AM, Adrienne Keller
 wrote:

Hi, I have a data frame with columns as follows: tree species (independent
variable) and several dependent variables (e.g. carbon, nitrogen,
phosphorus). Each row represents one tree sample. Some tree samples are
unique species in the data frame while other species were replicated (i.e.
rows 1,2,3 may be identical for the "tree species" column but have different
values for the other dependent variable columns). I want to create a new
data frame that selects only the tree species that have replicates. In other
words, I want to select all rows that have at least one replicate in the
column "tree species".

Ideas on how to write such a function?

Thanks,

Adrienne Keller

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





--
Stephen Sefick

| Auburn University   |
| Department of Biological Sciences   |
| 331 Funchess Hall  |
| Auburn, Alabama   |
| 36849|
|___|
| sas0...@auburn.edu |
| http://www.auburn.edu/~sas0025 |
|___|

Let's not spend our time and resources thinking about things that are
so little or so large that all they really do for us is puff us up and
make us feel like gods.  We are mammals, and have not exhausted the
annoying little problems of being mammals.

-K. Mullis

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


Re: [R] selecting only specific rows in R

2010-06-05 Thread stephen sefick
Reproducible dummy example, as to the posting guide.  look at unique-
you want to subset the data frame on all of the non-unique entries in
the species column...

x[x!=unique(x[,"species"]),]

Something like that, maybe.  If I had some data then I could probably
figure it out.  Use dput() or fake data to make a cut and paste-able
example.
HTH,

Stephen

On Sat, Jun 5, 2010 at 10:00 AM, Adrienne Keller
 wrote:
> Hi, I have a data frame with columns as follows: tree species (independent
> variable) and several dependent variables (e.g. carbon, nitrogen,
> phosphorus). Each row represents one tree sample. Some tree samples are
> unique species in the data frame while other species were replicated (i.e.
> rows 1,2,3 may be identical for the "tree species" column but have different
> values for the other dependent variable columns). I want to create a new
> data frame that selects only the tree species that have replicates. In other
> words, I want to select all rows that have at least one replicate in the
> column "tree species".
>
> Ideas on how to write such a function?
>
> Thanks,
>
> Adrienne Keller
>
> __
> 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.
>



-- 
Stephen Sefick

| Auburn University   |
| Department of Biological Sciences   |
| 331 Funchess Hall  |
| Auburn, Alabama   |
| 36849|
|___|
| sas0...@auburn.edu |
| http://www.auburn.edu/~sas0025 |
|___|

Let's not spend our time and resources thinking about things that are
so little or so large that all they really do for us is puff us up and
make us feel like gods.  We are mammals, and have not exhausted the
annoying little problems of being mammals.

-K. Mullis

__
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] StatET plot problem

2010-06-05 Thread Bunny, lautloscrew.com
Philippe, 

now I  tried to run the SciViews-K / Komodo combo on my Mac. It did work and I 
like it. Thx for your suggestion.
On first sight everything works really well. The only thing that bothers me a 
little bit, is that I was only able to run it with the "directly in terminal" 
option. 
Everytime I start ?whateverhelp  from Komodo R inside the terminal crashes. If 
I run ?myhelp directly from the terminal, everything works just fine. Probably 
I could just live with that, but somehow I want to fix it or at least know why 
this is happening. 

Besides, I think the code folding, syntax highlighting and auto-complete / 
command+t stuff is really an advantage over the standard editor on a mac and 
it´s well worth the hustle. 

best

matt


On 04.06.2010, at 11:13, Philippe Grosjean wrote:

> On 04/06/10 10:37, Bunny, lautloscrew.com wrote:
>> Dear all,
>> 
>> after trying several suggestions from the list for a nice R-Editor / IDE for 
>> MacOS X and really trying some of those that needed to be configured a 
>> little more (such as emacs, aquamacs and StatET / Eclipse), I prefer StatET 
>> at the moment. I found more experienced like John suggesting this 
>> combination (http://www.mail-archive.com/r-help@r-project.org/msg38883.html) 
>> on Mac OS X.
>> 
>> So far I am really happy with it except for the plotting. I just can´t get 
>> plots to go. everytime I plot(x) nothing happens. What´s striking is that 
>> the edit() works and opens up in X11. Is there some configuration option I 
>> just missed ?
>> 
>> best regards
> 
> You haven't try SciViews-K/Komodo, don't you? 
> (http://www.sciviews.org/SciViews-K).
> Best,
> 
> Philippe
> 
>> matt
>> __
>> 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] Building a package using classes

2010-06-05 Thread Bryan Hanson
Sébastien, late last year I found myself in the same situation, and asked a
question or two about classes, which produced some very helpful answers.
The thread starts here:
http://r.789695.n4.nabble.com/Need-Advice-Considering-Converting-a-Package-f
rom-S3-to-S4-td898853.html#a898853

Good Luck, Bryan
*
Bryan Hanson
Acting Chair
Professor of Chemistry & Biochemistry
DePauw University, Greencastle IN USA



On 6/5/10 10:20 AM, "Sébastien Durand"  wrote:

> Hello,
> 
> I am looking for an efficient and complete free tutorial to learn how to
> properly use, create and manage classes and their methods.
> 
> I have build few R packages in the past but I was not going very far in class
> definition and so forth. So I wish to drastically improve my coding skills in
> R...
> 
> Any quick comments.
> 
> Thanks a lot for your time and consideration.
> 
> Sébastien.
> __
> 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] Factor to variable

2010-06-05 Thread Pete B

Hi

How about ...

# Data
lines = "Col1 Col2 Col3 Col4
Text1 Text2 X0.1 5
Text1 Text2 X0.2 10
Text1 Text2 X0.3 15
Text1 Text3 X0.1 5
Text1 Text3 X0.2 10
Text1 Text3 X0.3 15"

# Create Dataframe
DF <- read.table(textConnection(lines), header = TRUE, check.names = FALSE)

# Create Numeric Variable 
DF$Col5 = as.numeric(sub("X","",DF$Col3))

HTH

Pete
-- 
View this message in context: 
http://r.789695.n4.nabble.com/Factor-to-variable-tp2244337p2244384.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] apply min function rowwise

2010-06-05 Thread Joshua Wiley
Hello M,

My guess is that it has something to do with the class of the
variables.  Perhaps you could provide a small sample dataframe?  Also
you might try running str() on your data frame and seeing if the
results are what you would expect.  As a side note, it is not
necessary to make an anonymous function here, as you are allowed to
pass arguments to the function applied.

apply(canc[,vec],1, min, na.rm=TRUE)

Best regards,

Josh

On Sat, Jun 5, 2010 at 8:30 AM, moleps  wrote:
> I´m trying to tease out the minimum value from a row in a dataframe where all 
> the variables are dates.
>
> apply(canc[,vec],1,function(x)min(x,na.rm=T))
>
>
> However it only returns empty strings for the entire dataframe except for one 
> date value (which is not the minimum date).
>
> I´ve also tried
>
> apply(canc[,vec],1,function(x)max(x,na.rm=T))
>
> which provides values rowwise, but many of them are not in fact the largest 
> in the row.
>
>
> Any advice?
>
>
> Regards,
>
> //M
>
> __
> 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.
>



-- 
Joshua Wiley
Senior in Psychology
University of California, Riverside
http://www.joshuawiley.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] plotting a dataset with median 0

2010-06-05 Thread Marc Schwartz
On Jun 5, 2010, at 9:08 AM, Georg Ehret wrote:

> Thank you, this is partially hepful Jim,
> my data are in 3 categories on the x-axis. Does anyone know of a method of
> plotting values identical on the y-axis distributed (adjacent to each other
> - piled up) on the x-axis?
> 
> 
> On Sat, Jun 5, 2010 at 12:00 PM, Jim Lemon  wrote:
> 
>> On 06/05/2010 07:35 AM, Georg Ehret wrote:
>> 
>>> Dear R community,
>>>  I am working on a dataset that has median 0 (due to many "0"
>>> entries)
>>> for my principal variable of interest (40 entries in total). I would like
>>> to
>>> plot a graph of this variable to show it visually, but have a hard time:
>>> boxplots are not informative (because median 0). Conventional scatterplots
>>> are neither. Is there a good way to do this (e.g. plotting the "0" values
>>> with a jitter or something else...)?
>>> 
>>> Hi Georg,
>> Depending upon what you are plotting it against, count.overplot in the
>> plotrix package might do some good.
>> 
>> Jim


Georg,

Strictly speaking, a barplot() with 'beside = TRUE' might be helpful, but the 
offsetting nature of the bars can actually impede the interpretation the plot. 

A barchart() in lattice would enable you to create separate barplots, one for 
each category per 'panel'. This can also be done using par("mfrow" = c(3, 1)) 
in base graphics, where you would end up with three barplot()s, vertically 
aligned over each other. You would just have to be sure to explicitly define 
the x and y axis axis limits appropriately, so that these are consistent across 
the three plots, to aid in the visual comparison. See ?par for more information.

Both of the above, presume that you are looking at discrete counts on the y 
axis and not a continuous distribution.

The histogram() function in lattice might be another approach, possibly with 
overlapping density plots, creating a histogram per group in each panel.

Overlapping density plots might make also sense. densityplot() in the lattice 
package would be one approach, as well as the sm.density.compare() function in 
the 'sm' CRAN package. An example of the latter is at the bottom of:

  http://www.statmethods.net/graphs/density.html

Examples of the lattice plots are at:

  http://bm2.genes.nig.ac.jp/RGM2/R_current/library/lattice/man/histogram.html

If you change the last densityplot() example to:

  library(lattice)
  densityplot( ~ height, groups = voice.part, data = singer, plot.points = 
FALSE)

you can get something similar to the overlapping density plots in the 'sm' 
package.

Food for thought.

HTH,

Marc Schwartz

__
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] apply min function rowwise

2010-06-05 Thread moleps
I´m trying to tease out the minimum value from a row in a dataframe where all 
the variables are dates. 

apply(canc[,vec],1,function(x)min(x,na.rm=T))


However it only returns empty strings for the entire dataframe except for one 
date value (which is not the minimum date).

I´ve also tried 

apply(canc[,vec],1,function(x)max(x,na.rm=T))

which provides values rowwise, but many of them are not in fact the largest in 
the row.


Any advice?


Regards,

//M

__
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] selecting only specific rows in R

2010-06-05 Thread Adrienne Keller
Hi, I have a data frame with columns as follows: tree species  
(independent variable) and several dependent variables (e.g. carbon,  
nitrogen, phosphorus). Each row represents one tree sample. Some tree  
samples are unique species in the data frame while other species were  
replicated (i.e. rows 1,2,3 may be identical for the "tree species"  
column but have different values for the other dependent variable  
columns). I want to create a new data frame that selects only the tree  
species that have replicates. In other words, I want to select all  
rows that have at least one replicate in the column "tree species".


Ideas on how to write such a function?

Thanks,

Adrienne Keller

__
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] R2HTML problem

2010-06-05 Thread RGtk2User

Im developing an application with R and Gtk+. It's just a simple GUI which
helps new users to interactuate with R. Thing is, when you do a statistical
analysis, I also want to provide a HTML report, but HTMLStart doesnt work
propperly when executing from TinnR. It does create the file but not empty,
I've tried some examples from different websites, and it's always the same..
it works if I execute it from the R prompt, but doesnt when it comes to
execute it from TinnR. So, any ideas? Im trying to divide the internal code
of the HTMLStart function to find out where it crashes, but I couldnt find
it yet. Thanks in advance
-- 
View this message in context: 
http://r.789695.n4.nabble.com/R2HTML-problem-tp2244294p2244294.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] fixed intercept

2010-06-05 Thread dwinsemius

?offset
?formula

On Jun 4, 2010, at 4:53 PM, array chip wrote:

Hi, is it possible to specify a constant intercept (based on prior  
knowledge) in linear regression using lm()?


Thanks

John

__
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] Building a package using classes

2010-06-05 Thread Sébastien Durand
Hello,

I am looking for an efficient and complete free tutorial to learn how to 
properly use, create and manage classes and their methods.

I have build few R packages in the past but I was not going very far in class 
definition and so forth. So I wish to drastically improve my coding skills in 
R...

Any quick comments.

Thanks a lot for your time and consideration.

Sébastien.
__
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 'points' function to plot two curves with errbar

2010-06-05 Thread Yogesh Tiwari
Dear R Users,
I am using R on windows.

how to use 'points' function to plot two curves with errbar

I am doing like:

x.val <- as.integer(names(co2mean))
errbar(x.val, co2mean, co2mean + co2sd, co2mean - co2sd, xaxt='n', col=1,
xlab=NA,ylab=NA)# obs error bar
lines(x.val, co2mean, col=1, lwd=2)

errbar(x.val, co2tm3.month.mean, co2tm3.month.mean + co2sd.tm3,
co2tm3.month.mean - co2sd.tm3, xaxt='n', col=2, xlab=NA,ylab=NA)# model
error bar
lines(x.val, co2tm3.month.mean, col=2, lwd=2)

Above code replaces first error bar and its line with second. Kindly help,
how to use 'points' function here so both above can get over ploted

Thanks,
Regards,
Yogesh

Best Regards,
Yogesh

[[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] Factor to variable

2010-06-05 Thread bjlwilkinson
I have a data frame called z that includes four columns:

Col1 Col2 Col3 Col4
Text1 Text2 X0.1 5
Text1 Text2 X0.2 10
Text1 Text2 X0.3 15
Text1 Text3 X0.1 5
Text1 Text3 X0.2 10
Text1 Text3 X0.3 15

I am trying to convert the 3rd column to the numeric value excluding the X so 
that I can produce a lattice plot. 

I have tried a number of approaches including z$Col3[z$Col3=="X0.1"]="0.1" as a 
first step but get an error: invalid factor level NAs generated. 


Sent from my BlackBerry® wireless device
__
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] (no subject)

2010-06-05 Thread cahyo kristiono
Dear Sirs
 
First herewith I'll introduce myself. My name is Kristiono, I want ask you to 
help me how to get  ZINB (Zero Inflated Negative Binomial) regression 
modeling step by step.
Anyway, I get some trouble to get step by step about 
1.    How to get the log likelihood function of ZINB (step by step)
2.    How to get first derivative, second derifative to get MLE by Newton 
Raphson (step by step)
3.    Syntax program 
 
I want ask you to help me please to solve my trouble above, because I'm very 
realy need it soon.
 I will thank you a lot for your help.
 Sincerely.
Kristiono


[[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] lattice::panel.levelplot.raster too picky with unequal spacing

2010-06-05 Thread baptiste auguie
Hi again,

Another thought on this new function. Would it be possible to adapt
the colour scale in the legend to use grid.raster as well, so that
when the panel performs a smooth interpolation the legend also does
the same? It's particularly clear when saving as a pdf, where viewer
artifacts create spurious and visually unpleasant white bands between
the different colour levels.

I wrote a function for another package that may be useful here,

colorStrip <-
  function (fill = 1:3, colour = fill, draw = TRUE, raster = FALSE,
direction = c("vertical", "horizontal"))
{

  fill.numeric <- is.numeric(fill)
  fill[fill.numeric] <- rgb(t(col2rgb(fill[fill.numeric])), maxColorValue=255)

  direction <- match.arg(direction)

  my.grob <- if (raster) {

fillm <- switch(direction,
"horizontal" = matrix(fill, nrow = 1),
"vertical" =  matrix(fill, ncol = 1))

rasterGrob(fillm, x = unit(0.5, "npc"),
   y = unit(0.5, "npc"), width = unit(1, "npc"),
   height = unit(1, "npc"), just = "centre",
   hjust = NULL, vjust = NULL,
   interpolate = TRUE, default.units = "npc", name = NULL,
   gp = gpar(), vp = NULL)
} else {
positions <- cbind(seq(0 + 0.5/length(fill),
   1 - 0.5/length(fill), length = length(fill)),
   rep(0.5, length(fill)),
   1/length(fill), 1)

xy <- switch(direction,
 "horizontal" = positions[, 1:4],
 "vertical" =  positions[, c(2:1, 4:3)])

grid.rect(x = unit(xy[, 1], "npc"), y = unit(xy[, 2], "npc"),
  width = unit(xy[, 3], "npc"),
  height = unit(xy[, 4], "npc"), just = "center",
  hjust = NULL, vjust = NULL, default.units = "npc",
  name = NULL, gp = gpar(fill = fill, col = colour),
  draw = FALSE, vp = NULL)
  }
  if (draw)
grid.draw(my.grob)

  my.grob
}

# testing
cols <- c("#4C00F0", "#0046EC", "#00E2BF", "#00FF00", "#00FF00",
"#92E500", "#FFA100", "#FF3100", "#FF")

pdf("colortest.pdf")
colorStrip(cols, raster=T, direction="vertical")
grid.newpage()
colorStrip(cols, raster=F, direction="vertical")
grid.newpage()
colorStrip(cols, raster=T, direction="horizontal")
grid.newpage()
colorStrip(cols, raster=F, direction="horizontal")
dev.off()


Best,

baptiste

On 18 May 2010 15:30, Deepayan Sarkar  wrote:
> On Tue, May 18, 2010 at 6:32 PM, baptiste auguie
>  wrote:
>> Dear all,
>>
>> I got a couple of warnings using panel.levelplot.raster,
>>
>> In panel.levelplot.raster(..., interpolate = TRUE) :
>>  'y' values are not equispaced; output will be wrong
>>
>> although I was quite sure my data were equally spaced (indeed, I
>> created them with seq()). A closer look at the source code reveals
>> that the function tests for exact uniformity in grid spacing,
>>
>>  if (length(unique(diff(uy))) != 1)
>>            warning("'x' values are not equispaced; output will be wrong")
>
> Maybe a better test would be
>
> isTRUE(all.equal(diff(range(diff(ux))), 0))
>
> I'll try that out for the next release.
>
> -Deepayan
>
>>
>> The following dummy example would suggest that a strict equality is
>> not always suitable,
>>
>> x <- seq(0, 50, length=100)
>> ux <- sort(unique(x[!is.na(x)]))
>> length(unique(diff(ux)))
>> # 8
>> sd(unique(diff(ux)))
>> #  2.462951e-15
>>
>> Suggestions / comments are welcome.
>>
>> Best regards,
>>
>> baptiste
>>
>>
>> sessionInfo()
>> R version 2.11.0 RC (2010-04-16 r51754)
>> i386-apple-darwin9.8.0
>>
>> locale:
>> [1] en_GB.UTF-8/en_GB.UTF-8/C/C/en_GB.UTF-8/en_GB.UTF-8
>>
>> attached base packages:
>> [1] stats     graphics  grDevices utils     datasets  methods   base
>>
>> other attached packages:
>> [1] lattice_0.18-5
>>
>> loaded via a namespace (and not attached):
>> [1] grid_2.11.0  tools_2.11.0
>>
>>
>>
>> --

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


[R] Help on Multiple Structural break unit root test

2010-06-05 Thread ERIC AIDOO
Help.
Please am search for R package that will enable me to
perform Lumsdain and Papell unit root test with multiple structural break or
minimum LM unit root test with multiple structural break

thank you

[[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 on ARFIMA modeling

2010-06-05 Thread ERIC AIDOO
Dear R Users,
Please I have applied the arfima  procedure in the forecast package
to my time series data named "x" as shown below but it does not work
well for me

fit <- arfima(x)

[[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] Factor to variable

2010-06-05 Thread Phil Spector

Try

  z$Col3 = as.numeric(sub('^X','',as.character(z$Col3)))

- Phil Spector
 Statistical Computing Facility
 Department of Statistics
 UC Berkeley
 spec...@stat.berkeley.edu


On Sat, 5 Jun 2010, bjlwilkin...@gmail.com wrote:


I have a data frame called z that includes four columns:

Col1 Col2 Col3 Col4
Text1 Text2 X0.1 5
Text1 Text2 X0.2 10
Text1 Text2 X0.3 15
Text1 Text3 X0.1 5
Text1 Text3 X0.2 10
Text1 Text3 X0.3 15

I am trying to convert the 3rd column to the numeric value excluding the X so 
that I can produce a lattice plot.

I have tried a number of approaches including z$Col3[z$Col3=="X0.1"]="0.1" as a 
first step but get an error: invalid factor level NAs generated.


Sent from my BlackBerry® wireless device
__
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] Your message to R-help awaits moderator approval

2010-06-05 Thread Gabor Grothendieck
On Sat, Jun 5, 2010 at 10:01 AM, Duncan Murdoch
 wrote:
> Gabor Grothendieck wrote:
>>
>> This has happened to me too.  The last time it occurred I was replying
>> to another post and on my second attempt I deleted the replied-to
>> portion and reposted just my portion and it worked.
>>
>> On Fri, Jun 4, 2010 at 4:35 PM, yjmha69  wrote:
>>
>>>
>>> What filter rule is violated?
>>> So frustrated, why can't I post question!
>>>
>
> The problem is that you are posting from gmail.com, and yjmha69 was posting
> from yahoo.com.  The messages will eventually make it through if you are
> patient.
>

There must be more to it than that since they sometimes go through
immediately and sometimes not.   Perhaps addresses could be
white-listed if they had previously posted.

__
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] Write.fwf works from Mac, throws different number of row error in Windows

2010-06-05 Thread Duncan Murdoch
You need to give us something reproducible or we won't likely be able to 
help you.  Put together a small example that illustrates the problem, 
and it will likely be fixed pretty quickly, or your error will be 
pointed out.  (You need to give us a way to construct outframe, we don't 
have it.)


Duncan Murdoch

mazibuko wrote:
Hello, 


I am having a problem with write.fwf in Windows. I wrote a code to ingest a
number of text files with weather data in them, process them, and then
output a text file with two parts: 1) a set of column names, 2) the
processed data table. 


I wrote and tested the program on my Mac, and it worked fine. However, on
the windows machine, where I intend the work to be done, when I run the
following line (last line of the script): 

  

write.fwf(outframe,file=outfile1,sep="",quote=FALSE,rownames=FALSE,colnames=FALSE,


+
width=c(4,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8),append=TRUE,justify='right')

I get the following error: 


Error in data.frame(colname = colnamesMy, nlevels = 0, position = 0, width =
0,  : 
  arguments imply differing number of rows: 0, 1

In addition: Warning message:
In write.fwf(outframe, file = outfile1, sep = "", quote = FALSE,  :
  recycling 'width'

I can't see the reason for this. The data in outframe are all numeric, and
it worked on the Mac, and outframe has 7 rows on Windows and on the Mac, so
I am not sure what is going on here.

Here is my traceback() and sessionInfo() in case it helps: 

  

traceback()

3: stop("arguments imply differing number of rows: ", paste(unique(nrows), 
   collapse = ", "))
2: data.frame(colname = colnamesMy, nlevels = 0, position = 0, width = 0, 
   digits = 0, exp = 0, stringsAsFactors = FALSE)
1: write.fwf(outframe, file = outfile1, sep = "", quote = FALSE, 
   rownames = FALSE, colnames = FALSE, width = c(4, 8, 8, 8, 
   8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8), append = TRUE, 
   justify = "right")
  

sessionInfo()

R version 2.10.1 (2009-12-14) 
i386-pc-mingw32 


locale:
[1] LC_COLLATE=English_United States.1252  LC_CTYPE=English_United
States.1252   
[3] LC_MONETARY=English_United States.1252 LC_NUMERIC=C  
[5] LC_TIME=English_United States.1252


attached base packages:
[1] splines   stats graphics  grDevices utils datasets  methods  
base 


other attached packages:
[1] doBy_4.0.5  survival_2.35-7 gdata_2.7.1 chron_2.3-34   


loaded via a namespace (and not attached):
[1] cluster_1.12.1 grid_2.10.1gtools_2.6.1   Hmisc_3.7-0   
[5] lattice_0.17-26Matrix_0.999375-33
  

Any advice on this will be much appreciated. 

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] Factor to variable

2010-06-05 Thread bjlwilkinson
I have a data frame called z that includes four columns:

Col1 Col2 Col3 Col4
Text1 Text2 X0.1 5
Text1 Text2 X0.2 10
Text1 Text2 X0.3 15
Text1 Text3 X0.1 5
Text1 Text3 X0.2 10
Text1 Text3 X0.3 15

I am trying to convert the 3rd column to the numeric value excluding the X so 
that I can produce a lattice plot. 

I have tried a number of approaches including z$Col3[z$Col3=="X0.1"]="0.1" as a 
first step but get an error: invalid factor level NAs generated. 


Sent from my BlackBerry® wireless device
__
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] plotting a dataset with median 0

2010-06-05 Thread Georg Ehret
Thank you, this is partially hepful Jim,
my data are in 3 categories on the x-axis. Does anyone know of a method of
plotting values identical on the y-axis distributed (adjacent to each other
- piled up) on the x-axis?

Thank you to all, best regards, Georg.
**
Georg Ehret
Johns Hopkins
Baltimore

On Sat, Jun 5, 2010 at 12:00 PM, Jim Lemon  wrote:

> On 06/05/2010 07:35 AM, Georg Ehret wrote:
>
>> Dear R community,
>>   I am working on a dataset that has median 0 (due to many "0"
>> entries)
>> for my principal variable of interest (40 entries in total). I would like
>> to
>> plot a graph of this variable to show it visually, but have a hard time:
>> boxplots are not informative (because median 0). Conventional scatterplots
>> are neither. Is there a good way to do this (e.g. plotting the "0" values
>> with a jitter or something else...)?
>>
>>  Hi Georg,
> Depending upon what you are plotting it against, count.overplot in the
> plotrix package might do some good.
>
> Jim
>
>

[[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] Your message to R-help awaits moderator approval

2010-06-05 Thread Duncan Murdoch

Gabor Grothendieck wrote:

This has happened to me too.  The last time it occurred I was replying
to another post and on my second attempt I deleted the replied-to
portion and reposted just my portion and it worked.

On Fri, Jun 4, 2010 at 4:35 PM, yjmha69  wrote:
  

What filter rule is violated?
So frustrated, why can't I post question!



The problem is that you are posting from gmail.com, and yjmha69 was 
posting from yahoo.com.  The messages will eventually make it through if 
you are patient.


Duncan Murdoch



- Original Message 
From: "r-help-boun...@r-project.org" 
To: yjmh...@yahoo.com
Sent: Fri, June 4, 2010 12:28:37 PM
Subject: Your message to R-help awaits moderator approval

Your mail to 'R-help' with the subject

subsetting a dataframe

Is being held until the list moderator can review it for approval.

The reason it is being held:

The message headers matched a filter rule

Either the message will get posted to the list, or you will receive
notification of the moderator's decision.  If you would like to cancel
this posting, please visit the following URL:


https://stat.ethz.ch/mailman/confirm/r-help/151139c40b029d260fb9bde07e60a96a68dc572d




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


Re: [R] General-purpose GPU computing in statistics (using R)

2010-06-05 Thread Ravi Varadhan
Dear Professor Ripley,

Thank you very much for your lucid and useful reply. I really appreciate your 
perspectives on this.  I have one follow-up question.  Could you please explain 
the meaning of the statement that the algorithms would need to exploit 
multi-core CPUs differently than they would GPGPUs?  What is (are) the main 
differences likely to be?  One thing I could think of would be that the each 
GPGPU has limited memory and hence, in addition to parallelism, the data also 
needs to be broken up into smaller chunks, which is not the case for multicore 
CPUs.  Are there other major differences?

Best regards,.
Ravi.



Ravi Varadhan, Ph.D.
Assistant Professor,
Division of Geriatric Medicine and Gerontology
School of Medicine
Johns Hopkins University

Ph. (410) 502-2619
email: rvarad...@jhmi.edu


- Original Message -
From: Prof Brian Ripley 
Date: Friday, June 4, 2010 6:26 am
Subject: Re: [R] General-purpose GPU computing in statistics (using R)
To: Ravi Varadhan 
Cc: R-help@r-project.org


> On Thu, 3 Jun 2010, Ravi Varadhan wrote:
>  
>  >Hi All,
>  >
>  >I have been reading about general purpose GPU (graphical processing 
> units)
>  >computing for computational statistics.  I know very little about 
> this, but
>  >I read that GPUs currently cannot handle double-precision floating points
>  
>  Not so for a while, and the latest ones are quite fast at it.
>  
>  >and also that they are not necessarily IEEE compliant.  However, I 
> am not
>  >sure what the practical impact of this limitation is likely to be on
>  >computational statistics problems (e.g. optimization, multivariate analysis,
>  >MCMC, etc.).
>  >
>  >What are the main obstacles that are likely to prevent widespread 
> use of
>  >this technology in computational statistics?
>  
>  Developing highly parallel algorithms that can exploit the 
> architectures.  That's not just in statistics, see e.g.
>  
>  
>  
>  (A Tesla C2050 is the latest generation GPU -- shipping within the 
> last month.)
>  
>  >Can algorithms be coded in R to take advantage of the GPU 
> architecture to speed up computations?  I would appreciate hearing 
> from R sages about their views on the usefulness of general purpose 
> GPU (graphical processing units) computing for computational 
> statistics.  I would also like to hear about views on the future of 
> GPGPU - i.e. is it here to stay or is it just a gimmick that will 
> quietly disappear into the oblivion.
>  
>  They need a lot of programming work to use, and the R packages 
> currently attempting to use them (cudaBayesreg and gputools) are very 
> specialized.  It seems likely that they will remain a niche area, In 
> much the same way that enhanced BLAS are -- there are problems for 
> which the latter can make a big difference, but they are far from 
> universally useful.
>  
>  We've been here several times before: when I was on UK national 
> supercomputing committees in the 1980s and 90s there were several 
> similar contenders (SIMD arrays, Inmos Transputers ...) and all faded 
> away.
>  
>  That is not to say that general purpose parallelism is not going to 
> be central, as we each get (several) machines with many CPU cores.  
> But that sort of parallelism is likely to be exploited in different 
> ways from that of GPUs.
>  
>  >
>  >
>  >
>  >Thanks very much.
>  >
>  >
>  >
>  >Best regards,
>  >
>  >Ravi.
>  >
>  >
>  >--
>  >
>  >Ravi Varadhan, Ph.D.
>  >
>  >Assistant Professor,
>  >
>  >Center on Aging and Health,
>  >
>  >Johns Hopkins University School of Medicine
>  >
>  >(410)502-2619
>  >
>  >rvarad...@jhmi.edu
>  >
>  >
>  >tml
>  >
>  >
>  >
>  >
>  >
>  >
>  >[[alternative HTML version deleted]]
>  >
>  >__
>  >R-help@r-project.org mailing list
>  >
>  >PLEASE do read the posting guide 
>  >and provide commented, minimal, self-contained, reproducible code.
>  >
>  
>  -- 
>  Brian D. Ripley,  rip...@stats.ox.ac.uk
>  Professor of Applied Statistics,  
>  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.


Re: [R] variation

2010-06-05 Thread Jannis

Sorry, my remark about the variance and standard deviation was nonsense!
 There are functions for both measures in R!


Jannis

Jannis schrieb:
As far as I know there is no such function (i could be wrong here!). The 
reason for that might be that it is so straightforward to calculate it 
as the ratio of sd() and mean()for similar reasons there is most 
probably no function for the variance (and only one for std.dev)I 
would think that the easiest solution for you is to create the function 
(~3 lines of code) yourself!


Cheers
Jannis

Adel ESSAFI schrieb:

2010/6/5 Adel ESSAFI 

 

2010/6/5 Jannis 

What exactly do you mean by "variation"? As I understand it, this 
term is a
   
broad term for all kinds of different "spread measures" (like 
quantile range
or standard deviation). Do you mean the Coefficient of Variation? If 
you

found out how to
  


Yes, that what I mean. But I looked for ready  function :)



 

Yes, that what I mean. But I looked for ready  function :)


   

compute the mean and the std.dev., it is straightforward to calculate
it.

Adel ESSAFI schrieb:

 

Hi list
I am a new user of R. I ask for some "beginner" question

I am searching if there is any function that computes the variation of
some
discrete values of a vector (mean() and sd() exists, but i have not 
find

variation).

Thanks in advance

Adel


  




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



  

--
PhD candidate in Computer Science
Address
3 avenue lamine, cité ezzahra, Sousse 4000
Tunisia
tel: +216 97 246 706 (+33640302046 jusqu'au 15/6)
fax: +216 71 391 166






  



__
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] variation

2010-06-05 Thread Jannis
As far as I know there is no such function (i could be wrong here!). The 
reason for that might be that it is so straightforward to calculate it 
as the ratio of sd() and mean()for similar reasons there is most 
probably no function for the variance (and only one for std.dev)I 
would think that the easiest solution for you is to create the function 
(~3 lines of code) yourself!


Cheers
Jannis

Adel ESSAFI schrieb:

2010/6/5 Adel ESSAFI 

  

2010/6/5 Jannis 

What exactly do you mean by "variation"? As I understand it, this term is a


broad term for all kinds of different "spread measures" (like quantile range
or standard deviation). Do you mean the Coefficient of Variation? If you
found out how to
  


Yes, that what I mean. But I looked for ready  function :)



  

Yes, that what I mean. But I looked for ready  function :)




compute the mean and the std.dev., it is straightforward to calculate
it.

Adel ESSAFI schrieb:

  

Hi list
I am a new user of R. I ask for some "beginner" question

I am searching if there is any function that computes the variation of
some
discrete values of a vector (mean() and sd() exists, but i have not find
variation).

Thanks in advance

Adel


 


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



  

--
PhD candidate in Computer Science
Address
3 avenue lamine, cité ezzahra, Sousse 4000
Tunisia
tel: +216 97 246 706 (+33640302046 jusqu'au 15/6)
fax: +216 71 391 166






  



__
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] strange behaviour of CairoPNG

2010-06-05 Thread Henrik Bengtsson
FYI, follow the information in the email footer:

> PLEASE do read the posting guide http://www.R-project.org/posting-guide.html

and make sure at a minimum to report your sessionInfo(). That
increases your chances to get a response.

/Henrik

On Sat, Jun 5, 2010 at 11:42 AM, Thomas Steiner  wrote:
> OK, no reply. :-(
> I'm more offensive: this is a bug!
> the font-parameter of the text fucntion does not work properly in the
> Cairo-package
> thomas
>
>
> 2010/6/4 Thomas Steiner :
>> Hi,
>> could it be that the text() fuction gives different output for normal
>> png() and CarioPNG()?
>> See the following example and the attached images: the font=2 and
>> font=3 seem to be exchanged!
>> Thanks for help,
>> Thomas
>>
>> CairoPNG("Test-cairo.png",width=750,height=690)
>> #png("Test-normal.png",width=750,height=690)
>>
>> plot(1,1,type="n",main="normal")
>> text(1,1,"normal",adj=c(1,1))
>> text(1,1,"bold",font=2,adj=c(-1,-1))
>> text(1,1,"italic",font=3,adj=c(1,-1))
>> text(1,1,"italic&bold",font=4,adj=c(-1,1))
>>
>> dev.off()
>>
>
> __
> 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] variation

2010-06-05 Thread Adel ESSAFI
2010/6/5 Adel ESSAFI 

>
>
> 2010/6/5 Jannis 
>
> What exactly do you mean by "variation"? As I understand it, this term is a
>> broad term for all kinds of different "spread measures" (like quantile range
>> or standard deviation). Do you mean the Coefficient of Variation? If you
>> found out how to
>
>
Yes, that what I mean. But I looked for ready  function :)



>
> Yes, that what I mean. But I looked for ready  function :)
>
>
>> compute the mean and the std.dev., it is straightforward to calculate
>> it.
>>
>> Adel ESSAFI schrieb:
>>
>>> Hi list
>>> I am a new user of R. I ask for some "beginner" question
>>>
>>> I am searching if there is any function that computes the variation of
>>> some
>>> discrete values of a vector (mean() and sd() exists, but i have not find
>>> variation).
>>>
>>> Thanks in advance
>>>
>>> Adel
>>>
>>>
>>>  
>>>
>>>
>>> __
>>> 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.
>>>
>>>
>>
>>
>
>
> --
> PhD candidate in Computer Science
> Address
> 3 avenue lamine, cité ezzahra, Sousse 4000
> Tunisia
> tel: +216 97 246 706 (+33640302046 jusqu'au 15/6)
> fax: +216 71 391 166
>



-- 
PhD candidate in Computer Science
Address
3 avenue lamine, cité ezzahra, Sousse 4000
Tunisia
tel: +216 97 246 706 (+33640302046 jusqu'au 15/6)
fax: +216 71 391 166

[[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] variation

2010-06-05 Thread Adel ESSAFI
2010/6/5 Jannis 

> What exactly do you mean by "variation"? As I understand it, this term is a
> broad term for all kinds of different "spread measures" (like quantile range
> or standard deviation). Do you mean the Coefficient of Variation? If you
> found out how to


Yes, that what I mean. But I looked for ready  function :)


> compute the mean and the std.dev., it is straightforward to calculate
> it.
>
> Adel ESSAFI schrieb:
>
>> Hi list
>> I am a new user of R. I ask for some "beginner" question
>>
>> I am searching if there is any function that computes the variation of
>> some
>> discrete values of a vector (mean() and sd() exists, but i have not find
>> variation).
>>
>> Thanks in advance
>>
>> Adel
>>
>>
>>  
>>
>>
>> __
>> 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.
>>
>>
>
>


-- 
PhD candidate in Computer Science
Address
3 avenue lamine, cité ezzahra, Sousse 4000
Tunisia
tel: +216 97 246 706 (+33640302046 jusqu'au 15/6)
fax: +216 71 391 166

[[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] tapply help

2010-06-05 Thread jim holtman
It this what you are looking for:

> set.seed(1)
> # create range for each possible class
> # 'name' the values so you can use them in the 'sapply' function
> lows<-c(a=1, b=2, c=3, d=4, e=5)
> highs<-c(a=5, b=6, c=7, d=8, e=9)
>
> # data values
> vals<-sample(1:10,100,replace=T)
>
> #classes
> classes<-sample(letters[1:5],100,replace=T)
>
> # split the data so that you retain the 'classes' name
> x.split <- split(vals, classes)
> percentage <- sapply(names(x.split), function(.class){
+ # compute the percentage based on 'class'
+ sum((x.split[[.class]] >= lows[.class]) &
+ (x.split[[.class]] <= highs[.class])) /
length(x.split[[.class]]) * 100
+ })
> percentage
   abcde
50.0 45.0 62.5 54.54545 55.6
>


On Fri, Jun 4, 2010 at 4:02 PM, Mark Ebbert  wrote:
> Dear R gurus,
>
> I am trying perform what I believe will be a pretty simple task, but I'm 
> struggling to figure out how to do it. I have two vectors of the same length, 
> the first is numeric and the second is factor. I understand that tapply is 
> perfect for applying a function to the numeric vector by subsets of the 
> factors in the second vector. My issue is trying to make use of two other 
> vectors within the custom function I've written for tapply. The two other 
> vectors are a high and low value for each subset I am breaking my data into, 
> and I want to calculate the percentage of data points that fall into each 
> respective range. I will attempt to provide a coherent example:
>
> # create range for each possible class
> lows<-c(1,2,3,4,5)
> highs<-c(5,6,7,8,9)
>
> # data values
> vals<-sample(1:10,100,replace=T)
>
> #classes
> classes<-sample(letters[1:5],100,replace=T)
>
> # Try to calculate percentage of values that fall
> # into the respective range for the given class.
> percentages<-tapply(vals,classes,
>        function(i){
>                length(i[i>=lows[index] & i<=highs[index]])/length(i)  # I 
> don't know how to actually keep an index count in tapply, but I'm guessing 
> there's a better way.
>        })
>
> I really appreciate any help.
>
> ME
> __
> 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] text with greek letters

2010-06-05 Thread Jannis

try

help(plotmath)

help(expression)

Thomas Bschorr schrieb:

Hi,

I am having troubles in putting greek letters and formatted text in a plot


m=1.43432
sig=0.124333
text(10.5,0.07,sprintf("=%1.2f±%1.2f",m,sig))
I would like to have the greek letter Sigma followed by the formatted numeric 
values of m and sig.
Does someone know a solution?

thanks a lot
Thomas

-
Thomas Bschorr

Department of Physics
Institute of Astronomy
ETH Zurich
Wolfgang-Pauli-Strasse 27, HIT J 11.3
CH-8093 Zürich
Switzerland

E-mail: bsch...@phys.ethz.ch
Phone: +41 (0)44 633-6684
Fax: +41 (0)44 633-1238
Web: http://www.exp-astro.phys.ethz.ch 


[[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] variation

2010-06-05 Thread Jannis
What exactly do you mean by "variation"? As I understand it, this term 
is a broad term for all kinds of different "spread measures" (like 
quantile range or standard deviation). Do you mean the Coefficient of 
Variation? If you found out how to compute the mean and the std.dev., it 
is straightforward to calculate it.


Adel ESSAFI schrieb:

Hi list
I am a new user of R. I ask for some "beginner" question

I am searching if there is any function that computes the variation of some
discrete values of a vector (mean() and sd() exists, but i have not find
variation).

Thanks in advance

Adel


  



__
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] Fwd: How to make R automatic?

2010-06-05 Thread Adel ESSAFI
-- Forwarded message --
From: Adel ESSAFI 
Date: 2010/6/5
Subject: Re: [R] How to make R automatic?
To: zhangted001 


Well, I am new but i will give you an example of script that I run


cat exec2.sh
R --no-save   << EOF
fl=list.files(pattern="*.dat")

for( j in 1:length(fl)){
   a=read.table(fl[j])
   debut=a[,1]
   fin=a[,2]
   duree=a[,3]
   u=matrix(ncol=1,nrow=length(fin)-1)
   for( i in 1:length(fin)-1) u[i]=debut[i+1]-fin[i]
   if (! (is.na(mean(duree)) || is.na(sd(duree)) || is.na(mean(u)) ||
is.na(sd(u)
) ) )  {
   cat (fl[j]," ",mean(duree)," ",sd(duree)," ",mean(u)," ",sd(u),"
",trunc((mean(duree)/(mean(duree)+mean(u)))*100)," ",length(debut),
"\n",file="testlogsnavai",append=TRUE)
  }
}

This works perfect




2010/6/5 zhangted001 


> Thank you all for the information!  That is exactly what I was looking for.
>
> --
> View this message in context:
> http://r.789695.n4.nabble.com/How-to-make-R-automatic-tp2238541p2244132.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.
>



-- 
PhD candidate in Computer Science
Address
3 avenue lamine, cité ezzahra, Sousse 4000
Tunisia
tel: +216 97 246 706 (+33640302046 jusqu'au 15/6)
fax: +216 71 391 166



-- 
PhD candidate in Computer Science
Address
3 avenue lamine, cité ezzahra, Sousse 4000
Tunisia
tel: +216 97 246 706 (+33640302046 jusqu'au 15/6)
fax: +216 71 391 166

[[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] Wrong symbol rendering in plots (Ubuntu)

2010-06-05 Thread Yvonnick NOEL
Hello,

I have the very same problem. Plotting code that used to work before I
upgraded to Ubuntu Lucid Lynx does not work anymore. For example:

plot(1:10)
text(6,4,expression(pi))

The 'pi' greek letter appear as a \neq ("different from" symbol).

Yvonnick Noel

__
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] exporting the whole output

2010-06-05 Thread Jim Lemon

On 06/05/2010 07:31 PM, suman dhara wrote:

Sir,
I want to export the whole result generated by lda function.I have used the
following R-code.But, it is not working.Can you help me?


a<-lda(y~.,data=data)
write.table(a,file="G:/a.csv",sep=",")


Hi Suman,
Try this:

library(prettyR)
delim.table(a,"G:/a.csv")

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.


Re: [R] strange behaviour of CairoPNG

2010-06-05 Thread Thomas Steiner
OK, no reply. :-(
I'm more offensive: this is a bug!
the font-parameter of the text fucntion does not work properly in the
Cairo-package
thomas


2010/6/4 Thomas Steiner :
> Hi,
> could it be that the text() fuction gives different output for normal
> png() and CarioPNG()?
> See the following example and the attached images: the font=2 and
> font=3 seem to be exchanged!
> Thanks for help,
> Thomas
>
> CairoPNG("Test-cairo.png",width=750,height=690)
> #png("Test-normal.png",width=750,height=690)
>
> plot(1,1,type="n",main="normal")
> text(1,1,"normal",adj=c(1,1))
> text(1,1,"bold",font=2,adj=c(-1,-1))
> text(1,1,"italic",font=3,adj=c(1,-1))
> text(1,1,"italic&bold",font=4,adj=c(-1,1))
>
> dev.off()
>

__
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 make R automatic?

2010-06-05 Thread zhangted001

Thank you all for the information!  That is exactly what I was looking for.
 
-- 
View this message in context: 
http://r.789695.n4.nabble.com/How-to-make-R-automatic-tp2238541p2244132.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] exporting the whole output

2010-06-05 Thread suman dhara
Sir,
I want to export the whole result generated by lda function.I have used the
following R-code.But, it is not working.Can you help me?


a<-lda(y~.,data=data)
write.table(a,file="G:/a.csv",sep=",")


Regards,
Suman Dhara

[[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] Greek letters and formatted text

2010-06-05 Thread baptiste auguie
Try

text(0.8,1,bquote("<"*sigma*">"==.(round(m,2))*"±"*.(round(sig,2

?bquote
?plotmath

On 5 June 2010 11:36, Thomas Bschorr  wrote:
> Hi,
>
> I desperately try to do s.th. like
>
> m=1.23455
> sig=0.84321
>
> plot(1,1)
>
> text(0.8,1,sprintf("=%1.2f±%1.2f",m,sig))
>
> where actually the greek letter should appear for Sigma.
> I have tried all sorts of combinations with expression and paste etc. but 
> could not work it out. Maybe someone has an idea and can help me.
>
> Thanks a lot+
>
> Thomas
>
> __
> 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] variation

2010-06-05 Thread Adel ESSAFI
Hi list
I am a new user of R. I ask for some "beginner" question

I am searching if there is any function that computes the variation of some
discrete values of a vector (mean() and sd() exists, but i have not find
variation).

Thanks in advance

Adel


-- 
PhD candidate in Computer Science
Address
3 avenue lamine, cité ezzahra, Sousse 4000
Tunisia
tel: +216 97 246 706 (+33640302046 jusqu'au 15/6)
fax: +216 71 391 166

[[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] plotting a dataset with median 0

2010-06-05 Thread Jim Lemon

On 06/05/2010 07:35 AM, Georg Ehret wrote:

Dear R community,
   I am working on a dataset that has median 0 (due to many "0" entries)
for my principal variable of interest (40 entries in total). I would like to
plot a graph of this variable to show it visually, but have a hard time:
boxplots are not informative (because median 0). Conventional scatterplots
are neither. Is there a good way to do this (e.g. plotting the "0" values
with a jitter or something else...)?


Hi Georg,
Depending upon what you are plotting it against, count.overplot in the 
plotrix package might do some good.


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.


[R] Greek letters and formatted text

2010-06-05 Thread Thomas Bschorr
Hi,

I desperately try to do s.th. like

m=1.23455
sig=0.84321

plot(1,1)

text(0.8,1,sprintf("=%1.2f±%1.2f",m,sig))

where actually the greek letter should appear for Sigma.
I have tried all sorts of combinations with expression and paste etc. but could 
not work it out. Maybe someone has an idea and can help me.

Thanks a lot+

Thomas

__
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] rgl installation failure

2010-06-05 Thread khush ........
Hi,

Thanks Berwin for your suggestions , sorry to mention but it was fedora 12
OS that I am using. Actually I was missing libraries png which I installed
using yum and it work good now.

Earlier png.h was missing in /usr/includes/ but its is showing .

Thanks alot for your kind help.

Cheers

Thank you

Jeet

On Sat, Jun 5, 2010 at 1:07 PM, Berwin A Turlach wrote:

> G'day,
>
> On Sat, 5 Jun 2010 12:51:08 +0530
> "khush "  wrote:
>
> > I am trying to install rgl package under R and getting some errors
> > which is below.
> >
> > > install.packages("rgl")
> > Warning in install.packages("rgl") :
> >   argument 'lib' is missing: using '/usr/lib/R/library'
> > trying URL 'http://cran.csie.ntu.edu.tw/src/contrib/rgl_0.91.tar.gz'
> > Content type 'application/x-gzip' length 1677498 bytes (1.6 Mb)
> > opened URL
> > ==
> > downloaded 1.6 Mb
> >
> > * installing *source* package _rgl_ ...
> > checking for gcc... gcc -m32 -std=gnu99
> > checking for C compiler default output file name... a.out
> > checking whether the C compiler works... yes
> > checking whether we are cross compiling... no
> > checking for suffix of executables...
> > checking for suffix of object files... o
> > checking whether we are using the GNU C compiler... yes
> > checking whether gcc -m32 -std=gnu99 accepts -g... yes
> > checking for gcc -m32 -std=gnu99 option to accept ISO C89... none
> > needed checking how to run the C preprocessor... gcc -m32 -std=gnu99
> > -E checking for gcc... (cached) gcc -m32 -std=gnu99
> > checking whether we are using the GNU C compiler... (cached) yes
> > checking whether gcc -m32 -std=gnu99 accepts -g... (cached) yes
> > checking for gcc -m32 -std=gnu99 option to accept ISO C89... (cached)
> > none needed
> > checking for libpng-config... no
> > checking libpng... checking for grep that handles long lines and -e...
> > /bin/grep
> > checking for egrep... /bin/grep -E
> > checking for ANSI C header files... yes
> > checking for sys/types.h... yes
> > checking for sys/stat.h... yes
> > checking for stdlib.h... yes
> > checking for string.h... yes
> > checking for memory.h... yes
> > checking for strings.h... yes
> > checking for inttypes.h... yes
> > checking for stdint.h... yes
> > checking for unistd.h... yes
> > checking png.h usability... no
> > checking png.h presence... no
> > checking for png.h... no
> > checking for png_read_update_info in -lpng... no
>
> You should heed indications as the above, i.e. that items checked for
> are not found.
>
> [...]
>
> > In file included from pixmap.cpp:14:
> > pngpixmap.h:3:17: error: png.h: No such file or directory
>
> And this compiler error seems to be directly linked to the issues
> identified by configure; and all further error come from the fact that
> png.h cannot be found.
>
> You seem to be using some flavour of Unix, presumably GNU/Linux; but
> from your posting it is impossible to say which one.  On a Debian based
> system (e.g. Kubuntu 9.10 which I am using), I would issue the command
> (assuming that apt-file is installed and initialised):
>
> ber...@bossiaea:~$ apt-file find include/png.h
> libpng12-dev: /usr/include/png.h
>
> and then check whether the libpng12-dev package is installed.  If not,
> I would install it and retry.  Perhaps that would be all that is needed
> to compile rgl, but there might be other packages missing.
>
> If you have a system based on RedHat and Suse, you will have to figure
> out how to use the package management tools on those systems to find
> out which packages have to be installed additionally so that you are
> able to compile rgl.
>
> HTH.
>
> Cheers,
>
>Berwin
>
> == Full address 
> Berwin A Turlach  Tel.: +61 (8) 6488 3338 (secr)
> School of Maths and Stats (M019)+61 (8) 6488 3383 (self)
> The University of Western Australia   FAX : +61 (8) 6488 1028
> 35 Stirling Highway
> Crawley WA 6009e-mail: ber...@maths.uwa.edu.au
> Australia
> http://www.maths.uwa.edu.au/~berwin
>

[[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] rgl installation failure

2010-06-05 Thread Berwin A Turlach
G'day,

On Sat, 5 Jun 2010 12:51:08 +0530
"khush "  wrote:

> I am trying to install rgl package under R and getting some errors
> which is below.
> 
> > install.packages("rgl")
> Warning in install.packages("rgl") :
>   argument 'lib' is missing: using '/usr/lib/R/library'
> trying URL 'http://cran.csie.ntu.edu.tw/src/contrib/rgl_0.91.tar.gz'
> Content type 'application/x-gzip' length 1677498 bytes (1.6 Mb)
> opened URL
> ==
> downloaded 1.6 Mb
> 
> * installing *source* package _rgl_ ...
> checking for gcc... gcc -m32 -std=gnu99
> checking for C compiler default output file name... a.out
> checking whether the C compiler works... yes
> checking whether we are cross compiling... no
> checking for suffix of executables...
> checking for suffix of object files... o
> checking whether we are using the GNU C compiler... yes
> checking whether gcc -m32 -std=gnu99 accepts -g... yes
> checking for gcc -m32 -std=gnu99 option to accept ISO C89... none
> needed checking how to run the C preprocessor... gcc -m32 -std=gnu99
> -E checking for gcc... (cached) gcc -m32 -std=gnu99
> checking whether we are using the GNU C compiler... (cached) yes
> checking whether gcc -m32 -std=gnu99 accepts -g... (cached) yes
> checking for gcc -m32 -std=gnu99 option to accept ISO C89... (cached)
> none needed
> checking for libpng-config... no
> checking libpng... checking for grep that handles long lines and -e...
> /bin/grep
> checking for egrep... /bin/grep -E
> checking for ANSI C header files... yes
> checking for sys/types.h... yes
> checking for sys/stat.h... yes
> checking for stdlib.h... yes
> checking for string.h... yes
> checking for memory.h... yes
> checking for strings.h... yes
> checking for inttypes.h... yes
> checking for stdint.h... yes
> checking for unistd.h... yes
> checking png.h usability... no
> checking png.h presence... no
> checking for png.h... no
> checking for png_read_update_info in -lpng... no

You should heed indications as the above, i.e. that items checked for
are not found.

[...]

> In file included from pixmap.cpp:14:
> pngpixmap.h:3:17: error: png.h: No such file or directory

And this compiler error seems to be directly linked to the issues
identified by configure; and all further error come from the fact that
png.h cannot be found.

You seem to be using some flavour of Unix, presumably GNU/Linux; but
from your posting it is impossible to say which one.  On a Debian based
system (e.g. Kubuntu 9.10 which I am using), I would issue the command
(assuming that apt-file is installed and initialised):

ber...@bossiaea:~$ apt-file find include/png.h
libpng12-dev: /usr/include/png.h

and then check whether the libpng12-dev package is installed.  If not,
I would install it and retry.  Perhaps that would be all that is needed
to compile rgl, but there might be other packages missing.

If you have a system based on RedHat and Suse, you will have to figure
out how to use the package management tools on those systems to find
out which packages have to be installed additionally so that you are
able to compile rgl.

HTH.

Cheers,

Berwin

== Full address 
Berwin A Turlach  Tel.: +61 (8) 6488 3338 (secr)
School of Maths and Stats (M019)+61 (8) 6488 3383 (self)
The University of Western Australia   FAX : +61 (8) 6488 1028
35 Stirling Highway   
Crawley WA 6009e-mail: ber...@maths.uwa.edu.au
Australiahttp://www.maths.uwa.edu.au/~berwin

__
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] rgl installation failure

2010-06-05 Thread khush ........
Hello,

I am trying to install rgl package under R and getting some errors which is
below.

> install.packages("rgl")
Warning in install.packages("rgl") :
  argument 'lib' is missing: using '/usr/lib/R/library'
trying URL 'http://cran.csie.ntu.edu.tw/src/contrib/rgl_0.91.tar.gz'
Content type 'application/x-gzip' length 1677498 bytes (1.6 Mb)
opened URL
==
downloaded 1.6 Mb

* installing *source* package ‘rgl’ ...
checking for gcc... gcc -m32 -std=gnu99
checking for C compiler default output file name... a.out
checking whether the C compiler works... yes
checking whether we are cross compiling... no
checking for suffix of executables...
checking for suffix of object files... o
checking whether we are using the GNU C compiler... yes
checking whether gcc -m32 -std=gnu99 accepts -g... yes
checking for gcc -m32 -std=gnu99 option to accept ISO C89... none needed
checking how to run the C preprocessor... gcc -m32 -std=gnu99 -E
checking for gcc... (cached) gcc -m32 -std=gnu99
checking whether we are using the GNU C compiler... (cached) yes
checking whether gcc -m32 -std=gnu99 accepts -g... (cached) yes
checking for gcc -m32 -std=gnu99 option to accept ISO C89... (cached) none
needed
checking for libpng-config... no
checking libpng... checking for grep that handles long lines and -e...
/bin/grep
checking for egrep... /bin/grep -E
checking for ANSI C header files... yes
checking for sys/types.h... yes
checking for sys/stat.h... yes
checking for stdlib.h... yes
checking for string.h... yes
checking for memory.h... yes
checking for strings.h... yes
checking for inttypes.h... yes
checking for stdint.h... yes
checking for unistd.h... yes
checking png.h usability... no
checking png.h presence... no
checking for png.h... no
checking for png_read_update_info in -lpng... no
configure: libpng header and lib found
configure: using libpng dynamic linkage
checking for X... libraries , headers
checking GL/gl.h usability... yes
checking GL/gl.h presence... yes
checking for GL/gl.h... yes
checking GL/glu.h usability... yes
checking GL/glu.h presence... yes
checking for GL/glu.h... yes
checking for glEnd in -lGL... yes
checking for gluProject in -lGLU... yes
checking for freetype-config... yes
configure: using Freetype and FTGL
configure: creating ./config.status
config.status: creating src/Makevars
** libs
g++ -m32 -I/usr/include/R -DHAVE_PNG_H -DHAVE_FREETYPE -Iext/ftgl
-I/usr/include/freetype2 -Iext -I/usr/local/include   -O2 -g -pipe -Wall
-Wp,-D_FORTIFY_SOURCE=2 -fexceptions -fstack-protector
--param=ssp-buffer-size=4 -m32 -march=i686 -mtune=atom
-fasynchronous-unwind-tables -fpic  -O2 -g -pipe -Wall
-Wp,-D_FORTIFY_SOURCE=2 -fexceptions -fstack-protector
--param=ssp-buffer-size=4 -m32 -march=i686 -mtune=atom
-fasynchronous-unwind-tables -c BBoxDeco.cpp -o BBoxDeco.o
g++ -m32 -I/usr/include/R -DHAVE_PNG_H -DHAVE_FREETYPE -Iext/ftgl
-I/usr/include/freetype2 -Iext -I/usr/local/include   -O2 -g -pipe -Wall
-Wp,-D_FORTIFY_SOURCE=2 -fexceptions -fstack-protector
--param=ssp-buffer-size=4 -m32 -march=i686 -mtune=atom
-fasynchronous-unwind-tables -fpic  -O2 -g -pipe -Wall
-Wp,-D_FORTIFY_SOURCE=2 -fexceptions -fstack-protector
--param=ssp-buffer-size=4 -m32 -march=i686 -mtune=atom
-fasynchronous-unwind-tables -c Background.cpp -o Background.o
g++ -m32 -I/usr/include/R -DHAVE_PNG_H -DHAVE_FREETYPE -Iext/ftgl
-I/usr/include/freetype2 -Iext -I/usr/local/include   -O2 -g -pipe -Wall
-Wp,-D_FORTIFY_SOURCE=2 -fexceptions -fstack-protector
--param=ssp-buffer-size=4 -m32 -march=i686 -mtune=atom
-fasynchronous-unwind-tables -fpic  -O2 -g -pipe -Wall
-Wp,-D_FORTIFY_SOURCE=2 -fexceptions -fstack-protector
--param=ssp-buffer-size=4 -m32 -march=i686 -mtune=atom
-fasynchronous-unwind-tables -c Color.cpp -o Color.o
g++ -m32 -I/usr/include/R -DHAVE_PNG_H -DHAVE_FREETYPE -Iext/ftgl
-I/usr/include/freetype2 -Iext -I/usr/local/include   -O2 -g -pipe -Wall
-Wp,-D_FORTIFY_SOURCE=2 -fexceptions -fstack-protector
--param=ssp-buffer-size=4 -m32 -march=i686 -mtune=atom
-fasynchronous-unwind-tables -fpic  -O2 -g -pipe -Wall
-Wp,-D_FORTIFY_SOURCE=2 -fexceptions -fstack-protector
--param=ssp-buffer-size=4 -m32 -march=i686 -mtune=atom
-fasynchronous-unwind-tables -c Disposable.cpp -o Disposable.o
g++ -m32 -I/usr/include/R -DHAVE_PNG_H -DHAVE_FREETYPE -Iext/ftgl
-I/usr/include/freetype2 -Iext -I/usr/local/include   -O2 -g -pipe -Wall
-Wp,-D_FORTIFY_SOURCE=2 -fexceptions -fstack-protector
--param=ssp-buffer-size=4 -m32 -march=i686 -mtune=atom
-fasynchronous-unwind-tables -fpic  -O2 -g -pipe -Wall
-Wp,-D_FORTIFY_SOURCE=2 -fexceptions -fstack-protector
--param=ssp-buffer-size=4 -m32 -march=i686 -mtune=atom
-fasynchronous-unwind-tables -c Light.cpp -o Light.o
g++ -m32 -I/usr/include/R -DHAVE_PNG_H -DHAVE_FREETYPE -Iext/ftgl
-I/usr/include/freetype2 -Iext -I/usr/local/include   -O2 -g -pipe -Wall
-Wp,-D_FORTIFY_SOURCE=2 -fexceptions -fstack-protector
--param=ssp-buffer-size=4 -m32 -march=i686 -mtune=atom
-fasynchronous-unw