[R] Error in R-SVM help:

2011-02-20 Thread Angel Russo
Greetings:

I am trying to use your R code for R-SVM as follows. Why it dosen't print
the LOO.error and the list of features?

http://www.stanford.edu/group/wonglab/RSVMpage/R-SVM.html

My training data as follows contains 142 cases and 264 features. instead I
get en error as below "invalid 'digits' argument". Is a working example
available anywhere using R-code of R-SVM?

Thanks very much.

> source("R-SVM.R")
> data<-ReadSVMdata("train.txt")
> len<-length(data$y)
> print(data$y)
  [1] -1 -1  1 -1 -1  1  1  1 -1 -1 -1 -1 -1 -1  1  1  1 -1 -1  1 -1  1  1
1  1
 [26]  1  1  1  1 -1  1 -1  1  1 -1 -1  1 -1 -1  1 -1 -1 -1  1  1  1  1 -1
-1 -1
 [51] -1 -1 -1 -1 -1 -1  1 -1 -1 -1 -1 -1  1 -1 -1 -1 -1  1 -1 -1 -1 -1  1
-1  1
 [76] -1 -1  1 -1  1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1  1 -1 -1 -1 -1 -1 -1  1
1 -1
[101] -1  1 -1 -1 -1 -1 -1  1 -1  1  1 -1 -1 -1 -1  1  1 -1 -1  1 -1 -1 -1
-1 -1
[126]  1 -1  1 -1  1  1 -1 -1 -1  1  1  1 -1 -1 -1 -1  1
> print(dim(data$x))
[1] 142 264
> x<-data$x
> y<-data$y
> ladder<-CreatLadder(len)
> RSVMsum <- RSVM(x,y,ladder,"LOO")
> SummaryRSVM(RSVMsum)
*Error in print.default("MinCV error of", min(RSVMres$Error), "at",
MinLevel,  :
  invalid 'digits' argument
Calls: SummaryRSVM -> print -> print.default
Execution halted*



I only modified the ReadSVMdata function

ReadSVMdata <- function(filename)
{
dd <- read.table( filename, header=TRUE,sep="\t")
x <- as.matrix( dd[, 14:(ncol(dd))] )
class <- as.numeric(dd[,2])
class[class==2] <- -1

y <- class
ret <- list(x=x, y=y)
}

and un-commented this line "print("MinCV error of", min(RSVMres$Error),
"at", MinLevel, "genes" )" in function Summary(RSVM).

