[R] can rows of text be repeated using R to create a new datafile

2006-07-08 Thread Bob Green
I am hoping for some advice as to whether the following task can be 
performed in R?

I have a spreadsheet with 325 rows x 3 columns. The data was collected from 
40 individuals who in most instances generated 8 bi-polar constructs  (the 
poles are separated by //). The first column is the construct number = 
1  to 325. The second is an id number =1 to 40; the third column is the 
data to be coded.  Because persons 1, 18 & 40 generated 9 rows of data, and 
person 5, 10 rows; rows =325 not 320.

What I want to do is repeat each row a set number of times - hopefully 4 
(the number of coders to code the data). Once repeated there would be 4 
conids x 1 , 4  x 2 etc …. 4x 325.


Currently this is how the first 2 rows look:

conid   person  construct
1   1   offence against property  // offence against person
2   1   insight & cooperative with treatment //  lack insight

This is how I want them to look after editing.

conid   person  construct
1   1   offence against property  // offence against person
1   1   offence against property  // offence against person
1   1   offence against property  // offence against person
1   1   offence against property  // offence against person
2   1   insight & cooperative with treatment //  lack insight
2   1   insight & cooperative with treatment //  lack insight
2   1   insight & cooperative with treatment //  lack insight
2   1   insight & cooperative with treatment //  lack insight
2   1   insight & cooperative with treatment //  lack insight



Any assistance is much appreciated,

Bob

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


Re: [R] can rows of text be repeated using R to create a new datafile

2006-07-08 Thread Gabor Grothendieck
Open Excel, select the data and press ctrl-C.
In R, type this line at the console to
read the clipboard into a data frame DF (or
see the section on Excel in the R Import/Export
manual for other ways):

  DF <- read.delim("clipboard", header = TRUE)

Now you can do this:

   DF[rep(1:nrow(DF), each = 4),]

On 7/8/06, Bob Green <[EMAIL PROTECTED]> wrote:
> I am hoping for some advice as to whether the following task can be
> performed in R?
>
> I have a spreadsheet with 325 rows x 3 columns. The data was collected from
> 40 individuals who in most instances generated 8 bi-polar constructs  (the
> poles are separated by //). The first column is the construct number =
> 1  to 325. The second is an id number =1 to 40; the third column is the
> data to be coded.  Because persons 1, 18 & 40 generated 9 rows of data, and
> person 5, 10 rows; rows =325 not 320.
>
> What I want to do is repeat each row a set number of times - hopefully 4
> (the number of coders to code the data). Once repeated there would be 4
> conids x 1 , 4  x 2 etc …. 4x 325.
>
>
> Currently this is how the first 2 rows look:
>
> conid   person  construct
> 1   1   offence against property  // offence against person
> 2   1   insight & cooperative with treatment //  lack insight
>
> This is how I want them to look after editing.
>
> conid   person  construct
> 1   1   offence against property  // offence against person
> 1   1   offence against property  // offence against person
> 1   1   offence against property  // offence against person
> 1   1   offence against property  // offence against person
> 2   1   insight & cooperative with treatment //  lack insight
> 2   1   insight & cooperative with treatment //  lack insight
> 2   1   insight & cooperative with treatment //  lack insight
> 2   1   insight & cooperative with treatment //  lack insight
> 2   1   insight & cooperative with treatment //  lack insight
>
>
>
> Any assistance is much appreciated,
>
> Bob

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


Re: [R] parametric proportional hazard regression

2006-07-08 Thread Valentin Dimitrov


--- Frank E Harrell Jr <[EMAIL PROTECTED]>
wrote:


> That will be a very strange model that I've never
> seen used before in 
> survival analysis.  Interpretation of parameters
> other than the hazard 
> ratio may be tricky.  Why do you need a
> nontraditional model such as this?
> 
> Frank
> 
> -- 
> Frank E Harrell Jr   Professor and Chair  
> School of Medicine
>   Department of Biostatistics  
> Vanderbilt University
> 


I am new to the field of survival analysis and my
first  text read on that topic is Franses/Paap,
Quantitative Models in Marketing Research, Chapter 8.
There the kind of models I describe are the standard
proportional hazard models. But also in Internet I
find texts which say something about parametric PH
models, where the baseline hazard can take some
specific form! See for instance:
http://www.weibull.com/AccelTestWeb/proportional_hazards_model.htm
The second part reads "parametric PH models" and there
is an example with the Weibull baseline distribution.
The log-likelihood is derived, too. The same could be
done with the other distributions I mentioned
(lognormal, loglogistic, exponential). 
Anyway, if you say these models are untraditional,
then maybe there is also no R-function for them...
In that case I'll write a R-code myself to fit them
using ML.

Kind regards,
Valentin

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


Re: [R] parametric proportional hazard regression

2006-07-08 Thread Gabor Grothendieck
There is some generalized F code (which would
include many other parameteric survival models as
submodels) at this page.  The R package seems
somewhat non-standard in terms of installation
and I have not tried it:
http://www.math.mun.ca/~ypeng/research/

On 7/8/06, Valentin Dimitrov <[EMAIL PROTECTED]> wrote:
>
> I am new to the field of survival analysis and my
> first  text read on that topic is Franses/Paap,
> Quantitative Models in Marketing Research, Chapter 8.
> There the kind of models I describe are the standard
> proportional hazard models. But also in Internet I
> find texts which say something about parametric PH
> models, where the baseline hazard can take some
> specific form! See for instance:
> http://www.weibull.com/AccelTestWeb/proportional_hazards_model.htm
> The second part reads "parametric PH models" and there
> is an example with the Weibull baseline distribution.
> The log-likelihood is derived, too. The same could be
> done with the other distributions I mentioned
> (lognormal, loglogistic, exponential).
> Anyway, if you say these models are untraditional,
> then maybe there is also no R-function for them...
> In that case I'll write a R-code myself to fit them
> using ML.
>
> Kind regards,
> Valentin
>
> __
> R-help@stat.math.ethz.ch mailing list
> https://stat.ethz.ch/mailman/listinfo/r-help
> PLEASE do read the posting guide! http://www.R-project.org/posting-guide.html
>

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


[R] Availability of quadplot3d package (UseR!2006 Four Dimensional Barycentric Plots in 3D)

2006-07-08 Thread Carlos Ortega
Dear List,

I have been unable fo find the package quadplot3d referred in the
Abstract/Presentation "Four Dimensional Barycentric Plot in 3D" presented in
the UserR!2006.

Does anyone know if it is available ? And if so, if it is ported to Windows
?

Thanks in anticipation,
Carlos Ortega

[[alternative HTML version deleted]]

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


[R] survfit, unused argument(s) (error ...)

2006-07-08 Thread Søren Merser
Hi 

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

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

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

Regards Soren

Windows XP, SP2
R 2.3.0

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


Re: [R] KhmaladzeTest

2006-07-08 Thread roger koenker
Questions about packages should be directed to the package maintainers.
A more concise example of the difficulty, with accessible data would  
also be helpful.

url:www.econ.uiuc.edu/~rogerRoger Koenker
email   [EMAIL PROTECTED]   Department of Economics
vox:217-333-4558University of Illinois
fax:217-244-6678Champaign, IL 61820


On Jul 7, 2006, at 7:39 PM, raul sanchez wrote:

> Hello. I am a beginer in R and I can not implement the  
> KhmaladzeTest in the following command. Please help me!!!
>   PD: I attach thw results and the messages of the R program
>
>   R : Copyright 2006, The R Foundation for Statistical Computing
> Version 2.3.1 (2006-06-01)
> ISBN 3-900051-07-0
>
> R es un software libre y viene sin GARANTIA ALGUNA.
> Usted puede redistribuirlo bajo ciertas circunstancias.
> Escriba 'license()' o 'licence()' para detalles de distribucion.
>
> R es un proyecto colaborativo con muchos contribuyentes.
> Escriba 'contributors()' para obtener mas informacion y
> 'citation()' para saber como citar R o paquetes de R en publicaciones.
>
> Escriba 'demo()' para demostraciones, 'help()' para el sistema on-line
> de ayuda,
> o 'help.start()' para abrir el sistema de ayuda HTML con su navegador.
> Escriba 'q()' para salir de R.
>
>> utils:::menuInstallLocal()
> package 'quantreg' successfully unpacked and MD5 sums checked
> updating HTML package descriptions
>> utils:::menuInstallLocal()
> package 'foreign' successfully unpacked and MD5 sums checked
> updating HTML package descriptions
>> utils:::menuInstallLocal()
> package 'Rcmdr' successfully unpacked and MD5 sums checked
> updating HTML package descriptions
>> local({pkg <- select.list(sort(.packages(all.available = TRUE)))
> + if(nchar(pkg)) library(pkg, character.only=TRUE)})
>> local({pkg <- select.list(sort(.packages(all.available = TRUE)))
> + if(nchar(pkg)) library(pkg, character.only=TRUE)})
> quantreg package loaded:  To cite see citation("quantreg")
>> local({pkg <- select.list(sort(.packages(all.available = TRUE)))
> + if(nchar(pkg)) library(pkg, character.only=TRUE)})
>> local({pkg <- select.list(sort(.packages(all.available = TRUE)))
> + if(nchar(pkg)) library(pkg, character.only=TRUE)})
> Loading required package: tcltk
> Loading Tcl/Tk interface ... done
> --- Please select a CRAN mirror for use in this session ---
> also installing the dependencies 'acepack', 'scatterplot3d',  
> 'fBasics',
> 'Hmisc', 'quadprog', 'oz', 'mlbench', 'randomForest', 'SparseM',
> 'xtable', 'chron', 'fCalendar', 'its', 'tseries', 'DAAG', 'e1071',  
> 'mvtnorm',
> 'zoo', 'strucchange', 'sandwich', 'dynlm', 'leaps'
>
> probando la URL
> 'http://cran.au.r-project.org/bin/windows/contrib/2.3/ 
> acepack_1.3-2.2.zip'
> Content
> type 'application/zip' length 55667 bytes
> URL abierta
> downloaded 54Kb
>
> probando la URL
> 'http://cran.au.r-project.org/bin/windows/contrib/2.3/ 
> scatterplot3d_0.3-24.zip'
> Content
> type 'application/zip' length 540318 bytes
> URL abierta
> downloaded 527Kb
>
> probando la URL
> 'http://cran.au.r-project.org/bin/windows/contrib/2.3/ 
> fBasics_221.10065.zip'
> Content
> type 'application/zip' length 3327499 bytes
> URL abierta
> downloaded 3249Kb
>
> probando la URL
> 'http://cran.au.r-project.org/bin/windows/contrib/2.3/ 
> Hmisc_3.0-12.zip'
> Content
> type 'application/zip' length 1993038 bytes
> URL abierta
> downloaded 1946Kb
>
> probando la URL
> 'http://cran.au.r-project.org/bin/windows/contrib/2.3/ 
> quadprog_1.4-8.zip'
> Content
> type 'application/zip' length 38626 bytes
> URL abierta
> downloaded 37Kb
>
> probando la URL
> 'http://cran.au.r-project.org/bin/windows/contrib/2.3/oz_1.0-13.zip'
> Content
> type 'application/zip' length 39640 bytes
> URL abierta
> downloaded 38Kb
>
> probando la URL
> 'http://cran.au.r-project.org/bin/windows/contrib/2.3/ 
> mlbench_1.1-1.zip'
> Content
> type 'application/zip' length 1324913 bytes
> URL abierta
> downloaded 1293Kb
>
> probando la URL
> 'http://cran.au.r-project.org/bin/windows/contrib/2.3/ 
> randomForest_4.5-16.zip'
> Content
> type 'application/zip' length 209710 bytes
> URL abierta
> downloaded 204Kb
>
> probando la URL
> 'http://cran.au.r-project.org/bin/windows/contrib/2.3/ 
> SparseM_0.68.zip'
> Content
> type 'application/zip' length 728594 bytes
> URL abierta
> downloaded 711Kb
>
> probando la URL
> 'http://cran.au.r-project.org/bin/windows/contrib/2.3/ 
> xtable_1.3-2.zip'
> Content
> type 'application/zip' length 56703 bytes
> URL abierta
> downloaded 55Kb
>
> probando la URL
> 'http://cran.au.r-project.org/bin/windows/contrib/2.3/chron_2.3-4.zip'
> Content
> type 'application/zip' length 101287 bytes
> URL abierta
> downloaded 98Kb
>
> probando la URL
> 'http://cran.au.r-project.org/bin/windows/contrib/2.3/ 
> fCalendar_221.10065.zip'
> Content
> type 'application/zip' length 754551 bytes
> URL abierta
> downloaded 736Kb
>
> probando la URL
> 'http://c

[R] Non-Numeric Histograms

2006-07-08 Thread justin rapp
I have a dataset with a variable that is non-numeric.  I was wondering
if there is an easy way in R to create a bar graph that will tell me
how many of each level of this non-numeric variable are in the overall
dataset.

Specifically, if my variable is LETTER, and I have A, B,C, D, E, F and
I want to find out how many of each letter there are, what is the
easiest way to do this in R and use the information to make a plot?

jdr

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


Re: [R] Non-Numeric Histograms

2006-07-08 Thread Uwe Ligges
justin rapp wrote:
> I have a dataset with a variable that is non-numeric.  I was wondering
> if there is an easy way in R to create a bar graph that will tell me
> how many of each level of this non-numeric variable are in the overall
> dataset.
> 
> Specifically, if my variable is LETTER, and I have A, B,C, D, E, F and
> I want to find out how many of each letter there are, what is the
> easiest way to do this in R and use the information to make a plot?


  barplot(table(c("A", "A", "B")))

Uwe Ligges


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

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


Re: [R] Availability of quadplot3d package (UseR!2006 Four Dimensional Barycentric Plots in 3D)

2006-07-08 Thread Uwe Ligges
Carlos Ortega wrote:
> Dear List,
> 
> I have been unable fo find the package quadplot3d referred in the
> Abstract/Presentation "Four Dimensional Barycentric Plot in 3D" presented in
> the UserR!2006.
> 
> Does anyone know if it is available ? And if so, if it is ported to Windows
> ?


I think we should ask the author of that presentation, Geoffrey Matthews 
(CCing).

I'm also interested in adding a corresponding plot feature into package 
klaR, which currently only covers static "quadplots". Hence it would be 
nice to see the package quadplot3d on CRAN, or at least I'd like to see 
its functionality contributed to some other CRAN package such as misc3d.

Uwe Ligges



> Thanks in anticipation,
> Carlos Ortega
> 
>   [[alternative HTML version deleted]]
> 
> __
> R-help@stat.math.ethz.ch mailing list
> https://stat.ethz.ch/mailman/listinfo/r-help
> PLEASE do read the posting guide! http://www.R-project.org/posting-guide.html

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


[R] which model (GLMs)is the best?

2006-07-08 Thread zhijie zhang
Dear friends,
 I used R to analyze my data with the models of generalized linear models,
and found three models were relatively good, but i can't decide which is the
best,how should i do ?

*Model1:*

glm(formula = snail ~ grass + gheight + humidity + altitude + soiltem +
airtem + grass:altitude, *family = Gamma(link = inverse*),

data = model, na.action = na.exclude, control = list(epsilon = 1e-04,

maxit = 50, trace = T))

(Dispersion parameter for Gamma family taken to be 0.2644025)

Null deviance: 63.635  on 161  degrees of freedom

Residual deviance: 42.324  on 151  degrees of freedom

AIC: 1528.1



*Model2:*

glm(formula = snail ~ grass + gheight + humidity + altitude + soiltem +
airtem + grass:altitude, *family = quasi(link = inverse, variance = "mu^2")*,
data = model, na.action = na.exclude, control = list(epsilon = 1e-04, maxit
= 50, trace = F))

(Dispersion parameter for quasi family taken to be 0.2644025)

Deviance Residuals:

Null deviance: 63.635  on 161  degrees of freedom

Residual deviance: 42.324  on 151  degrees of freedom

AIC: NA

* *

*Model3:*

glm(formula = snail ~ grass + gheight + humidity + altitude + soiltem +
airtem + grass:altitude, *family = quasi(link = log, variance =
"mu^3"),*data = model,
na.action = na.exclude,

control = list(epsilon = 1e-04, maxit = 50, trace = F))

(Dispersion parameter for quasi family taken to be 0.005042872)

Deviance Residuals:

Null deviance: 1.4113  on 161  degrees of freedom

Residual deviance: 1.0080  on 151  degrees of freedom

AIC: NA
How should i evaluate my models in R? Thanks very much!

-- 
Kind Regards,
Zhi Jie,Zhang ,PHD
Department of Epidemiology
School of Public Health
Fudan University
Tel:86-21-54237149

[[alternative HTML version deleted]]

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


[R] another tcl/tk query

2006-07-08 Thread Charles Annis, P.E.
Greetings:

I wish to use a tcl/tk widget to ask for user-selected parameter values.  My
widget works – it asks for and returns to my workspace the stuff I need.
Here is a snippet of my code:

###
OnOK <- function()
{
LOG.X <<- as.logical(as.character(tclvalue(log.X.buttonValue)))
LOG.Y <<- as.logical(as.character(tclvalue(log.Y.buttonValue)))
natural.units.â.decision   <<-
as.double(as.character(tclvalue(â.decision)))
natural.units.left.censor  <<-
as.double(as.character(tclvalue(left.censor)))
natural.units.right.censor <<-
as.double(as.character(tclvalue(right.censor)))
tkdestroy(t2)
}
###


My problem is this:  I would like to use the new input in the same routine
that created, used, and destroyed the widget.  I can’t seem to do that.  The
routine executes with what it has.  I must wait for the calling routine to
end before I can use the new info, which is correctly place in the
workspace, in subsequent R routines.

Is there a way I can use the updated values in the same routine that created
the widget?

Thanks for your advice – and patience.


Charles Annis, P.E.

PS - I did read Prof. Ripley's post of Wed 8/31/2005
"Re: [R] tcl/tk return problem" but was unable to benefit from it.


[EMAIL PROTECTED]
phone: 561-352-9699
eFax:  614-455-3265
http://www.StatisticalEngineering.com
 

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


Re: [R] Fwd: time series patterns

2006-07-08 Thread Spencer Graves
  For my previous email on this thread, I couldn't find Jim Lindsey's 
home page.  I just found it via www.r-project.org -> Search
-> "R Site Search" -> "Jim Lindsey's packages."  This led me to 
"http://popgen.unimaas.nl/~jlindsey/rcode.html";.

  ... just in case someone following this thread also has this problem.
  Spencer Graves

##
  I how you code something like this depends on what you plan to do
with it.  If it were my problem, I might want to try some hidden Markov
models.  RSiteSearch("hidden markov", "functions") produced 29 hits for
me just now.  You might try some of the packages mentioned there.  They
might suggest supplemental coding and / or plotting procedures that
might provide insight into your application.

  Hope this helps.
  Spencer Graves
p.s.  The 'repeated' package and others by J.K. Lindsey are not
available from CRAN.  A year ago, I downloaded material from his
personal web site, which was the first hit on a Google search for "J K
Lindsey".  I also remember seeing it on CRAN or r-project.org.  Today,
the closest I can come is "[EMAIL PROTECTED]" (Tél :+32 4 3662964).
If you want to try any of his R packages and you don't have any better
results with a web search than I got just now, I suggest send him an
email.

Raphael Fraser wrote:
> -- Forwarded message --
> From: Alexander Nervedi <[EMAIL PROTECTED]>
> Date: Jun 30, 2006 4:56 PM
> Subject: time series patterns
> To: [EMAIL PROTECTED]
> 
> 
> Hi all.
> 
> I have a factor variable distributed over time. I am looking for an elegant
> way to code duration of a state. Suppose,
> 
>> rainfall.shocks <- factor(sample(c(1,2,3), size = 15, replace = TRUE, prob
>> = unit.p),
> +  label = c("Drought", "Normal", "High"))
>> rainfall.shocks
> [1] Normal  HighHighDrought Normal  Normal  HighNormal  Drought
> [10] Normal  Drought Normal  Normal  Normal  Normal
> 
> 
> So capture the duration of say drought, I'd need a variable that is able to
> keep track of rainfall.shocks as well as its past values. I was wondering if
> there is any obvious way to do this. the Drought variable in this case would
> have values
> 
> 0 0 0 1 0 0 0 0 1 0 1 0 0 0 0
> 
> many thanks for the suggestions you are likely to make.
> 
> Alexander Nervedi
> 
> _
> Express yourself instantly with MSN Messenger! Download today - it's FREE!
> http://messenger.msn.click-url.com/go/onm00200471ave/direct/01/
> 
> __
> R-help@stat.math.ethz.ch mailing list
> https://stat.ethz.ch/mailman/listinfo/r-help
> PLEASE do read the posting guide! http://www.R-project.org/posting-guide.html

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


[R] SUMMARY: R crash with ''library(Matrix); as(x, "dgCMatrix")' [was: Warning while subsetting...]

2006-07-08 Thread Thaden, John J
With thanks to Matrix package co-author Martin 
Maechler, I'm happy to report satisfactory closure 
of two recent threads I initiated about that package: 
   -  Warning while subsetting with Matrix
   -  R Crash with 'library(Matrix);as(x,"dgCMatrix")
   
In the first, I reported seeing a warning message after
selecting a subset of a matrix 'M' of class "dgTMatrix"
via the first but not the second of these commands:
 
  M10 <- M[1:10,]
  M10 <- M[1:10,1:10]

Acting on Martin's advice, I upgraded Matrix version 
0.995-10 to version 0.995-11.  This eliminated the
warning message.

In the second, I reported that class-conversion of 
a self-constructed "dgTMatrix" of dimension 600 X 4482
caused R to crash when done via either of the first two
but neither of the last two of these commands:

  Mc <- as(M, "dgCMatrix")
  Mm <- as(M, "matrix")
  Mc <- rbind(as(M[1:300,], "dgCMatrix"), as(M[301:600], "dgCMatrix")
  Mm <- rbind(as(M[1:300,], "matrix"), as(M[301:600], "matrix")

I surmised this was a memory issue but Martin pointed out 
the memory demand to hold even the expanded sparse matrix
is actually rather small (8 x 600 x 4482 = 21549456 bytes
= 21.5 Megabytes).
 
For obvious bandwidth reasons, I did not post my large 
matrix, so Martin created one of his own.  Neither he 
nor I could reproduce crashes with his matrix. Offlist,
I sent him my matrix. Upon class-conversion, it crashed 
his machine too.

Upon inspection, Martin discovered that my matrix did not
conform to the dgTMatrix class as defined in Matrix. In 
particular, my slots [EMAIL PROTECTED] and [EMAIL PROTECTED] were integer 
vectors 
beginning with ones, i.e., they respectively indexed the
first row and column of the matrix as "1", not as "0".  

However, correcting this did not stop crashes, until I also
realized that [EMAIL PROTECTED] had 601 (not 600) unique integer values, 
and corrected my Dims slot ([EMAIL PROTECTED]) to be c(601,4482).  This 
stopped the crashes.

Once created, Matrix objects behave like matrix objects in
the sense that "one-based" indexing is used to subset them
or re-assign values to them.  But for users who create 
them, especially using the new() function, it is helpful
to remind oneself that Matrix objects are created and 
stored using "zero-based" indexing.  This fact is
mentioned only obliquely in the current version's PDF file
and R-accessible documentation.  Hopefully that will change.

Again, my thanks to Martin. For me this experience confirms
The vigor of open-source, forum-supported projects.

-John Thaden, Ph.D.
Research Assistant Professor of Geriatrics
University of Arkansas for Medical Sciences
Little Rock, AR 72205
USA

Confidentiality Notice: This e-mail message, including any a...{{dropped}}

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


[R] Adding Lines to Plot

2006-07-08 Thread justin rapp
This seems like a question that I should be able to answer on my own
but after looking at the documentation I cannot seem to find the
correct method.

How do I add lines to a bar plot that extend from the vertical axis?
For example, my vertical axis is numbered in increments of 10 and I
would like these to go across the whole graph.

Also, is there a way to have R label the value of each bar so that I
know the value of each factor that is being plotted?

Thanks in advance.

jdr

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


Re: [R] PLS method

2006-07-08 Thread Spencer Graves
  I believe that regression coefficients can change signs in partial 
least squares (pls) or in the related structural equation modeling (sem) 
for roughly the same reasons they can change sign in ordinary least 
squares (ols).  Both PLS and SEM essentially assume that the 
'independent' variables (X's) in the model are linear combinations of 
unobserved 'structural' variables plus noise.  Then the response 
variable(s) are linear combinations of these unobserved structural 
variables plus error.

  I have used neither pls nor sem, so I can't go beyond this.  If it 
were my problem and I wanted to understand it better, I might cut the 
example down still further, e.g., to 4 observations with only 2 X's, and 
then try to program the entire thing in Excel using the 'solver'.  Or 
make local copies of functions like 'mvr' and use 'debug' to walk 
through the code line by line, looking carefully at what it does.

  Before you do that, however, if you aren't clear on the similarities 
and differences between pls and sem, I suggest you explore that, e.g., 
using Google.  Just now, I found the following pls / sem comparison: 
"http://www2.gsu.edu/~mkteer/relmeth.html";.

  Hope this helps.
  Spencer Graves

Sun Jia wrote:
> dear all,
> 
> I am a new comer to R and statistic.  Now I have a little confuse about the
> package pls.
> 
> I have to use 5 components to form a model. There are strong relationship
> between some of the components, which leads to the changes of the sign of
> each coeficeince, of course this is unwanted when using the normal
> regression way. So I choose the way of PLS, which is good at solve this kind
> of problem.
> 
> In my work,
> 
> q is the response and w,c,d,r,o are the 5 components.
> 
>  w c   d  r   oq
> 
> 1  219.580 0.880 102.742 12.988 0.9380 11
> 
> 2  245.806 0.900  97.798 11.764 1.0080 12
> 
> 3  219.850 0.910  93.764  5.608 1.1006 16
> 
> 4  226.904 0.842 110.080 14.614 0.8398  7
> 
> 5  250.792 0.868 108.212 14.714 0.8990 10
> 
> 6  225.264 0.930  96.748  6.906 1.1784 16
> 
> 7  229.562 0.856 103.204 12.900 0.8730 12
> 
> 8  239.560 0.880 101.036 11.766 0.9452 12
> 
> 9  199.008 0.920  91.338  3.918 1.1234 17
> 
> 10 220.458 0.910  88.322  9.868 1.0746 13
> 
> 11 201.228 0.910  89.202 10.328 1.0514 14
> 
> 12 199.160 0.920  90.126  2.088 1.1326 15
> 
> 13 135.540 0.786 121.506 19.140 0.6934  2
> 
> 14 296.272 0.864 130.896 22.614 0.9104  6
> 
> 15 190.766 0.840 108.050  7.336 0.8210  8
> 
> I have used the following sentence.
> 
> b.pls<-mvr(q~w+c+d+r+o,data=b,method="simpls")
> 
>> coef.mvr(b.pls)
> 
> , , 5 comps
> 
> 
> 
> q
> 
> w  0.01993749
> 
> c 12.42713250
> 
> d -0.12050551
> 
> r -0.20287088
> 
> o  9.63670488
> 
> 
> 
>  I have found that the sign of each component still cannot be explained by
> the reality. For instance, the sign of w should be negative rather than
> positive.
> 
>> b.pls<-mvr(q~c+d+r+o,data=b,method="simpls")
> 
>> coef.mvr(b.pls)
> 
> , , 4 comps
> 
> 
> 
> q
> 
> c 76.39196611
> 
> d -0.06512864
> 
> r -0.18272329
> 
> o -3.02212146
> 
> 
> 
> 
> 
> When I delete one of the components, the w, I found the coefficients of the
> rest ones also changes the sign, the component of o.
> 
> As far as I concerned, this kind of situation should only happened when use
> the normal regression rather than PLS regression.
> 
> Is there any wrong with my understanding?
> 
>  Why does this problem happen?
> 
> 
> 
> I am appreciated for your help and answer.
> 
> __
> R-help@stat.math.ethz.ch mailing list
> https://stat.ethz.ch/mailman/listinfo/r-help
> PLEASE do read the posting guide! http://www.R-project.org/posting-guide.html

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


[R] Summary Statistics for data.frame

2006-07-08 Thread justin rapp
I apologize for my constant questions but I am new to R and trying to
gain an appreciation for its capabilities.  The following task is easy
in Excel and I was hoping somebody could give me a quick explanation
for how it can be acheived in R so I can avoid having to switch
between the two applications.

How do I find the Summary Statistics in one Vector of the dataframe by
levels in another of the vectors.

For example, I have the following headings for my data.frame.
Conference
Year Drafted
Height
Weight
Ratio

I would like to see compute the mean Height, Weight, and Ratio as well
as their variances for each of the years under Year
Drafted(1980-2000).  What is the most efficient way of doing this?

Thank you.

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


Re: [R] Summary Statistics for data.frame

2006-07-08 Thread Duncan Murdoch
On 7/8/2006 3:44 PM, justin rapp wrote:
> I apologize for my constant questions but I am new to R and trying to
> gain an appreciation for its capabilities.  The following task is easy
> in Excel and I was hoping somebody could give me a quick explanation
> for how it can be acheived in R so I can avoid having to switch
> between the two applications.
> 
> How do I find the Summary Statistics in one Vector of the dataframe by
> levels in another of the vectors.
> 
> For example, I have the following headings for my data.frame.
> Conference
> Year Drafted
> Height
> Weight
> Ratio
> 
> I would like to see compute the mean Height, Weight, and Ratio as well
> as their variances for each of the years under Year
> Drafted(1980-2000).  What is the most efficient way of doing this?

I think the quickest is

by(mydf, mydf$Year, summary)

but this won't give you the variance.  You'll need your own little 
function to calculate mean and variance, e.g.

mysummary <- function(df) apply(df, 2,
function(x) c(mean=mean(x), variance=var(x)))

by(mydf, mydf$Year, mysummary)

If you don't like the format of the output, you can play around with the 
mysummary function.  It will be applied to each subset of the 
data.frame, and the results will be put together into a list with one 
entry per level of mydf$Year.


Duncan

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


Re: [R] Summary Statistics for data.frame

2006-07-08 Thread justin rapp
When I attempt to use the mysummary function, I obtain the following error:

Error in var(x) : missing observations in cov/cor

When I use:
by(data.logistic,data.logistic$Ydrafted,summary)

I receive no errors. I cut and pasted your mysummary function directly
into my r console.  Should I have made any adjustments to the code?

jdr

On 7/8/06, Duncan Murdoch <[EMAIL PROTECTED]> wrote:
> On 7/8/2006 3:44 PM, justin rapp wrote:
> > I apologize for my constant questions but I am new to R and trying to
> > gain an appreciation for its capabilities.  The following task is easy
> > in Excel and I was hoping somebody could give me a quick explanation
> > for how it can be acheived in R so I can avoid having to switch
> > between the two applications.
> >
> > How do I find the Summary Statistics in one Vector of the dataframe by
> > levels in another of the vectors.
> >
> > For example, I have the following headings for my data.frame.
> > Conference
> > Year Drafted
> > Height
> > Weight
> > Ratio
> >
> > I would like to see compute the mean Height, Weight, and Ratio as well
> > as their variances for each of the years under Year
> > Drafted(1980-2000).  What is the most efficient way of doing this?
>
> I think the quickest is
>
> by(mydf, mydf$Year, summary)
>
> but this won't give you the variance.  You'll need your own little
> function to calculate mean and variance, e.g.
>
> mysummary <- function(df) apply(df, 2,
> function(x) c(mean=mean(x), variance=var(x)))
>
> by(mydf, mydf$Year, mysummary)
>
> If you don't like the format of the output, you can play around with the
> mysummary function.  It will be applied to each subset of the
> data.frame, and the results will be put together into a list with one
> entry per level of mydf$Year.
>
>
> Duncan
>

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


Re: [R] Summary Statistics for data.frame

2006-07-08 Thread Duncan Murdoch
On 7/8/2006 4:55 PM, justin rapp wrote:
> When I attempt to use the mysummary function, I obtain the following error:
> 
> Error in var(x) : missing observations in cov/cor

var() gives that error if it sees NA values.  You can get it to remove 
them by using

var(x, na.rm = TRUE)

instead of var(x).  Whether that makes sense depends on the context of 
your problem.

Duncan Murdoch

> 
> When I use:
> by(data.logistic,data.logistic$Ydrafted,summary)
> 
> I receive no errors. I cut and pasted your mysummary function directly
> into my r console.  Should I have made any adjustments to the code?
> 
> jdr
> 
> On 7/8/06, Duncan Murdoch <[EMAIL PROTECTED]> wrote:
>> On 7/8/2006 3:44 PM, justin rapp wrote:
>>> I apologize for my constant questions but I am new to R and trying to
>>> gain an appreciation for its capabilities.  The following task is easy
>>> in Excel and I was hoping somebody could give me a quick explanation
>>> for how it can be acheived in R so I can avoid having to switch
>>> between the two applications.
>>>
>>> How do I find the Summary Statistics in one Vector of the dataframe by
>>> levels in another of the vectors.
>>>
>>> For example, I have the following headings for my data.frame.
>>> Conference
>>> Year Drafted
>>> Height
>>> Weight
>>> Ratio
>>>
>>> I would like to see compute the mean Height, Weight, and Ratio as well
>>> as their variances for each of the years under Year
>>> Drafted(1980-2000).  What is the most efficient way of doing this?
>> I think the quickest is
>>
>> by(mydf, mydf$Year, summary)
>>
>> but this won't give you the variance.  You'll need your own little
>> function to calculate mean and variance, e.g.
>>
>> mysummary <- function(df) apply(df, 2,
>> function(x) c(mean=mean(x), variance=var(x)))
>>
>> by(mydf, mydf$Year, mysummary)
>>
>> If you don't like the format of the output, you can play around with the
>> mysummary function.  It will be applied to each subset of the
>> data.frame, and the results will be put together into a list with one
>> entry per level of mydf$Year.
>>
>>
>> Duncan
>>

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


[R] String mathematical function to R-function

2006-07-08 Thread Cleber N.Borges


hello

I make a subroutine that give-me a (mathematical)
function in string format.
I would like transform this string into function ( R
function ).

thanks for any tips.
cleber


#e.g.
fun_String = "-100*x1 + 0*x2 + 100*x3"

fun <- function(x1,x2,x3){
return(


evaluation( fun_String )


)





True String mathematical function :-(  :-(

> nomes
[1] "8.49*x1*z1 + 6.13*x1*z2 + 6.4*x1*z3 + 6.9*x2*z1 +
4.54*x2*z2 + 3.99*x2*z3 + 19.31*x3*z1 + 12.49*x3*z2 +
3.86*x3*z3 + 5.25*x1*z1*z2 + -6.2*x1*z1*z3 +
9.07*x1*z2*z3 + 10.87*x2*z1*z2 + 9.78*x2*z1*z3 +
49.05*x2*z2*z3 + 4.56*x1*x2*z1 + -4.9*x1*x2*z2 +
4.01*x1*x2*z3 + -0.39*x3*z1*z2 + 14.34*x3*z1*z3 +
0.7*x3*z2*z3 + -2.84*x1*x3*z1 + 20.25*x1*x3*z2 +
6.44*x1*x3*z3 + -4.91*x2*x3*z1 + 5.45*x2*x3*z2 +
37.99*x2*x3*z3 + -22.24*x1*z1*z2*z3 +
-97.41*x2*z1*z2*z3 + -8.67*x1*x2*z1*z2 +
49.14*x1*x2*z1*z3 + 14.24*x1*x2*z2*z3 +
282.71*x3*z1*z2*z3 + 34.83*x1*x3*z1*z2 +
111.2*x1*x3*z1*z3 + 101.38*x1*x3*z2*z3 +
-6.93*x2*x3*z1*z2 + 90.16*x2*x3*z1*z3 +
-9.11*x2*x3*z2*z3 + 17.22*x1*x2*x3*z1 +
-29.42*x1*x2*x3*z2 + -19.87*x1*x2*x3*z3 +
-277.41*x1*x2*z1*z2*z3 + -482.82*x1*x3*z1*z2*z3 +
-688.23*x2*x3*z1*z2*z3 + -588.4*x1*x2*x3*z1*z2 +
-197.31*x1*x2*x3*z1*z3 + -722.58*x1*x2*x3*z2*z3 +
5536.59*x1*x2*x3*z1*z2*z3"
> 





___ 

o discador agora!

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


Re: [R] String mathematical function to R-function

2006-07-08 Thread Renaud Lancelot
> fun_String <- "-100*x1 + 0*x2 + 100*x3"
>
> fun <- function(x1, x2, x3){
+   eval(parse(text = fun_String))
+   }
>
> fun(4:0, -2:2, 0:4)
[1] -400 -2000  200  400

Best,

Renaud

2006/7/8, Cleber N.Borges <[EMAIL PROTECTED]>:
>
>
> hello
>
> I make a subroutine that give-me a (mathematical)
> function in string format.
> I would like transform this string into function ( R
> function ).
>
> thanks for any tips.
> cleber
>
>
> #e.g.
> fun_String = "-100*x1 + 0*x2 + 100*x3"
>
> fun <- function(x1,x2,x3){
> return(
> 
>
> evaluation( fun_String )
>
> 
> )
>
>
>
>
>
> True String mathematical function :-(  :-(
>
> > nomes
> [1] "8.49*x1*z1 + 6.13*x1*z2 + 6.4*x1*z3 + 6.9*x2*z1 +
> 4.54*x2*z2 + 3.99*x2*z3 + 19.31*x3*z1 + 12.49*x3*z2 +
> 3.86*x3*z3 + 5.25*x1*z1*z2 + -6.2*x1*z1*z3 +
> 9.07*x1*z2*z3 + 10.87*x2*z1*z2 + 9.78*x2*z1*z3 +
> 49.05*x2*z2*z3 + 4.56*x1*x2*z1 + -4.9*x1*x2*z2 +
> 4.01*x1*x2*z3 + -0.39*x3*z1*z2 + 14.34*x3*z1*z3 +
> 0.7*x3*z2*z3 + -2.84*x1*x3*z1 + 20.25*x1*x3*z2 +
> 6.44*x1*x3*z3 + -4.91*x2*x3*z1 + 5.45*x2*x3*z2 +
> 37.99*x2*x3*z3 + -22.24*x1*z1*z2*z3 +
> -97.41*x2*z1*z2*z3 + -8.67*x1*x2*z1*z2 +
> 49.14*x1*x2*z1*z3 + 14.24*x1*x2*z2*z3 +
> 282.71*x3*z1*z2*z3 + 34.83*x1*x3*z1*z2 +
> 111.2*x1*x3*z1*z3 + 101.38*x1*x3*z2*z3 +
> -6.93*x2*x3*z1*z2 + 90.16*x2*x3*z1*z3 +
> -9.11*x2*x3*z2*z3 + 17.22*x1*x2*x3*z1 +
> -29.42*x1*x2*x3*z2 + -19.87*x1*x2*x3*z3 +
> -277.41*x1*x2*z1*z2*z3 + -482.82*x1*x3*z1*z2*z3 +
> -688.23*x2*x3*z1*z2*z3 + -588.4*x1*x2*x3*z1*z2 +
> -197.31*x1*x2*x3*z1*z3 + -722.58*x1*x2*x3*z2*z3 +
> 5536.59*x1*x2*x3*z1*z2*z3"
> >
>
>
>
>
>
> ___
>
> o discador agora!
>
> __
> R-help@stat.math.ethz.ch mailing list
> https://stat.ethz.ch/mailman/listinfo/r-help
> PLEASE do read the posting guide! http://www.R-project.org/posting-guide.html
>


-- 
Renaud LANCELOT
Département Elevage et Médecine Vétérinaire (EMVT) du CIRAD
Directeur adjoint chargé des affaires scientifiques

CIRAD, Animal Production and Veterinary Medicine Department
Deputy director for scientific affairs

Campus international de Baillarguet
TA 30 / B (Bât. B, Bur. 214)
34398 Montpellier Cedex 5 - France
Tél   +33 (0)4 67 59 37 17
Secr. +33 (0)4 67 59 39 04
Fax   +33 (0)4 67 59 37 95

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


[R] Combining a list of similar dataframes into a single dataframe

2006-07-08 Thread Mike Nielsen
I would be very grateful to anyone who could point to the error of my
ways in the following.

I have a dataframe called net1, as such:

> str(net1)
`data.frame':114192 obs. of  9 variables:
 $ server : Factor w/ 122 levels "AB93-99","AMP93-1",..: 1 1 1
1 1 1 1 1 1 1 ...
 $ ts :'POSIXct', format: chr  "2006-06-30 12:31:44"
"2006-06-30 12:31:44" "2006-06-30 12:31:44" "2006-06-30 12:31:44" ...
 $ instance   : Factor w/ 22 levels "1","2","Compaq Ethernet_Fast
Ethernet Adapter_Module",..: 4 4 4 4 4 4 4 4 4 4 ...
 $ instanceno : Factor w/ 3 levels "1","2","3": 1 1 1 1 1 1 1 1 1 1 ...
 $ perftime   : num  3.16e+13 3.16e+13 3.16e+13 3.16e+13 3.16e+13 ...
 $ perffreq   : num  6.99e+08 6.99e+08 6.99e+08 6.99e+08 6.99e+08 ...
 $ perftime100nsec: num  1.28e+17 1.28e+17 1.28e+17 1.28e+17 1.28e+17 ...
 $ countername: Factor w/ 4 levels "Bytes Received/sec",..: 1 3 2
4 1 3 2 4 1 3 ...
 $ countervalue   : num  6.08e+07 6.64e+07 5.58e+06 1.00e+08 6.09e+07 ...
>

What I am trying to do is subset this thing down by server, instance,
instanceno, countername and then apply a function to each subsetted
dataframe.  The function performs a calculation on countervalue,
essentially "collapsing" instanceno and instance down to a single
value.

Here is a snippet of my code:
t1 <- by(net1,
 list(
  net1$server,
  factor(as.character(net1$countername))),# get rid of
unused levels of countername for this server
 function(x){
   g <- by(x,
   list(factor(as.character(x$instance)), # get rid of
unused levels of instance for this server
   factor(as.character(x$instanceno))),   # same with instanceno

function(y){c(NA,mean(y$perffreq)*diff(y$countervalue)/diff(y$perftime))})
   data.frame(server=x$server,
  ts=x$ts,
  countername = x$countername,
  countervalue =
apply(sapply(g[!sapply(g,is.null)],I),1,sum))
 })

So t1 then is a list of dataframes, each with an identical set of columns)

> str(t1[[1]])
`data.frame':   149 obs. of  4 variables:
 $ server  : Factor w/ 122 levels "AB93-99","AMP93-1",..: 1 1 1 1
1 1 1 1 1 1 ...
 $ ts  :'POSIXct', format: chr  "2006-06-30 12:31:44"
"2006-06-30 12:32:58" "2006-06-30 12:34:46" "2006-06-30 12:36:55" ...
 $ countername : Factor w/ 4 levels "Bytes Received/sec",..: 1 1 1 1 1
1 1 1 1 1 ...
 $ countervalue: numNA  938  816 4213  906 ...

What I'd dearly love to do, without looping or lapply-ing through t1
and rbinding (too much data for this to finish quickly enough -- this
is about 10% of what I'm eventually going to have to manage), is
convert t1 to one big dataframe.

On the other hand, I admit that I may be going about this wrongly from
the start; perhaps there's a better approach?

Any pointers would be most gratefully received.

Many thanks!


-- 
Regards,

Mike Nielsen

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


[R] denominator degrees of freedom and F-values in nlme

2006-07-08 Thread M R Robinson
Hello,

I am struggling to understand how denominator degrees of freedom and 
subsequent significance testing based upon them works in nlme models.

I have a data set of 736 measurements (weight), taken within 3 
different age groups, on 497 individuals who fall into two 
morphological catagories (horn types).

My model is:  Y ~ weight + horn type / age group, random=~1|individual

I am modeling this using glmm.PQL function with family=neg.bin 
(negative binomial distribution, estimating theta based upon a glm 
without individual as a random effect). My data set will not be 
balanced, with varying numbers of measurements taken on different 
individuals and some individuals have no weight measures just a 
morphological type.

My output:
  denDFnumberdf
Intercept 495
weight232   1
horn type 495   1
horn type:age 232   4

So my question is where do these denDF come from and how are they 
calculated? I wish to then test significane of these fixed effects and 
can get F-ratio's and P-values but are these appropriate?

Thank-you for your time.
Kind regards
Matthew

*
Matt Robinson

Institute of Evolutionary Biology
Room 413, Ashworth Labs,
King's Buildings,
University of Edinburgh
EH9 3JT, UK

Tel: 0131 650 5990

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


Re: [R] Combining a list of similar dataframes into a single dataframe

2006-07-08 Thread Mike Nielsen
Well, this worked, and rather more quickly than I had expected.

Many thanks to the dogs, who told me the answer in return for walking
them and feeding them!

> jj <- eval(parse(text=paste(sep=" ","rbind(",paste(sep=" 
> ","t1[[",1:length(t1),"]]",collapse=","),")")))
> str(jj)
`data.frame':   85644 obs. of  4 variables:
 $ server  : Factor w/ 122 levels "AB93-99","AMP93-1",..: 1 1 1 1
1 1 1 1 1 1 ...
 $ ts  :'POSIXct', format: chr  "2006-06-30 12:31:44"
"2006-06-30 12:32:58" "2006-06-30 12:34:46" "2006-06-30 12:36:55" ...
 $ countername : Factor w/ 4 levels "Bytes Received/sec",..: 1 1 1 1 1
1 1 1 1 1 ...
 $ countervalue: numNA  938  816 4213  906 ...
>

On 7/8/06, Mike Nielsen <[EMAIL PROTECTED]> wrote:
> I would be very grateful to anyone who could point to the error of my
> ways in the following.
>
> I have a dataframe called net1, as such:
>
> > str(net1)
> `data.frame':114192 obs. of  9 variables:
>  $ server : Factor w/ 122 levels "AB93-99","AMP93-1",..: 1 1 1
> 1 1 1 1 1 1 1 ...
>  $ ts :'POSIXct', format: chr  "2006-06-30 12:31:44"
> "2006-06-30 12:31:44" "2006-06-30 12:31:44" "2006-06-30 12:31:44" ...
>  $ instance   : Factor w/ 22 levels "1","2","Compaq Ethernet_Fast
> Ethernet Adapter_Module",..: 4 4 4 4 4 4 4 4 4 4 ...
>  $ instanceno : Factor w/ 3 levels "1","2","3": 1 1 1 1 1 1 1 1 1 1 ...
>  $ perftime   : num  3.16e+13 3.16e+13 3.16e+13 3.16e+13 3.16e+13 ...
>  $ perffreq   : num  6.99e+08 6.99e+08 6.99e+08 6.99e+08 6.99e+08 ...
>  $ perftime100nsec: num  1.28e+17 1.28e+17 1.28e+17 1.28e+17 1.28e+17 ...
>  $ countername: Factor w/ 4 levels "Bytes Received/sec",..: 1 3 2
> 4 1 3 2 4 1 3 ...
>  $ countervalue   : num  6.08e+07 6.64e+07 5.58e+06 1.00e+08 6.09e+07 ...
> >
>
> What I am trying to do is subset this thing down by server, instance,
> instanceno, countername and then apply a function to each subsetted
> dataframe.  The function performs a calculation on countervalue,
> essentially "collapsing" instanceno and instance down to a single
> value.
>
> Here is a snippet of my code:
> t1 <- by(net1,
>  list(
>   net1$server,
>   factor(as.character(net1$countername))),# get rid of
> unused levels of countername for this server
>  function(x){
>g <- by(x,
>list(factor(as.character(x$instance)), # get rid of
> unused levels of instance for this server
>factor(as.character(x$instanceno))),   # same with 
> instanceno
>
> function(y){c(NA,mean(y$perffreq)*diff(y$countervalue)/diff(y$perftime))})
>data.frame(server=x$server,
>   ts=x$ts,
>   countername = x$countername,
>   countervalue =
> apply(sapply(g[!sapply(g,is.null)],I),1,sum))
>  })
>
> So t1 then is a list of dataframes, each with an identical set of columns)
>
> > str(t1[[1]])
> `data.frame':   149 obs. of  4 variables:
>  $ server  : Factor w/ 122 levels "AB93-99","AMP93-1",..: 1 1 1 1
> 1 1 1 1 1 1 ...
>  $ ts  :'POSIXct', format: chr  "2006-06-30 12:31:44"
> "2006-06-30 12:32:58" "2006-06-30 12:34:46" "2006-06-30 12:36:55" ...
>  $ countername : Factor w/ 4 levels "Bytes Received/sec",..: 1 1 1 1 1
> 1 1 1 1 1 ...
>  $ countervalue: numNA  938  816 4213  906 ...
>
> What I'd dearly love to do, without looping or lapply-ing through t1
> and rbinding (too much data for this to finish quickly enough -- this
> is about 10% of what I'm eventually going to have to manage), is
> convert t1 to one big dataframe.
>
> On the other hand, I admit that I may be going about this wrongly from
> the start; perhaps there's a better approach?
>
> Any pointers would be most gratefully received.
>
> Many thanks!
>
>
> --
> Regards,
>
> Mike Nielsen
>


-- 
Regards,

Mike Nielsen

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


Re: [R] Adding Lines to Plot

2006-07-08 Thread markleeds
>From: justin rapp <[EMAIL PROTECTED]>
>Date: Sat Jul 08 14:05:12 CDT 2006
>To: r-help@stat.math.ethz.ch
>Subject: [R] Adding Lines to Plot

i'm not definite on this and even
if it works , it;s not the most
efficient
but

abline(h=10)
abline(h=20)
abline(h=30)
etc

i'd be curious if that works on a bar plot
because i don't use bar plots. someone else will answer that knows
more than me. i just like to try to help out once in a while because
i get s much help form this list.









>This seems like a question that I should be able to answer on my own
>but after looking at the documentation I cannot seem to find the
>correct method.
>
>How do I add lines to a bar plot that extend from the vertical axis?
>For example, my vertical axis is numbered in increments of 10 and I
>would like these to go across the whole graph.
>
>Also, is there a way to have R label the value of each bar so that I
>know the value of each factor that is being plotted?
>
>Thanks in advance.
>
>jdr
>
>__
>R-help@stat.math.ethz.ch mailing list
>https://stat.ethz.ch/mailman/listinfo/r-help
>PLEASE do read the posting guide! http://www.R-project.org/posting-guide.html

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


Re: [R] Combining a list of similar dataframes into a single data frame [Broadcast]

2006-07-08 Thread Liaw, Andy
A couple of suggestions:
 
1. This screams out for do.call.  Try jj <- do.call("rbind", t1).
2. Use rowSums() instead of apply(..., 1, sum).
 
Andy

  _  

From: [EMAIL PROTECTED] on behalf of Mike Nielsen
Sent: Sat 7/8/2006 7:20 PM
To: r-help@stat.math.ethz.ch
Subject: Re: [R] Combining a list of similar dataframes into a single
dataframe [Broadcast]



Well, this worked, and rather more quickly than I had expected. 

Many thanks to the dogs, who told me the answer in return for walking 
them and feeding them! 

> jj <- eval(parse(text=paste(sep=" ","rbind(",paste(sep="
","t1[[",1:length(t1),"]]",collapse=","),")"))) 
> str(jj) 
`data.frame':   85644 obs. of  4 variables: 
 $ server  : Factor w/ 122 levels "AB93-99","AMP93-1",..: 1 1 1 1 
1 1 1 1 1 1 ... 
 $ ts  :'POSIXct', format: chr  "2006-06-30 12:31:44" 
"2006-06-30 12:32:58" "2006-06-30 12:34:46" "2006-06-30 12:36:55" ... 
 $ countername : Factor w/ 4 levels "Bytes Received/sec",..: 1 1 1 1 1 
1 1 1 1 1 ... 
 $ countervalue: numNA  938  816 4213  906 ... 
> 

On 7/8/06, Mike Nielsen <[EMAIL PROTECTED]> wrote: 
> I would be very grateful to anyone who could point to the error of my 
> ways in the following. 
> 
> I have a dataframe called net1, as such: 
> 
> > str(net1) 
> `data.frame':114192 obs. of  9 variables: 
>  $ server : Factor w/ 122 levels "AB93-99","AMP93-1",..: 1 1 1 
> 1 1 1 1 1 1 1 ... 
>  $ ts :'POSIXct', format: chr  "2006-06-30 12:31:44" 
> "2006-06-30 12:31:44" "2006-06-30 12:31:44" "2006-06-30 12:31:44" ... 
>  $ instance   : Factor w/ 22 levels "1","2","Compaq Ethernet_Fast 
> Ethernet Adapter_Module",..: 4 4 4 4 4 4 4 4 4 4 ... 
>  $ instanceno : Factor w/ 3 levels "1","2","3": 1 1 1 1 1 1 1 1 1 1
... 
>  $ perftime   : num  3.16e+13 3.16e+13 3.16e+13 3.16e+13 3.16e+13 ... 
>  $ perffreq   : num  6.99e+08 6.99e+08 6.99e+08 6.99e+08 6.99e+08 ... 
>  $ perftime100nsec: num  1.28e+17 1.28e+17 1.28e+17 1.28e+17 1.28e+17 ... 
>  $ countername: Factor w/ 4 levels "Bytes Received/sec",..: 1 3 2 
> 4 1 3 2 4 1 3 ... 
>  $ countervalue   : num  6.08e+07 6.64e+07 5.58e+06 1.00e+08 6.09e+07 ... 
> > 
> 
> What I am trying to do is subset this thing down by server, instance, 
> instanceno, countername and then apply a function to each subsetted 
> dataframe.  The function performs a calculation on countervalue, 
> essentially "collapsing" instanceno and instance down to a single 
> value. 
> 
> Here is a snippet of my code: 
> t1 <- by(net1, 
>  list( 
>   net1$server, 
>   factor(as.character(net1$countername))),# get rid of 
> unused levels of countername for this server 
>  function(x){ 
>g <- by(x, 
>list(factor(as.character(x$instance)), # get rid of 
> unused levels of instance for this server 
>factor(as.character(x$instanceno))),   # same with
instanceno 
> 
> function(y){c(NA,mean(y$perffreq)*diff(y$countervalue)/diff(y$perftime))})

>data.frame(server=x$server, 
>   ts=x$ts, 
>   countername = x$countername, 
>   countervalue = 
> apply(sapply(g[!sapply(g,is.null)],I),1,sum)) 
>  }) 
> 
> So t1 then is a list of dataframes, each with an identical set of columns)

> 
> > str(t1[[1]]) 
> `data.frame':   149 obs. of  4 variables: 
>  $ server  : Factor w/ 122 levels "AB93-99","AMP93-1",..: 1 1 1 1 
> 1 1 1 1 1 1 ... 
>  $ ts  :'POSIXct', format: chr  "2006-06-30 12:31:44" 
> "2006-06-30 12:32:58" "2006-06-30 12:34:46" "2006-06-30 12:36:55" ... 
>  $ countername : Factor w/ 4 levels "Bytes Received/sec",..: 1 1 1 1 1 
> 1 1 1 1 1 ... 
>  $ countervalue: numNA  938  816 4213  906 ... 
> 
> What I'd dearly love to do, without looping or lapply-ing through t1 
> and rbinding (too much data for this to finish quickly enough -- this 
> is about 10% of what I'm eventually going to have to manage), is 
> convert t1 to one big dataframe. 
> 
> On the other hand, I admit that I may be going about this wrongly from 
> the start; perhaps there's a better approach? 
> 
> Any pointers would be most gratefully received. 
> 
> Many thanks! 
> 
> 
> -- 
> Regards, 
> 
> Mike Nielsen 
> 


-- 
Regards, 

Mike Nielsen 

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


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


[R] Hunting for snow...

2006-07-08 Thread Brian Lunergan
Evening folks:

I did an install.views of finance and econometrics and between the two of 
them R reported 'FracSim', 'RDCOMClient', 'snow', 'VGAM', and 'segmented' 
as missing dependencies. Now, I've managed to hunt down what appear to be 
current zip file copies of all of the packages but 'snow'. Is there a 
windows edition of the package out there someplace that will get along with 
R v2.3.1 and if so, how do I find it?

Please and thanks...

-- 
Brian Lunergan
Nepean, Ontario
Canada


---
avast! Antivirus: Outbound message clean.
Virus Database (VPS): 0627-3, 2006-07-07
Tested on: 2006-07-08 20:53:28
avast! is copyright (c) 2000-2006 ALWIL Software.
http://www.avast.com

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


Re: [R] String mathematical function to R-function

2006-07-08 Thread Liaw, Andy
Here's one long-winded way of going about it, using R's ability to
manipulate functions as first class objects:
 
> f.string
[1] "x1 + sqrt(3*x2)"
> p.string <- parse(text=f.string)
> f <- function() {}# empty function
> v <- all.vars(p.string)  # all the variables in the expression
> a <- do.call("alist", as.list(rep(TRUE, length(v # contruct arguments
> names(a) <- v
> formals(f) <- a
> body(f) <- p.string
> f
function (x1 = TRUE, x2 = TRUE) 
x1 + sqrt(3 * x2)
> f(3, 4)
[1] 6.464102

Andy

  _  

From: [EMAIL PROTECTED] on behalf of Renaud Lancelot
Sent: Sat 7/8/2006 6:25 PM
To: Cleber N.Borges
Cc: r-help@stat.math.ethz.ch
Subject: Re: [R] String mathematical function to R-function [Broadcast]



> fun_String <- "-100*x1 + 0*x2 + 100*x3" 
> 
> fun <- function(x1, x2, x3){ 
+   eval(parse(text = fun_String)) 
+   } 
> 
> fun(4:0, -2:2, 0:4) 
[1] -400 -2000  200  400 

Best, 

Renaud 

2006/7/8, Cleber N.Borges <[EMAIL PROTECTED]>: 
> 
> 
> hello 
> 
> I make a subroutine that give-me a (mathematical) 
> function in string format. 
> I would like transform this string into function ( R 
> function ). 
> 
> thanks for any tips. 
> cleber 
> 
> 
> #e.g. 
> fun_String = "-100*x1 + 0*x2 + 100*x3" 
> 
> fun <- function(x1,x2,x3){ 
> return( 
>  
> 
> evaluation( fun_String ) 
> 
>  
> ) 
> 
> 
> 
> 
> 
> True String mathematical function :-(  :-( 
> 
> > nomes 
> [1] "8.49*x1*z1 + 6.13*x1*z2 + 6.4*x1*z3 + 6.9*x2*z1 + 
> 4.54*x2*z2 + 3.99*x2*z3 + 19.31*x3*z1 + 12.49*x3*z2 + 
> 3.86*x3*z3 + 5.25*x1*z1*z2 + -6.2*x1*z1*z3 + 
> 9.07*x1*z2*z3 + 10.87*x2*z1*z2 + 9.78*x2*z1*z3 + 
> 49.05*x2*z2*z3 + 4.56*x1*x2*z1 + -4.9*x1*x2*z2 + 
> 4.01*x1*x2*z3 + -0.39*x3*z1*z2 + 14.34*x3*z1*z3 + 
> 0.7*x3*z2*z3 + -2.84*x1*x3*z1 + 20.25*x1*x3*z2 + 
> 6.44*x1*x3*z3 + -4.91*x2*x3*z1 + 5.45*x2*x3*z2 + 
> 37.99*x2*x3*z3 + -22.24*x1*z1*z2*z3 + 
> -97.41*x2*z1*z2*z3 + -8.67*x1*x2*z1*z2 + 
> 49.14*x1*x2*z1*z3 + 14.24*x1*x2*z2*z3 + 
> 282.71*x3*z1*z2*z3 + 34.83*x1*x3*z1*z2 + 
> 111.2*x1*x3*z1*z3 + 101.38*x1*x3*z2*z3 + 
> -6.93*x2*x3*z1*z2 + 90.16*x2*x3*z1*z3 + 
> -9.11*x2*x3*z2*z3 + 17.22*x1*x2*x3*z1 + 
> -29.42*x1*x2*x3*z2 + -19.87*x1*x2*x3*z3 + 
> -277.41*x1*x2*z1*z2*z3 + -482.82*x1*x3*z1*z2*z3 + 
> -688.23*x2*x3*z1*z2*z3 + -588.4*x1*x2*x3*z1*z2 + 
> -197.31*x1*x2*x3*z1*z3 + -722.58*x1*x2*x3*z2*z3 + 
> 5536.59*x1*x2*x3*z1*z2*z3" 
> > 
> 
> 
> 
> 
> 
> ___ 
> 
> o discador agora! 
> 
> __ 
> R-help@stat.math.ethz.ch mailing list 
> https://stat.ethz.ch/mailman/listinfo/r-help
  
> PLEASE do read the posting guide!
http://www.R-project.org/posting-guide.html
  
> 


-- 
Renaud LANCELOT 
Département Elevage et Médecine Vétérinaire (EMVT) du CIRAD 
Directeur adjoint chargé des affaires scientifiques 

CIRAD, Animal Production and Veterinary Medicine Department 
Deputy director for scientific affairs 

Campus international de Baillarguet 
TA 30 / B (Bât. B, Bur. 214) 
34398 Montpellier Cedex 5 - France 
Tél   +33 (0)4 67 59 37 17 
Secr. +33 (0)4 67 59 39 04 
Fax   +33 (0)4 67 59 37 95 

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


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


[R] last 2 questions about save and load

2006-07-08 Thread markleeds
i played around and i get the hang of save and load. I just
have two final questions :

1) is loading the RandomFields package the only
way to check if a file ( created through the save function )
is out there or not ? Because, I generally won't know if one has
been created yet or not.

2) Suppose, you have the case where you
created and saved a file. When you do an ls()
without loading that file, it doesn't show up in the list
obviously. So, if you want to delete that file for whatever
reason, is it possible ? Thanks.

   Mark

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


[R] package:Matrix handling of data with identical indices

2006-07-08 Thread Thaden, John J
In the Matrix package v. 0.995-11 I see that the dgTMatrix
Class for compressed, sparse, triplet-form matrices handles
Identically indexed data instances by summing their values,
e.g., 

library(Matrix)
(Mt <- new("dgTMatrix", 
   i = as.integer(c(0,0,1,1,4)),
   j = as.integer(c(0,1,2,2,4)),
   x = as.double(1:5),
   Dim = as.integer(c(5,5
## 5 x 5 sparse Matrix of class "dgTMatrix"
## [1,] 1 2 . . .
## [2,] . . 7 . .<--- 7 = 3 + 4.
## [3,] . . . . .
## [4,] . . . . .
## [5,] . . . . 5

# If instead I make a dgCMatrix-class matrix, the first
# instance is overwritten by the second, e.g.,

library(Matrix)
(Mc <- new("dgCMatrix", 
   i = as.integer(c(0,0,1,1,4)),
   p = as.integer(c(0,1,2,4,5)),
   x = as.double(1:5),
   Dim = as.integer(c(5,5
## 5 x 5 sparse Matrix of class "dgCMatrix"
## 
## [1,] 1 2 . .
## [2,] . . 4 .   <-- the datum '3' has been lost.
## [3,] . . . .
## [4,] . . . .
## [5,] . . . 5 

# If one arrives at the dgCMatrix via the dgTMatrix class,
# the summed value is of course preserved, e.g.,

(Mtc <- as(Mt, "dgCMatrix"))
## 5 x 5 sparse Matrix of class "dgCMatrix"
##   
## [1,] 1 2 . . .
## [2,] . . 7 . .
## [3,] . . . . .
## [4,] . . . . .
## [5,] . . . . 5

As there is nothing inherent in either compressed, sparse,
format that would prevent recognition and handling of
duplicated index pairs, I'm curious why the dgCMatrix
class doesn't also add x values in those instances?
I wonder also if others might benefit also by being able
to choose how these instances are handled, i.e.,
whether they are summed, averaged or overwritten?  

-John Thaden, Ph.D.
Research Assistant Professor of Geriatrics
University of Arkansas for Medical Sciences
Little Rock AR, USA


Confidentiality Notice: This e-mail message, including any a...{{dropped}}

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


Re: [R] Non-Numeric Histograms

2006-07-08 Thread Jim Lemon
justin rapp wrote:
> I have a dataset with a variable that is non-numeric.  I was wondering
> if there is an easy way in R to create a bar graph that will tell me
> how many of each level of this non-numeric variable are in the overall
> dataset.
> 
> Specifically, if my variable is LETTER, and I have A, B,C, D, E, F and
> I want to find out how many of each letter there are, what is the
> easiest way to do this in R and use the information to make a plot?
> 
Hi Justin,

You might want to take a look at freq and plot.freq in the plotrix package.

JIm

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


Re: [R] dotplot (lattice) with panel.segments and groups

2006-07-08 Thread Sebastian Luque
"Gabor Grothendieck" <[EMAIL PROTECTED]> wrote:

On 7/7/06, Deepayan Sarkar <[EMAIL PROTECTED]> wrote:

> On 7/7/06, Gabor Grothendieck <[EMAIL PROTECTED]> wrote:
>>> Could you explain what panel.groups= does and what the difference
>>> is between panel.groups= and panel= ?  In ?xyplot it just says:

>>> panel.groups: useful mostly for 'xyplot' and 'densityplot'. Applies
>>> when 'panel' is 'panel.superpose' (which happens by default
>>> in these cases if 'groups' is non-null)

>>> which indicates when it might apply but not what it does.

>> That's wrong (it used to be right - a good example of why \synopsis is
>> bad). Since lattice 0.13-x, panel.superpose is never the default panel
>> function. An updated version with improved documentation should be out
>> soon.

>> 'panel.groups' is simply an argument to panel.superpose, and is
>> described in ?panel.superpose. Thus, it only makes sense as an
>> argument to xyplot/dotplot/whatever when the panel function is
>> panel.superpose, and not otherwise. The entry for the graphical
>> parameters in ?panel.superpose isn't as useful as it could be, I have
>> just updated it to read:

>> col, col.line, col.symbol, pch, cex, fill, font, fontface,
>> fontfamily, lty, lwd, alpha: graphical
>> parameters, replicated to be as long as the number of
>> groups.  These are eventually passed down to 'panel.groups',
>> but as scalars rather than vectors.  When 'panel.groups' is
>> called for the i-th level of 'groups', the corresponding
>> element of each graphical parameter is passed to it.

>> Hope that makes things a bit clearer.


Thanks Gabor and Deepayan for your responses.


Cheers,

-- 
Seb

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