[[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 change dataframe to tables

2011-02-20 Thread Lao Meng
Well,it's my daily work on duty,not homework:)



2011/2/18 Dennis Murphy 

> This is a built-in dataset in R - see ?HairEyeColor and str() it.  I smell
> homework...
>
> Dennis
>
>   On Thu, Feb 17, 2011 at 11:50 PM, Lao Meng  wrote:
>
>>  The data is in the attachment.
>>
>> What I wanna get is:
>> , , Sex = Male
>>   Eye
>> HairBrown Blue Hazel Green
>>  Black32   1110 3
>>  Brown53   502515
>>  Red  10   10 7 7
>>  Blond 3   30 5 8
>> , , Sex = Female
>>   Eye
>> HairBrown Blue Hazel Green
>>  Black369 5 2
>>  Brown66   342914
>>  Red  167 7 7
>>  Blond 4   64 5 8
>>
>>
>> Then,how to change the dataframe to tables?
>>
>> Many thanks for your help.
>>
>> Best
>>
>> __
>> R-help@r-project.org mailing list
>> https://stat.ethz.ch/mailman/listinfo/r-help
>> PLEASE do read the posting guide
>> http://www.R-project.org/posting-guide.html
>> and provide commented, minimal, self-contained, reproducible code.
>>
>>
>

[[alternative HTML version deleted]]

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


Re: [R] How to change dataframe to tables

2011-02-20 Thread Lao Meng
Thanks!
It works well.

2011/2/18 Henrique Dallazuanna 

> Try this:
>
>  xtabs(Freq ~ Hair + Eye + Sex, Dat)
>
> Using Dimitri's Dat example.
>
>   On Fri, Feb 18, 2011 at 5:50 AM, Lao Meng  wrote:
>
>>  The data is in the attachment.
>>
>> What I wanna get is:
>> , , Sex = Male
>>   Eye
>> HairBrown Blue Hazel Green
>>  Black32   1110 3
>>  Brown53   502515
>>  Red  10   10 7 7
>>  Blond 3   30 5 8
>> , , Sex = Female
>>   Eye
>> HairBrown Blue Hazel Green
>>  Black369 5 2
>>  Brown66   342914
>>  Red  167 7 7
>>  Blond 4   64 5 8
>>
>>
>> Then,how to change the dataframe to tables?
>>
>> Many thanks for your help.
>>
>> Best
>>
>> __
>> R-help@r-project.org mailing list
>> https://stat.ethz.ch/mailman/listinfo/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.


Re: [R] How to change dataframe to tables

2011-02-20 Thread Lao Meng
Thanks!
It works well.



2011/2/18 Dimitris Rizopoulos 

> say, 'Dat' is your data frame, then one way to do it is:
>
> with(Dat, tapply(freq, list(hair, eye, sex), c))
>
>
> I hope it helps.
>
> Best,
> Dimitris
>
>
>
>
> On 2/18/2011 8:50 AM, Lao Meng wrote:
>
>>  The data is in the attachment.
>>
>> What I wanna get is:
>> , , Sex = Male
>>Eye
>> HairBrown Blue Hazel Green
>>   Black32   1110 3
>>   Brown53   502515
>>   Red  10   10 7 7
>>   Blond 3   30 5 8
>> , , Sex = Female
>>Eye
>> HairBrown Blue Hazel Green
>>   Black369 5 2
>>   Brown66   342914
>>   Red  167 7 7
>>   Blond 4   64 5 8
>>
>>
>> Then,how to change the dataframe to tables?
>>
>> Many thanks for your help.
>>
>> Best
>>
>>
>>
>> __
>> R-help@r-project.org mailing list
>> https://stat.ethz.ch/mailman/listinfo/r-help
>> PLEASE do read the posting guide
>> http://www.R-project.org/posting-guide.html
>> and provide commented, minimal, self-contained, reproducible code.
>>
>
> --
> Dimitris Rizopoulos
> Assistant Professor
> Department of Biostatistics
> Erasmus University Medical Center
>
> Address: PO Box 2040, 3000 CA Rotterdam, the Netherlands
> Tel: +31/(0)10/7043478
> Fax: +31/(0)10/7043014
> Web: http://www.erasmusmc.nl/biostatistiek/
>

[[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 individual trajectories from individual growth model

2011-02-20 Thread Dennis Murphy
Hi:

These are sometimes called 'spaghetti plots'; here is a variation on an
example in the ggplot2 book by Hadley Wickham using the Oxboys data from
package nlme:

library(ggplot2)
data('Oxboys', package = 'nlme')
g <- ggplot(Oxboys, aes(x = age, y = height))
g + geom_line(aes(group = Subject)) +
  geom_smooth(aes(group = 1), colour = 'red', size = 1)

If you're not familiar with the package...
  * The first line that defines the object g sets up the 'base plot'; its
core 'aesthetics',
 or graphics elements, if you will, are the x-variable age and
y-variable height. These
 are expected to be present in every subsequent 'geom' call (think of a
geom as a type
 of plot, although it actually refers to its geometry)
 * + denotes addition of 'layers' to the plot; we add the individual
trajectories with geom_line(),
  where group = Subject indicates that separate lines be drawn for each
subject
 * the average line (with default confidence envelope) is drawn using a
smoother (geom_smooth);
   group = 1 indicates that we want the smooth over all subjects. Additional
properties (also
   plot elements) such as color and thickness (size) are added to make the
average line
   stand out from the individual trajectories.
 * Note that variables are mapped to aesthetics, but plot elements can also
be set to fixed
   values by defining them outside aes(). This is why, for example, ggplot2
'knew' to produce
   separate lines for each subject, because the group aesthetic was mapped
to values of Subject.

For more about ggplot2, see its on-line help page at
http://had.co.nz/ggplot2   Scroll to the bottom of the page to find them.

HTH,
Dennis

On Sun, Feb 20, 2011 at 12:59 PM, dadrivr  wrote:

>
> Hi all,
>
> I am trying to plot the fitted trajectories for each individual from an
> individual growth model (fit with a linear mixed effects model in lme).
>  How
> can I plot each person's trajectory in the *same* panel, along with the
> mean-level trajectory?
>
> Below is an image of a plot similar to what I'm trying to create (from:
> http://jpepsy.oxfordjournals.org/content/31/10/1002/F6.large.jpg):
> http://r.789695.n4.nabble.com/file/n3315494/fitted_trajectories.jpg
>
> Thanks so much for your help!
> --
> View this message in context:
> http://r.789695.n4.nabble.com/Plotting-individual-trajectories-from-individual-growth-model-tp3315494p3315494.html
> Sent from the R help mailing list archive at Nabble.com.
>
> __
> R-help@r-project.org mailing list
> https://stat.ethz.ch/mailman/listinfo/r-help
> PLEASE do read the posting guide
> http://www.R-project.org/posting-guide.html
> and provide commented, minimal, self-contained, reproducible code.
>

[[alternative HTML version deleted]]

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


Re: [R] barplot, different color for shading lines and bar

2011-02-20 Thread Dennis Murphy
Hi:

This isn't hard to do with ggplot2. Here's a toy example:

d <- data.frame(gp = LETTERS[1:4], frq = c(10, 25, 30, 20))

library(ggplot2)

# The fill aesthetic colors the bars, the colour aesthetic does the same for
the borders.

# (1) Same color for both, use alpha transparency:
ggplot(d, aes(x = gp, y = frq)) +
   geom_bar(fill = 'blue', colour = 'blue', alpha = 0.2)

# (2) Use related colors (and throw in a white background):
ggplot(d, aes(x = gp, y = frq)) +
geom_bar(fill = 'blue', colour = 'navyblue', alpha = 0.2) + theme_bw()

# (3) Use different colors:
ggplot(d, aes(x = gp, y = frq)) +
geom_bar(fill = 'lavender', colour = 'navyblue') + theme_bw()

# (4) Map fill and border colors to values of gp:
ggplot(d, aes(x = gp, y = frq)) +
   geom_bar(aes(fill = gp, colour = gp), alpha = 0.3) + theme_bw()

# (4a) To get rid of the crossbar in the legend, add
last_plot() + scale_colour_discrete(legend = FALSE)

HTH,
Dennis

PS: I would have preferred to send this to the OP rather than the
respondent, but he didn't cc the original message, so...

On Sun, Feb 20, 2011 at 3:36 PM, Jannis  wrote:

> The easiest solution may be using par(new=TRUE) and to overlay a coloured
> barplot with a separate shaded barplot
>
>
> HTH
> Jannis
> On 02/19/2011 10:58 PM, Markus Loecher wrote:
>
>> Dear all,
>> might there be a modified barplot function out there which allows the user
>> to specify a fill color for the bars and independent parameters for the
>> overlaid shading lines ?
>> Currently, when I specify density and col, the fill color for the bars is
>> white.
>>
>> Thanks!
>>
>> Markus
>>
>>[[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.
>

[[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] Tips to export R plots (dotplot function) into latex

2011-02-20 Thread Ista Zahn
This sounds more like a LaTeX question than an R question...

\begin{center}
\includegraphics{...}
\end{center}

If you had something else in mind please post more details.

Best,
Ista
On Mon, Feb 21, 2011 at 1:03 AM, Antonio Paredes
 wrote:
> I'm looking for some tips on how to export R plots into latex. I can't
> centered the plots in latex (shift to the right).
>
> --
> -Tony
>
>        [[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.
>



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

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


Re: [R] Seeking help in Package development

2011-02-20 Thread Mike Marchywka












> Date: Sun, 20 Feb 2011 15:56:41 +0100
> From: lig...@statistik.tu-dortmund.de
> To: jwiley.ps...@gmail.com
> CC: r-help@r-project.org
> Subject: Re: [R] Seeking help in Package development
>
> May I add that the best documentation for building packages is the
> "Writing R Extensions" that ships with the current R version. It is
> always current, precise, and not as outdated as many resources you find
> "somewhere" in the web - yes, the one cited below is outdated.
>
> Uwe Ligges
>
>
> On 19.02.2011 22:59, Joshua Wiley wrote:
> > Dear Nipesh,
> >
> > On Sat, Feb 19, 2011 at 1:39 PM, Nipesh Bajaj wrote:
> >> Dear all, I am a new user of R and currently trying hard to develop my
> >> own package. Here I am following this tutorial
> >> 'http://www.mathfinance.cn/how-to-create-an-R-package-in-windows/'
> >>
> >> Here it says that (step 8): "open a “command prompt” window, change
> >> the directory to where your package is, type the command “R CMD build
> >> MonteCarloPi” to build the package, this will generate a file called
> >> MonteCarloPi_1.0.tar.gz. "
> >>

a
> >> black screen window) and then changed the directory, where my new
> >> package (a folder in current working directory in R, as created by
> >> 'package.skeleton') is there. Then typed 'R CMD build MyPackage' (I
> >> named my package as 'MyPackage'). However doing so I got following
> >> error in that command prompt:
> >>
> >> 'R' is not recognized as an internal or external command, operable
> >> program or batch file.
> >
> > This suggests that either your current directory does not contain R
> > and you have not added the directory containing R to the PATH

> > needs to know where to find the program to execute. You might find

> > prompt (geared towards XP, but cmd.exe has changed little from XP to
> > Vista, to 7---though increasing MS is encouraging users to switch over

> >
> > http://www.microsoft.com/resources/documentation/windows/xp/all/proddocs/en-us/ntcmds.mspx?mfr=true
> >
> >>
> >> Can somebody please guide me what to do in this situation?


I guess if you are shopping for alternative shells, consider cygwin and
then you get all the power of years of other developer's work. I am
not sure what MSFT is doing with a "powershell" but very good open tools
already exist for linux that cygwin allows you to use here. 
I have had a few issues with latest cygwin on Doh's 7 but probably 
due to install problems. I routinely use R with cygwin and have never
used a GUI wth R  except for a popup on debian version.


You will even find, if you learn the linux tools, that R makes a lot
more sense. I just started to play with package building, didn't complete
one yet, and everything pretty much made sense right away on debian. 



> >
> > You should also read the official R manual on installing and building

> > users. You may want to get Rtools and certainly follow the
> > instructions to add all the necessary directories to your PATH
> > variable. The steps will be something like:
> >
> > Right click My Computer -> Click Properties -> Click Advanced -> Click
> > Environment Variables -> edit the variable "PATH" to include relevant
> > R directories. Please note that this is not an exact step-by-step

> >
> > Official R Installation Manual (very relevant for building packages):
> > http://cran.r-project.org/doc/manuals/R-admin.html
> >
> > Good luck,
> >
> > Josh
> >
> >>
> >> Best 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-help@r-project.org mailing list
> https://stat.ethz.ch/mailman/listinfo/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] Confidence Intervals on Standard Curve

2011-02-20 Thread Ben Ward

On 20/02/2011 18:52, David Winsemius wrote:


On Feb 20, 2011, at 1:27 PM, Ben Ward wrote:


However, the

Y ~ X + Y^2

Produces the best fitting line - it is pretty much on the data points 
- I'm trying to make a standard curve, with which to take readings 
from a spectrophotometer off of. Rather than what I would normally 
use models for - such as hypothesis testing and analysis of data from 
experiments.


I thought we were leaving behind the model that had the dependent 
variable on both sides of hte equation. Can you explain how you would 
construct a chart or a function that will turn those results into 
something useful?


Sorry for any confusion, I am indeed leaving behind the Y ~ X + Y^2 
model, I was only mentioning that it had a higher R squared than 
anything else I had done.


I'll explain exactly what the chart/function is made from and is for, to 
remove any mystery or highlight anything important: The curve I'm trying 
to produce, is from readings from a spectrophotometer, from series of 
standards called the MacFarland Scale - tubes of solution which were 
made up to simulate different known numbers of bacteria in a liquid 
sample: the standards are of different intensities of coloudy-ness, and 
they represent different numbers of bacteria in a liquid medium. The (X) 
axis is % light transmission as measured by the spectrophotometer, the 
cloudier the standard, the lower this value, and the Bacterial Counts on 
the (Y) axis, are higher, the cloudier a sample (or the standards) are, 
thus it is higher with lower % Light Transmission. This is a negative 
curve, which never goes below 0, because you cant have less than no 
bacteria. This curve/function, which has been made from the standards of 
known numbers, will then be used to estimate the numbers of bacteria 
present in proper samples, rather than known standards. I would take the 
% Light Transmission Readings the spectrophotometer gives me for those 
standards, and then using the curve - or working through the function, 
calculate the (Approximate) number of bacteria present in my samples. I 
took 5, % Light Transmission readings for each standard to make sure the 
machine wasn't giving me wildly different readings (it' wasnt), and used 
them to try and construct a curve.


Hence my comment about  Y ~ X + Y^2 giving me a better fit (R-Squared). 
I need a good fit to make reliable predictions. However, since then, 
I've added an extra standard from the scale (There are about 10/11 
standards to the scale, but I've got 9, because the last few can't be 
made up accurately without introducing error or the lab tech's running 
into difficulty doing it by hand), and the Y ~ X + Y^2 curve is no 
longer sufficient after this.


I followed a suggestion (I think by you) to try a GLM, with the poisson 
distribution, as I mentioned in my last email that went around, which 
wasn't closely fitting as I would like, it's my first experience with 
GLM, but to my understanding, the Residual Deviance, was orders higher 
than the residual degrees of freedom. So under instruction of a 
textbook, I tried with a quasi-poisson, but still got the same result. 
Then (again textbook suggestion) tried with a negative binomial 
distribution, and got a much lower AIC value and a residual deviance 
much much closer to the residual degrees of freedom (the R print outs of 
them are on the previous email I sent around).


I hope this has explained when you asked "Can I explain how I would 
construct a chart or a function that will turn those results into 
something useful?"


Thanks,
Ben.W



Thanks,
Ben.

On 20/02/2011 11:53, nzcoops wrote:

model<- lm(Approximate.Counts~X..Light.Transmission +
I(Approximate.Counts^2), data=Standards)

Might not be addressing the problem, don't you have Y ~ X + Y^2 
here? That's

a violation of the assumptions of an lm isn't it?

Also for plotting CI on a curve look into ggplot2::geom_ribbon, it's 
much
nicer than just plotting lines and is easy to use. had.co.nz should 
set you

right for setting this up.





David Winsemius, MD
West Hartford, CT





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


Re: [R] Generating uniformly distributed correlated data.

2011-02-20 Thread Søren Faurby

Thanks to everybody for helpfull answers.

In case other people want to generate similar data at one time
The one function I have found without any apparant bias ( such as  
extreme clustering of the datapoints along one or both diagonals in  
plot(x,y) or a slight bias in the generated correlations is the  
function pcu from the library simecol


Kind regards, Soren

Citat af Spencer Graves :

  You may also be interested in the "psych" package or possibly  
"mvtBinaryEP".  I found these using "sos":



library(sos)
tc <- findFn('tetrachoric correlation') # 26 matches
tcs <- findFn('tetrachoric correlations')#27 matches
tc. <- tc|tcs
summary(tc.) # 35 links in 5 pkgs
tc.


  All but 3 of the 35 links are to "psych", and 2 of the  
remaining 3 are to two different copies of "mvtBinaryEP".  You might  
also Google for "tetrachoric correlation".



# OR:
u <- findFn('uniformly distributed correlated data') # 3 matches


  Hope this helps.
  Spencer


On 2/19/2011 9:21 PM, Jorge Ivan Velez wrote:

Hi Soren,

Take a look at http://tolstoy.newcastle.edu.au/R/help/05/07/7741.html

HTH,
Jorge


On Sat, Feb 19, 2011 at 9:17 PM, Søren Faurby<>  wrote:


I wish to generate a vector of uniformly distributed data with a defined
correlation to another vector

The only function I have been able to find doing something similar is
corgen from the library ecodist.

The following code generates data with the desired correlation to the
vector x but the resulting vector y is normal and not uniform distributed

library(ecodist)
x<- runif(10^5)
y<- corgen(x=x, r=.5)$y

Do anyone know a similar function generating uniform distributed data or a
way of transforming y to the desired distribution while keeping the
correlation between x and y

Kind regards, Soren

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


[R] Tips to export R plots (dotplot function) into latex

2011-02-20 Thread Antonio Paredes
I'm looking for some tips on how to export R plots into latex. I can't
centered the plots in latex (shift to the right).

-- 
-Tony

[[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] list of features from svmpath?

2011-02-20 Thread Angel Russo
How can I get the list of non-zero features from svmpath at any given
lambda? All I get is following information and information about what
features were selected. In Iris example, we have 4 features and 60 cases. In
my own example which is 200cases by 300 features, I can't figure out how to
print the list of non-zero (beta) or features from svmpath.

Any help? Thanks.




> solution <- svmpath(as.matrix(iris[1:60,1:4]), buffer, type="class",
trace=FALSE)

> names(solution)
 [1] "alpha""alpha0"   "lambda"   "alpha00"
"Error""SumEps"
 [7] "Size.Elbow"   "Elbow""Moveto"   "Movefrom"
"Obs.step" "Step"
[13] "kernel"   "param.kernel" "x""y""call"


> solution$alpha0
 [1] 130.785000 108.685000 106.21  86.13  85.485000  71.176837
68.197549  67.660686
 [9]  60.847899  58.442887  53.721098  53.544146  44.61  44.525517
44.415343  39.709048
[17]  38.832267  36.940401  33.800161  28.115484  25.859545  25.734545
24.818367  19.666905
[25]  18.833000  17.768614  17.219663  16.737715  15.503339  14.717148
8.586288
> solution$Obs.step
 [1] 27 53 27 53 32 51 32 51 26 55  6 55 57  6 44 57 59 44 19 44 59 52 19 44
21 52 56 21 52 42 26
[32] 56 45 52 54 42

[[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] Same color key for multiple lattice contour plots

2011-02-20 Thread joepvanderzanden

Hi all,

I'm trying to make multiple lattice contour plots which have the same color
key, to allow good comparisons. However, I run into some problems when
fitting the plots to the color key. Basically my strategy to tackle this
problem was:
1) define a color key for all plots;
2) calculate the variable range for each plot;
3) calculate the range of colors from the color key that correspond with the
variable range in each plot.

This works fine for one plot but gives problems for an other. The code is
shown below. Any ideas of how to solve this would be very welcome!

Thanks in advance,

Joep van der Zanden
MSc student Hydrology and Water Quality
Wageningen University, The Netherlands / University of Sydney, Australia


# variable to plot: groundwater heads for 2 situations (L Med Clay Grass; S
Clay Loam Trees): z2 and z1
# x: range of distances to river
# y: range of lambda values

## define input data
x <- vector(mode="numeric", length=64)
for(i in 1:8){x[((i-1)*8+1):(i*8)]<- c(0,25,65,140,240,390,590,840)}
y <- vector(mode="numeric", length=64)
for(i in 1:8){y[((i-1)*8+1):(i*8)]<- c(.1,.2,.3,.4,.5,.6,.7,.8)[i]}

#Groundwater heads L Med Clay Grass:
z1<-c(-2.50,-2.505624,-2.518618,-2.545173,-2.573554,-2.602523,-2.618828,-2.626615,
 
-2.50,-2.605805,-2.753376,-2.975772,-3.176528,-3.384182,-3.522155,-3.600701,
 
-2.50,-2.665630,-2.899457,-3.264895,-3.622645,-4.027824,-4.344277,-4.552091,
 
-2.50,-2.681250,-2.937271,-3.338646,-3.736416,-4.193448,-4.559524,-4.805040,
 
-2.50,-2.704198,-2.995056,-3.458425,-3.932201,-4.493279,-4.964342,-5.291613,
 
-2.50,-2.714743,-3.021087,-3.511101,-4.015649,-4.616914,-5.126386,-5.482788,
 
-2.50,-2.714741,-3.021320,-3.512125,-4.018124,-4.621621,-5.133251,-5.491187,
 
-2.50,-2.714734,-3.021383,-3.512441,-4.018981,-4.623628,-5.137014,-5.496542)

#Groundwater heads S Clay Loam Trees:
z2<-c(-3.98,-3.097126,-3.239426,-3.473582,-3.721368,-4.020646,-4.277272,-4.457723,
 
-3.000100,-3.107293,-3.263420,-3.518309,-3.786358,-4.109567,-4.386844,-4.582058,
 
-3.000100,-3.110692,-3.271133,-3.531996,-3.805475,-4.134907,-4.417481,-4.616469,
 
-3.000100,-3.110448,-3.270550,-3.531059,-3.804453,-4.134001,-4.416834,-4.616037,
 
-3.000100,-3.111242,-3.272157,-3.533380,-3.806871,-4.136071,-4.418223,-4.616824,
 
-3.000100,-3.110467,-3.270084,-3.528994,-3.799932,-4.125979,-4.405361,-4.601977,
 
-3.000100,-3.110983,-3.271263,-3.531276,-3.803556,-4.131419,-4.412594,-4.610585,
 
-3.000100,-3.111398,-3.272309,-3.533291,-3.806408,-4.135115,-4.416826,-4.615104)


##step 1 define color key
bynumb <- .2 # delta
deltaseq <- seq(-5.8,-2,by=bynumb) # define color key
numbcolstotal <- length(deltaseq)-1 # number of colors in color key


#define plot for L Med Clay Grass:
x.marginal <- seq(min(x), max(x), length.out = 50)
y.marginal <- seq(min(y), max(y), length.out = 50)
xy.marginal <- list(x = x.marginal, y = y.marginal)
zz <- loess((z1) ~ x * y)
grid <- expand.grid(xy.marginal)
grid[, "fit"] <- c(predict(zz, grid))

 # step 2 calculate the range of groundwater heads for this plot:
rangehere<-seq(floor(min(z1)/bynumb)*bynumb,ceiling(max(z1)/bynumb)*bynumb,by=bynumb)
 # rangehere appears to be seq(-5.6, -2.4, by = -.2, length = 17)
 # step 3 calculate the range of colors that fit to the range of groundwater
heads
colorrange<-round(seq(((rangehere[1]-deltaseq[1])/bynumb)+1,((max(rangehere)-deltaseq[1])/bynumb),1))
  # colorrange is 1 to 16 --> should be correct.
  
plot1 <- contourplot(fit~x*y, data = grid,cuts =
length(colorrange)-2,region=TRUE,
col.regions=rev(rainbow(n=numbcolstotal))[colorrange],
   
colorkey=list(col=rev(rainbow(n=numbcolstotal)),at=deltaseq,labels=list(at=deltaseq)),
xlab="distance to river (m)", ylab="lambda (/d)", main="Mean Z, L Med
Clay, Grass")

## do the same for S Clay Loam Trees.
x.marginal <- seq(min(x), max(x), length.out = 50)
y.marginal <- seq(min(y), max(y), length.out = 50)
xy.marginal <- list(x = x.marginal, y = y.marginal)
zz <- loess((z2) ~ x * y)
grid <- expand.grid(xy.marginal)
grid[, "fit"] <- c(predict(zz, grid))

# step 2
rangehere<-seq(floor(min(z2)/bynumb)*bynumb,ceiling(max(z2)/bynumb)*bynumb,by=bynumb)
# step 3
colorrange<-round(seq(((rangehere[1]-deltaseq[1])/bynumb)+1,((max(rangehere)-deltaseq[1])/bynumb),1))

plot2 <- contourplot(fit~x*y, data = grid,cuts =
length(colorrange)-2,region=TRUE,
col.regions=rev(rainbow(n=numbcolstotal))[colorrange],
   
colorkey=list(col=rev(rainbow(n=numbcolstotal)),at=deltaseq,labels=list(at=deltaseq)),
xlab="distance to river (m)", ylab="lambda (/d)", main="Mean Z, S Clay
Loam, Trees")

print(plot1, position=c(0, 0.5, 1, 1), more=TRUE)
print(plot2, position=c(0,0,1,0.5))

# --> second plot is OK, first one not...
-- 
View this message in context: 
http://r.789695.n4.nabble.com/Same-color-key-for-multiple-lattice-contour-plots-tp3316654p3316654.html
Sent from the R help mailing list archive at Nabble.com.

__
R-help@r-project.org mai

[R] QuadTree

2011-02-20 Thread Jaimin Dave
Could any one tell me how to implement QuadTree in R?
Or are there any packages avaialble to implement it in R.

[[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] barplot, different color for shading lines and bar

2011-02-20 Thread Jannis
The easiest solution may be using par(new=TRUE) and to overlay a 
coloured barplot with a separate shaded barplot



HTH
Jannis
On 02/19/2011 10:58 PM, Markus Loecher wrote:

Dear all,
might there be a modified barplot function out there which allows the user
to specify a fill color for the bars and independent parameters for the
overlaid shading lines ?
Currently, when I specify density and col, the fill color for the bars is
white.

Thanks!

Markus

[[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] Matrix Help

2011-02-20 Thread Mark Knecht
On Sun, Feb 20, 2011 at 2:56 PM, Dmitry Berman  wrote:
> On Sun, Feb 20, 2011 at 5:55 PM, Dmitry Berman  wrote:
>
>> Listers,
>>
>> I have a simple matrix:
>>
>> --
>> m <-c(1:7)
>> m <- cbind(m)
>>
>> m
>> [1,] 1
>> [2,] 2
>> [3,] 3
>> [4,] 4
>> [5,] 5
>> [6,] 6
>> [7,] 7
>> ---
>>
>> I want to add a second column using:
>>
>>
>>
> m[,2] <- cbind(m,8:14)
> But I get the error:
> Error in m[, 2] <- cbind(m, 8:14) : subscript out of bounds
>
> What am I doing wrong?
>
> Thanks
>
>        [[alternative HTML version deleted]]
>
> __
> R-help@r-project.org mailing list
> https://stat.ethz.ch/mailman/listinfo/r-help
> PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
> and provide commented, minimal, self-contained, reproducible code.
>

How about:

m1 <-c(1:7)
M1<-cbind(m1)
M1

m2 <-c(2:8)
M2<-cbind(m2)
M2

cbind(M1,M2)

__
R-help@r-project.org mailing list
https://stat.ethz.ch/mailman/listinfo/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 Help

2011-02-20 Thread David Winsemius


On Feb 20, 2011, at 5:56 PM, Dmitry Berman wrote:

On Sun, Feb 20, 2011 at 5:55 PM, Dmitry Berman   
wrote:



Listers,

I have a simple matrix:

--
m <-c(1:7)
m <- cbind(m)

m
[1,] 1
[2,] 2
[3,] 3
[4,] 4
[5,] 5
[6,] 6
[7,] 7
---

I want to add a second column using:




m[,2] <- cbind(m,8:14)


Don't reference the column number on the LHS:

m <- 1:7
m <- cbind(m, 8:14)

> m
 m
[1,] 1  8
[2,] 2  9
[3,] 3 10
[4,] 4 11
[5,] 5 12
[6,] 6 13
[7,] 7 14

But I get the error:
Error in m[, 2] <- cbind(m, 8:14) : subscript out of bounds

What am I doing wrong?

Thanks

[[alternative HTML version deleted]]

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


David Winsemius, MD
West Hartford, CT

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


Re: [R] Matrix Help

2011-02-20 Thread Dmitry Berman
On Sun, Feb 20, 2011 at 5:55 PM, Dmitry Berman  wrote:

> Listers,
>
> I have a simple matrix:
>
> --
> m <-c(1:7)
> m <- cbind(m)
>
> m
> [1,] 1
> [2,] 2
> [3,] 3
> [4,] 4
> [5,] 5
> [6,] 6
> [7,] 7
> ---
>
> I want to add a second column using:
>
>
>
m[,2] <- cbind(m,8:14)
But I get the error:
Error in m[, 2] <- cbind(m, 8:14) : subscript out of bounds

What am I doing wrong?

Thanks

[[alternative HTML version deleted]]

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


[R] Matrix Help

2011-02-20 Thread Dmitry Berman
Listers,

I have a simple matrix:

--
m <-c(1:7)
m <- cbind(m)

m
[1,] 1
[2,] 2
[3,] 3
[4,] 4
[5,] 5
[6,] 6
[7,] 7
---

I want to add a second column using:

[[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] inter-specific competition - community matrices and two species models using Lotka-Volterra

2011-02-20 Thread Ben Bolker
Bob O'Hara  gmail.com> writes:

> 
> On 20 February 2011 16:19, Chris Buddenhagen wrote:
> 
> > Does anyone know of example r-code/packages for carrying out analysis?
> > Preferably this would have examples from real experimental data of two or
> > more competing species...
> >
> > In discrete time, you can use a Gompertz model:
> 
> which reduces to a VAR(1) model, which is a multivariate time series model,
> check here:
> 
> 

  If you have observation error (which you might be able to ignore/
say is negligible in some *experimental* contexts, although hardly
ever in observational contexts) you would want to take this one
step further and think about using the MARSS (multivariate 
autoregressive state-space) package (also check out dlm, sspir packages).
  You should definitely take a look at Ives et al 2003 Ecological
Monographs: unfortunately for you, they used Matlab rather than
R, but you might be able to make the translation to the MARSS package
fairly painlessly since the underlying methods are very very similar.

__
R-help@r-project.org mailing list
https://stat.ethz.ch/mailman/listinfo/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] prevent export of specific functions in NAMESPACE

2011-02-20 Thread Duncan Murdoch

On 11-02-20 11:58 AM, Rajarshi Guha wrote:

Hi, I'd like to prevent the export a specific function in the
NAMESPACE file. The example in the R documentation uses a regex to
prevent export of a set of functions, but as far as I can see there is
no easy way to specify that a function of a specific name should not
be exported. This thread
(http://www.mail-archive.com/r-help@r-project.org/msg42961.html)
suggests that a regex is not the way to 'negate' a string literal.

So to prevent export of specific functions, do I need to explicitly
list all functions that are to be exported?



Why not name the one function according to a pattern different from the 
rest of your function names, such as starting it with a ., as the 
example in the manual does?


Duncan Murdoch

__
R-help@r-project.org mailing list
https://stat.ethz.ch/mailman/listinfo/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] joint estimation of two poisson equations

2011-02-20 Thread danielepippo

Hi,
  I have the same problem to find out the standard errors of the parameter
in the same package you have used. 
I couldn't find out how to get standard errors and p-values from the 
package, so I bootstrapped them.
Can you explain your method to find out the standard errors with the
bootstrap method?


Thanks a lot

-- 
View this message in context: 
http://r.789695.n4.nabble.com/joint-estimation-of-two-poisson-equations-tp894847p3315520.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] Plotting individual trajectories from individual growth model

2011-02-20 Thread dadrivr

Hi all,

I am trying to plot the fitted trajectories for each individual from an
individual growth model (fit with a linear mixed effects model in lme).  How
can I plot each person's trajectory in the *same* panel, along with the
mean-level trajectory?

Below is an image of a plot similar to what I'm trying to create (from:
http://jpepsy.oxfordjournals.org/content/31/10/1002/F6.large.jpg):
http://r.789695.n4.nabble.com/file/n3315494/fitted_trajectories.jpg 

Thanks so much for your help!
-- 
View this message in context: 
http://r.789695.n4.nabble.com/Plotting-individual-trajectories-from-individual-growth-model-tp3315494p3315494.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] Bootstraps standard error

2011-02-20 Thread danielepippo

Can anyone help me please?
-- 
View this message in context: 
http://r.789695.n4.nabble.com/Bootstraps-standard-error-tp3313322p3315463.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] Bootstraps standard error

2011-02-20 Thread David Winsemius


On Feb 20, 2011, at 2:20 PM, danielepippo wrote:



when I calculate the bootstrap standard errors


... of what?


the results are summarized in
a matrix with columns equal to the parameters of the model.


... but they are all the same within each row???


In my case I
have a matrix like this:
   [,1]   [,2] [,3]  [,4] [,5]
[,6][,7]  [,8][,9]
[1,] -2.285122 -2.285122 -2.285122 -2.285122 -2.285122 -2.285122  
-2.285122


[2,] -2.320864 -2.320864 -2.320864 -2.320864 -2.320864 -2.320864
-2.320864
[3,] -2.424021 -2.424021 -2.424021 -2.424021 -2.424021 -2.424021
-2.424021
[4,] -2.424027 -2.424027 -2.424027 -2.424027 -2.424027 -2.424027
-2.424027
[5,] -2.386161 -2.386161 -2.386161 -2.386161 -2.386161 -2.386161  
-2.386161
[6,] -2.470702 -2.470702 -2.470702 -2.470702 -2.470702 -2.470702  
-2.470702
[7,] -2.424967 -2.424967 -2.424967 -2.424967 -2.424967 -2.424967  
-2.424967
[8,] -2.331261 -2.331261 -2.331261 -2.331261 -2.331261 -2.331261  
-2.331261
[9,] -2.415814 -2.415814 -2.415814 -2.415814 -2.415814 -2.415814  
-2.415814

[10,] -2.418828 -2.418828 -2.418828 -2.418828 -2.418828 -2.418828
-2.418828
[11,] -2.328493 -2.328493 -2.328493 -2.328493 -2.328493 -2.328493  
-2.328493
[12,] -2.369575 -2.369575 -2.369575 -2.369575 -2.369575 -2.369575  
-2.369575
[13,] -2.386355 -2.386355 -2.386355 -2.386355 -2.386355 -2.386355  
-2.386355
[14,] -2.417921 -2.417921 -2.417921 -2.417921 -2.417921 -2.417921  
-2.417921
[15,] -2.296758 -2.296758 -2.296758 -2.296758 -2.296758 -2.296758  
-2.296758
[16,] -2.490558 -2.490558 -2.490558 -2.490558 -2.490558 -2.490558  
-2.490558

[17,] -2.483024 -2.483024 -2.483024 -2.483024 -2.483024 -2.483024
-2.483024
[18,] -2.336290 -2.336290 -2.336290 -2.336290 -2.336290 -2.336290
-2.336290
[19,] -2.357479 -2.357479 -2.357479 -2.357479 -2.357479 -2.357479
-2.357479
[20,] -2.391479 -2.391479 -2.391479 -2.391479 -2.391479 -2.391479
-2.391479

In the pdf file, where I've found the example, the matrix result has  
the
same equal columns, where the columns are relate to the nine  
parameters.
If I have to calculate the standard errors of each parameters, in  
the pdf

there is this:
At the end matrix results contains the bootstrap values of the  
parameters
and thus bootstrap standard errors can be obtained merely by  
calculating the

standard errors of the columns.

How can I merely calculate thees standard errors?


I am unable to understand the question (or do anything with the data)  
because:

-- no R code
-- no description of the "bootstrap" procedure
-- the cited source of data has a contingency table
-- apparently the data is in a pdf file that does not allow copying
-- the "nine parameters" appear to be _somehow_ related to the column  
headings (i.e. count categories) of that contingency table
-- it is difficult to imagine how that series of 9 identical numbers  
within each row presented above relates to the (obviously non-uniform)  
9 column contingency table in the pdf file




The pdf is in the following file:
http://r.789695.n4.nabble.com/file/n3315394/example.pdf example.pdf


Which is an extract from a larger paper in the Journal of Statistical  
Software. The dataset is cited to be available in the bivpois package,  
but the package does not seem to be currently in CRAN, although its  
appearance in CRANtastic suggests it may be accessible through the  
Archives.


I have to ask   is this homework?



Thank you very much..
Pippo
--
View this message in context: 
http://r.789695.n4.nabble.com/Bootstraps-standard-error-tp3313322p3315394.html
Sent from the R help mailing list archive at Nabble.com.



David Winsemius, MD
West Hartford, CT

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


Re: [R] Random Forest & Cross Validation

2011-02-20 Thread Max Kuhn
> I am using randomForest package to do some prediction job on GWAS data. I
> firstly split the data into training and testing set (70% vs 30%), then
> using training set to grow the trees (ntree=10). It looks that the OOB
> error in training set is good (<10%). However, it is not very good for the
> test set with a AUC only about 50%.

Did you do any feature selection in the training set? If so, you also
need to include that step in the cross-validation to get realistic
performance estimates (see Ambroise and McLachlan. Selection bias in
gene extraction on the basis of microarray gene-expression data.
Proceedings of the National Academy of Sciences (2002) vol. 99 (10)
pp. 6562-6566).

In the caret package, train() can be used to get cross-validation
estimates for RF and the sbf() function (for selection by filter) can
be used to include simple univariate filters in the CV procedure.

> Although some people said no cross-validation was necessary for RF, I still
> felt unsafe and thought a testing set is important. I felt really frustrated
> with the results.

CV is needed when you want an assessment of performance on a test set.
In this sense, RF is like any other method.

-- 

Max

__
R-help@r-project.org mailing list
https://stat.ethz.ch/mailman/listinfo/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] Variable length datafile import problem

2011-02-20 Thread John Kane
Hi Ingo, 

Sorry for being so slow to get back to you.  I've had a bit of a problem with 
my internet connection.

Just how large is the data set?  You might want to have a look at this thread 
re size of R data files. 
http://r.789695.n4.nabble.com/Boundaries-of-R-td3312593.html .

In any case, from a bit more poking around in the file it looks like the last 
column, Column LN in Calc, is the problem. It has only NaN in row 57 as a 
value.  If I remove it I can read in the rest of the file.  In fact simply 
changing it to 0 (zero) makes the file readable.

I've had a look at it in Calc and in jEdit but cannot see anything suspicious 
there.  I suspect there must be something funny in there since at Row 32 also 
ends with NaN and seems to be reading in properly.  

BTW what are the NaN's doing there?



--- On Fri, 2/18/11, Ingo Reinhold  wrote:

> From: Ingo Reinhold 
> Subject: RE: [R] Variable length datafile import problem
> To: "John Kane" , "r-help@r-project.org" 
> 
> Received: Friday, February 18, 2011, 3:16 AM
> Hi John, 
> 
> seems there is no easy way. I'll just precondition it with
> AWK as described here 
> http://www.mail-archive.com/r-help@stat.math.ethz.ch/msg53401.html
> 
> There are some remarks in the thread that R is not supposed
> to read too large files for "political" reasons. Maybe
> that's it.
> 
> Many thanks again for the effort. 
> 
> Ingo
> 
> From: John Kane [jrkrid...@yahoo.ca]
> Sent: Thursday, February 17, 2011 11:54 AM
> To: Ingo Reinhold
> Subject: RE: [R] Variable length datafile import problem
> 
> Generally most of the gurus are in this list. 
> Hopefully someone will take an interest in the problem.
> 
> I suspect that there may be some kind of weird value in the
> file that is upsetting in import.  Given the results I
> got when I removed the data past BD and then at AL it seems
> that the problem might be within this range.
> 
> You could try removing half the data between those columns
> and see what happens, then repeat if something turns up.
> It's tedious but unless someone with a better grasp of
> variable length data import can help it's the best I can
> suggest.
> 
> BTW you only replied to me.  You should make sure to
> cc the list otherwise readers won't realise that I am being
> of no help.
> 
> If you still have the problem by Saturday e-mail me or post
> to the list and I'll try to spent some more time messing
> about with the problem.
> 
> Sorry to be of so little help.
> --- On Thu, 2/17/11, Ingo Reinhold 
> wrote:
> 
> > From: Ingo Reinhold 
> > Subject: RE: [R] Variable length datafile import
> problem
> > To: "John Kane" 
> > Received: Thursday, February 17, 2011, 5:36 AM
> > Hi John,
> >
> > as it seems we're hitting the wall here, can you
> maybe
> > recommend another mailing list with "gurus" (as you
> put it)
> > that may be able to help?
> >
> > Regards,
> >
> > Ingo
> > 
> > From: John Kane [jrkrid...@yahoo.ca]
> > Sent: Thursday, February 17, 2011 11:25 AM
> > To: Ingo Reinhold
> > Subject: RE: [R] Variable length datafile import
> problem
> >
> > Hi Ingo,
> >
> > I've had a bit of time to examine the file and I must
> say
> > that, at the moment, I have no idea what is going on.
> > I tried the old cut the file into pieces trick just
> came up
> > with even more anomalous results.
> >
> > My first attempt remove all the data past column AL in
> an
> > OOo Calc spreadsheet.  This created a
> rectangular
> > dataset It imported into R with no problem with 38
> columns
> > as expected.
> >
> > Then I deleted all the data from the orignal data
> file
> > (test.dat) removing all the data past column BD in an
> OOo
> > Calc spreadsheet.
> >
> > This imported a file with only 38 columns.
> >
> > Something very funny is happening but at the moment I
> have
> > no
> >
> > --- On Wed, 2/16/11, Ingo Reinhold 
> > wrote:
> >
> > > From: Ingo Reinhold 
> > > Subject: RE: [R] Variable length datafile import
> > problem
> > > To: "John Kane" 
> > > Received: Wednesday, February 16, 2011, 1:59 AM
> > > Hi John,
> > >
> > > V1 should be just a character. However I figured
> > something
> > > out myself. The import looks OK in terms of
> column
> > when
> > > adding the flush=TRUE option.
> > >
> > > I am still very confused about the dimensions
> that
> > the
> > > imported data shows. Loading my data file into
> > something
> > > like OOspreadsheet shows me a maximum of about
> 245,
> > which
> > > does not correspond to the 146 generated by R.
> Any
> > idea
> > > where this saturation comes from?
> > >
> > > Thanks,
> > >
> > > Ingo
> > > 
> > > From: John Kane [jrkrid...@yahoo.ca]
> > > Sent: Wednesday, February 16, 2011 1:57 AM
> > > To: Ingo Reinhold
> > > Subject: RE: [R] Variable length datafile import
> > problem
> > >
> > > Is rawData$V1 intended to be factor or
> character?
> > >
> > > str(rawData) gives
> > > $ V1  : Factor w/ 5

Re: [R] Bootstraps standard error

2011-02-20 Thread danielepippo

when I calculate the bootstrap standard errors the results are summarized in
a matrix with columns equal to the parameters of the model. In my case I
have a matrix like this:
[,1]   [,2] [,3]  [,4] [,5] 
[,6][,7]  [,8][,9] 
 [1,] -2.285122 -2.285122 -2.285122 -2.285122 -2.285122 -2.285122 -2.285122

 [2,] -2.320864 -2.320864 -2.320864 -2.320864 -2.320864 -2.320864
-2.320864
 [3,] -2.424021 -2.424021 -2.424021 -2.424021 -2.424021 -2.424021
-2.424021
 [4,] -2.424027 -2.424027 -2.424027 -2.424027 -2.424027 -2.424027
-2.424027
 [5,] -2.386161 -2.386161 -2.386161 -2.386161 -2.386161 -2.386161 -2.386161
 [6,] -2.470702 -2.470702 -2.470702 -2.470702 -2.470702 -2.470702 -2.470702
 [7,] -2.424967 -2.424967 -2.424967 -2.424967 -2.424967 -2.424967 -2.424967
 [8,] -2.331261 -2.331261 -2.331261 -2.331261 -2.331261 -2.331261 -2.331261
 [9,] -2.415814 -2.415814 -2.415814 -2.415814 -2.415814 -2.415814 -2.415814
[10,] -2.418828 -2.418828 -2.418828 -2.418828 -2.418828 -2.418828
-2.418828
[11,] -2.328493 -2.328493 -2.328493 -2.328493 -2.328493 -2.328493 -2.328493
[12,] -2.369575 -2.369575 -2.369575 -2.369575 -2.369575 -2.369575 -2.369575
[13,] -2.386355 -2.386355 -2.386355 -2.386355 -2.386355 -2.386355 -2.386355
[14,] -2.417921 -2.417921 -2.417921 -2.417921 -2.417921 -2.417921 -2.417921
[15,] -2.296758 -2.296758 -2.296758 -2.296758 -2.296758 -2.296758 -2.296758
[16,] -2.490558 -2.490558 -2.490558 -2.490558 -2.490558 -2.490558 -2.490558
[17,] -2.483024 -2.483024 -2.483024 -2.483024 -2.483024 -2.483024
-2.483024
[18,] -2.336290 -2.336290 -2.336290 -2.336290 -2.336290 -2.336290
-2.336290
[19,] -2.357479 -2.357479 -2.357479 -2.357479 -2.357479 -2.357479
-2.357479
[20,] -2.391479 -2.391479 -2.391479 -2.391479 -2.391479 -2.391479
-2.391479

In the pdf file, where I've found the example, the matrix result has the
same equal columns, where the columns are relate to the nine parameters.
If I have to calculate the standard errors of each parameters, in the pdf
there is this:
At the end matrix results contains the bootstrap values of the parameters
and thus bootstrap standard errors can be obtained merely by calculating the
standard errors of the columns. 

How can I merely calculate thees standard errors?

The pdf is in the following file:
http://r.789695.n4.nabble.com/file/n3315394/example.pdf example.pdf 

Thank you very much..
Pippo
 



 
-- 
View this message in context: 
http://r.789695.n4.nabble.com/Bootstraps-standard-error-tp3313322p3315394.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] Confidence Intervals on Standard Curve

2011-02-20 Thread David Winsemius


On Feb 20, 2011, at 1:27 PM, Ben Ward wrote:


However, the

Y ~ X + Y^2

Produces the best fitting line - it is pretty much on the data  
points - I'm trying to make a standard curve, with which to take  
readings from a spectrophotometer off of. Rather than what I would  
normally use models for - such as hypothesis testing and analysis of  
data from experiments.


I thought we were leaving behind the model that had the dependent  
variable on both sides of hte equation. Can you explain how you would  
construct a chart or a function that will turn those results into  
something useful?




Thanks,
Ben.

On 20/02/2011 11:53, nzcoops wrote:

model<- lm(Approximate.Counts~X..Light.Transmission +
I(Approximate.Counts^2), data=Standards)

Might not be addressing the problem, don't you have Y ~ X + Y^2  
here? That's

a violation of the assumptions of an lm isn't it?

Also for plotting CI on a curve look into ggplot2::geom_ribbon,  
it's much
nicer than just plotting lines and is easy to use. had.co.nz should  
set you

right for setting this up.





David Winsemius, MD
West Hartford, CT

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


Re: [R] concatenate vector after strsplit()

2011-02-20 Thread Robert Baer
Thanks Gabor.  Your suggestions work as well and have been helpful in my 
understanding,  I can't use any excuse of not knowing about "]" in this 
case!


Rob


fil3 = sapply(ls1, function(x) paste(x[1:4], collapse = ""))
fil4 = sapply(unname(as.data.frame(ls1))[1:4,], paste, collapse = "")
fil5 = sapply(as.data.frame(ls1)[1:4,], paste, collapse = "")
What I want to end up with is a vector that is the row-wise concatenation 
of
the strings in each row of your matrix or each element of my original 
list.


Try this:

  sapply(ls1, function(x) paste(x[1:4], collapse = ""))

or this:

  sapply(unname(as.data.frame(ls))[1:4,], paste, collapse = "")

If you don't mind ugly names on the result the last one can be shortened 
to:


  sapply(as.data.frame(ls)[1:4,], paste, collapse = "")

--
Statistics & Software Consulting
GKX Group, GKX Associates Inc.
tel: 1-877-GKX-GROUP
email: ggrothendieck at gmail.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] Confidence Intervals on Standard Curve

2011-02-20 Thread Ben Ward
It is, I tried a glm with a poisson distribution, as was suggested to me 
previously, but the Residual Deviance was too high - the book I'm 
reading says it suggests overdispersion because it's way above the 
Residual degrees of freedom:


glm(formula = Approximate.Counts ~ X..Light.Transmission, family = poisson,
data = Standard)

Deviance Residuals:
   Min  1Q  Median  3Q Max
-6.434  -2.822  -1.257   4.319   9.432

Coefficients:
Estimate Std. Error z value Pr(>|z|)
(Intercept)7.7584256  0.0058981  1315.4 <2e-16 ***
X..Light.Transmission -0.0497474  0.0004951  -100.5 <2e-16 ***
---
Signif. codes:  0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1

(Dispersion parameter for poisson family taken to be 1)

Null deviance: 15709.90  on 39  degrees of freedom
Residual deviance:   671.91  on 38  degrees of freedom
AIC: 1030.7

Number of Fisher Scoring iterations: 4

It suggested using quasi-poisson but that didn't alter anything, so then 
used a negative binomial and gained the result:


glm.nb(formula = Approximate.Counts ~ X..Light.Transmission,
data = Standard, init.theta = 67.14797983, link = log)

Deviance Residuals:
Min   1Q   Median   3Q  Max
-1.5281  -0.9208  -0.1883   0.9685   2.0121

Coefficients:
  Estimate Std. Error z value Pr(>|z|)
(Intercept)7.697970.02819  273.11 <2e-16 ***
X..Light.Transmission -0.044100.00141  -31.26 <2e-16 ***
---
Signif. codes:  0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1

(Dispersion parameter for Negative Binomial(67.148) family taken to be 1)

Null deviance: 905.35  on 39  degrees of freedom
Residual deviance:  40.39  on 38  degrees of freedom
AIC: 517.21

Number of Fisher Scoring iterations: 1


  Theta:  67.1
  Std. Err.:  16.1

 2 x log-likelihood:  -511.21

Which shows a much lower Residual Deviance, and AIC. I plot it and It is 
also pretty good. I'm yet to assess it with plot(model). This is my 
first proper go with GLM so I'm not confident at evaluating them, 
although I am aware that a better model of the data has lower AIC, and 
Residual Deviance should not be orders above the degrees of freedom.


However, the

Y ~ X + Y^2

Produces the best fitting line - it is pretty much on the data points - 
I'm trying to make a standard curve, with which to take readings from a 
spectrophotometer off of. Rather than what I would normally use models 
for - such as hypothesis testing and analysis of data from experiments.


Thanks,
Ben.

On 20/02/2011 11:53, nzcoops wrote:

model<- lm(Approximate.Counts~X..Light.Transmission +
I(Approximate.Counts^2), data=Standards)

Might not be addressing the problem, don't you have Y ~ X + Y^2 here? That's
a violation of the assumptions of an lm isn't it?

Also for plotting CI on a curve look into ggplot2::geom_ribbon, it's much
nicer than just plotting lines and is easy to use. had.co.nz should set you
right for setting this up.


__
R-help@r-project.org mailing list
https://stat.ethz.ch/mailman/listinfo/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] concatenate vector after strsplit()

2011-02-20 Thread Robert Baer
Thanks Jorge and David.  Both worked.  Looks like I have to read more on "[" 
as an extractor function for lists.  do.call() is also on my list of "low 
level magic' I don't understand.Appreciate the help!


fil1 = do.call(c, lapply(lapply(ls1, "[", 1:4), paste, sep = "", collapse = 
"-"))

fil2 = sapply(lapply(ls1, "[", 1:4), paste, collapse="-")

ls1 <- list(c("Focused", "10k", "A12", "t04.tif", "+", "µm"), 
c("Focused",

"10k", "A12", "t08.tif", "+", "µm"), c("Focused", "10k", "A12",
"t12.tif", "+", "µm"), c("Focused", "10k", "A12", "t16.tif",
"+", "µm"), c("Focused", "10k", "A12", "t20.tif", "+", "µm"),
  c("Focused", "10k", "A12", "t24.tif", "+", "µm"), c("Focused",
  "10k", "A12", "t36.tif", "+", "µm"), c("Focused", "10k",
  "A12", "t48.tif", "+", "µm"), c("Focused", "10k", "B12",
  "t04.tif", "+", "µm"), c("Focused", "10k", "B12", "t08.tif",
  "+", "µm"))


Perhaps:

> sapply(ls1, paste, collapse="")
[1] "Focused10kA12t04.tif+µm" "Focused10kA12t08.tif+µm"
[3] "Focused10kA12t12.tif+µm" "Focused10kA12t16.tif+µm"
[5] "Focused10kA12t20.tif+µm" "Focused10kA12t24.tif+µm"
[7] "Focused10kA12t36.tif+µm" "Focused10kA12t48.tif+µm"
[9] "Focused10kB12t04.tif+µm" "Focused10kB12t08.tif+µm"

(I changed the name and will not illustrate its assignment to  "file". It 
is generally considered poor programming practice  to use  function names 
for variable objects.)


I suppose it would be better practice on my part to read the question 
more thoroughly:


> sapply(lapply(ls1, "[", 1:4), paste, collapse="")
 [1] "Focused10kA12t04.tif" "Focused10kA12t08.tif"
 [3] "Focused10kA12t12.tif" "Focused10kA12t16.tif"
 [5] "Focused10kA12t20.tif" "Focused10kA12t24.tif"
 [7] "Focused10kA12t36.tif" "Focused10kA12t48.tif"
 [9] "Focused10kB12t04.tif" "Focused10kB12t08.tif"


--
David.


# Test the waters with one element
cat(unlist(ls[1])[1:4])  # WHY DOES THE COMMAND PROMPT NOT  APPEAR 
ON NEXT LINE AS USUAL???


# Appears to work except for command prompt glitch

# Attempts to use tapply() don't get me anywhere
file <- tapply(unlist(ls), list(1:length(unlist(ls))), 
cat(unlist(ls[1])[1:4]))


I'm grateful for an approach to putting my vector together, but I'd 
also love to understand the headache I've apparently given the  command 
parser.  I'm apparently doing some "no no".


Thanks,

Rob


R.Version()

$platform
[1] "i386-pc-mingw32"

$arch
[1] "i386"

$os
[1] "mingw32"

$system
[1] "i386, mingw32"

$status
[1] ""

$major
[1] "2"

$minor
[1] "12.1"

$year
[1] "2010"

$month
[1] "12"

$day
[1] "16"

$`svn rev`
[1] "53855"

$language
[1] "R"

$version.string
[1] "R version 2.12.1 (2010-12-16)"




David Winsemius, MD
West Hartford, CT

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

and provide commented, minimal, self-contained, reproducible code.



__
R-help@r-project.org mailing list
https://stat.ethz.ch/mailman/listinfo/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] concatenate vector after strsplit()

2011-02-20 Thread Gabor Grothendieck
On Sun, Feb 20, 2011 at 12:43 PM, Robert Baer  wrote:
>> You might try
>>
>> do.call(rbind, lapply(yourlist, "[", 1:4))
>
> Thanks, Jorge, but when I tried this I simply got a matrix of character
> strings rather than my original list of character strings as in:
>>
>> m = do.call(rbind, lapply(ls, "[", 1:4))
>> m
>
>     [,1]      [,2]  [,3]  [,4]
> [1,] "Focused" "10k" "A12" "t04.tif"
> [2,] "Focused" "10k" "A12" "t08.tif"
> [3,] "Focused" "10k" "A12" "t12.tif"
> [4,] "Focused" "10k" "A12" "t16.tif"
> [5,] "Focused" "10k" "A12" "t20.tif"
> [6,] "Focused" "10k" "A12" "t24.tif"
> [7,] "Focused" "10k" "A12" "t36.tif"
> [8,] "Focused" "10k" "A12" "t48.tif"
> [9,] "Focused" "10k" "B12" "t04.tif"
> [10,] "Focused" "10k" "B12" "t08.tif"
>>
> What I want to end up with is a vector that is the row-wise concatenation of
> the strings in each row of your matrix or each element of my original list.

Try this:

   sapply(ls, function(x) paste(x[1:4], collapse = ""))

or this:

   sapply(unname(as.data.frame(ls))[1:4,], paste, collapse = "")

If you don't mind ugly names on the result the last one can be shortened to:

   sapply(as.data.frame(ls)[1:4,], paste, collapse = "")

-- 
Statistics & Software Consulting
GKX Group, GKX Associates Inc.
tel: 1-877-GKX-GROUP
email: ggrothendieck at gmail.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] Conditional sum

2011-02-20 Thread mathijsdevaan

Thanks for the quick response, but it doesn't do the trick. There are two
problems:
1. The ith value of the newly created variable DF$D also includes the ith
value of DF$C (this problem is easily solved by DF$D = DF$D-DF$C.)
2. If group i in DF$group appears more than once in year t, the value of the
second observation of that group exceeds (includes) the value of the first
observation. Example (group b1 and a2 in 2001 are duplicated):

DF = data.frame(read.table(textConnection("group  year  C 
1 b1  1999  0.25 
2 c1  1999  0.25 
3 d1  1999  0.25 
4 a2  1999  0.25 
5 c2  1999  0.25 
6 d2  1999  0.25 
7 a3  1999  0.25 
8 b3  1999  0.25 
9 d3  1999  0.25 
10 a4  1999  0.25 
11 b4  1999  0.25 
12 c4  1999  0.25 
13 b1  2001  0.5 
14 a2  2001  0.5 
15 b1  2004  0.33 
16 c1  2004  0.33 
17 a2  2004  0.33 
18 c2  2004  0.33 
19 a3  2004  0.33 
20 b3  2004  0.33 
21 d2  1980  0.4 
22 a3  1980  0.4 
23 b4  1981  0.4 
24 c1  1981  0.4
25 b1  2001  0.5 
26 a2  2001  0.5"),head=TRUE)) 

by(DF,DF$group, FUN = function(x){print(str(x))}) 

DF = DF[order(DF$group,DF$year),] 

by(DF,DF$group, FUN = function(x){cumsum(x$C)}) 

by(DF,DF$group, FUN = function(x){cumsum(x$C)-x$C}) 

DF$D = unlist(by(DF,DF$group, FUN = function(x){cumsum(x$C)}))

DF$D = DF$D-DF$C
Dieter Menne wrote:
> 
> 
> mathijsdevaan wrote:
>> 
>> I have a DF like this:
>> 
>> DF = data.frame(read.table(textConnection("A  B  C 
>> 1 b1  1999  0.25
>> 2 c1  1999  0.25
>> ..
>> For each factor in A I want to sum the values of C for all years(Bn)
>> prior to the current year(Bi):
>> 
>> 1 b1  1999  0.25  0
>> 2 c1  1999  0.25  0.4
>> 3 d1  1999  0.25  0
>> 
>> 
> In steps following the "thinking order". You could shorten this
> considerably. I slightly changed you column names to more speakable ones.
> 
> Dieter
> 
> 
> DF = data.frame(read.table(textConnection("group  year  C
> 1 b1  1999  0.25
> 2 c1  1999  0.25
> 3 d1  1999  0.25
> 4 a2  1999  0.25
> 5 c2  1999  0.25
> 6 d2  1999  0.25
> 7 a3  1999  0.25
> 8 b3  1999  0.25
> 9 d3  1999  0.25
> 10 a4  1999  0.25
> 11 b4  1999  0.25
> 12 c4  1999  0.25
> 13 b1  2001  0.5
> 14 a2  2001  0.5
> 15 b1  2004  0.33
> 16 c1  2004  0.33
> 17 a2  2004  0.33
> 18 c2  2004  0.33
> 19 a3  2004  0.33
> 20 b3  2004  0.33
> 21 d2  1980  0.4
> 22 a3  1980  0.4
> 23 b4  1981  0.4
> 24 c1  1981  0.4"),head=TRUE))
> 
> by(DF,DF$group, FUN = function(x){
>   print(str(x))
> })
> # Looks like we should order...
> # Other solutions are possible, but ordering all first might (not tested)
> # be the most efficient way for large sets
> DF = DF[order(DF$group,DF$year),]
> # Let's try cumsum on each group
> by(DF,DF$group, FUN = function(x){
>   cumsum(x$C)
> })
> # That's not exactly your defininition of "prior"
> # correct for first value
> by(DF,DF$group, FUN = function(x){
>   cumsum(x$C)-x$C
> })
> # Now the data are  in right order, make vector of result
> DF$D = unlist(by(DF,DF$group, FUN = function(x){
>   cumsum(x$C)
> }))
> # You could sort by row names now to restore the old order
> 
> 

-- 
View this message in context: 
http://r.789695.n4.nabble.com/Conditional-sum-tp3315163p3315318.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] tikzDevice compiling problem

2011-02-20 Thread cuass

Thank you!
-- 
View this message in context: 
http://r.789695.n4.nabble.com/tikzDevice-compiling-problem-tp3309028p3315247.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] concatenate vector after strsplit()

2011-02-20 Thread David Winsemius


On Feb 20, 2011, at 12:49 PM, David Winsemius wrote:



On Feb 20, 2011, at 11:13 AM, Robert Baer wrote:


ls is a list of character vectors created by strsplit()

I want to concatenate  the 1st 4 character elements of each list  
item as a new vector called file.  I admit to being confused about  
list syntax even after numerous readings.


Here's what I tried:

ls <- list(c("Focused", "10k", "A12", "t04.tif", "+", "µm"),  
c("Focused",

"10k", "A12", "t08.tif", "+", "µm"), c("Focused", "10k", "A12",
"t12.tif", "+", "µm"), c("Focused", "10k", "A12", "t16.tif",
"+", "µm"), c("Focused", "10k", "A12", "t20.tif", "+", "µm"),
  c("Focused", "10k", "A12", "t24.tif", "+", "µm"), c("Focused",
  "10k", "A12", "t36.tif", "+", "µm"), c("Focused", "10k",
  "A12", "t48.tif", "+", "µm"), c("Focused", "10k", "B12",
  "t04.tif", "+", "µm"), c("Focused", "10k", "B12", "t08.tif",
  "+", "µm"))


Perhaps:

> sapply(ls1, paste, collapse="")
[1] "Focused10kA12t04.tif+µm" "Focused10kA12t08.tif+µm"
[3] "Focused10kA12t12.tif+µm" "Focused10kA12t16.tif+µm"
[5] "Focused10kA12t20.tif+µm" "Focused10kA12t24.tif+µm"
[7] "Focused10kA12t36.tif+µm" "Focused10kA12t48.tif+µm"
[9] "Focused10kB12t04.tif+µm" "Focused10kB12t08.tif+µm"

(I changed the name and will not illustrate its assignment to  
"file". It is generally considered poor programming practice  to use  
function names for variable objects.)


I suppose it would be better practice on my part to read the question  
more thoroughly:


> sapply(lapply(ls1, "[", 1:4), paste, collapse="")
 [1] "Focused10kA12t04.tif" "Focused10kA12t08.tif"
 [3] "Focused10kA12t12.tif" "Focused10kA12t16.tif"
 [5] "Focused10kA12t20.tif" "Focused10kA12t24.tif"
 [7] "Focused10kA12t36.tif" "Focused10kA12t48.tif"
 [9] "Focused10kB12t04.tif" "Focused10kB12t08.tif"


--
David.


# Test the waters with one element
cat(unlist(ls[1])[1:4])  # WHY DOES THE COMMAND PROMPT NOT  
APPEAR ON NEXT LINE AS USUAL???


# Appears to work except for command prompt glitch

# Attempts to use tapply() don't get me anywhere
file <- tapply(unlist(ls), list(1:length(unlist(ls))),  
cat(unlist(ls[1])[1:4]))


I'm grateful for an approach to putting my vector together, but I'd  
also love to understand the headache I've apparently given the  
command parser.  I'm apparently doing some "no no".


Thanks,

Rob


R.Version()

$platform
[1] "i386-pc-mingw32"

$arch
[1] "i386"

$os
[1] "mingw32"

$system
[1] "i386, mingw32"

$status
[1] ""

$major
[1] "2"

$minor
[1] "12.1"

$year
[1] "2010"

$month
[1] "12"

$day
[1] "16"

$`svn rev`
[1] "53855"

$language
[1] "R"

$version.string
[1] "R version 2.12.1 (2010-12-16)"




David Winsemius, MD
West Hartford, CT

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


Re: [R] concatenate vector after strsplit()

2011-02-20 Thread David Winsemius


On Feb 20, 2011, at 11:13 AM, Robert Baer wrote:


ls is a list of character vectors created by strsplit()

I want to concatenate  the 1st 4 character elements of each list  
item as a new vector called file.  I admit to being confused about  
list syntax even after numerous readings.


Here's what I tried:

ls <- list(c("Focused", "10k", "A12", "t04.tif", "+", "µm"),  
c("Focused",

"10k", "A12", "t08.tif", "+", "µm"), c("Focused", "10k", "A12",
"t12.tif", "+", "µm"), c("Focused", "10k", "A12", "t16.tif",
"+", "µm"), c("Focused", "10k", "A12", "t20.tif", "+", "µm"),
   c("Focused", "10k", "A12", "t24.tif", "+", "µm"), c("Focused",
   "10k", "A12", "t36.tif", "+", "µm"), c("Focused", "10k",
   "A12", "t48.tif", "+", "µm"), c("Focused", "10k", "B12",
   "t04.tif", "+", "µm"), c("Focused", "10k", "B12", "t08.tif",
   "+", "µm"))


Perhaps:

> sapply(ls1, paste, collapse="")
 [1] "Focused10kA12t04.tif+µm" "Focused10kA12t08.tif+µm"
 [3] "Focused10kA12t12.tif+µm" "Focused10kA12t16.tif+µm"
 [5] "Focused10kA12t20.tif+µm" "Focused10kA12t24.tif+µm"
 [7] "Focused10kA12t36.tif+µm" "Focused10kA12t48.tif+µm"
 [9] "Focused10kB12t04.tif+µm" "Focused10kB12t08.tif+µm"

(I changed the name and will not illustrate its assignment to "file".  
It is generally considered poor programming practice  to use function  
names for variable objects.)

--
David.


# Test the waters with one element
cat(unlist(ls[1])[1:4])  # WHY DOES THE COMMAND PROMPT NOT  
APPEAR ON NEXT LINE AS USUAL???


# Appears to work except for command prompt glitch

# Attempts to use tapply() don't get me anywhere
file <- tapply(unlist(ls), list(1:length(unlist(ls))),  
cat(unlist(ls[1])[1:4]))


I'm grateful for an approach to putting my vector together, but I'd  
also love to understand the headache I've apparently given the  
command parser.  I'm apparently doing some "no no".


Thanks,

Rob


R.Version()

$platform
[1] "i386-pc-mingw32"

$arch
[1] "i386"

$os
[1] "mingw32"

$system
[1] "i386, mingw32"

$status
[1] ""

$major
[1] "2"

$minor
[1] "12.1"

$year
[1] "2010"

$month
[1] "12"

$day
[1] "16"

$`svn rev`
[1] "53855"

$language
[1] "R"

$version.string
[1] "R version 2.12.1 (2010-12-16)"


[[alternative HTML version deleted]]

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


David Winsemius, MD
West Hartford, CT

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


Re: [R] concatenate vector after strsplit()

2011-02-20 Thread Robert Baer

You might try

do.call(rbind, lapply(yourlist, "[", 1:4))
Thanks, Jorge, but when I tried this I simply got a matrix of character 
strings rather than my original list of character strings as in:

m = do.call(rbind, lapply(ls, "[", 1:4))
m

 [,1]  [,2]  [,3]  [,4]
[1,] "Focused" "10k" "A12" "t04.tif"
[2,] "Focused" "10k" "A12" "t08.tif"
[3,] "Focused" "10k" "A12" "t12.tif"
[4,] "Focused" "10k" "A12" "t16.tif"
[5,] "Focused" "10k" "A12" "t20.tif"
[6,] "Focused" "10k" "A12" "t24.tif"
[7,] "Focused" "10k" "A12" "t36.tif"
[8,] "Focused" "10k" "A12" "t48.tif"
[9,] "Focused" "10k" "B12" "t04.tif"
[10,] "Focused" "10k" "B12" "t08.tif"


What I want to end up with is a vector that is the row-wise concatenation of 
the strings in each row of your matrix or each element of my original list. 
I thought the cat() function should get me part way there, but as I 
indicated below, there seem to be a parsing issue of some sort the way I'm 
using it.






ls is a list of character vectors created by strsplit()

I want to concatenate  the 1st 4 character elements of each list item as 
a

new vector called file.  I admit to being confused about list syntax even
after numerous readings.

Here's what I tried:

ls <- list(c("Focused", "10k", "A12", "t04.tif", "+", "µm"), c("Focused",
"10k", "A12", "t08.tif", "+", "µm"), c("Focused", "10k", "A12",
"t12.tif", "+", "µm"), c("Focused", "10k", "A12", "t16.tif",
"+", "µm"), c("Focused", "10k", "A12", "t20.tif", "+", "µm"),
   c("Focused", "10k", "A12", "t24.tif", "+", "µm"), c("Focused",
   "10k", "A12", "t36.tif", "+", "µm"), c("Focused", "10k",
   "A12", "t48.tif", "+", "µm"), c("Focused", "10k", "B12",
   "t04.tif", "+", "µm"), c("Focused", "10k", "B12", "t08.tif",
   "+", "µm"))

# Test the waters with one element
cat(unlist(ls[1])[1:4])  # WHY DOES THE COMMAND PROMPT NOT APPEAR ON
NEXT LINE AS USUAL???

# Appears to work except for command prompt glitch

# Attempts to use tapply() don't get me anywhere
file <- tapply(unlist(ls), list(1:length(unlist(ls))),
cat(unlist(ls[1])[1:4]))

I'm grateful for an approach to putting my vector together, but I'd also
love to understand the headache I've apparently given the command parser.
 I'm apparently doing some "no no".

Thanks,

Rob

> R.Version()
$platform
[1] "i386-pc-mingw32"

$arch
[1] "i386"

$os
[1] "mingw32"

$system
[1] "i386, mingw32"

$status
[1] ""

$major
[1] "2"

$minor
[1] "12.1"

$year
[1] "2010"

$month
[1] "12"

$day
[1] "16"

$`svn rev`
[1] "53855"

$language
[1] "R"

$version.string
[1] "R version 2.12.1 (2010-12-16)"


   [[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] Plot of set

2011-02-20 Thread David Winsemius


On Feb 20, 2011, at 4:41 AM, . . wrote:



I am in the situation where I have to make a two-dimential plot of a  
set. If I simplify my data it would be something along the lines of  
wanting to plot {x,y| x^2+y^2 < = 1}.
I am aware of the contour and persp plot, but cannot figure out how  
to convert one of those to draw the set. I have tried to google  
different ways of plotting in R but have not been able to find a  
method through that either.



I don't see a third dimension implied in what you presented:

x <- runif(1000)
y <- runif(1000)
plot(x[x^2 +y^2 < 1], y[x^2 +y^2 < 1])
title(main="Uncorrelated X and Y ointly satisfying condition")

--

David Winsemius, MD
West Hartford, CT

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


Re: [R] Conditional sum

2011-02-20 Thread Dieter Menne


mathijsdevaan wrote:
> 
> I have a DF like this:
> 
> DF = data.frame(read.table(textConnection("A  B  C 
> 1 b1  1999  0.25
> 2 c1  1999  0.25
> ..
> For each factor in A I want to sum the values of C for all years(Bn) prior
> to the current year(Bi):
> 
> 1 b1  1999  0.25  0
> 2 c1  1999  0.25  0.4
> 3 d1  1999  0.25  0
> 
> 
In steps following the "thinking order". You could shorten this
considerably. I slightly changed you column names to more speakable ones.

Dieter


DF = data.frame(read.table(textConnection("group  year  C
1 b1  1999  0.25
2 c1  1999  0.25
3 d1  1999  0.25
4 a2  1999  0.25
5 c2  1999  0.25
6 d2  1999  0.25
7 a3  1999  0.25
8 b3  1999  0.25
9 d3  1999  0.25
10 a4  1999  0.25
11 b4  1999  0.25
12 c4  1999  0.25
13 b1  2001  0.5
14 a2  2001  0.5
15 b1  2004  0.33
16 c1  2004  0.33
17 a2  2004  0.33
18 c2  2004  0.33
19 a3  2004  0.33
20 b3  2004  0.33
21 d2  1980  0.4
22 a3  1980  0.4
23 b4  1981  0.4
24 c1  1981  0.4"),head=TRUE))

by(DF,DF$group, FUN = function(x){
  print(str(x))
})
# Looks like we should order...
# Other solutions are possible, but ordering all first might (not tested)
# be the most efficient way for large sets
DF = DF[order(DF$group,DF$year),]
# Let's try cumsum on each group
by(DF,DF$group, FUN = function(x){
  cumsum(x$C)
})
# That's not exactly your defininition of "prior"
# correct for first value
by(DF,DF$group, FUN = function(x){
  cumsum(x$C)-x$C
})
# Now the data are  in right order, make vector of result
DF$D = unlist(by(DF,DF$group, FUN = function(x){
  cumsum(x$C)
}))
# You could sort by row names now to restore the old order

-- 
View this message in context: 
http://r.789695.n4.nabble.com/Conditional-sum-tp3315163p3315279.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] prevent export of specific functions in NAMESPACE

2011-02-20 Thread Rajarshi Guha
Hi, I'd like to prevent the export a specific function in the
NAMESPACE file. The example in the R documentation uses a regex to
prevent export of a set of functions, but as far as I can see there is
no easy way to specify that a function of a specific name should not
be exported. This thread
(http://www.mail-archive.com/r-help@r-project.org/msg42961.html)
suggests that a regex is not the way to 'negate' a string literal.

So to prevent export of specific functions, do I need to explicitly
list all functions that are to be exported?

-- 
Rajarshi Guha
NIH Chemical Genomics Center

__
R-help@r-project.org mailing list
https://stat.ethz.ch/mailman/listinfo/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] concatenate vector after strsplit()

2011-02-20 Thread Jorge Ivan Velez
Hi Robert,

You might try

do.call(rbind, lapply(yourlist, "[", 1:4))

and then write the resulting file using write.table(...).

Best,
Jorge

On Sun, Feb 20, 2011 at 11:13 AM, Robert Baer <> wrote:

> ls is a list of character vectors created by strsplit()
>
> I want to concatenate  the 1st 4 character elements of each list item as a
> new vector called file.  I admit to being confused about list syntax even
> after numerous readings.
>
> Here's what I tried:
>
> ls <- list(c("Focused", "10k", "A12", "t04.tif", "+", "µm"), c("Focused",
> "10k", "A12", "t08.tif", "+", "µm"), c("Focused", "10k", "A12",
> "t12.tif", "+", "µm"), c("Focused", "10k", "A12", "t16.tif",
> "+", "µm"), c("Focused", "10k", "A12", "t20.tif", "+", "µm"),
>c("Focused", "10k", "A12", "t24.tif", "+", "µm"), c("Focused",
>"10k", "A12", "t36.tif", "+", "µm"), c("Focused", "10k",
>"A12", "t48.tif", "+", "µm"), c("Focused", "10k", "B12",
>"t04.tif", "+", "µm"), c("Focused", "10k", "B12", "t08.tif",
>"+", "µm"))
>
> # Test the waters with one element
> cat(unlist(ls[1])[1:4])  # WHY DOES THE COMMAND PROMPT NOT APPEAR ON
> NEXT LINE AS USUAL???
>
> # Appears to work except for command prompt glitch
>
> # Attempts to use tapply() don't get me anywhere
> file <- tapply(unlist(ls), list(1:length(unlist(ls))),
> cat(unlist(ls[1])[1:4]))
>
> I'm grateful for an approach to putting my vector together, but I'd also
> love to understand the headache I've apparently given the command parser.
>  I'm apparently doing some "no no".
>
> Thanks,
>
> Rob
>
> > R.Version()
> $platform
> [1] "i386-pc-mingw32"
>
> $arch
> [1] "i386"
>
> $os
> [1] "mingw32"
>
> $system
> [1] "i386, mingw32"
>
> $status
> [1] ""
>
> $major
> [1] "2"
>
> $minor
> [1] "12.1"
>
> $year
> [1] "2010"
>
> $month
> [1] "12"
>
> $day
> [1] "16"
>
> $`svn rev`
> [1] "53855"
>
> $language
> [1] "R"
>
> $version.string
> [1] "R version 2.12.1 (2010-12-16)"
>
>
>[[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] concatenate vector after strsplit()

2011-02-20 Thread Robert Baer
ls is a list of character vectors created by strsplit()

I want to concatenate  the 1st 4 character elements of each list item as a new 
vector called file.  I admit to being confused about list syntax even after 
numerous readings.

Here's what I tried:

ls <- list(c("Focused", "10k", "A12", "t04.tif", "+", "µm"), c("Focused", 
"10k", "A12", "t08.tif", "+", "µm"), c("Focused", "10k", "A12", 
"t12.tif", "+", "µm"), c("Focused", "10k", "A12", "t16.tif", 
"+", "µm"), c("Focused", "10k", "A12", "t20.tif", "+", "µm"), 
c("Focused", "10k", "A12", "t24.tif", "+", "µm"), c("Focused", 
"10k", "A12", "t36.tif", "+", "µm"), c("Focused", "10k", 
"A12", "t48.tif", "+", "µm"), c("Focused", "10k", "B12", 
"t04.tif", "+", "µm"), c("Focused", "10k", "B12", "t08.tif", 
"+", "µm"))

# Test the waters with one element
cat(unlist(ls[1])[1:4])  # WHY DOES THE COMMAND PROMPT NOT APPEAR ON NEXT 
LINE AS USUAL???

# Appears to work except for command prompt glitch

# Attempts to use tapply() don't get me anywhere
file <- tapply(unlist(ls), list(1:length(unlist(ls))), cat(unlist(ls[1])[1:4]))

I'm grateful for an approach to putting my vector together, but I'd also love 
to understand the headache I've apparently given the command parser.  I'm 
apparently doing some "no no".

Thanks,

Rob

> R.Version()
$platform
[1] "i386-pc-mingw32"

$arch
[1] "i386"

$os
[1] "mingw32"

$system
[1] "i386, mingw32"

$status
[1] ""

$major
[1] "2"

$minor
[1] "12.1"

$year
[1] "2010"

$month
[1] "12"

$day
[1] "16"

$`svn rev`
[1] "53855"

$language
[1] "R"

$version.string
[1] "R version 2.12.1 (2010-12-16)"


[[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 Metafor

2011-02-20 Thread petretta


   Dear Sir, I'm using the "Metafor" package;

   however, introducing moderators, I'm unable to obtain both I^2 (%  
of total variability due to heterogeneity) and H^2 (total variability  
/ within-study variance). It is possible to obtain I^2 and H^2 also  
with moderators?

   As example

   _Dataset <- sqlQuery(channel = 1, select * from [Foglio1$])

   names(Dataset) <- make.names(names(Dataset))

   alloc.a <- ifelse(dat$alloc == "a", 1, 0)

   alloc.b <- ifelse(dat$alloc == "b", 1, 0)

   alloc.c <- ifelse(dat$alloc == "c", 1, 0)

   res<-rma.uni(yi, vi, mods=cbind(alloc.a, alloc.b, Year),  
measure="GEN", intercept=TRUE, data=dat, slab=Author, subset, add=1/2,  
to="only0", vtype="LS", method="REML", weighted=TRUE, knha=FALSE,  
btt=c(2,3))

   > print (res)

   Mixed-Effects Model (k = 22; tau^2 estimator: REML)

   tau^2 (estimate of residual amount of heterogeneity): 0.7810 (SE = 0.2924)

   tau (sqrt of the estimate of residual heterogeneity): 0.8838

   Test for Residual Heterogeneity:

   QE(df = 18) = 223.3159, p-val < .0001

   Test of Moderators (coefficient(s) 2,3):

   QM(df = 2) = 0.8251, p-val = 0.6620

   Model Results:

     estimate   se zval    pval  ci.lb ci.ub  

   intrcpt  -135.3524  54.4487  -2.4859  0.0129  -242.0700  -28.6349  *

   alloc.a    -0.3836   0.4529  -0.8469  0.3971    -1.2713    0.5042  

   alloc.b    -0.3656   0.5529  -0.6613  0.5084    -1.4493    0.7180  

   Year    0.0673   0.0273   2.4677  0.0136 0.0139    0.1208  *

   Many thanks

   _

   Mario Petretta
Dipartimento di Medicina Clinica Scienze Cardiovascolari e Immunologiche
Facoltà di Medicina e Chirurgia
Università di Napoli Federico II
081 - 7462233



[[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] Plot of set

2011-02-20 Thread . .

I am in the situation where I have to make a two-dimential plot of a set. If I 
simplify my data it would be something along the lines of wanting to plot {x,y| 
x^2+y^2 < = 1}. 
I am aware of the contour and persp plot, but cannot figure out how to convert 
one of those to draw the set. I have tried to google different ways of plotting 
in R but have not been able to find a method through that either. 
 
Thanks in advance
 
Lise  
[[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] Conditional sum

2011-02-20 Thread mathijsdevaan

Hi,

I have a DF like this:

DF = data.frame(read.table(textConnection("A  B  C 
1 b1  1999  0.25
2 c1  1999  0.25
3 d1  1999  0.25
4 a2  1999  0.25
5 c2  1999  0.25
6 d2  1999  0.25
7 a3  1999  0.25
8 b3  1999  0.25
9 d3  1999  0.25
10 a4  1999  0.25
11 b4  1999  0.25
12 c4  1999  0.25
13 b1  2001  0.5
14 a2  2001  0.5
15 b1  2004  0.33
16 c1  2004  0.33
17 a2  2004  0.33
18 c2  2004  0.33
19 a3  2004  0.33
20 b3  2004  0.33
21 d2  1980  0.4
22 a3  1980  0.4
23 b4  1981  0.4
24 c1  1981  0.4"),head=TRUE,stringsAsFactors=FALSE))

For each factor in A I want to sum the values of C for all years(Bn) prior
to the current year(Bi):

1 b1  1999  0.25  0
2 c1  1999  0.25  0.4
3 d1  1999  0.25  0
4 a2  1999  0.25  0
5 c2  1999  0.25  0
6 d2  1999  0.25  0.4
7 a3  1999  0.25  0.4
8 b3  1999  0.25  0
9 d3  1999  0.25  0
10 a4 1999  0.25  0
11 b4 1999  0.25  0.4
12 c4 1999  0.25  0
13 b1 2001  0.50  0.25
14 a2 2001  0.50  0.25
15 b1 2004  0.33  0.75
16 c1 2004  0.33  0.65
17 a2 2004  0.33  0.75
18 c2 2004  0.33  0.25
19 a3 2004  0.33  0.65
20 b3 2004  0.33  0.25
21 d2 1980  0.40  0
22 a3 1980  0.40  0
23 b4 1981  0.40  0
24 c1 1981  0.40  0

If I do this - DF$D<-ave(DF$C,DF$A,FUN = function(x) sum(x)) - it returns
for each factor the sum of C for all years. How do I build the (B) condition
in this function? Thanks very much! 

-- 
View this message in context: 
http://r.789695.n4.nabble.com/Conditional-sum-tp3315163p3315163.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] Confidence Intervals on Standard Curve

2011-02-20 Thread nzcoops

model <- lm(Approximate.Counts~X..Light.Transmission +
I(Approximate.Counts^2), data=Standards) 

Might not be addressing the problem, don't you have Y ~ X + Y^2 here? That's
a violation of the assumptions of an lm isn't it?

Also for plotting CI on a curve look into ggplot2::geom_ribbon, it's much
nicer than just plotting lines and is easy to use. had.co.nz should set you
right for setting this up.
-- 
View this message in context: 
http://r.789695.n4.nabble.com/Confidence-Intervals-on-Standard-Curve-tp3313850p3315071.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] inter-specific competition - community matrices and two species models using Lotka-Volterra

2011-02-20 Thread Bob O'Hara
On 20 February 2011 16:19, Chris Buddenhagen  wrote:

> Does anyone know of example r-code/packages for carrying out analysis?
> Preferably this would have examples from real experimental data of two or
> more competing species...
>
> In discrete time, you can use a Gompertz model:

which reduces to a VAR(1) model, which is a multivariate time series model,
check here:


Bob

-- 
Bob O'Hara

Biodiversity and Climate Research Centre
Senckenberganlage 25
D-60325 Frankfurt am Main,
Germany

Tel: +49 69 798 40216
Mobile: +49 1515 888 5440
WWW:   http://www.bik-f.de/root/index.php?page_id=219
Blog: http://blogs.nature.com/boboh
Journal of Negative Results - EEB: www.jnr-eeb.org

[[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] inter-specific competition - community matrices and two species models using Lotka-Volterra

2011-02-20 Thread Chris Buddenhagen
Does anyone know of example r-code/packages for carrying out analysis?
Preferably this would have examples from real experimental data of two or
more competing species...

Thanks

Chris Buddenhagen

[[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] Seeking help in Package development

2011-02-20 Thread Uwe Ligges
May I add that the best documentation for building packages is the 
"Writing R Extensions" that ships with the current R version. It is 
always current, precise, and not as outdated as many resources you find 
"somewhere" in the web - yes, the one cited below is outdated.


Uwe Ligges


On 19.02.2011 22:59, Joshua Wiley wrote:

Dear Nipesh,

On Sat, Feb 19, 2011 at 1:39 PM, Nipesh Bajaj  wrote:

Dear all, I am a new user of R and currently trying hard to develop my
own package. Here I am following this tutorial
'http://www.mathfinance.cn/how-to-create-an-R-package-in-windows/'

Here it says that (step 8): "open a “command prompt” window, change
the directory to where your package is, type the command “R CMD build
MonteCarloPi” to build the package, this will generate a file called
MonteCarloPi_1.0.tar.gz. "

According to that, I have opened the Windows command prompt window (a
black screen window) and then changed the directory, where my new
package (a folder in current working directory in R, as created by
'package.skeleton') is there. Then typed 'R CMD build MyPackage' (I
named my package as 'MyPackage'). However doing so I got following
error in that command prompt:

'R' is not recognized as an internal or external command, operable
program or batch file.


This suggests that either your current directory does not contain R
and you have not added the directory containing R to the PATH
environment variable in Windows.  For that command to work, Windows
needs to know where to find the program to execute.  You might find
this site useful for becoming more familiar with the Windows command
prompt (geared towards XP, but cmd.exe has changed little from XP to
Vista, to 7---though increasing MS is encouraging users to switch over
to using the Windows powershell):

http://www.microsoft.com/resources/documentation/windows/xp/all/proddocs/en-us/ntcmds.mspx?mfr=true



Can somebody please guide me what to do in this situation?


You should also read the official R manual on installing and building
R from source.  Particularly pay attention to the sections for Windows
users.  You may want to get Rtools and certainly follow the
instructions to add all the necessary directories to your PATH
variable.  The steps will be something like:

Right click My Computer ->  Click Properties ->  Click Advanced ->  Click
Environment Variables ->  edit the variable "PATH" to include relevant
R directories.  Please note that this is not an exact step-by-step
process as it varies slightly by different versions of Windows.

Official R Installation Manual (very relevant for building packages):
http://cran.r-project.org/doc/manuals/R-admin.html

Good luck,

Josh



Best 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-help@r-project.org mailing list
https://stat.ethz.ch/mailman/listinfo/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] covar

2011-02-20 Thread Juliet Hannah
Relatedness if often defined in terms of the kinship matrix. It may be
helpful to search for this. Several packages in R use this matrix
including the kinship package.

On Wed, Feb 16, 2011 at 3:14 PM, Val  wrote:
> Hi all,
>
> I want to construct relatedness among individuals and have a look at the
> following script.
>
> #
> rm(list=ls())
>
> N=5
> id   = c(1:N)
> dad = c(0,0,0,3,3)
> mom  = c(0,0,2,1,1)
> sex  = c(2,2,1,2,2) # 1= M and 2=F
>
>   A=diag(nrow = N)
>   for(i in 1:N)    {
>      for(j in i:N)      {
>         ss = dad[j]
>         dd = mom[j]
>         sx = sex[j]
>          if( ss > 0 && dd > 0 )
>            {
>              if(i == j)
>                   { A[i,i] = 1 + 0.5*A[ss,dd] }
>                 else
>                  { A[i,j] = A[i,ss] + 0.5*(A[i,dd])
>                    A[j,i] = A[i,j] }
>            }
>
>      } #inner for loop
>     } # outer for loop
>  A
>
> If the sex is male ( sex=1)  then I want to set A[i,i]=0.5*A[ss,dd]
> If it is female ( sex=2) then A[i,i] = 1 + 0.5*A[ss,dd]
>
>
> How do I do it ?
>
> I tried several cases but it did not work from me. Your assistance is
> highly  appreciated  in advance
>
> Thanks
>
>        [[alternative HTML version deleted]]
>
> __
> R-help@r-project.org mailing list
> https://stat.ethz.ch/mailman/listinfo/r-help
> PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
> and provide commented, minimal, self-contained, reproducible code.
>

__
R-help@r-project.org mailing list
https://stat.ethz.ch/mailman/listinfo/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] pre-announcement Google Summer of Code 2011 -- R projects

2011-02-20 Thread Prof. John C Nash
In a little over a month (Mar 28), students will have just over a week (until 
April 8) to
apply to work on Google Summer of Code projects. In the past few years, R has 
had several
such projects funded. Developers and mentors are currently preparing project 
outlines on
the R wiki at http://rwiki.sciviews.org/doku.php?id=developers:projects:gsoc2011

This is just a pre-announcement, as the application time will be very short.

Please let Claudia Beleites or I know if there are any errors or other problems 
on that page.

JN

__
R-help@r-project.org mailing list
https://stat.ethz.ch/mailman/listinfo/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] Generating uniformly distributed correlated data.

2011-02-20 Thread Sarah Goslee
On Sun, Feb 20, 2011 at 12:18 AM, Peter Langfelder
 wrote:
> On Sat, Feb 19, 2011 at 6:17 PM, Søren Faurby
>  wrote:
>> I wish to generate a vector of uniformly distributed data with a defined
>> correlation to another vector
>>
>> The only function I have been able to find doing something similar is corgen
>> from the library ecodist.
>>
>> The following code generates data with the desired correlation to the vector
>> x but the resulting vector y is normal and not uniform distributed
>>
>> library(ecodist)
>> x <- runif(10^5)
>> y <- corgen(x=x, r=.5)$y
>>
>> Do anyone know a similar function generating uniform distributed data or a
>> way of transforming y to the desired distribution while keeping the
>> correlation between x and y
>
> Hi Soren,
>
> I'm not aware of such functions, but you can try the following code:
>
> # generate some x
> n = 100
> x = runif(n)
> r = 0.5;
>
> y = r * scale(x) + sqrt(1-r^2) * scale(runif(n));
>
> cor(x,y)
>

That's the method used in corgen() and it produces a normally-distributed y even
if x is uniform.

Correlated normals are a much easier problem than correlated uniforms.

Maybe some of the other links will give you ideas.

Sarah
--
Sarah Goslee
http://www.functionaldiversity.org

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


Re: [R] Scaling Lattice Graphics for tikzDevice

2011-02-20 Thread Deepayan Sarkar
On Sun, Feb 20, 2011 at 5:23 AM, Elliot Joel Bernstein
 wrote:
>
> On Feb 18, 2011 11:02 PM, "Deepayan Sarkar" 
> wrote:
>>
>> On Fri, Feb 18, 2011 at 11:04 PM, Elliot Joel Bernstein
>>  wrote:
>> > I'm trying to use lattice graphics to produce some small plots for
>> > inclusion in a LaTeX file. I want the LaTeX fonts to be used in the plots,
>> > but to be scaled down to match the size of the plot. I have written the
>> > following code to apply a scaling factor to all the "cex" and "padding"
>> > entries in the trellis parameters, but there is still a large white space
>> > between the key and the top of the plot area. Does anyone know how I can 
>> > get
>> > rid of that (or if I'm going about this all wrong and there's a much 
>> > cleaner
>> > way)?
>> >
>> > ## -- ##
>> > ## test.R ##
>> > ## -- ##
>> >
>> > require(tikzDevice)
>>
>> I have not (yet) used tikzDevice, so don't know what impact it will
>> have, but in my experience with pdf(), it's usually more effective to
>> create a larger file and then scale it when including it in the .tex
>> file.
>>
>> -Deepayan
>>

[...]

>
> Deepayan -
>
> Thank you for your reply. In the past I've generally done what you suggest,
> but I'm trying to use tikz so the graphics can inherit the fonts used in the
> LaTeX document. Is there a way to do that with the pdf device?

Probably not, but look at the ?cairo_pdf device. It can use locally
installed truetype fonts through fontconfig, and truetype versions of
computer modern are available (I knew the details once, but don't have
time to find them again right now).

Also look at http://www.stat.auckland.ac.nz/~paul/R/CM/CMR.html

-Deepayan

__
R-help@r-project.org mailing list
https://stat.ethz.ch/mailman/listinfo/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] Generating uniformly distributed correlated data.

2011-02-20 Thread Enrico Schumann

maybe this helps
http://comisef.wikidot.com/tutorial:correlateduniformvariates

regards
enrico 

> -Ursprüngliche Nachricht-
> Von: r-help-boun...@r-project.org 
> [mailto:r-help-boun...@r-project.org] Im Auftrag von Søren Faurby
> Gesendet: Sonntag, 20. Februar 2011 03:18
> An: r-help@r-project.org
> Betreff: [R] Generating uniformly distributed correlated data.
> 
> I wish to generate a vector of uniformly distributed data 
> with a defined correlation to another vector
> 
> The only function I have been able to find doing something 
> similar is corgen from the library ecodist.
> 
> The following code generates data with the desired 
> correlation to the vector x but the resulting vector y is 
> normal and not uniform distributed
> 
> library(ecodist)
> x <- runif(10^5)
> y <- corgen(x=x, r=.5)$y
> 
> Do anyone know a similar function generating uniform 
> distributed data or a way of transforming y to the desired 
> distribution while keeping the correlation between x and y
> 
> Kind regards, Soren
> 
> __
> R-help@r-project.org mailing list
> https://stat.ethz.ch/mailman/listinfo/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] Generating uniformly distributed correlated data.

2011-02-20 Thread Spencer Graves
   You may also be interested in the "psych" package or possibly 
"mvtBinaryEP".  I found these using "sos":


library(sos)
tc <- findFn('tetrachoric correlation') # 26 matches
tcs <- findFn('tetrachoric correlations')#27 matches
tc. <- tc|tcs
summary(tc.) # 35 links in 5 pkgs
tc.


   All but 3 of the 35 links are to "psych", and 2 of the remaining 
3 are to two different copies of "mvtBinaryEP".  You might also Google 
for "tetrachoric correlation".


# OR:
u <- findFn('uniformly distributed correlated data') # 3 matches


   Hope this helps.
   Spencer


On 2/19/2011 9:21 PM, Jorge Ivan Velez wrote:
> Hi Soren,
>
> Take a look at http://tolstoy.newcastle.edu.au/R/help/05/07/7741.html
>
> HTH,
> Jorge
>
>
> On Sat, Feb 19, 2011 at 9:17 PM, Søren Faurby<>  wrote:
>
>> I wish to generate a vector of uniformly distributed data with a defined
>> correlation to another vector
>>
>> The only function I have been able to find doing something similar is
>> corgen from the library ecodist.
>>
>> The following code generates data with the desired correlation to the
>> vector x but the resulting vector y is normal and not uniform distributed
>>
>> library(ecodist)
>> x<- runif(10^5)
>> y<- corgen(x=x, r=.5)$y
>>
>> Do anyone know a similar function generating uniform distributed data or a
>> way of transforming y to the desired distribution while keeping the
>> correlation between x and y
>>
>> Kind regards, Soren
>>
>> __
>> R-help@r-project.org mailing list
>> https://stat.ethz.ch/mailman/listinfo/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.

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