# [R] help with interpreting what nnet() output gives:

Hassan, Hafsa Hafsa.Hassan at trgworld.com
Thu Jun 30 12:32:24 CEST 2011

```Greetings list,

I am new to programming in R, and am using nnet() function for a project on
neural networking.

Firstly I wish to ask if there is any pdf explaining the algorithm nnet
uses, which could tell me what the objects of the nnet class, like 'conn',
'nconn, 'nsunits', n and 'nunits' mean, and how weights are calculated.
The package pdf has little or no explanations, and the C +R source code
availabe at CRAN is too difficult to comprehend. Can anyone please help?

Also, i wish to know how the *number* of weights is calculated. When the
nnet() command is run, it ouputs, on the console, the number of weights, and
values of 'value'. But how do you calculate the number of weights in nnet,
say, if you are feeding it an MxN inputs dataframe (i.e. M observations,
each having N inputs, like the iris dataset has M=150 and N=4), and getting,
say, x number of outputs for each observation?

Thank you,
Hafsa

The code I used is from the Package nnet pdf:(nneds nnet package loaded)

# use half the iris data
ir <- rbind(iris3[,,1],iris3[,,2],iris3[,,3])
targets <- class.ind( c(rep("s", 50), rep("c", 50), rep("v", 50)) )
samp <- c(sample(1:50,25), sample(51:100,25), sample(101:150,25))
ir1 <- nnet(ir[samp,], targets[samp,], size = 2, rang = 0.1,
decay = 5e-4, maxit = 200)
test.cl <- function(true, pred) {
true <- max.col(true)
cres <- max.col(pred)
table(true, cres)
}
test.cl(targets[-samp,], predict(ir1, ir[-samp,]))

_________________________________________________________________

> bounding box of Australia and all elements have the value of -9990
>
> bb<-matrix(c(rep(-9999,691*886)),nrow=691
> ,ncol=886,dimnames=list(seq(-10,-44.50,by=-0.05),seq(112,156.25,by=0.05)))
>
> #dfr with row names and col names and values to be replaced in the matrix
>
> dfr <- data.frame(cbind(x=seq(120,125,by=0.05), y=-25, var.1=1))

Why are you making this into a dataframe? You're ending up with y
containing -25 repeated 101 times, and var.1 containing 1 repeated 101
times. If these aren't actually going to be different in your final
version, I'd make a list instead.

Also, x actually corresponds to the column names of bb, and y to the rownames.

> #insert the values from the dfr into the matrix
> bb[dfr\$x,dfr\$y]<-d\$var.1

And then you're trying to use x and y for indexing, rather than
comparing them to the names of bb.

You need to use (with x and y switched):
bb[rownames(bb) %in% as.character(dfr\$y), colnames(bb) %in% as.character(dfr\$x)]

And you can assign anything you want to that, except d\$var.1 because
that doesn't exist. Presumably you mean dfr\$var.1.

Sarah

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

------------------------------

Message: 2
Date: Wed, 29 Jun 2011 12:26:18 +0200
From: Kai Serschmarn <serschmarn at googlemail.com>
To: r-help at r-project.org
Subject: Re: [R] parse XML file
Message-ID: <562B00CB-95D5-45C1-A387-CF285C3315F4 at gmail.com>
Content-Type: text/plain; charset=US-ASCII; format=flowed; delsp=yes

Thank you Barry, that works fine.
Sorry for stupid questions... however, I couldn't manage to get a
dataframe out of this.

That's what I was doing:

dumpData <-  function(doc){
for(i in 1:length(doc)){
stns = doc[[i]]
for (j in 1:length(stns)){
cat(stns\$attributes['value'],stns[[j]][[1]]\$value,stns[[j]]
\$attributes['date'],"\n")
}
}
}
dumpData(doc)

Thanks for your helping
kai
>
> Am 29.06.2011 um 1106 schrieb Barry Rowlingson:
>
>> Run that on your doc to see it printed out. Save to a data frame if
>> that's what you need.
>>
>> This is not the perfect way to do it, since if you have other (non
>> <stationname> or <v>) elements it'll try and handle those too, and
>> fail. There's probably a way of looping over all <stationname>
>> elements but XML makes me feel sick when I try and remember how to
>> parse it in R at this time of the morning. its probably in the docs
>> but this should get you started.
>>
>> Barry
>

------------------------------

Message: 3
Date: Wed, 29 Jun 2011 07:57:23 -0400
From: Ben Tupper <btupper at bigelow.org>
To: r-help cran-R <r-help at r-project.org>
Cc: Kai Serschmarn <serschmarn at googlemail.com>
Subject: Re: [R] parse XML file
Message-ID: <A1DC0866-780F-47F3-9E66-DB6C225B40CE at bigelow.org>
Content-Type: text/plain; charset=US-ASCII; format=flowed; delsp=yes

Hi,

On Jun 29, 2011, at 6:26 AM, Kai Serschmarn wrote:

> Thank you Barry, that works fine.
> Sorry for stupid questions... however, I couldn't manage to get a
> dataframe out of this.
>
> That's what I was doing:
>
> doc = xmlRoot(xmlTreeParse("de.dwd.klis.TADM.xml"))
> dumpData <-  function(doc){
> 	for(i in 1:length(doc)){
> 		stns = doc[[i]]
> 	for (j in 1:length(stns)){
> 		cat(stns\$attributes['value'],stns[[j]][[1]]\$value,stns[[j]]
> \$attributes['date'],"\n")
> 		}
> 		}
> 		}
> dumpData(doc)
>

Perhaps this would work for you.  It generates a list of data frames,
one for each station.

###### BEGIN

## start with your doc - split it into a list of nodes (one for each
child)
stn <-  xmlChildren(doc)

# converts a station node to a data frame
getMyStation <- function(x){

# get the name of the station
stationName <- xmlAttrs(x)["value"]

# a function to extract the date and value
getMyRecords <- function(x){
date <- xmlAttrs(x)["date"]
val <- xmlValue(x)
y <- c( date, val)
return(y)
}

# for each child, extract the records
r <- lapply(x, getMyRecords)
nR <- length(r)

# bind into one matrix - all characters as this point
y <- do.call(rbind, r)

# make a data.frame
df <- data.frame("Station" = rep(stationName, nR), "date" = y[,1],
"value" = y[,2],
row.names = 1:nR, stringsAsFactors = FALSE)

return(df)
}

# now loop through the station nodes - extract data into a data frame
x <- lapply(stn, getMyStation)

##### END

Cheers,
Ben

Ben Tupper
Bigelow Laboratory for Ocean Sciences
180 McKown Point Rd. P.O. Box 475
West Boothbay Harbor, Maine   04575-0475
http://www.bigelow.org/

------------------------------

Message: 4
Date: Wed, 29 Jun 2011 14:25:59 +0200
To: r-help at r-project.org
Subject: [R] Tell emacs to load new R version
Message-ID: <BANLkTimDCf_JB12vwDM-FS=9NA7LGh6+nQ at mail.gmail.com>
Content-Type: text/plain

Dear,

How do I tell Emacs to update to the new R version I installed? It still
loads the old R version. I already updated the the system path, but that
didn't seem to work.

Thanks for your help,

--

[[alternative HTML version deleted]]

------------------------------

Message: 5
Date: Wed, 29 Jun 2011 01:09:58 -0700 (PDT)
From: Hafsa Hassan <Hafsa.Hassan at trgworld.com>
To: r-help at r-project.org
Subject: Re: [R] What training algorithm does nnet package use?
Message-ID: <1309334998583-3632339.post at n4.nabble.com>
Content-Type: text/plain; charset=us-ascii

Greetings list,

I am new to programming in R, and am using nnet() function for a project on
neural networking.

Firslty i widh to ask if there is any pdf explaining the algorithm nnet
uses, which could tell me what the objects of the nnet class, like 'conn',
'nconn, 'nsunits', n and 'nunits' mean, and how weights are calculated.
The package odf has little or no explanations, and the C +R surce code
availabe at CRAN is too difficult to comprehend. Can anyone please help?

Also, i wish to know how the *number* of wieghts is calculated. when the
nnet() command is run, it ouputs, on the console, the number of weights, and
values of 'value'. But how do you calculate the bnumber of weights in nnet,
say, if you are feeding it an MxN inputs dataframe (i.e. M observations,
each having N inputs, like the iris dataset has M=150 and N=4), and getting,
say, x number of outouts for each observation?

Thank you,
Hafsa

--
View this message in context: http://r.789695.n4.nabble.com/R-What-training-algorithm-does-nnet-package-use-tp813206p3632339.html
Sent from the R help mailing list archive at Nabble.com.

------------------------------

Message: 6
Date: Wed, 29 Jun 2011 17:54:51 +0900
From: Takatsugu Kobayashi <taquito2007 at gmail.com>
To: R-help at r-project.org
Subject: [R] customer segmentation using a large data with many zeros
Message-ID: <BANLkTi=T8Gnv8VFq2bOhD=99AOxHFjsBCw at mail.gmail.com>
Content-Type: text/plain; charset=ISO-8859-1

Hi,

I am looking for clustering techniques that are tolerant to large
datasets (500,000 unique customers with transaction records).

I basically would like to conduct customer segmentation based on their
transaction history - what they bought, how often they visited stores,
demographics etc. And transaction part of the data is binary: 1 if
they bought, let's say, fruits etc.

Now the problem is that

1. transaction part includes lots of zeros
2. not every variables are continuous

Polychoric correlations might be useful for the second part, but I am
not sure how to go about the first one.
I appreciate if anyone could give me advice.

Thanks!!

Taka

------------------------------

Message: 7
Date: Wed, 29 Jun 2011 09:20:54 +0000
From: Martin Wilkes <m.wilkes at worc.ac.uk>
To: "r-help at r-project.org" <r-help at r-project.org>
Subject: [R] Gaussian low-pass filter
Message-ID:
<0FF99068D2A5FE47B4E705BF5A997B30A406 at EX-MBX-01.worc.ac.uk>
Content-Type: text/plain; charset="iso-8859-7"

I want to filter my time series with a low-pass filter using a Gaussian smoothing function defined as:

w(t) = (2??^2)^0.5  exp(-t^2/2?^2)

I was hoping to use an existing function to filter my data but help.search and Rsitesearch produced no useful results.

Can anyone tell me if there is an existing function that will do the job?  If not, how would I begin to go about building such a filter?

Thanks

Martin Wilkes
University of Worcester

------------------------------

Message: 8
Date: Wed, 29 Jun 2011 11:38:17 +0200
From: Ida Dolciotti <ida.dolciotti at ufz.de>
To: r-help at r-project.org
Subject: [R] Find the function of a line
Message-ID: <4E0AF289.3050909 at ufz.de>
Content-Type: text/plain; CHARSET=US-ASCII; format=flowed

Hello everybody,

I have drawn a line in a x y plot  that links the minimum and maximum
points in the plot

plot(xx,yy)

a=max(yy)
b=min(yy)

lines(c(xx[yy==a],xx[yy==b]),c(a,b))

Now I would like to know if it is possible to extrapolate the
characteristic of the line (intercept and slope).

Is it there and appropriate function for this?

Thanks for your help!

Ida D.

--
Ida Dolciotti, M.Sc.
Phd student, Dept. System Ecotoxicology
Helmholtz Centre for Environmental Research - UFZ
Permoserstr. 15
04318 Leipzig

phone:	+49 - 341/235-1498
fax: 	+49 - 341/235-1785

email: ida.dolciotti at ufz.de
website: http://www.ufz.de/index.php?en=17738

------------------------------

Message: 9
Date: Wed, 29 Jun 2011 16:49:10 +0700
From: "Lam Phung Khanh" <lampk at oucru.org>
To: <r-help at r-project.org>
Subject: [R] Problem: Update of glm-object cannot find where the data
object	is located
Message-ID:
<6445519563098A4DAC6475E596D9233701E7B66E at bemail.oucru.org>
Content-Type: text/plain;	charset="US-ASCII"

Hi everybody,

I want to ask your help to explain what is going on with my following
code:

> mydata <- data.frame(y=rbinom(100, 1, 0.5), x1=rnorm(100),
x2=rnorm(100))

> glm.fit.method <-
function(model,data,...){glm(formula=model,data=data,family="binomial",.
..)}

> fit1 <- glm(y ~ x1 + x2, data=mydata, family=binomial())
> update(fit1, .~1)

Call:  glm(formula = y ~ 1, family = binomial(), data = mydata)

Coefficients:
(Intercept)
-0.04001

Degrees of Freedom: 99 Total (i.e. Null);  99 Residual
Null Deviance:       138.6
Residual Deviance: 138.6              AIC: 140.6

> fit2 <- glm.fit.method(y ~ x1 + x2, data=mydata)
> update(fit2, .~1)

Error in as.data.frame.default(data, optional = TRUE) :
cannot coerce class '"function"' into a data.frame

One might expect that model 1 and model 2 are the same. So, it is
strange when this error occured. We can fix it easily by telling
"update" which data to evaluate:

> update(fit2, .~1, data=mydata)

Call:  glm(formula = y ~ 1, family = "binomial", data = mydata)

Coefficients:
(Intercept)
-0.04001

Degrees of Freedom: 99 Total (i.e. Null);  99 Residual
Null Deviance:       138.6
Residual Deviance: 138.6              AIC: 140.6

I guest the problem may due to the fact that "update" requires
specifying which data is updated or the dataset named "data". fit1 and
fit2 just differ in a very small point:
> fit1\$call
glm(formula = y ~ x1 + x2, family = binomial(), data = mydata)
> fit2\$call
glm(formula = model, family = "binomial", data = data)

I am looking forward to your response,

Thanks,

Lam Phung Khanh
PhD student
Centre for Tropical Medicine
Oxford University Clinical Research Unit
190 Ben Ham Tu, Quan 5, Ho Chi Minh City
Vietnam
E-mail: lampk at oucru.org

P/S: Detail of my current R version is

R version 2.13.0 (2011-04-13)
Platform: i386-pc-mingw32/i386 (32-bit)

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

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

loaded via a namespace (and not attached):
[1] tools_2.13.0

------------------------------

Message: 10
Date: Wed, 29 Jun 2011 02:53:38 -0700 (PDT)
From: Komal <Komalsharif86 at gmail.com>
To: r-help at r-project.org
Subject: Re: [R] 2D Random walk
Message-ID: <1309341218546-3632459.post at n4.nabble.com>
Content-Type: text/plain; charset=us-ascii

Hi,

I saw your code and try running it, it works!! Can you please write this
code in a user defined function.
I tried making it with making a function and cant run it.

--
View this message in context: http://r.789695.n4.nabble.com/2D-Random-walk-tp3069557p3632459.html
Sent from the R help mailing list archive at Nabble.com.

------------------------------

Message: 11
Date: Wed, 29 Jun 2011 03:01:51 -0700 (PDT)
From: Komal <Komalsharif86 at gmail.com>
To: r-help at r-project.org
Subject: [R] 2d rndom walk
Message-ID: <1309341711503-3632468.post at n4.nabble.com>
Content-Type: text/plain; charset=us-ascii

Hi all,

Can anyone please tell me how to calculate the expected distance covered in
a 2d random walk. Please!

--
View this message in context: http://r.789695.n4.nabble.com/2d-rndom-walk-tp3632468p3632468.html
Sent from the R help mailing list archive at Nabble.com.

------------------------------

Message: 12
Date: Wed, 29 Jun 2011 04:12:44 -0700 (PDT)
From: 2pol <philippkynast at gmx.de>
To: r-help at r-project.org
Subject: [R] XML parsing
Message-ID: <1309345964507-3632544.post at n4.nabble.com>
Content-Type: text/plain; charset=UTF-8

Hi,
i want to parse a XML-File.
I made some Tutorial but with my special Format it don't work.
An Example of my format:

<?xml version="1.0" encoding="ISO-8859-1"?>
<mzML xmlns="http://psi.hupo.org/ms/mzml"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://psi.hupo.org/ms/mzml
http://psidev.info/files/ms/mzML/xsd/mzML1.1.0_idx.xsd" version="1.1">
<cvList count="3">
<cv id="MS" fullName="Proteomics Standards Initiative Mass Spectrometry
Ontology" version="1.3.1" URI="http://psidev.info/ms/mzML/psi-ms.obo"/>
<cv id="UO" fullName="Unit Ontology" version="1.15"
URI="http://obo.cvs.sourceforge.net/obo/obo/ontology/phenotype/unit.obo"/>
<cv id="IMS" fullName="Imaging MS Ontology" version="0.9.1"
</cvList>
<fileDescription>
<fileContent>
<cvParam cvRef="MS" accession="MS:1000579" name="MS1 spectrum"
value=""/>
<cvParam cvRef="MS" accession="MS:1000128" name="profile spectrum"
value=""/>
<cvParam cvRef="IMS" accession="IMS:1000080" name="universally unique
identifier" value="{554A27FA-79D2-4766-9A2C-862E6D78B1F3}"/>
<cvParam cvRef="IMS" accession="IMS:1000091" name="ibd SHA-1"
value="A5BE532D25997B71BE6D20C76561DDC4D5307DDD"/>
<cvParam cvRef="IMS" accession="IMS:1000030" name="continuous"
value=""/>
</fileContent>
<sourceFileList count="1">
<sourceFile id="sf1" name="Example.raw" location="C:\Users\Thorsten
Schramm\Documents\Promotion\imzML\Website\files\Beispiel-Dateien\Example
images\">
<cvParam cvRef="MS" accession="MS:1000563" name="Thermo RAW file"
value=""/>
<cvParam cvRef="MS" accession="MS:1000768" name="Thermo nativeID
format" value=""/>
<cvParam cvRef="MS" accession="MS:1000569" name="SHA-1"
value="7623BE263B25FF99FDF017154B86FAB742D4BB0B"/>
</sourceFile>
</sourceFileList>
<contact>
<cvParam cvRef="MS" accession="MS:1000586" name="contact name"
value="Thorsten Schramm"/>
<cvParam cvRef="MS" accession="MS:1000590" name="contact organization"
value="Institut f?r Anorganische und Analytische Chemie"/>
<cvParam cvRef="MS" accession="MS:1000587" name="contact address"
value="Schubertstra?e 60, Haus 16, Gie?en, Germany"/>
<cvParam cvRef="MS" accession="MS:1000589" name="contact email"
value="thorsten.schramm at anorg.chemie.uni-.giessen.de"/>
</contact>
</fileDescription>
<referenceableParamGroupList count="4">
<referenceableParamGroup id="mzArray">
<cvParam cvRef="MS" accession="MS:1000576" name="no compression"
value=""/>
<cvParam cvRef="MS" accession="MS:1000514" name="m/z array" value=""
unitCvRef="MS" unitAccession="MS:1000040" unitName="m/z"/>
<cvParam cvRef="IMS" accession="IMS:1000101" name="external data"
value="true"/>
<cvParam cvRef="MS" accession="MS:1000521" name="32-bit float"
value=""/>
</referenceableParamGroup>
<referenceableParamGroup id="intensityArray">
<cvParam cvRef="MS" accession="MS:1000576" name="no compression"
value=""/>
<cvParam cvRef="MS" accession="MS:1000515" name="intensity array"
value="" unitCvRef="MS" unitAccession="MS:1000131" unitName="number of
counts"/>
<cvParam cvRef="IMS" accession="IMS:1000101" name="external data"
value="true"/>
<cvParam cvRef="MS" accession="MS:1000521" name="32-bit float"
value=""/>
</referenceableParamGroup>
<referenceableParamGroup id="scan1">
<cvParam cvRef="MS" accession="MS:1000093" name="increasing m/z scan"
value=""/>
<cvParam cvRef="MS" accession="MS:1000095" name="linear" value=""/>
<cvParam cvRef="MS" accession="MS:1000512" name="filter string"
value="ITMS - p NSI Full ms [100,00-800,00]"/>
</referenceableParamGroup>
<referenceableParamGroup id="spectrum1">
<cvParam cvRef="MS" accession="MS:1000579" name="MS1 spectrum"
value=""/>
<cvParam cvRef="MS" accession="MS:1000511" name="ms level" value="0"/>
<cvParam cvRef="MS" accession="MS:1000128" name="profile spectrum"
value=""/>
<cvParam cvRef="MS" accession="MS:1000129" name="negative scan"
value=""/>
</referenceableParamGroup>
</referenceableParamGroupList>
<sampleList count="1">
<sample id="sample1" name="Sample1">
<cvParam cvRef="MS" accession="MS:1000001" name="sample number"
value="1"/>
</sample>
</sampleList>
<softwareList count="2">
<software id="Xcalibur" version="2.2">
<cvParam cvRef="MS" accession="MS:1000532" name="Xcalibur" value=""/>
</software>
<software id="TMC" version="1.1 beta">
<cvParam cvRef="MS" accession="MS:1000799" name="custom unreleased
software tool" value=""/>
</software>
</softwareList>
<scanSettingsList count="1">
<scanSettings id="scansettings1">
<cvParam cvRef="IMS" accession="IMS:1000401" name="top down"
value=""/>
<cvParam cvRef="IMS" accession="IMS:1000413" name="flyback" value=""/>
<cvParam cvRef="IMS" accession="IMS:1000480" name="horizontal line
scan" value=""/>
<cvParam cvRef="IMS" accession="IMS:1000491" name="linescan left
right" value=""/>
<cvParam cvRef="IMS" accession="IMS:1000042" name="max count of pixel
x" value="3"/>
<cvParam cvRef="IMS" accession="IMS:1000043" name="max count of pixel
y" value="3"/>
<cvParam cvRef="IMS" accession="IMS:1000044" name="max dimension x"
value="300" unitCvRef="UO" unitAccession="UO:0000017"
unitName="micrometer"/>
<cvParam cvRef="IMS" accession="IMS:1000045" name="max dimension y"
value="300" unitCvRef="UO" unitAccession="UO:0000017"
unitName="micrometer"/>
<cvParam cvRef="IMS" accession="IMS:1000046" name="pixel size x"
value="100" unitCvRef="UO" unitAccession="UO:0000017"
unitName="micrometer"/>
<cvParam cvRef="IMS" accession="IMS:1000047" name="pixel size y"
value="100" unitCvRef="UO" unitAccession="UO:0000017"
unitName="micrometer"/>
<cvParam cvRef="MS" accession="MS:1000836" name="dried dropplet"
value=""/>
<cvParam cvRef="MS" accession="MS:1000835" name="matrix solution
concentration" value="10"/>
<cvParam cvRef="MS" accession="MS:1000834" name="matrix solution"
value="DHB"/>
</scanSettings>
</scanSettingsList>
<instrumentConfigurationList count="1">
<instrumentConfiguration id="LTQFTUltra0">
<cvParam cvRef="MS" accession="MS:1000557" name="LTQ FT Ultra"
value=""/>
<cvParam cvRef="MS" accession="MS:1000529" name="instrument serial
number" value="none"/>
<componentList count="3">
<source order="1">
<cvParam cvRef="MS" accession="MS:1000073" name="electrospray
ionization" value=""/>
<cvParam cvRef="MS" accession="MS:1000485" name="nanospray inlet"
value=""/>
<cvParam cvRef="MS" accession="MS:1000843" name="wavelength"
value="337"/>
<cvParam cvRef="MS" accession="MS:1000844" name="focus diameter x"
value="10"/>
<cvParam cvRef="MS" accession="MS:1000845" name="focus diameter y"
value="10"/>
<cvParam cvRef="MS" accession="MS:1000846" name="pulse energy"
value="10"/>
<cvParam cvRef="MS" accession="MS:1000847" name="pulse duration"
value="10"/>
<cvParam cvRef="MS" accession="MS:1000848" name="attenuation"
value="50"/>
<cvParam cvRef="MS" accession="MS:1000850" name="gas laser"
value=""/>
<cvParam cvRef="IMS" accession="IMS:1000202" name="target
material" value="Conductive Glas"/>
</source>
<analyzer order="2">
<cvParam cvRef="MS" accession="MS:1000264" name="ion trap"
value=""/>
<cvParam cvRef="MS" accession="MS:1000014" name="accuracy"
value="0" unitCvRef="MS" unitAccession="MS:1000040" unitName="m/z"/>
</analyzer>
<detector order="3">
<cvParam cvRef="MS" accession="MS:1000253" name="electron
multiplier" value=""/>
<cvParam cvRef="MS" accession="MS:1000120" name="transient
recorder" value=""/>
</detector>
</componentList>
<softwareRef ref="Xcalibur"/>
</instrumentConfiguration>
</instrumentConfigurationList>
<dataProcessingList count="2">
<dataProcessing id="XcaliburProcessing">
<processingMethod order="1" softwareRef="Xcalibur">
<cvParam cvRef="MS" accession="MS:1000594" name="low intensity data
point removal" value=""/>
</processingMethod>
</dataProcessing>
<dataProcessing id="TMCConversion">
<processingMethod order="2" softwareRef="TMC">
<cvParam cvRef="MS" accession="MS:1000544" name="Conversion to mzML"
value=""/>
</processingMethod>
</dataProcessing>
</dataProcessingList>
<run defaultInstrumentConfigurationRef="LTQFTUltra0"
defaultSourceFileRef="sf1" id="Experiment01" sampleRef="sample1"
startTimeStamp="2009-08-11T15:59:44">
<spectrumList count="9" defaultDataProcessingRef="XcaliburProcessing">
<spectrum id="Scan=1" defaultArrayLength="0" index="0">
<referenceableParamGroupRef ref="spectrum1"/>
<scanList count="1">
<cvParam cvRef="MS" accession="MS:1000795" name="no combination"
value=""/>
<scan instrumentConfigurationRef="LTQFTUltra0">
<referenceableParamGroupRef ref="scan1"/>
<cvParam cvRef="IMS" accession="IMS:1000050" name="position x"
value="1"/>
<cvParam cvRef="IMS" accession="IMS:1000051" name="position y"
value="1"/>
</scan>
</scanList>
<binaryDataArrayList count="2">
<binaryDataArray encodedLength="0">
<referenceableParamGroupRef ref="mzArray"/>
<cvParam cvRef="IMS" accession="IMS:1000103" name="external
array length" value="8399"/>
<cvParam cvRef="IMS" accession="IMS:1000102" name="external
offset" value="16"/>
<cvParam cvRef="IMS" accession="IMS:1000104" name="external
encoded length" value="33596"/>
<binary/>
</binaryDataArray>
<binaryDataArray encodedLength="0">
<referenceableParamGroupRef ref="intensityArray"/>
<cvParam cvRef="IMS" accession="IMS:1000103" name="external
array length" value="8399"/>
<cvParam cvRef="IMS" accession="IMS:1000102" name="external
offset" value="33612"/>
<cvParam cvRef="IMS" accession="IMS:1000104" name="external
encoded length" value="33596"/>
<binary/>
</binaryDataArray>
</binaryDataArrayList>
</spectrum>
<spectrum id="Scan=2" defaultArrayLength="0" index="1">
<referenceableParamGroupRef ref="spectrum1"/>
<scanList count="1">
<cvParam cvRef="MS" accession="MS:1000795" name="no combination"
value=""/>
<scan instrumentConfigurationRef="LTQFTUltra0">
<referenceableParamGroupRef ref="scan1"/>
<cvParam cvRef="IMS" accession="IMS:1000050" name="position x"
value="2"/>
<cvParam cvRef="IMS" accession="IMS:1000051" name="position y"
value="1"/>
</scan>
</scanList>
<binaryDataArrayList count="2">
<binaryDataArray encodedLength="0">
<referenceableParamGroupRef ref="mzArray"/>
<cvParam cvRef="IMS" accession="IMS:1000103" name="external
array length" value="8399"/>
<cvParam cvRef="IMS" accession="IMS:1000102" name="external
offset" value="16"/>
<cvParam cvRef="IMS" accession="IMS:1000104" name="external
encoded length" value="33596"/>
<binary/>
</binaryDataArray>
<binaryDataArray encodedLength="0">
<referenceableParamGroupRef ref="intensityArray"/>
<cvParam cvRef="IMS" accession="IMS:1000103" name="external
array length" value="8399"/>
<cvParam cvRef="IMS" accession="IMS:1000102" name="external
offset" value="67208"/>
<cvParam cvRef="IMS" accession="IMS:1000104" name="external
encoded length" value="33596"/>
<binary/>
</binaryDataArray>
</binaryDataArrayList>
</spectrum>
<spectrum id="Scan=3" defaultArrayLength="0" index="2">
<referenceableParamGroupRef ref="spectrum1"/>
<scanList count="1">
<cvParam cvRef="MS" accession="MS:1000795" name="no combination"
value=""/>
<scan instrumentConfigurationRef="LTQFTUltra0">
<referenceableParamGroupRef ref="scan1"/>
<cvParam cvRef="IMS" accession="IMS:1000050" name="position x"
value="3"/>
<cvParam cvRef="IMS" accession="IMS:1000051" name="position y"
value="1"/>
</scan>
</scanList>
<binaryDataArrayList count="2">
<binaryDataArray encodedLength="0">
<referenceableParamGroupRef ref="mzArray"/>
<cvParam cvRef="IMS" accession="IMS:1000103" name="external
array length" value="8399"/>
<cvParam cvRef="IMS" accession="IMS:1000102" name="external
offset" value="16"/>
<cvParam cvRef="IMS" accession="IMS:1000104" name="external
encoded length" value="33596"/>
<binary/>
</binaryDataArray>
<binaryDataArray encodedLength="0">
<referenceableParamGroupRef ref="intensityArray"/>
<cvParam cvRef="IMS" accession="IMS:1000103" name="external
array length" value="8399"/>
<cvParam cvRef="IMS" accession="IMS:1000102" name="external
offset" value="100804"/>
<cvParam cvRef="IMS" accession="IMS:1000104" name="external
encoded length" value="33596"/>
<binary/>
</binaryDataArray>
</binaryDataArrayList>
</spectrum>
<spectrum id="Scan=4" defaultArrayLength="0" index="3">
<referenceableParamGroupRef ref="spectrum1"/>
<scanList count="1">
<cvParam cvRef="MS" accession="MS:1000795" name="no combination"
value=""/>
<scan instrumentConfigurationRef="LTQFTUltra0">
<referenceableParamGroupRef ref="scan1"/>
<cvParam cvRef="IMS" accession="IMS:1000050" name="position x"
value="1"/>
<cvParam cvRef="IMS" accession="IMS:1000051" name="position y"
value="2"/>
</scan>
</scanList>
<binaryDataArrayList count="2">
<binaryDataArray encodedLength="0">
<referenceableParamGroupRef ref="mzArray"/>
<cvParam cvRef="IMS" accession="IMS:1000103" name="external
array length" value="8399"/>
<cvParam cvRef="IMS" accession="IMS:1000102" name="external
offset" value="16"/>
<cvParam cvRef="IMS" accession="IMS:1000104" name="external
encoded length" value="33596"/>
<binary/>
</binaryDataArray>
<binaryDataArray encodedLength="0">
<referenceableParamGroupRef ref="intensityArray"/>
<cvParam cvRef="IMS" accession="IMS:1000103" name="external
array length" value="8399"/>
<cvParam cvRef="IMS" accession="IMS:1000102" name="external
offset" value="134400"/>
<cvParam cvRef="IMS" accession="IMS:1000104" name="external
encoded length" value="33596"/>
<binary/>
</binaryDataArray>
</binaryDataArrayList>
</spectrum>
<spectrum id="Scan=5" defaultArrayLength="0" index="4">
<referenceableParamGroupRef ref="spectrum1"/>
<scanList count="1">
<cvParam cvRef="MS" accession="MS:1000795" name="no combination"
value=""/>
<scan instrumentConfigurationRef="LTQFTUltra0">
<referenceableParamGroupRef ref="scan1"/>
<cvParam cvRef="IMS" accession="IMS:1000050" name="position x"
value="2"/>
<cvParam cvRef="IMS" accession="IMS:1000051" name="position y"
value="2"/>
</scan>
</scanList>
<binaryDataArrayList count="2">
<binaryDataArray encodedLength="0">
<referenceableParamGroupRef ref="mzArray"/>
<cvParam cvRef="IMS" accession="IMS:1000103" name="external
array length" value="8399"/>
<cvParam cvRef="IMS" accession="IMS:1000102" name="external
offset" value="16"/>
<cvParam cvRef="IMS" accession="IMS:1000104" name="external
encoded length" value="33596"/>
<binary/>
</binaryDataArray>
<binaryDataArray encodedLength="0">
<referenceableParamGroupRef ref="intensityArray"/>
<cvParam cvRef="IMS" accession="IMS:1000103" name="external
array length" value="8399"/>
<cvParam cvRef="IMS" accession="IMS:1000102" name="external
offset" value="167996"/>
<cvParam cvRef="IMS" accession="IMS:1000104" name="external
encoded length" value="33596"/>
<binary/>
</binaryDataArray>
</binaryDataArrayList>
</spectrum>
<spectrum id="Scan=6" defaultArrayLength="0" index="5">
<referenceableParamGroupRef ref="spectrum1"/>
<scanList count="1">
<cvParam cvRef="MS" accession="MS:1000795" name="no combination"
value=""/>
<scan instrumentConfigurationRef="LTQFTUltra0">
<referenceableParamGroupRef ref="scan1"/>
<cvParam cvRef="IMS" accession="IMS:1000050" name="position x"
value="3"/>
<cvParam cvRef="IMS" accession="IMS:1000051" name="position y"
value="2"/>
</scan>
</scanList>
<binaryDataArrayList count="2">
<binaryDataArray encodedLength="0">
<referenceableParamGroupRef ref="mzArray"/>
<cvParam cvRef="IMS" accession="IMS:1000103" name="external
array length" value="8399"/>
<cvParam cvRef="IMS" accession="IMS:1000102" name="external
offset" value="16"/>
<cvParam cvRef="IMS" accession="IMS:1000104" name="external
encoded length" value="33596"/>
<binary/>
</binaryDataArray>
<binaryDataArray encodedLength="0">
<referenceableParamGroupRef ref="intensityArray"/>
<cvParam cvRef="IMS" accession="IMS:1000103" name="external
array length" value="8399"/>
<cvParam cvRef="IMS" accession="IMS:1000102" name="external
offset" value="201592"/>
<cvParam cvRef="IMS" accession="IMS:1000104" name="external
encoded length" value="33596"/>
<binary/>
</binaryDataArray>
</binaryDataArrayList>
</spectrum>
<spectrum id="Scan=7" defaultArrayLength="0" index="6">
<referenceableParamGroupRef ref="spectrum1"/>
<scanList count="1">
<cvParam cvRef="MS" accession="MS:1000795" name="no combination"
value=""/>
<scan instrumentConfigurationRef="LTQFTUltra0">
<referenceableParamGroupRef ref="scan1"/>
<cvParam cvRef="IMS" accession="IMS:1000050" name="position x"
value="1"/>
<cvParam cvRef="IMS" accession="IMS:1000051" name="position y"
value="3"/>
</scan>
</scanList>
<binaryDataArrayList count="2">
<binaryDataArray encodedLength="0">
<referenceableParamGroupRef ref="mzArray"/>
<cvParam cvRef="IMS" accession="IMS:1000103" name="external
array length" value="8399"/>
<cvParam cvRef="IMS" accession="IMS:1000102" name="external
offset" value="16"/>
<cvParam cvRef="IMS" accession="IMS:1000104" name="external
encoded length" value="33596"/>
<binary/>
</binaryDataArray>
<binaryDataArray encodedLength="0">
<referenceableParamGroupRef ref="intensityArray"/>
<cvParam cvRef="IMS" accession="IMS:1000103" name="external
array length" value="8399"/>
<cvParam cvRef="IMS" accession="IMS:1000102" name="external
offset" value="235188"/>
<cvParam cvRef="IMS" accession="IMS:1000104" name="external
encoded length" value="33596"/>
<binary/>
</binaryDataArray>
</binaryDataArrayList>
</spectrum>
<spectrum id="Scan=8" defaultArrayLength="0" index="7">
<referenceableParamGroupRef ref="spectrum1"/>
<scanList count="1">
<cvParam cvRef="MS" accession="MS:1000795" name="no combination"
value=""/>
<scan instrumentConfigurationRef="LTQFTUltra0">
<referenceableParamGroupRef ref="scan1"/>
<cvParam cvRef="IMS" accession="IMS:1000050" name="position x"
value="2"/>
<cvParam cvRef="IMS" accession="IMS:1000051" name="position y"
value="3"/>
</scan>
</scanList>
<binaryDataArrayList count="2">
<binaryDataArray encodedLength="0">
<referenceableParamGroupRef ref="mzArray"/>
<cvParam cvRef="IMS" accession="IMS:1000103" name="external
array length" value="8399"/>
<cvParam cvRef="IMS" accession="IMS:1000102" name="external
offset" value="16"/>
<cvParam cvRef="IMS" accession="IMS:1000104" name="external
encoded length" value="33596"/>
<binary/>
</binaryDataArray>
<binaryDataArray encodedLength="0">
<referenceableParamGroupRef ref="intensityArray"/>
<cvParam cvRef="IMS" accession="IMS:1000103" name="external
array length" value="8399"/>
<cvParam cvRef="IMS" accession="IMS:1000102" name="external
offset" value="268784"/>
<cvParam cvRef="IMS" accession="IMS:1000104" name="external
encoded length" value="33596"/>
<binary/>
</binaryDataArray>
</binaryDataArrayList>
</spectrum>
<spectrum id="Scan=9" defaultArrayLength="0" index="8">
<referenceableParamGroupRef ref="spectrum1"/>
<scanList count="1">
<cvParam cvRef="MS" accession="MS:1000795" name="no combination"
value=""/>
<scan instrumentConfigurationRef="LTQFTUltra0">
<referenceableParamGroupRef ref="scan1"/>
<cvParam cvRef="IMS" accession="IMS:1000050" name="position x"
value="3"/>
<cvParam cvRef="IMS" accession="IMS:1000051" name="position y"
value="3"/>
</scan>
</scanList>
<binaryDataArrayList count="2">
<binaryDataArray encodedLength="0">
<referenceableParamGroupRef ref="mzArray"/>
<cvParam cvRef="IMS" accession="IMS:1000103" name="external
array length" value="8399"/>
<cvParam cvRef="IMS" accession="IMS:1000102" name="external
offset" value="16"/>
<cvParam cvRef="IMS" accession="IMS:1000104" name="external
encoded length" value="33596"/>
<binary/>
</binaryDataArray>
<binaryDataArray encodedLength="0">
<referenceableParamGroupRef ref="intensityArray"/>
<cvParam cvRef="IMS" accession="IMS:1000103" name="external
array length" value="8399"/>
<cvParam cvRef="IMS" accession="IMS:1000102" name="external
offset" value="302380"/>
<cvParam cvRef="IMS" accession="IMS:1000104" name="external
encoded length" value="33596"/>
<binary/>
</binaryDataArray>
</binaryDataArrayList>
</spectrum>
</spectrumList>
</run>
</mzML>

I want following Information:
from mzML/run/spectrumList the "count"-value.
I try this like this:

>root <- xmlTreeParse("Example_Continuous.imzML",useInternal = TRUE)
>spectrumList <-getNodeSet(root,"//spectrumList")
>sapply(spectrumList,xmlGetAttr,"count")
list()

Here I get List and no value, because the node spectrumList is empty.
Are there some methods for confortable navigating in the tree, like:
getChildrenByName.

--
View this message in context: http://r.789695.n4.nabble.com/XML-parsing-tp3632544p3632544.html
Sent from the R help mailing list archive at Nabble.com.

------------------------------

Message: 13
Date: Wed, 29 Jun 2011 04:22:59 -0700 (PDT)
From: niharsharma <nihar at caltech.edu>
To: r-help at r-project.org
Subject: Re: [R] Prediction with Bayesian Network?
Message-ID: <1309346579850-3632567.post at n4.nabble.com>
Content-Type: text/plain; charset=us-ascii

Hi Marco,

I am wondering if there are any developments on this front? Is this
learn-and-predict workflow now possible?

--
View this message in context: http://r.789695.n4.nabble.com/Prediction-with-Bayesian-Network-tp859920p3632567.html
Sent from the R help mailing list archive at Nabble.com.

------------------------------

Message: 14
Date: Wed, 29 Jun 2011 08:54:55 -0400
From: Sarah Goslee <sarah.goslee at gmail.com>
To: Ida Dolciotti <ida.dolciotti at ufz.de>
Cc: r-help at r-project.org
Subject: Re: [R] Find the function of a line
Message-ID: <BANLkTikwiFidSAVpkPnLw1TeHS6YV3fY4Q at mail.gmail.com>
Content-Type: text/plain; charset=ISO-8859-1

lm()?
Or simple geometry?

lm(c(a,b) ~ c(xx[yy==a],xx[yy==b]))

will give you the slope and the intercept.

Sarah

On Wed, Jun 29, 2011 at 5:38 AM, Ida Dolciotti <ida.dolciotti at ufz.de> wrote:
> Hello everybody,
>
> I have drawn a line in a x y plot ?that links the minimum and maximum points
> in the plot
>
> plot(xx,yy)
>
> a=max(yy)
> b=min(yy)
>
> lines(c(xx[yy==a],xx[yy==b]),c(a,b))
>
> Now I would like to know if it is possible to extrapolate the characteristic
> of the line (intercept and slope).
>
> Is it there and appropriate function for this?
>
> Thanks for your help!
>
> Ida D.
>
> --

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

------------------------------

Message: 15
Date: Wed, 29 Jun 2011 14:58:19 +0200
From: Petr PIKAL <petr.pikal at precheza.cz>
To: Ida Dolciotti <ida.dolciotti at ufz.de>
Cc: r-help at r-project.org
Subject: [R] Odp:  Find the function of a line
Message-ID:
<OF59D9B967.B14CAC00-ONC12578BE.0047275F-C12578BE.00473C6B at precheza.cz>

Content-Type: text/plain; charset="US-ASCII"

Hi

r-help-bounces at r-project.org napsal dne 29.06.2011 11:38:17:

> Ida Dolciotti <ida.dolciotti at ufz.de>

> Hello everybody,
>
> I have drawn a line in a x y plot  that links the minimum and maximum
> points in the plot
>
> plot(xx,yy)
>
> a=max(yy)
> b=min(yy)
>
> lines(c(xx[yy==a],xx[yy==b]),c(a,b))
>
> Now I would like to know if it is possible to extrapolate the
> characteristic of the line (intercept and slope).
>
> Is it there and appropriate function for this?

Maybe ?abline

Regards
Petr

>
> Thanks for your help!
>
> Ida D.
>
> --
> Ida Dolciotti, M.Sc.
> Phd student, Dept. System Ecotoxicology
> Helmholtz Centre for Environmental Research - UFZ
> Permoserstr. 15
> 04318 Leipzig
>
> phone:   +49 - 341/235-1498
> fax:    +49 - 341/235-1785
>
> email: ida.dolciotti at ufz.de
> website: http://www.ufz.de/index.php?en=17738
>
> ______________________________________________
> R-help at r-project.org mailing list
> https://stat.ethz.ch/mailman/listinfo/r-help
> PLEASE do read the posting guide
http://www.R-project.org/posting-guide.html
> and provide commented, minimal, self-contained, reproducible code.

------------------------------

Message: 16
Date: Wed, 29 Jun 2011 09:32:11 -0400
From: David Winsemius <dwinsemius at comcast.net>
To: Komal <Komalsharif86 at gmail.com>
Cc: r-help at r-project.org
Subject: Re: [R] 2d rndom walk
Message-ID: <C9F581AA-D5AD-45E0-A683-E8EA777CD09E at comcast.net>
Content-Type: text/plain; charset=US-ASCII; format=flowed; delsp=yes

On Jun 29, 2011, at 6:01 AM, Komal wrote:

> Hi all,
>
> Can anyone please tell me how to calculate the expected distance
> covered in
> a 2d random walk. Please!

If  the "2d random walk" is the binomial version you were looking at
in Jim Holtmans' function from Dec 2010 on a 2D lattice, would it be
trivially (and with zero variance) either t*2 or t*sqrt(2) depending
on whether you define the term "distance travelled" by the edges of
successive squares or by their diagonals?

--

David Winsemius, MD
West Hartford, CT

------------------------------

Message: 17
Date: Wed, 29 Jun 2011 09:19:54 -0500
From: David L Carlson <dcarlson at tamu.edu>
To: "'David Kaplan'" <dkaplan at education.wisc.edu>,
<r-help at stat.math.ethz.ch>
Subject: Re: [R] Question about error message
Message-ID: <003e01cc3667\$9e3c5ff0\$dab51fd0\$@edu>
Content-Type: text/plain; charset="us-ascii"

I'd guess that "filename" is not a matrix nor something that can be coerced
into a matrix. Try

> class(filename)

To find out if it is a matrix. Without knowing more about "filename" it is
hard to diagnose. It could be a data.frame with a character field or some
other simple issue resulting from importing the data into R.

> str(filename)

Will list the fields in the "filename" and their type. For norm they must
all be numeric.

----------------------------------------------
David L Carlson
Associate Professor of Anthropology
Texas A&M University
College Station, TX 77843-4352

-----Original Message-----
From: r-help-bounces at r-project.org [mailto:r-help-bounces at r-project.org] On
Behalf Of David Kaplan
Sent: Tuesday, June 28, 2011 3:22 PM
To: r-help at stat.math.ethz.ch
Subject: [R] Question about error message

Greetings,

I'm getting this error message using Joe Shafer's "NORM" package.

Error in storage.mode(x) <- "double" :
(list) object cannot be coerced to type 'double'

I'm not sure what this means.

I get this message when running

s <- prelim.norm(filename)

prelim.norm is used to develop some summary statistics, etc. before
implementing the EM algorithm for missing data.  Please note that this
is a data fusion exercise and there is considerable amounts of missing
data by design.

David

--

=======================================================================
David Kaplan, Ph.D.
Professor
Department of Educational Psychology
University of Wisconsin - Madison
Educational Sciences, Room, 1082B
1025 W. Johnson Street

email: dkaplan at education.wisc.edu
homepage:
http://www.education.wisc.edu/edpsych/default.aspx?content=kaplan.html
Phone: 608-262-0836
=======================================================================

[[alternative HTML version deleted]]

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

------------------------------

Message: 18
Date: Wed, 29 Jun 2011 16:24:55 +0100 (BST)
From: Iain Gallagher <iaingallagher at btopenworld.com>
To: r-help at r-project.org
Subject: [R] median time period
Message-ID:
<1309361095.68973.YahooMailClassic at web86705.mail.ird.yahoo.com>
Content-Type: text/plain; charset=utf-8

Hello List

I'm trying to calculate the median period (in months) of a set of time intervals (between two interventions).

I have been playing with the lubridate package to create the intervals but I can't think of the right approach to get the median timeperiod.

Toy code:

library(lubridate)
test <- c('08-04-22', '08-07-28', '09-03-02', '09-03-03', '09-01-30', '09-03-09', '10-02-24', '10-03-05')
test <- ymd(test)
intervals <- as.period(test[5:8] - test[1:4])

intervals
[1] 9 months and 8 days    7 months and 9 days    11 months and 22 days
[4] 1 year and 2 days

How can I convert this 'period' object to months? From there I think I should just convert to 'numeric' and calculate the median.

Garrett if you're out there - great package but could you help please!?

Best

iain

> sessionInfo()
R version 2.13.0 (2011-04-13)
Platform: x86_64-pc-linux-gnu (64-bit)

locale:
[1] LC_CTYPE=en_GB.utf8       LC_NUMERIC=C
[3] LC_TIME=en_GB.utf8        LC_COLLATE=en_GB.utf8
[5] LC_MONETARY=C             LC_MESSAGES=en_GB.utf8
[7] LC_PAPER=en_GB.utf8       LC_NAME=C
[11] LC_MEASUREMENT=en_GB.utf8 LC_IDENTIFICATION=C

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

other attached packages:
[1] lubridate_0.2.4

loaded via a namespace (and not attached):
[1] plyr_1.5.2  stringr_0.4

------------------------------

Message: 19
Date: Wed, 29 Jun 2011 08:27:32 -0700 (PDT)
From: tomtomme <langkamp at tomblog.de>
To: r-help at r-project.org
Subject: [R] time series interpolation
Message-ID: <1309361252263-3633193.post at n4.nabble.com>
Content-Type: text/plain; charset=UTF-8

Hi there,
I?ve got a datatable in R which I try to interpolate with this and get the
Error below:

> new\$temp<- approx(w03_11temp\$temp, n = (nrow(w03_11temp)*5))\$y

Error in new\$temp <- approx(w03_11temp\$temp, n = (nrow(w03_11temp) * 5))\$y :
Object of type 'closure' not registered

Any idea?? Thanks a lot.

--
View this message in context: http://r.789695.n4.nabble.com/time-series-interpolation-tp3633193p3633193.html
Sent from the R help mailing list archive at Nabble.com.

------------------------------

Message: 20
Date: Wed, 29 Jun 2011 11:41:06 -0400
From: Vivian Zhuang <statinfo88 at gmail.com>
To: Daniel Malter <daniel at umd.edu>
Cc: r-help at r-project.org
Subject: Re: [R] a Weighted Least Square Model for a Binary Outcome
Message-ID: <BANLkTi=D4AWXgF03hz4gmu0wH=heNaRJqQ at mail.gmail.com>
Content-Type: text/plain; charset=ISO-8859-1

Hi Daniel,

Thanks for your reply. The weight is dependent on the estimated E(Y).
In other words, I need R to estimate the beta coefficients and weights
simultaneously, like what is performed in gls(). However, the weight
form allowed in gls() is different from what I want.

In SPSS, we can simply use the code of 'COMPUTE WGT = 1/(yhat * (1 -
yhat))'. But I do not know how to do it in R. I tried yhat but R did
not recognize it.

Best Regards,
Vivian

On Tue, Jun 28, 2011 at 10:18 PM, Daniel Malter <daniel at umd.edu> wrote:
> You can specify the weights=... argument in the lm() function as vector of
> weights, one for each observation. Should that not do what your are trying
> to do?
>
> HTH,
> Daniel
>
> --
> View this message in context: http://r.789695.n4.nabble.com/a-Weighted-Least-Square-Model-for-a-Binary-Outcome-tp3631551p3631834.html
> Sent from the R help mailing list archive at Nabble.com.
>
> ______________________________________________
> R-help at r-project.org mailing list
> https://stat.ethz.ch/mailman/listinfo/r-help
> PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
> and provide commented, minimal, self-contained, reproducible code.
>

------------------------------

Message: 21
Date: Wed, 29 Jun 2011 16:50:31 +0100 (BST)
From: Iain Gallagher <iaingallagher at btopenworld.com>
To: r-help at r-project.org
Subject: Re: [R] median time period
Message-ID:
<1309362631.30862.YahooMailClassic at web86703.mail.ird.yahoo.com>
Content-Type: text/plain; charset=iso-8859-1

Typical - you post to the list and then work it out for yourself!

Anyway here's my solution

Toy code as before then:

intervalsMonths <- 12 * intervals\$year + intervals\$month

#convert whole years to months then add the remaining months for that entry in intervals

medianMonths <- median(as.numeric(intervalsMonths))

Best

iain

--- On Wed, 29/6/11, Iain Gallagher <iaingallagher at btopenworld.com> wrote:

> From: Iain Gallagher <iaingallagher at btopenworld.com>
> Subject: [R] median time period
> To: r-help at r-project.org
> Date: Wednesday, 29 June, 2011, 16:24
> Hello List
>
> I'm trying to calculate the median period (in months) of a
> set of time intervals (between two interventions).
>
> I have been playing with the lubridate package to create
> the intervals but I can't think of the right approach to get
> the median timeperiod.
>
> Toy code:
>
> library(lubridate)
> test <- c('08-04-22', '08-07-28', '09-03-02',
> '09-03-03', '09-01-30', '09-03-09', '10-02-24', '10-03-05')
> test <- ymd(test)
> intervals <- as.period(test[5:8] - test[1:4])
>
> intervals
> [1] 9 months and 8 days? ? 7 months and 9
> days? ? 11 months and 22 days
> [4] 1 year and 2 days
>
> How can I convert this 'period' object to months? From
> there I think I should just convert to 'numeric' and
> calculate the median.
>
> Garrett if you're out there - great package but could you
>
> Best
>
> iain
>
> > sessionInfo()
> R version 2.13.0 (2011-04-13)
> Platform: x86_64-pc-linux-gnu (64-bit)
>
> locale:
>  [1] LC_CTYPE=en_GB.utf8? ?
> ???LC_NUMERIC=C? ? ? ?
> ? ???
>  [3] LC_TIME=en_GB.utf8? ? ? ?
> LC_COLLATE=en_GB.utf8? ?
>  [5] LC_MONETARY=C? ? ? ? ?
> ???LC_MESSAGES=en_GB.utf8???
>  [7] LC_PAPER=en_GB.utf8? ?
> ???LC_NAME=C? ? ? ?
> ? ? ? ?
>  [9] LC_ADDRESS=C? ? ? ? ? ?
> ? LC_TELEPHONE=C? ? ? ?
> ???
> [11] LC_MEASUREMENT=en_GB.utf8 LC_IDENTIFICATION=C?
> ? ?
>
> attached base packages:
> [1] stats? ???graphics? grDevices
> utils? ???datasets?
> methods???base? ???
>
> other attached packages:
> [1] lubridate_0.2.4
>
> loaded via a namespace (and not attached):
> [1] plyr_1.5.2? stringr_0.4
>
>
> ______________________________________________
> R-help at r-project.org
> mailing list
> https://stat.ethz.ch/mailman/listinfo/r-help
> PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
> and provide commented, minimal, self-contained,
> reproducible code.
>

------------------------------

Message: 22
Date: Wed, 29 Jun 2011 10:32:27 -0700 (PDT)
From: Cody Hamilton <cody.shawn at yahoo.com>
To: r-help at r-project.org
Subject: [R] Error in testInstalledBasic
Message-ID: <125335.98983.qm at web120511.mail.ne1.yahoo.com>
Content-Type: text/plain; charset=utf-8

Hi,

I am running R 2.13.0 on a Windows 7 machine.

I ran the script:

testInstalledBasic('devel')

and received the following warning message:

running tests of consistency of as/is.*
creating ?isas-tests.R?
running code in ?isas-tests.R?
comparing ?isas-tests.Rout? to ?isas-tests.Rout.save? ...running tests of random deviate generation -- fails occasionally
running code in ?p-r-random-tests.R?
comparing ?p-r-random-tests.Rout? to ?p-r-random-tests.Rout.save? ...running tests of primitives
running code in ?primitives.R?
FAILED
Warning message:
running command '"C:/PROGRA~1/R/R-213~1.0/bin/i386/R" CMD BATCH --vanilla --no-timing "primitives.R" "primitives.Rout"' had status 1

I checked the primitives.Rout.fail file, which contains the following text:

R version 2.13.0 (2011-04-13)
Copyright (C) 2011 The R Foundation for Statistical Computing
ISBN 3-900051-07-0
Platform: i386-pc-mingw32/i386 (32-bit)

R is free software and comes with ABSOLUTELY NO WARRANTY.
You are welcome to redistribute it under certain conditions.
Type 'license()' or 'licence()' for distribution details.

R is a collaborative project with many contributors.
'citation()' on how to cite R or R packages in publications.

Type 'demo()' for some demos, 'help()' for on-line help, or
'help.start()' for an HTML browser interface to help.
Type 'q()' to quit R.

> ## check that the 'internal generics' are indeed generic.
>
> x <- structure(pi, class="testit")
> xx <- structure("OK", class="testOK")
>
> for(f in ls(.GenericArgsEnv, all.names=TRUE))
+ {
+     cat("testing S3 generic '", f, "'\n", sep="")
+     method <- paste(f, "testit", sep=".")
+     if(f %in% "seq.int") {
+         ## note that this dispatches on 'seq'.
+         assign("seq.testit", function(...) xx, .GlobalEnv)
+         res <- seq.int(x, x)
+     } else {
+         if(length(grep("<-\$", f)) > 0) {
+             assign(method, function(x, value) xx, .GlobalEnv)
+             y <- x
+             res <- eval(substitute(ff(y, value=pi), list(ff=as.name(f))))
+         } else {
+             ff <- get(f, .GenericArgsEnv)
+             body(ff) <- xx
+             assign(method, ff, .GlobalEnv)
+             res <- eval(substitute(ff(x), list(ff=as.name(f))))
+         }
+     }
+     stopifnot(res == xx)
+     rm(method)
+ }
testing S3 generic '-'
testing S3 generic '!'
testing S3 generic '!='
testing S3 generic '%%'
testing S3 generic '%/%'
testing S3 generic '&'
testing S3 generic '*'
testing S3 generic '/'
testing S3 generic '^'
testing S3 generic '|'
testing S3 generic '+'
testing S3 generic '<'
testing S3 generic '<='
testing S3 generic '=='
testing S3 generic '>'
testing S3 generic '>='
testing S3 generic 'abs'
testing S3 generic 'acos'
testing S3 generic 'acosh'
testing S3 generic 'all'
testing S3 generic 'any'
testing S3 generic 'Arg'
testing S3 generic 'as.character'
testing S3 generic 'as.complex'
testing S3 generic 'as.double'
testing S3 generic 'as.environment'
testing S3 generic 'as.integer'
testing S3 generic 'as.logical'
testing S3 generic 'as.numeric'
testing S3 generic 'as.raw'
testing S3 generic 'as.real'
testing S3 generic 'asin'
testing S3 generic 'asinh'
testing S3 generic 'atan'
testing S3 generic 'atanh'
testing S3 generic 'c'
testing S3 generic 'ceiling'
testing S3 generic 'Conj'
testing S3 generic 'cos'
testing S3 generic 'cosh'
testing S3 generic 'cummax'
testing S3 generic 'cummin'
testing S3 generic 'cumprod'
testing S3 generic 'cumsum'
testing S3 generic 'digamma'
testing S3 generic 'dim'
testing S3 generic 'dim<-'
testing S3 generic 'dimnames'
testing S3 generic 'dimnames<-'
testing S3 generic 'exp'
testing S3 generic 'expm1'
testing S3 generic 'floor'
testing S3 generic 'gamma'
testing S3 generic 'Im'
testing S3 generic 'is.array'
testing S3 generic 'is.finite'
testing S3 generic 'is.infinite'
testing S3 generic 'is.matrix'
testing S3 generic 'is.na'
testing S3 generic 'is.nan'
testing S3 generic 'is.numeric'
testing S3 generic 'length'
testing S3 generic 'length<-'
testing S3 generic 'levels<-'
testing S3 generic 'lgamma'
testing S3 generic 'log'
testing S3 generic 'log10'
testing S3 generic 'log1p'
testing S3 generic 'log2'
testing S3 generic 'max'
testing S3 generic 'min'
testing S3 generic 'Mod'
testing S3 generic 'names'
testing S3 generic 'names<-'
testing S3 generic 'prod'
testing S3 generic 'range'
testing S3 generic 'Re'
testing S3 generic 'rep'
testing S3 generic 'round'
testing S3 generic 'seq.int'
testing S3 generic 'sign'
testing S3 generic 'signif'
testing S3 generic 'sin'
testing S3 generic 'sinh'
testing S3 generic 'sqrt'
testing S3 generic 'sum'
testing S3 generic 'tan'
testing S3 generic 'tanh'
testing S3 generic 'trigamma'
testing S3 generic 'trunc'
testing S3 generic 'xtfrm'
>
> ## and that no others are generic
> for(f in ls(.ArgsEnv, all.names=TRUE))
+ {
+     if(f == "browser") next
+     cat("testing non-generic '", f, "'\n", sep="")
+     method <- paste(f, "testit", sep=".")
+     fx <- get(f, envir=.ArgsEnv)
+     body(fx) <- quote(return(42))
+     assign(method, fx, .GlobalEnv)
+     na <- length(formals(fx))
+     res <- NULL
+     if(na == 1)
+         res <- try(eval(substitute(ff(x), list(ff=as.name(f)))), silent = TRUE)
+     else if(na == 2)
+         res <- try(eval(substitute(ff(x, x), list(ff=as.name(f)))), silent = TRUE)
+     if(!inherits(res, "try-error") && identical(res, 42)) stop("is generic")
+     rm(method)
+ }
testing non-generic '%*%'
testing non-generic '.C'
testing non-generic '.cache_class'
testing non-generic '.Call'
testing non-generic '.Call.graphics'
testing non-generic '.External'
testing non-generic '.External.graphics'
testing non-generic '.Fortran'
testing non-generic '.Internal'
testing non-generic '.Primitive'
testing non-generic '.primTrace'
testing non-generic '.primUntrace'
testing non-generic '.subset'
testing non-generic '.subset2'
testing non-generic 'as.call'
testing non-generic 'attr'
testing non-generic 'attr<-'
testing non-generic 'attributes'
testing non-generic 'attributes<-'
testing non-generic 'baseenv'
testing non-generic 'call'
testing non-generic 'class'
testing non-generic 'class<-'
testing non-generic 'emptyenv'
testing non-generic 'enc2native'
testing non-generic 'enc2utf8'
testing non-generic 'environment<-'
testing non-generic 'expression'
testing non-generic 'gc.time'
testing non-generic 'globalenv'
testing non-generic 'interactive'
testing non-generic 'invisible'
testing non-generic 'is.atomic'
testing non-generic 'is.call'
testing non-generic 'is.character'
testing non-generic 'is.complex'
testing non-generic 'is.double'
testing non-generic 'is.environment'
testing non-generic 'is.expression'
testing non-generic 'is.function'
testing non-generic 'is.integer'
testing non-generic 'is.language'
testing non-generic 'is.list'
testing non-generic 'is.logical'
testing non-generic 'is.name'
testing non-generic 'is.null'
testing non-generic 'is.object'
testing non-generic 'is.pairlist'
testing non-generic 'is.raw'
testing non-generic 'is.real'
testing non-generic 'is.recursive'
testing non-generic 'is.single'
testing non-generic 'is.symbol'
testing non-generic 'list'
testing non-generic 'missing'
testing non-generic 'nargs'
testing non-generic 'nzchar'
testing non-generic 'oldClass'
testing non-generic 'oldClass<-'
testing non-generic 'on.exit'
testing non-generic 'pos.to.env'
testing non-generic 'proc.time'
testing non-generic 'quote'
testing non-generic 'retracemem'
testing non-generic 'seq_along'
testing non-generic 'seq_len'
testing non-generic 'standardGeneric'
testing non-generic 'storage.mode<-'
testing non-generic 'substitute'
testing non-generic 'switch'
testing non-generic 'tracemem'
testing non-generic 'unclass'
tracemem[0x01b4fdd0 -> 0x03a3a6b8]: eval eval doTryCatch tryCatchOne tryCatchList tryCatch try
testing non-generic 'untracemem'
testing non-generic 'UseMethod'
>
>
> ## check that all primitives are accounted for in .[Generic]ArgsEnv.
> ## and nothing else
> ff <- ls("package:base", all.names=TRUE)
> ff <- ff[sapply(ff, function(x) is.primitive(get(x, "package:base")))]
> lang_elements <-
+     c('\$', '\$<-', '&&', '(', ':', '<-', '<<-', '=', '@',
+       '[', '[<-', '[[', '[[<-', 'break', 'for', 'function', 'if', 'next',
+       'repeat', 'return', 'while', '{', '||', '~')
>
> known <- c(ls(.GenericArgsEnv, all.names=TRUE),
+            ls(.ArgsEnv, all.names=TRUE),
+            lang_elements)
> stopifnot(ff %in% known, known %in% ff)
>
>
> ## check which are not considered as possibles for S4 generic
> ff4 <- names(methods:::.BasicFunsList)
> # as.double and as.real are the same as as.numeric
> S4generic <- ff %in% c(ff4, "as.double", "as.real")
> notS4 <- ff[!S4generic]
> if(length(notS4))
+     cat("primitives not covered in methods:::.BasicFunsList:",
+         paste(sQuote(notS4), collapse=", "), "\n")
> stopifnot(S4generic)
>
> # functions which are listed but not primitive
> extraS4 <- c('all', 'any', 'max', 'min', 'prod', 'range',
+              'round', 'signif', 'sum')
> ff4[!ff4 %in% c(ff, extraS4)]
character(0)
> stopifnot(ff4 %in% c(ff, extraS4))
>
>
> ## primitives which are not internally generic cannot have S4 methods
> ## unless specifically arranged (e.g. %*%)
> nongen_prims <- ff[!ff %in% ls(.GenericArgsEnv, all.names=TRUE)]
> ff3 <- names(methods:::.BasicFunsList)[sapply(methods:::.BasicFunsList, function(x) is.logical(x) && !x)]
> ex <- nongen_prims[!nongen_prims %in% c("\$", "\$<-", "[", "[[" ,"[[<-", "[<-", "%*%", ff3)]
> if(length(ex))
+     cat("non-generic primitives not excluded in methods:::.BasicFunsList:",
+         paste(sQuote(ex), collapse=", "), "\n")
> stopifnot(length(ex) == 0)
>
> ## Now check that (most of) those which are listed really are generic.
> require(methods)
> setClass("foo", representation(x="numeric", y="numeric"))
[1] "foo"
> xx <- new("foo",  x=1, y=2)
> S4gen <- names(methods:::.BasicFunsList)[sapply(methods:::.BasicFunsList, function(x) is.function(x))]
> for(f in S4gen) {
+     g <- get(f)
+     if(is.primitive(g)) g <- getGeneric(f) # should error on non-Generics.
+     ff <- args(g)
+     body(ff) <- "testit"
+     nm <- names(formals(ff))
+     ## the Summary group gives problems
+     if(nm[1] == '...') {
+         cat("skipping '", f, "'\n", sep="")
+         next
+     }
+     cat("testing '", f, "'\n", sep="")
+     setMethod(f, "foo", ff)
+     ## might have created a generic, so redo 'get'
+     stopifnot(identical(getGeneric(f)(xx), "testit"))
+ }
testing '\$'
testing '\$<-'
testing '['
testing '[<-'
testing '[['
testing '[[<-'
testing '%*%'
testing 'xtfrm'
testing 'c'
testing 'all'
testing 'any'
testing 'sum'
testing 'prod'
testing 'max'
testing 'min'
testing 'range'
testing '!'
testing '!='
testing '%%'
testing '%/%'
testing '&'
testing '*'
testing '+'
testing '-'
testing '/'
testing '<'
testing '<='
testing '=='
testing '>'
testing '>='
testing 'Arg'
testing 'Conj'
testing 'Im'
testing 'Mod'
testing 'Re'
testing '^'
testing 'abs'
testing 'acos'
testing 'acosh'
testing 'as.character'
testing 'as.complex'
testing 'as.double'
testing 'as.environment'
testing 'as.integer'
testing 'as.logical'
testing 'as.numeric'
testing 'as.raw'
testing 'as.real'
testing 'asin'
testing 'asinh'
testing 'atan'
testing 'atanh'
testing 'ceiling'
testing 'cos'
testing 'cosh'
testing 'cummax'
testing 'cummin'
testing 'cumprod'
testing 'cumsum'
testing 'digamma'
testing 'dim'
testing 'dim<-'
testing 'dimnames'
testing 'dimnames<-'
testing 'exp'
testing 'expm1'
testing 'floor'
testing 'gamma'
testing 'is.array'
testing 'is.finite'
testing 'is.infinite'
testing 'is.matrix'
testing 'is.na'
testing 'is.nan'
testing 'is.numeric'
testing 'length'
testing 'length<-'
testing 'levels<-'
testing 'lgamma'
testing 'log'
testing 'log10'
testing 'log1p'
testing 'log2'
testing 'names'
testing 'names<-'
testing 'rep'
testing 'round'
testing 'seq.int'
testing 'sign'
testing 'signif'
testing 'sin'
testing 'sinh'
testing 'sqrt'
testing 'tan'
testing 'tanh'
testing 'trigamma'
testing 'trunc'
testing '|'
>
> ## check that they do argument matching, or at least check names
> except <- c("call", "switch", ".C", ".Fortran", ".Call", ".External",
+             ".Call.graphics", ".External.graphics", ".subset", ".subset2",
+             ".primTrace", ".primUntrace", "lazyLoadDBfetch",
+             ".Internal", ".Primitive", "^", "|", "%*%", "rep", "seq.int",
+             ## these may not be enabled
+             "tracemem", "retracemem", "untracemem")
>
> for(f in ls(.GenericArgsEnv, all.names=TRUE)[-(1:15)])
+ {
+     if (f %in% except) next
+     g <- get(f, envir = .GenericArgsEnv)
+     an <- names(formals(args(g)))
+     if(length(an) >0 && an[1] == "...") next
+     an <- an[an != "..."]
+     a <- rep(list(NULL), length(an))
+     names(a) <- c("zZ", an[-1])
+     res <- try(do.call(f, a), silent = TRUE)
+     m <- geterrmessage()
+     if(!grepl('does not match|unused argument', m))
+         stop("failure on ", f)
+ }
Error: failure on >=
Execution halted

Is there something wrong with my install?

Regards,
-Cody

------------------------------

Message: 23
Date: Wed, 29 Jun 2011 15:15:43 +0200
From: nejc bergant <nbergant at gmail.com>
To: r-help at r-project.org
Subject: [R] R package Forecast
Message-ID: <BANLkTim7QcJVotjVacvAsHmW+XGgc1CuVg at mail.gmail.com>
Content-Type: text/plain

Hello all

First of all I must emphasize that I am fascinated about Forecast package.
However I have difficulty to execute 'ets' procedure. After I write code:

b<-matrix(a[,3], nrow=5, ncol=12,
dimnames=list(c("2005","2006","2007","2008","2009"),
c("jan","feb","mar","apr","may","jun","jul","aug","sep","oct","nov","dec")
))
fit<-ets(b)
plot(forecast(fit))

I get this error note: *'Error in ets(b) : y should be a univariate time
series'*.

Could you please be so kind as to let me know what could be the problem.
File 'Test.txt' is database which includes three variables: year, month and
dependent variable.

I am looking forward to hearing from you.

Kind regards, Nejc.

[[alternative HTML version deleted]]

------------------------------

Message: 24
Date: Wed, 29 Jun 2011 17:54:49 +0200
From: Zulima Tablado Almela <zutal at yahoo.es>
To: r-help at r-project.org
Subject: [R] Measure the distance/home range along  terrain surface
Message-ID: <4E0B4AC9.8000008 at yahoo.es>
Content-Type: text/plain; charset=ISO-8859-1; format=flowed

Hello all,

I have two questions:

1)Given two coordinates on a digital elevation model (DEM), I would like
to measure the actual distance traveled between the two locations,
assuming a straight line route. Does anyone know the function(if there
exists) to do that in R?

2)How can I calculate or correct the home range size taking into account
the variations in elevation (DEM) within it?

Thank you so much in advance, any suggestion will be very much appreciated,

Zulima

------------------------------

Message: 25
Date: Wed, 29 Jun 2011 11:50:54 -0500
From: Katia Smirnova <katiasmirn at gmail.com>
To: r-help at r-project.org
Subject: [R] 4D data acsess
Message-ID: <BANLkTikhKKRKaiC8RnMQ08an4JYo3oObSA at mail.gmail.com>
Content-Type: text/plain

Hi, I have a 4D data file from MATLAB, call it X,  that I want to analyze in
R. The first 3 dimensions are x y z coordinates and the forth is a value in
time.

If you took a sample vector in matlab it would look like

vec1 = X(x1, y1, z1, :)
vec2 = X( x2, y2, z2, :)

this would give you all values (I have 300 of them) corresponding to this
(x1,y1,z1) point of X.

Now I read the MATLAB datafile 4D X into R and want to address vec1 and vec2
in R and work with the fourth column values only.

I tried something like X[ x1, y1, z1, ] to pull out the 4th column values
but R tells me that X has incorrect dimensions.

I'd like to start with being able to find say correlation between vec1 and
vec2

Any suggestions?

[[alternative HTML version deleted]]

------------------------------

Message: 26
Date: Wed, 29 Jun 2011 05:46:00 -0700 (PDT)
From: Komal <Komalsharif86 at gmail.com>
To: r-help at r-project.org
Subject: Re: [R] 2D Random walk
Message-ID: <1309351560126-3632734.post at n4.nabble.com>
Content-Type: text/plain; charset=us-ascii

Please change the code to a user defined function.

--
View this message in context: http://r.789695.n4.nabble.com/2D-Random-walk-tp3069557p3632734.html
Sent from the R help mailing list archive at Nabble.com.

------------------------------

Message: 27
Date: Wed, 29 Jun 2011 07:48:27 -0700 (PDT)
From: Lisa <lisajca at gmail.com>
To: r-help at r-project.org
Subject: Re: [R] Derivative of a function
Message-ID: <1309358907941-3633071.post at n4.nabble.com>
Content-Type: text/plain; charset=us-ascii

This is not a homework. I just want to see if there are some R functions or
some ideas I can borrow to solve my problem.

--
View this message in context: http://r.789695.n4.nabble.com/Derivative-of-a-function-tp3631814p3633071.html
Sent from the R help mailing list archive at Nabble.com.

------------------------------

Message: 28
Date: Wed, 29 Jun 2011 08:30:23 -0700 (PDT)
From: Komal <Komalsharif86 at gmail.com>
To: r-help at r-project.org
Subject: Re: [R] 2D Random walk
Message-ID: <1309361423196-3633205.post at n4.nabble.com>
Content-Type: text/plain; charset=us-ascii

HI Jholtman,

walk.2d<-function(n)
{
rw <- matrix(0, ncol = 2, nrow = n)

# generate the indices to set the deltas
indx <- cbind(seq(n), sample(c(1, 2), n, TRUE))

# now set the values
rw[indx] <- sample(c(-1, 1), n, TRUE)

# cumsum the columns
rw[,1] <- cumsum(rw[, 1])
rw[,2] <- cumsum(rw[, 2])

return(rw[,1],rw[,2])
}
n<-1000

plot(walk.2d(n), type="n",xlab="x",ylab="y",main="Random Walk Simulation In
Two Dimensions",xlim=range(rw[,1]),ylim=range(rw[,2]))

# use 'segments' to color each path
segments(head(rw[, 1], -1), head(rw[, 2], -1), tail(rw[, 1], -1), tail(rw[,
2], -1), col ="blue")

I tried to make it in a function.. its not working I dont know why... please
help me correcting this code.

--
View this message in context: http://r.789695.n4.nabble.com/2D-Random-walk-tp3069557p3633205.html
Sent from the R help mailing list archive at Nabble.com.

------------------------------

Message: 29
Date: Wed, 29 Jun 2011 08:42:33 -0700 (PDT)
From: Simon Goodman <s.j.goodman at leeds.ac.uk>
To: r-help at r-project.org
Subject: [R] Testing if a variable is specified within a function &
adding TRUE/FALSE options to functions
Message-ID: <1309362153308-3633248.post at n4.nabble.com>
Content-Type: text/plain; charset=us-ascii

I have 2 related questions about functions.

1. I am writing a function to plot data from a time series with the form

myplot<-function(data, d1,d2) {    }

Where d1 and d2 are two dates in a time series. The idea being that if no
values for d1 and d2 are entered then the function defaults to plotting the
whole time series, else it plots the data for the interval specified by d1
and d2.

I am attempting to test if the variable d1 has been inputted by using a
different function, orginally posted on a R help forum by Brian Ripley.

testObject <- function(object)
{
exists(as.character(substitute(object)))
}

here testObject(x) returns FALSE if x is not currently present a variable in
the work space image.

testObject works fine outside my plotting function, but not within it.... it
always returns FALSE inside the plotting function even when d1 is being
given by the user.

I get the same result even if the testObject function is defined inside the
plotting function....

I suspect this may be due to enviroment being searched for d1.... but can't
find work out how to make it search for d1 within the 'myplot' function - I
think this can done using 'where' or 'environment' - but the documentation
on these commands is a little opaque.

2. For the 'myplot' function I would also like to add a customlegend=TRUE
(or FALSE) option, which determines if a custom legend is plotted (if not
inputted it would default to TRUE), but haven't been able to find anything
on how to specify this kind TRUE/FALSE of option for functions.

Thanks, Simon

--
View this message in context: http://r.789695.n4.nabble.com/Testing-if-a-variable-is-specified-within-a-function-adding-TRUE-FALSE-options-to-functions-tp3633248p3633248.html
Sent from the R help mailing list archive at Nabble.com.

------------------------------

Message: 30
Date: Wed, 29 Jun 2011 08:44:21 -0700 (PDT)
From: Komal <Komalsharif86 at gmail.com>
To: r-help at r-project.org
Subject: Re: [R] 2d rndom walk
Message-ID: <1309362261729-3633249.post at n4.nabble.com>
Content-Type: text/plain; charset=us-ascii

walk.2d<-function(n)
{
rw <- matrix(0, ncol = 2, nrow = n)

# generate the indices to set the deltas
indx <- cbind(seq(n), sample(c(1, 2), n, TRUE))

# now set the values
rw[indx] <- sample(c(-1, 1), n, TRUE)

# cumsum the columns
rw[,1] <- cumsum(rw[, 1])
rw[,2] <- cumsum(rw[, 2])

return(rw[,1],rw[,2])

}
n<-1000

plot(walk.2d(n), type="n",xlab="x",ylab="y",main="Random Walk Simulation In
Two Dimensions",xlim=range(rw[,1]),ylim=range(rw[,2]))

# use 'segments' to color each path
segments(head(rw[, 1], -1), head(rw[, 2], -1), tail(rw[, 1], -1), tail(rw[,
2], -1), col ="blue")

This code is giving me error in the return()... what to write in return()???

--
View this message in context: http://r.789695.n4.nabble.com/2d-rndom-walk-tp3632468p3633249.html
Sent from the R help mailing list archive at Nabble.com.

------------------------------

Message: 31
Date: Wed, 29 Jun 2011 21:42:21 +0400
From: ?????????  <mxidibq at telenet.be>
To: <ainane at umd.edu>, <tom.bronakoski at talgov.com>,
<r-help at r-project.org>,	<watkins at phonenet.com>, <fifem at michigan.go>
Subject: [R] Discover the latest in search engine marketing! Hear from
the	experts at insurance.com - FileSONIC Download
Message-ID: <F27D30CFE4554B189C62CEA1EF07F47D at gsrq>
Content-Type: text/plain

Discover the latest in search engine marketing! Hear from the experts at insurance.com - FileSONIC Download

text version 4 MB - http://www.filesonic.com/file/1331332724/1.txt

video version 100 MB - http://www.filesonic.com/file/1332481834/1.avi

[[alternative HTML version deleted]]

------------------------------

Message: 32
Date: Wed, 29 Jun 2011 19:43:40 +0200
From: Hugo Mildenberger <Hugo.Mildenberger at web.de>
To: Aya74656 at gmx.de
Cc: r-help at r-project.org
Subject: Re: [R] connecting R and PostgreSQL
Message-ID: <4E0B644C.6080903 at web.de>
Content-Type: text/plain; charset=ISO-8859-1

Marie,

you did not say if you work on Windows or Unix. The manual from google
belongs to the R package RpostgreSQL. This package makes use the native
PostgreSQL driver. As I read the documentation, the package's DBI
interface must be somehow binary compatible with the Postgres version
installed. It installs and works seamlessly here on Linux, and also
works with Windows Vista, but I remember that I had to shuffle some dlls
from the postgresql directory. So if you provide some more information,
maybe I'll remember what I did to get it running.

Best regards

Hugo

Am 28.06.2011 14:15, schrieb Aya74656 at gmx.de:
> Dear R-helpers,
>
> I'm an absolute beginner using both R and PostgreSQL, but now I have to work with both programs. I need to connect R and my Postgres-database, but every attempt so far has failed (I tried using the RpgSQL package as well as RdbiPgSQL, the first, following this manual (http://code.google.com/p/rpostgresql/) didn't find any drivers for the database (step no. 1) whereas the second doesn't work with R version 2.13).
>
> Could someone please be so kind to either provide a step-by-step instruction on how to make this connection work or direct me to a manual?
>
> Thanks in advance.
>
> Yours sincerly,
>
> Marie
> --
>
> ______________________________________________
> R-help at r-project.org mailing list
> https://stat.ethz.ch/mailman/listinfo/r-help
> PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
> and provide commented, minimal, self-contained, reproducible code.
>

------------------------------

Message: 33
Date: Wed, 29 Jun 2011 14:01:33 -0400
From: David Winsemius <dwinsemius at comcast.net>
To: Komal <Komalsharif86 at gmail.com>
Cc: r-help at r-project.org
Subject: Re: [R] 2d rndom walk
Message-ID: <DA303AC2-2239-4565-9254-C41453C40FDE at comcast.net>
Content-Type: text/plain; charset=US-ASCII; format=flowed; delsp=yes

On Jun 29, 2011, at 11:44 AM, Komal wrote:

>
>
>
> walk.2d<-function(n)
> {
> rw <- matrix(0, ncol = 2, nrow = n)
>
> # generate the indices to set the deltas
> indx <- cbind(seq(n), sample(c(1, 2), n, TRUE))
>
> # now set the values
> rw[indx] <- sample(c(-1, 1), n, TRUE)
>
> # cumsum the columns
> rw[,1] <- cumsum(rw[, 1])
> rw[,2] <- cumsum(rw[, 2])
>
> return(rw[,1],rw[,2])
>
> }
> n<-1000
>
> plot(walk.2d(n), type="n",xlab="x",ylab="y",main="Random Walk
> Simulation In
> Two Dimensions",xlim=range(rw[,1]),ylim=range(rw[,2]))
>
>        # use 'segments' to color each path
> segments(head(rw[, 1], -1), head(rw[, 2], -1), tail(rw[, 1], -1),
> tail(rw[,
> 2], -1), col ="blue")
>
>
> This code is giving me error in the return()... what to write in
> return()???

You are requested to post the _entire_ error message. It seems rather
informative. You are giving two arguments to return() and it only
accepts one. Probably better success with return(rw).

--
David Winsemius, MD
West Hartford, CT

------------------------------

Message: 34
Date: Wed, 29 Jun 2011 14:10:59 -0400
From: David Winsemius <dwinsemius at comcast.net>
To: Lisa <lisajca at gmail.com>
Cc: r-help at r-project.org
Subject: Re: [R] Derivative of a function
Message-ID: <7193A8B2-CDB6-4876-8020-CF36D7DDC5F6 at comcast.net>
Content-Type: text/plain; charset=US-ASCII; format=flowed; delsp=yes

On Jun 29, 2011, at 10:48 AM, Lisa wrote:

> This is not a homework. I just want to see if there are some R
> functions or
> some ideas I can borrow to solve my problem.

There is a deriv function that provides limited support for symbolic
differentiation.

The Rhelp list is advertised ( http://www.R-project.org/posting-guide.html
) as expecting you to have made some efforts at searching. This
answer might not have floated to the surface among the thousand or so
hits, but at least you should have tried.

RSiteSearch("derivative")

And there is, of course, CrossValidated: http://stats.stackexchange.com/

>
> --
> View this message in context: http://r.789695.n4.nabble.com/Derivative-of-a-function-tp3631814p3633071.html
> Sent from the R help mailing list archive at Nabble.com.
>
> ______________________________________________
> R-help at r-project.org mailing list
> https://stat.ethz.ch/mailman/listinfo/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

------------------------------

Message: 35
Date: Wed, 29 Jun 2011 14:16:02 -0400
From: Gabor Grothendieck <ggrothendieck at gmail.com>
To: Lisa <lisajca at gmail.com>
Cc: r-help at r-project.org
Subject: Re: [R] Derivative of a function
Message-ID: <BANLkTi=DQGso+aywk4JbPnYsSy5b7e6cPQ at mail.gmail.com>
Content-Type: text/plain; charset=ISO-8859-1

On Tue, Jun 28, 2011 at 10:03 PM, Lisa <lisajca at gmail.com> wrote:
> Dear all,
>
> I just want to get the derivative of a function that looks like:
>
> y = exp(x1*b) / (exp(x1*b) + exp(x2*b))
>
> where y is a scalar, x1, x2, and b are vectors. I am going to take the
> derivative of b with respect to y, but I cannot derive an expression in
> which b is function of y. I know there is another way to get the similar
> result, i.e., first take the derivative of y with respect to each element of
> b, and then take its reciprocal. But it is not what I want. Could someone
> please tell me how to solve this problem? Thank you in advance.

Assuming you meant the derivative of y with respect to b:

> D(expression(exp(x1*b) / (exp(x1*b) + exp(x2*b))), "b")
exp(x1 * b) * x1/(exp(x1 * b) + exp(x2 * b)) - exp(x1 * b) *
(exp(x1 * b) * x1 + exp(x2 * b) * x2)/(exp(x1 * b) + exp(x2 *
b))^2

See ?D and also note deriv on the same help page for another alternative.

--
Statistics & Software Consulting
GKX Group, GKX Associates Inc.
tel: 1-877-GKX-GROUP
email: ggrothendieck at gmail.com

------------------------------

Message: 36
Date: Wed, 29 Jun 2011 13:18:25 -0500
From: Marc Schwartz <marc_schwartz at me.com>
To: Iain Gallagher <iaingallagher at btopenworld.com>
Cc: r-help at r-project.org
Subject: Re: [R] median time period
Message-ID: <20E58C11-765D-416F-972A-1D00B29AFF29 at me.com>
Content-Type: text/plain; CHARSET=US-ASCII

Iain,

Just to throw out another option, using base R functions:

test <- c('08-04-22', '08-07-28', '09-03-02', '09-03-03', '09-01-30',
'09-03-09', '10-02-24', '10-03-05')

> median(as.numeric(diff(as.Date(test, format = "%y-%m-%d"), lag = 4) / 30.44))
[1] 10.54534

This uses the ?diff function which has a Date method (defaulting to units in days) and also a 'lag' option:

> diff(as.Date(test, format = "%y-%m-%d"), lag = 4)
Time differences in days
[1] 283 224 359 367

I use 30.44 above to convert days to months.

HTH,

Marc Schwartz

On Jun 29, 2011, at 10:50 AM, Iain Gallagher wrote:

[[elided Yahoo spam]]
>
> Anyway here's my solution
>
> Toy code as before then:
>
> intervalsMonths <- 12 * intervals\$year + intervals\$month
>
> #convert whole years to months then add the remaining months for that entry in intervals
>
> medianMonths <- median(as.numeric(intervalsMonths))
>
> Best
>
> iain
>
> --- On Wed, 29/6/11, Iain Gallagher <iaingallagher at btopenworld.com> wrote:
>
>> From: Iain Gallagher <iaingallagher at btopenworld.com>
>> Subject: [R] median time period
>> To: r-help at r-project.org
>> Date: Wednesday, 29 June, 2011, 16:24
>> Hello List
>>
>> I'm trying to calculate the median period (in months) of a
>> set of time intervals (between two interventions).
>>
>> I have been playing with the lubridate package to create
>> the intervals but I can't think of the right approach to get
>> the median timeperiod.
>>
>> Toy code:
>>
>> library(lubridate)
>> test <- c('08-04-22', '08-07-28', '09-03-02',
>> '09-03-03', '09-01-30', '09-03-09', '10-02-24', '10-03-05')
>> test <- ymd(test)
>> intervals <- as.period(test[5:8] - test[1:4])
>>
>> intervals
>> [1] 9 months and 8 days    7 months and 9
>> days    11 months and 22 days
>> [4] 1 year and 2 days
>>
>> How can I convert this 'period' object to months? From
>> there I think I should just convert to 'numeric' and
>> calculate the median.
>>
>> Garrett if you're out there - great package but could you
>>
>> Best
>>
>> iain

------------------------------

Message: 37
Date: Wed, 29 Jun 2011 20:24:06 +0200
From: Janko Thyson <janko.thyson.rstuff at googlemail.com>
To: "r-help at r-project. org" <r-help at r-project.org>
Subject: [R] Update MS Windows PATH variable based on a R script
Message-ID: <4E0B6DC6.1030709 at googlemail.com>
Content-Type: text/plain; charset=ISO-8859-1; format=flowed

Dear list,

this is not directly an R question, but it is somewhat related to R
aspects, so I hope it's okay to post it here:

I'd like to update my windows PATH based on a script routine in order to
make sure that crucial components are contained. Much like what happens
at the installation of Rtools (if desired). Now, can you do that from
within R or do I need some sort of windows batch file or something like
AutoIt script (http://www.autoitscript.com/site/autoit/)? If so, what
would I need to put in there?

Here's what I tried in R:

unlist(strsplit(Sys.getenv("PATH"), ";"))
PATH.0 <- Sys.getenv("PATH")
PATH.1 <- paste(PATH.0, "C:\\blabla\bin")
Sys.setenv("PATH"=PATH.1)
unlist(strsplit(Sys.getenv("PATH"), ";"))

The changes seem to be reflected, but when I check my PATH the new entry
isn't there. I guess there is no actual "feedback" to Windows system
environment variable and that's exactly what I would like to accomplish

Thanks a lot for any advice,
Janko

------------------------------

Message: 38
Date: 29 Jun 2011 13:29:07 -0500
From: "Christopher T. Moore" <moor0554 at umn.edu>
To: r-help at r-project.org
Subject: [R] Unexpected R Behavior: Adding 4 to Large Numbers/IDs
Containing	Current Year
Message-ID: <Gophermail.2.0.1106291329070.11765 at vs-w.tc.umn.edu>
Content-Type: text/plain; format=flowed; charset=UTF-8

Hello,

I have encountered some unexpected behavior in R that seems to occur as a
result of having the current year embedded in a number:

> ########################################
>
> #Some large numbers, representing IDs.
> IDs <- c(41255689815201100, 41255699815201100, 41255709815201100)
>
> #In scientific notation
> IDs
[1] 4.125569e+16 4.125570e+16 4.125571e+16
>
> #Change penalty.
> options(scipen = 5)
>
> #Why does R add 4?
> IDs
[1] 41255689815201104 41255699815201104 41255709815201104
>
> #Changing from numeric to character makes no difference.
> as.character(IDs)
[1] "41255689815201104" "41255699815201104" "41255709815201104"
>
> #What happens if I treat the numbers as characters?
IDs.character <- c("41255689815201100", "41255699815201100",
"41255709815201100")
>
> #No change.
> IDs.character
[1] "41255689815201100" "41255699815201100" "41255709815201100"
>
> #R adds 4 upon converting to numeric.
> as.numeric(IDs.character)
[1] 41255689815201104 41255699815201104 41255709815201104
>
#Is this problem occurring because the current year is embedded in the
number?
> IDs <- c(41255689815201100, 41255699815201000, 41255709815201200)
>
> #R is no longer adding 4 to the numbers without "2011".
> IDs
[1] 41255689815201104 41255699815201000 41255709815201200
>
> ########################################

Am I doing something wrong? Any insight on how I can avoid the problem of R
changing numbers on its own? Are others able to replicate this example? Is
this some kind of bug? Am I right that this problem is occurring because
the current year is embedded in the number? I discovered this when trying
to merge two data sets, one with IDs stored numbers and one with IDs as
characters. I have replicated this in Windows XP with R 2.12 and Windows 7
with R 2.13 (both 32- and 64-bit versions).

Thanks,
Chris

--
Christopher T. Moore, M.P.P.
Doctoral Student
Quantitative Methods in Education
University of Minnesota
44.9785?N, 93.2396?W
moor0554 at umn.edu
http://umn.edu/~moor0554

------------------------------

Message: 39
Date: Wed, 29 Jun 2011 14:33:29 -0400
From: Sarah Goslee <sarah.goslee at gmail.com>
To: Simon Goodman <s.j.goodman at leeds.ac.uk>
Cc: r-help at r-project.org
Subject: Re: [R] Testing if a variable is specified within a function
& adding TRUE/FALSE options to functions
Message-ID: <BANLkTi=W37yr3MOpCkhNU1a02Q5FwUwJZg at mail.gmail.com>
Content-Type: text/plain; charset=ISO-8859-1

Hi Simon,

On Wed, Jun 29, 2011 at 11:42 AM, Simon Goodman <s.j.goodman at leeds.ac.uk> wrote:
> I have 2 related questions about functions.
>
> 1. I am writing a function to plot data from a time series with the form
>
> myplot<-function(data, d1,d2) { ? ?}
>
> Where d1 and d2 are two dates in a time series. The idea being that if no
> values for d1 and d2 are entered then the function defaults to plotting the
> whole time series, else it plots the data for the interval specified by d1
> and d2.

The usual way to check whether an argument has been specified within a
function is by using missing().

> I am attempting to test if the variable d1 has been inputted by using a
> different function, orginally posted on a R help forum by Brian Ripley.
>
> testObject <- function(object)
> {
> ? exists(as.character(substitute(object)))
> }
>
> here testObject(x) returns FALSE if x is not currently present a variable in
> the work space image.
>
> testObject works fine outside my plotting function, but not within it.... it
> always returns FALSE inside the plotting function even when d1 is being
> given by the user.
>
> I get the same result even if the testObject function is defined inside the
> plotting function....
>
> I suspect this may be due to enviroment being searched for d1.... but can't
> find work out how to make it search for d1 within the 'myplot' function - I
> think this can done using 'where' or 'environment' - but the documentation
> on these commands is a little opaque.
>
> 2. For the 'myplot' function I would also like to add a customlegend=TRUE
> (or FALSE) option, which determines if a custom legend is plotted (if not
> inputted it would default to TRUE), but haven't been able to find anything
> on how to specify this kind TRUE/FALSE of option for functions.

I'm not sure what the question is, exactly. You do something like:

myfun <- function(whatever, customlegend=TRUE) {
# name the argument, give it a default value
plot(whatever)
if(customlegend) {
# do the custom legend stuff
} else {
# do whatever the other version is
}
invisible()
}

It's all a matter of passing arguments to your functions.

If those aren't really what you were asking, then you might need to
restate the questions.

Sarah

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

------------------------------

Message: 40
Date: Wed, 29 Jun 2011 14:36:06 -0400
From: Sarah Goslee <sarah.goslee at gmail.com>
To: Katia Smirnova <katiasmirn at gmail.com>
Cc: r-help at r-project.org
Subject: Re: [R] 4D data acsess
Message-ID: <BANLkTinNSMGjBJa2o=BZDWbF3wQSzHrFjA at mail.gmail.com>
Content-Type: text/plain; charset=ISO-8859-1

Hi Katia,

On Wed, Jun 29, 2011 at 12:50 PM, Katia Smirnova <katiasmirn at gmail.com> wrote:
> Hi, I have a 4D data file from MATLAB, call it X, ?that I want to analyze in
> R. The first 3 dimensions are x y z coordinates and the forth is a value in
> time.
>
> If you took a sample vector in matlab it would look like
>
> vec1 = X(x1, y1, z1, :)
> vec2 = X( x2, y2, z2, :)
>
> this would give you all values (I have 300 of them) corresponding to this
> (x1,y1,z1) point of X.
>
> Now I read the MATLAB datafile 4D X into R and want to address vec1 and vec2
> in R and work with the fourth column values only.

How did you import the MATLAB file?

> I tried something like X[ x1, y1, z1, ] to pull out the 4th column values
> but R tells me that X has incorrect dimensions.

We need a description of X. dim(X) and str(X) might be good starts.

You don't really provide enough information to be able to answer.

Sarah

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

------------------------------

Message: 41
Date: Wed, 29 Jun 2011 14:39:00 -0400
From: Jorge Ivan Velez <jorgeivanvelez at gmail.com>
To: Komal <Komalsharif86 at gmail.com>
Cc: r-help at r-project.org
Subject: Re: [R] 2d rndom walk
Message-ID: <BANLkTi=X4F86a3P=wU_co=EJCUxXiS0moA at mail.gmail.com>
Content-Type: text/plain

Hi Komal,
Try this:

walk2d<-function(n){
rw <- matrix(0, ncol = 2, nrow = n)

# generate the indices to set the deltas
indx <- cbind(seq(n), sample(c(1, 2), n, TRUE))

# now set the values
rw[indx] <- sample(c(-1, 1), n, TRUE)

# cumsum the columns
rw[,1] <- cumsum(rw[, 1])
rw[,2] <- cumsum(rw[, 2])
cbind(rw[,1],rw[,2])  # changed this

}

# example
n <- 100
rw <- walk2d(n)
plot(rw, xlab="x", ylab="y", main="Random Walk Simulation In Two
Dimensions",
xlim = range(rw[,1]), ylim = range(rw[,2]), las = 1)

HTH,
Jorge

On Wed, Jun 29, 2011 at 11:44 AM, Komal <> wrote:

>
>
>
> walk.2d<-function(n)
> {
> rw <- matrix(0, ncol = 2, nrow = n)
>
> # generate the indices to set the deltas
> indx <- cbind(seq(n), sample(c(1, 2), n, TRUE))
>
> # now set the values
> rw[indx] <- sample(c(-1, 1), n, TRUE)
>
> # cumsum the columns
> rw[,1] <- cumsum(rw[, 1])
> rw[,2] <- cumsum(rw[, 2])
>
> return(rw[,1],rw[,2])
>
> }
> n<-1000
>
> plot(walk.2d(n), type="n",xlab="x",ylab="y",main="Random Walk Simulation In
> Two Dimensions",xlim=range(rw[,1]),ylim=range(rw[,2]))
>
>        # use 'segments' to color each path
> segments(head(rw[, 1], -1), head(rw[, 2], -1), tail(rw[, 1], -1), tail(rw[,
> 2], -1), col ="blue")
>
>
> This code is giving me error in the return()... what to write in
> return()???
>
>
> --
> View this message in context:
> http://r.789695.n4.nabble.com/2d-rndom-walk-tp3632468p3633249.html
> Sent from the R help mailing list archive at Nabble.com.
>
> ______________________________________________
> R-help at r-project.org mailing list
> https://stat.ethz.ch/mailman/listinfo/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]]

------------------------------

Message: 42
Date: Wed, 29 Jun 2011 11:41:18 -0700
From: Peter Langfelder <peter.langfelder at gmail.com>
To: "Christopher T. Moore" <moor0554 at umn.edu>
Cc: r-help at r-project.org
Subject: Re: [R] Unexpected R Behavior: Adding 4 to Large Numbers/IDs
Containing Current Year
Message-ID: <BANLkTimoJe3QeOs3inDnw3F_6h66g_o6Rw at mail.gmail.com>
Content-Type: text/plain; charset=ISO-8859-1

You seem to be running into the limits of double-precision - your IDs
have 17 "significant" digits which is more than the double precision
floating point number can hold without any rounding errors.

Since you are using these numbers as IDs, simply keep them as
character strings throughout your code, and nothing will ever change.
Or shorten the IDs by a few digits and your IDs will be safe again.

HTH,

Peter

On Wed, Jun 29, 2011 at 11:29 AM, Christopher T. Moore <moor0554 at umn.edu> wrote:
> Hello,
>
> I have encountered some unexpected behavior in R that seems to occur as a
> result of having the current year embedded in a number:

------------------------------

Message: 43
Date: Wed, 29 Jun 2011 14:42:18 -0400
From: David Winsemius <dwinsemius at comcast.net>
To: "Christopher T. Moore" <moor0554 at umn.edu>
Cc: r-help at r-project.org
Subject: Re: [R] Unexpected R Behavior: Adding 4 to Large Numbers/IDs
Containing Current Year
Message-ID: <338B8CD2-265B-4A7E-8C70-DF23D3D7FFBB at comcast.net>
Content-Type: text/plain; charset=ISO-8859-1; format=flowed; delsp=yes

On Jun 29, 2011, at 2:29 PM, Christopher T. Moore wrote:

> Hello,
>
> I have encountered some unexpected behavior in R that seems to occur
> as a result of having the current year embedded in a number:

No. that is not the explanation.

>
>> ########################################
>> #Some large numbers, representing IDs.
>> IDs <- c(41255689815201100, 41255699815201100, 41255709815201100)

41255689815201100  > 2*10^9
[1] TRUE

So you may think you are working with integers but youa re in fact
working with floating point numbers. See the R-FAQ

--
David.
>> #In scientific notation
>> IDs
> [1] 4.125569e+16 4.125570e+16 4.125571e+16
>> #Change penalty.
>> options(scipen = 5)
>> #Why does R add 4?
>> IDs
> [1] 41255689815201104 41255699815201104 41255709815201104
>> #Changing from numeric to character makes no difference.
>> as.character(IDs)
> [1] "41255689815201104" "41255699815201104" "41255709815201104"
>> #What happens if I treat the numbers as characters?
> IDs.character <- c("41255689815201100", "41255699815201100",
> "41255709815201100")
>> #No change.
>> IDs.character
> [1] "41255689815201100" "41255699815201100" "41255709815201100"
>> #R adds 4 upon converting to numeric.
>> as.numeric(IDs.character)
> [1] 41255689815201104 41255699815201104 41255709815201104
> #Is this problem occurring because the current year is embedded in
> the number?
>> IDs <- c(41255689815201100, 41255699815201000, 41255709815201200)
>> #R is no longer adding 4 to the numbers without "2011".
>> IDs
> [1] 41255689815201104 41255699815201000 41255709815201200
>> ########################################
>
> Am I doing something wrong? Any insight on how I can avoid the
> problem of R changing numbers on its own? Are others able to
> replicate this example? Is this some kind of bug? Am I right that
> this problem is occurring because the current year is embedded in
> the number? I discovered this when trying to merge two data sets,
> one with IDs stored numbers and one with IDs as characters. I have
> replicated this in Windows XP with R 2.12 and Windows 7 with R 2.13
> (both 32- and 64-bit versions).
>
> Thanks,
> Chris
>
> --
> Christopher T. Moore, M.P.P.
> Doctoral Student
> Quantitative Methods in Education
> University of Minnesota
> 44.9785?N, 93.2396?W
> moor0554 at umn.edu
> http://umn.edu/~moor0554
>
> ______________________________________________
> R-help at r-project.org mailing list
> https://stat.ethz.ch/mailman/listinfo/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

------------------------------

Message: 44
Date: Wed, 29 Jun 2011 14:58:03 -0400
From: Duncan Murdoch <murdoch.duncan at gmail.com>
To: Janko Thyson <janko.thyson.rstuff at googlemail.com>
Cc: "r-help at r-project. org" <r-help at r-project.org>
Subject: Re: [R] Update MS Windows PATH variable based on a R script
Message-ID: <4E0B75BB.1030103 at gmail.com>
Content-Type: text/plain; charset=ISO-8859-1; format=flowed

On 29/06/2011 2:24 PM, Janko Thyson wrote:
> Dear list,
>
> this is not directly an R question, but it is somewhat related to R
> aspects, so I hope it's okay to post it here:
>
> I'd like to update my windows PATH based on a script routine in order to
> make sure that crucial components are contained. Much like what happens
> at the installation of Rtools (if desired). Now, can you do that from
> within R or do I need some sort of windows batch file or something like
> AutoIt script (http://www.autoitscript.com/site/autoit/)? If so, what
> would I need to put in there?

You need to set the registry entry if you want a persistent change to
the PATH.  Sys.setenv just modifies R's copy of the PATH.  Child
processes will see the modifications, but they don't last beyond the R
session.

You'll have to check MS docs to find which registry entry to mess with.
Alternatively, if you feel lucky, just use Control Panel to set some
strange path, then see where your change showed up using regedit.

R doesn't have a built-in function to write to the registry, but there
are various utilities available outside of R to do it.

Duncan Murdoch

>
> Here's what I tried in R:
>
> unlist(strsplit(Sys.getenv("PATH"), ";"))
> PATH.0<- Sys.getenv("PATH")
> PATH.1<- paste(PATH.0, "C:\\blabla\bin")
> Sys.setenv("PATH"=PATH.1)
> unlist(strsplit(Sys.getenv("PATH"), ";"))
>
> The changes seem to be reflected, but when I check my PATH the new entry
> isn't there. I guess there is no actual "feedback" to Windows system
> environment variable and that's exactly what I would like to accomplish
>
> Thanks a lot for any advice,
> Janko
>
> ______________________________________________
> R-help at r-project.org mailing list
> https://stat.ethz.ch/mailman/listinfo/r-help
> PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
> and provide commented, minimal, self-contained, reproducible code.

------------------------------

Message: 45
Date: Wed, 29 Jun 2011 11:31:36 -0700 (PDT)
From: siriustar <qinlangjinan at live.cn>
To: r-help at r-project.org
Subject: [R] optimization in for loop
Message-ID: <1309372296594-3633638.post at n4.nabble.com>
Content-Type: text/plain; charset=us-ascii

Hi, dear R help
I am trying to use optim inside a for loop:

##For example. a: intial guess.  b: result.  f: function to be minimized
for (i in 1:10) {
b[i] <- optim(a[i], f)}

However, some intial values cause error in optim function (e.g. " system is
computationally singular..."). Then the for loop stops and won't try the
following initial guesses.

What can I do if I want the for loop procedure to finish all the initial
guesses? I know this may be a stupid question.. but I am not familar with R
optim. So thankyou very much for any help..

Sirius

--
View this message in context: http://r.789695.n4.nabble.com/optimization-in-for-loop-tp3633638p3633638.html
Sent from the R help mailing list archive at Nabble.com.

------------------------------

Message: 46
Date: Wed, 29 Jun 2011 15:37:24 -0300
From: "Filipe Leme Botelho" <filipe.botelho at vpar.com.br>
To: "tomtomme" <langkamp at tomblog.de>, <r-help at r-project.org>
Subject: [R] RES:  time series interpolation
Message-ID:
<07E17EE73DE13B4897BC6FE325CF7A2401834953 at BRSAOWSEXCL001.votorantim.grupo>

Content-Type: text/plain;	charset="utf-8"

Hi Tom,

At least to me it?s hard to picture what?s wrong without further details regarding your data. I use spline/linear interpolation of time series regularly, so maybe this example help you out.

> ci_x
[1]   1   4  69 131 194 256 320 382
> ci_y
[1] 0.1211 0.1213 0.1233 0.1241 0.1250 0.1254 0.1255 0.1255
>
> approx(x=ci_x, y=ci_y, n=ci_x[length(ci_x)])\$y

Regards,
Filipe.

-----Mensagem original-----
De: r-help-bounces at r-project.org [mailto:r-help-bounces at r-project.org] Em nome de tomtomme
Enviada em: quarta-feira, 29 de junho de 2011 12:28
Para: r-help at r-project.org
Assunto: [R] time series interpolation

Hi there,
I?ve got a datatable in R which I try to interpolate with this and get the
Error below:

> new\$temp<- approx(w03_11temp\$temp, n = (nrow(w03_11temp)*5))\$y

Error in new\$temp <- approx(w03_11temp\$temp, n = (nrow(w03_11temp) * 5))\$y :
Object of type 'closure' not registered

Any idea?? Thanks a lot.

--
View this message in context: http://r.789695.n4.nabble.com/time-series-interpolation-tp3633193p3633193.html
Sent from the R help mailing list archive at Nabble.com.

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

"This message and its attachments may contain confidential and/or privileged information. If you are not the addressee, please, advise the sender immediately by replying to the e-mail and delete this message."

"Este mensaje y sus anexos pueden contener informaci?n confidencial o privilegiada. Si ha recibido este e-mail por error por favor b?rrelo y env?e un mensaje al remitente."

"Esta mensagem e seus anexos podem conter informa??o confidencial ou privilegiada. Caso n?o seja o destinat?rio, solicitamos a imediata notifica??o ao remetente e exclus?o da mensagem."

------------------------------

Message: 47
Date: Wed, 29 Jun 2011 12:07:48 -0700
From: Art Burke <Art.Burke at educationnorthwest.org>
To: "r-help at r-project.org" <r-help at r-project.org>
Subject: [R] update.packages fail
Message-ID:

Content-Type: text/plain

update.packages has suddenly stopped working for me (after working fine yesterday). My default mirror is at Oregon State University, but I get the following warning even after setting another mirror.  Other Internet connections are working on my computer.  Suggestions, please.

> update.packages()
Warning: unable to access index for repository http://www.stats.ox.ac.uk/pub/RWin/bin/windows/contrib/2.13
> sessionInfo()
R version 2.13.0 (2011-04-13)
Platform: i386-pc-mingw32/i386 (32-bit)

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

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

loaded via a namespace (and not attached):
[1] tools_2.13.0

Art
_______________________________________
Arthur J. Burke
Education Northwest
101 SW Main St, Suite 500
Portland OR 97204-3213
Art.Burke at educationnorthwest.org
Phone: 503-275-9592
http://educationnorthwest.org

[[alternative HTML version deleted]]

------------------------------

Message: 48
Date: Wed, 29 Jun 2011 15:11:06 -0400
From: David Winsemius <dwinsemius at comcast.net>
To: Filipe Leme Botelho <filipe.botelho at vpar.com.br>
Cc: r-help at r-project.org, tomtomme <langkamp at tomblog.de>
Subject: Re: [R] RES:  time series interpolation
Message-ID: <F4C64341-A69C-43EA-9BA1-DABAD2706FA9 at comcast.net>
Content-Type: text/plain; charset=ISO-8859-1; format=flowed; delsp=yes

On Jun 29, 2011, at 2:37 PM, Filipe Leme Botelho wrote:

> Hi Tom,
>
> At least to me it?s hard to picture what?s wrong without further
> details regarding your data. I use spline/linear interpolation of
> time series regularly, so maybe this example help you out.
>
>> ci_x
> [1]   1   4  69 131 194 256 320 382
>> ci_y
> [1] 0.1211 0.1213 0.1233 0.1241 0.1250 0.1254 0.1255 0.1255
>>
>> approx(x=ci_x, y=ci_y, n=ci_x[length(ci_x)])\$y
>
>
> Regards,
> Filipe.
>
> -----Mensagem original-----
> De: r-help-bounces at r-project.org [mailto:r-help-bounces at r-
> project.org] Em nome de tomtomme
> Enviada em: quarta-feira, 29 de junho de 2011 12:28
> Para: r-help at r-project.org
> Assunto: [R] time series interpolation
>
> Hi there,
> I?ve got a datatable in R which I try to interpolate with this and
> get the
> Error below:
>
>> new\$temp<- approx(w03_11temp\$temp, n = (nrow(w03_11temp)*5))\$y

It looks to me that you are trying to assign a column vector into a
dataframe but you are constructing it with five times as many elements
as the dataframe has rows. I am unable to explain the error message,
however. You say this is a 'datatable', so maybe the datatable
maintainers would have a better idea, assuming you are using your
terms correctly.

>
> Error in new\$temp <- approx(w03_11temp\$temp, n = (nrow(w03_11temp) *
> 5))\$y :
>  Object of type 'closure' not registered
>
> Any idea?? Thanks a lot.
>
> --
> View this message in context: http://r.789695.n4.nabble.com/time-series-interpolation-tp3633193p3633193.html
> Sent from the R help mailing list archive at Nabble.com.
>
> ______________________________________________
> R-help at r-project.org mailing list
> https://stat.ethz.ch/mailman/listinfo/r-help
> PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
> and provide commented, minimal, self-contained, reproducible code.
>
> "This message and its attachments may contain confidential and/or
> privileged information. If you are not the addressee, please, advise
> the sender immediately by replying to the e-mail and delete this
> message."
>
> "Este mensaje y sus anexos pueden contener informaci?n confidencial
> o privilegiada. Si ha recibido este e-mail por error por favor
> b?rrelo y env?e un mensaje al remitente."
>
> "Esta mensagem e seus anexos podem conter informa??o confidencial ou
> privilegiada. Caso n?o seja o destinat?rio, solicitamos a imediata
> notifica??o ao remetente e exclus?o da mensagem."
> ______________________________________________
> R-help at r-project.org mailing list
> https://stat.ethz.ch/mailman/listinfo/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

------------------------------

Message: 49
Date: Wed, 29 Jun 2011 15:12:33 -0400
From: David Winsemius <dwinsemius at comcast.net>
To: siriustar <qinlangjinan at live.cn>
Cc: r-help at r-project.org
Subject: Re: [R] optimization in for loop
Message-ID: <21C5B4AC-F8C4-4679-9D90-EB2B503DEB86 at comcast.net>
Content-Type: text/plain; charset=US-ASCII; format=flowed; delsp=yes

On Jun 29, 2011, at 2:31 PM, siriustar wrote:

> Hi, dear R help
> I am trying to use optim inside a for loop:
>
> ##For example. a: intial guess.  b: result.  f: function to be
> minimized
> for (i in 1:10) {
>  b[i] <- optim(a[i], f)}
>
> However, some intial values cause error in optim function (e.g. "
> system is
> computationally singular..."). Then the for loop stops and won't try
> the
> following initial guesses.

If you want to work around errors, you need to catch them and provide
alternative:

?try

>
> What can I do if I want the for loop procedure to finish all the
> initial
> guesses? I know this may be a stupid question.. but I am not familar
> with R
> optim. So thankyou very much for any help..
>
> Sirius
>
> --
> View this message in context: http://r.789695.n4.nabble.com/optimization-in-for-loop-tp3633638p3633638.html
> Sent from the R help mailing list archive at Nabble.com.
>
> ______________________________________________
> R-help at r-project.org mailing list
> https://stat.ethz.ch/mailman/listinfo/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

------------------------------

Message: 50
Date: Wed, 29 Jun 2011 21:15:34 +0200
From: Janko Thyson <janko.thyson.rstuff at googlemail.com>
To: Duncan Murdoch <murdoch.duncan at gmail.com>
Cc: "r-help at r-project. org" <r-help at r-project.org>
Subject: Re: [R] Update MS Windows PATH variable based on a R script
Message-ID: <4E0B79D6.8030700 at googlemail.com>
Content-Type: text/plain; charset=ISO-8859-1; format=flowed

On 29.06.2011 20:58, Duncan Murdoch wrote:
> On 29/06/2011 2:24 PM, Janko Thyson wrote:
>> Dear list,
>>
>> this is not directly an R question, but it is somewhat related to R
>> aspects, so I hope it's okay to post it here:
>>
>> I'd like to update my windows PATH based on a script routine in order to
>> make sure that crucial components are contained. Much like what happens
>> at the installation of Rtools (if desired). Now, can you do that from
>> within R or do I need some sort of windows batch file or something like
>> AutoIt script (http://www.autoitscript.com/site/autoit/)? If so, what
>> would I need to put in there?
>
> You need to set the registry entry if you want a persistent change to
> the PATH.  Sys.setenv just modifies R's copy of the PATH.  Child
> processes will see the modifications, but they don't last beyond the R
> session.
>
> You'll have to check MS docs to find which registry entry to mess
> with.  Alternatively, if you feel lucky, just use Control Panel to set
> some strange path, then see where your change showed up using regedit.
>
> R doesn't have a built-in function to write to the registry, but there
> are various utilities available outside of R to do it.
>
> Duncan Murdoch

[[elided Yahoo spam]]
Would you mind sharing how you do it with the Rtools Windows installer?
Or is that too much bound to installer details and can't be secluded
very well?

The motivation behind this is that I came to love applications that can
be run portably (i.e. apps that don't write anything to the Windows
registry and can therefore be easily be "installed" on a USB drive, for
example). That works just fine with R, my IDE Eclipse and also Rtools.
The problem is that I need a batch script that optionally checks under
which letter my USB drive is mounted and updates the relevant paths to
Rtools binaries in my Windows PATH to make it somewhat "dynamical". Of
course I'd like to clean everything up once my R-session terminates so I
can reset the Windows PATH to it's original state once I'm finished
working at a specific PC.

What I also just thought of: is there some way to specify relative and
not absolute paths in the windows PATH? I know that this works when you
have an .exe as a reference point (e.g. '..\somedir\' goes up one
directory relative to the directory where the .exe is called and then
moves into 'somedir'). But since there is no such thing as an .exe
involved, there's probably no way to do it.

But thanks for the info, I'll have a look at MS specific documentation
to get the job done.

Regards,
Janko
>
>>
>> Here's what I tried in R:
>>
>> unlist(strsplit(Sys.getenv("PATH"), ";"))
>> PATH.0<- Sys.getenv("PATH")
>> PATH.1<- paste(PATH.0, "C:\\blabla\bin")
>> Sys.setenv("PATH"=PATH.1)
>> unlist(strsplit(Sys.getenv("PATH"), ";"))
>>
>> The changes seem to be reflected, but when I check my PATH the new entry
>> isn't there. I guess there is no actual "feedback" to Windows system
>> environment variable and that's exactly what I would like to accomplish
>>
>> Thanks a lot for any advice,
>> Janko
>>
>> ______________________________________________
>> R-help at r-project.org mailing list
>> https://stat.ethz.ch/mailman/listinfo/r-help
>> PLEASE do read the posting guide
>> http://www.R-project.org/posting-guide.html
>> and provide commented, minimal, self-contained, reproducible code.
>
>

------------------------------

Message: 51
Date: Wed, 29 Jun 2011 15:24:08 -0400
From: Duncan Murdoch <murdoch.duncan at gmail.com>
To: Janko Thyson <janko.thyson.rstuff at googlemail.com>
Cc: "r-help at r-project. org" <r-help at r-project.org>
Subject: Re: [R] Update MS Windows PATH variable based on a R script
Message-ID: <4E0B7BD8.2010009 at gmail.com>
Content-Type: text/plain; charset=ISO-8859-1; format=flowed

On 29/06/2011 3:15 PM, Janko Thyson wrote:
> On 29.06.2011 20:58, Duncan Murdoch wrote:
>> On 29/06/2011 2:24 PM, Janko Thyson wrote:
>>> Dear list,
>>>
>>> this is not directly an R question, but it is somewhat related to R
>>> aspects, so I hope it's okay to post it here:
>>>
>>> I'd like to update my windows PATH based on a script routine in order to
>>> make sure that crucial components are contained. Much like what happens
>>> at the installation of Rtools (if desired). Now, can you do that from
>>> within R or do I need some sort of windows batch file or something like
>>> AutoIt script (http://www.autoitscript.com/site/autoit/)? If so, what
>>> would I need to put in there?
>>
>> You need to set the registry entry if you want a persistent change to
>> the PATH.  Sys.setenv just modifies R's copy of the PATH.  Child
>> processes will see the modifications, but they don't last beyond the R
>> session.
>>
>> You'll have to check MS docs to find which registry entry to mess
>> with.  Alternatively, if you feel lucky, just use Control Panel to set
>> some strange path, then see where your change showed up using regedit.
>>
>> R doesn't have a built-in function to write to the registry, but there
>> are various utilities available outside of R to do it.
>>
>> Duncan Murdoch
>
[[elided Yahoo spam]]
> Would you mind sharing how you do it with the Rtools Windows installer?
> Or is that too much bound to installer details and can't be secluded
> very well?

We use the Inno Setup installer; it has a function for this.  Here's the
code used:

Root: HKLM; Subkey: SYSTEM\CurrentControlSet\Control\Session
Manager\Environment; ValueType: expandsz; ValueName: PATH; ValueData:

So I guess I do know what the registry key is.

>
> The motivation behind this is that I came to love applications that can
> be run portably (i.e. apps that don't write anything to the Windows
> registry and can therefore be easily be "installed" on a USB drive, for
> example). That works just fine with R, my IDE Eclipse and also Rtools.
> The problem is that I need a batch script that optionally checks under
> which letter my USB drive is mounted and updates the relevant paths to
> Rtools binaries in my Windows PATH to make it somewhat "dynamical". Of
> course I'd like to clean everything up once my R-session terminates so I
> can reset the Windows PATH to it's original state once I'm finished
> working at a specific PC.
>
> What I also just thought of: is there some way to specify relative and
> not absolute paths in the windows PATH? I know that this works when you
> have an .exe as a reference point (e.g. '..\somedir\' goes up one
> directory relative to the directory where the .exe is called and then
> moves into 'somedir'). But since there is no such thing as an .exe
> involved, there's probably no way to do it.

As far as I know that's fine with R.  It uses various .exe's in the
bin/i386 or bin/x64 directories.  It doesn't use the path for anything
beyond startup.

Duncan Murdoch

>
> But thanks for the info, I'll have a look at MS specific documentation
> to get the job done.
>
> Regards,
> Janko
>>
>>>
>>> Here's what I tried in R:
>>>
>>> unlist(strsplit(Sys.getenv("PATH"), ";"))
>>> PATH.0<- Sys.getenv("PATH")
>>> PATH.1<- paste(PATH.0, "C:\\blabla\bin")
>>> Sys.setenv("PATH"=PATH.1)
>>> unlist(strsplit(Sys.getenv("PATH"), ";"))
>>>
>>> The changes seem to be reflected, but when I check my PATH the new entry
>>> isn't there. I guess there is no actual "feedback" to Windows system
>>> environment variable and that's exactly what I would like to accomplish
>>>
>>> Thanks a lot for any advice,
>>> Janko
>>>
>>> ______________________________________________
>>> R-help at r-project.org mailing list
>>> https://stat.ethz.ch/mailman/listinfo/r-help
>>> PLEASE do read the posting guide
>>> http://www.R-project.org/posting-guide.html
>>> and provide commented, minimal, self-contained, reproducible code.
>>
>>
>

------------------------------

Message: 52
Date: Wed, 29 Jun 2011 15:31:27 -0400
From: zubin <binabina at bellsouth.net>
To: r-help at r-project.org
Subject: [R] lmer() computational performance
Message-ID: <4E0B7D8F.8080105 at bellsouth.net>
Content-Type: text/plain; charset=ISO-8859-1

Hello, running a mixed model in the package LME4, lmer()

Panel data, have about 322 time periods and 50 states, total data set is
approx 15K records and about 20  explanatory variables.  Not a very
large data set.

We run random intercepts as well as random coefficients for about 10 of
the variables, the rest come in as fixed effects.   We are running into
a wall of time to execute these models.

A sample specification of all random effects:

lmer(Y ~ 1 + (x_078 + x_079 + growth_st_index  +
retail_st_index + Natl + econ_home_st_index +
econ_bankruptcy +  index2_HO  + GPND_ST  | state),
data = newData, doFit = TRUE)

Computation time is near 15 minutes.
System        ELAPSED        User
21.4            888.63        701.74

Does anyone have any ideas on way's to speed up lmer(), as well any
parallel implementations, or approaches/options to reduce computation time?

------------------------------

Message: 53
Date: Wed, 29 Jun 2011 15:34:41 -0400
From: "Richard Valliant" <rvalliant at survey.umd.edu>
To: <r-help at r-project.org>
Subject: [R] RWinEdt
Message-ID: <se0b4634.050 at SURVEYGWIA.UMD.EDU>
Content-Type: text/plain; charset=US-ASCII

I have a problem using RWinEdt 1.8.2 in Windows 7 Professional (64 bit).
System/software info:
R version 2.13.0 (2011-04-13)
Copyright (C) 2011 The R Foundation for Statistical Computing
ISBN 3-900051-07-0
Platform: x86_64-pc-mingw32/x64 (64-bit)
WinEdt  Build: 20071003  (v. 5.5)

After installing the R package and attempting to load I get:

> library(RWinEdt)
Warning message:
In shell(paste("\"\"", .gW\$InstallRoot, "\\WinEdt.exe\" -C=\"R-WinEdt\"
-E=",  :
'""C:\Program Files (x86)\WinEdt Team\WinEdt\WinEdt.exe"
-C="R-WinEdt" -E="C:\Users\rvalliant\AppData\Roaming\WinEdt\R.ini""'
execution failed with error code 1
>

The WinEdt window does not open. I can open it manually (since the
package installation created a desktop shortcut ("RWinEdt"). If a line
of R code is highlighted in RWinEdt and sent to the R Console with
Alt+p, the focus shifts to R console but nothing is copied.

This has come up before in a message from John Seers on 2 Mar 2011. Uwe
suggested this:
"One installing RWinEdt the first time, please run R with Administrator

privileges (right click to do so). Then installation should work
smoothly with WinEdt < 6.0."

I'm running WinEdt 5.5. I followed Uwe's suggestion but get the message
above.
Any suggestions?

Thanks,
Richard Valliant
University of Michigan

------------------------------

Message: 54
Date: Thu, 30 Jun 2011 08:12:00 +1200
From: Patrick Connolly <p_connolly at slingshot.co.nz>
Cc: r-help at r-project.org
Subject: Re: [R] Tell emacs to load new R version
Message-ID: <20110629201200.GB5819 at slingshot.co.nz>
Content-Type: text/plain; charset=us-ascii

On Wed, 29-Jun-2011 at 02:25PM +0200, Aditya Bhagwat wrote:

|> Dear,
|>
|> How do I tell Emacs to update to the new R version I installed? It still
|> loads the old R version. I already updated the the system path, but that
|> didn't seem to work.

Depends on information you didn't supply.

|>
|> Thanks for your help,
|>
|>
|> --
|>
|> 	[[alternative HTML version deleted]]
|>
|> ______________________________________________
|> R-help at r-project.org mailing list
|> https://stat.ethz.ch/mailman/listinfo/r-help
|> PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
|> and provide commented, minimal, self-contained, reproducible code.

--
~.~.~.~.~.~.~.~.~.~.~.~.~.~.~.~.~.~.~.~.~.~.~.~.~.~.~.~.~.~.~.~.~.~.~.~.
___    Patrick Connolly
{~._.~}                   Great minds discuss ideas
_( Y )_  	         Average minds discuss events
(:_~*~_:)                  Small minds discuss people
(_)-(_)  	                      ..... Eleanor Roosevelt

~.~.~.~.~.~.~.~.~.~.~.~.~.~.~.~.~.~.~.~.~.~.~.~.~.~.~.~.~.~.~.~.~.~.~.~.

------------------------------

Message: 55
Date: Thu, 30 Jun 2011 08:18:18 +1200
From: Rolf Turner <rolf.turner at xtra.co.nz>
To: Gabor Grothendieck <ggrothendieck at gmail.com>
Cc: r-help at r-project.org, Lisa <lisajca at gmail.com>
Subject: Re: [R] Derivative of a function
Message-ID: <4E0B888A.3060806 at xtra.co.nz>
Content-Type: text/plain; charset=ISO-8859-1; format=flowed

On 30/06/11 06:16, Gabor Grothendieck wrote:
> On Tue, Jun 28, 2011 at 10:03 PM, Lisa<lisajca at gmail.com>  wrote:
>> Dear all,
>>
>> I just want to get the derivative of a function that looks like:
>>
>> y = exp(x1*b) / (exp(x1*b) + exp(x2*b))
>>
>> where y is a scalar, x1, x2, and b are vectors. I am going to take the
>> derivative of b with respect to y, but I cannot derive an expression in
>> which b is function of y. I know there is another way to get the similar
>> result, i.e., first take the derivative of y with respect to each element of
>> b, and then take its reciprocal. But it is not what I want. Could someone
>> please tell me how to solve this problem? Thank you in advance.
> Assuming you meant the derivative of y with respect to b:

I think the original post made it quite clear that the derivative of b
with respect to y was indeed what was wanted; i.e. the OP needs to
do implicit differentiation which R does not do automatically.

cheers,

Rolf Turner
>> D(expression(exp(x1*b) / (exp(x1*b) + exp(x2*b))), "b")
> exp(x1 * b) * x1/(exp(x1 * b) + exp(x2 * b)) - exp(x1 * b) *
>      (exp(x1 * b) * x1 + exp(x2 * b) * x2)/(exp(x1 * b) + exp(x2 *
>      b))^2
>
> See ?D and also note deriv on the same help page for another alternative.
>

------------------------------

Message: 56
Date: Wed, 29 Jun 2011 13:23:17 -0700 (PDT)

To: Dennis Murphy <djmuser at gmail.com>
Cc: r-help at r-project.org
Subject: Re: [R] BY GROUP IN GEV
Message-ID:
<1309378997.47325.YahooMailRC at web121702.mail.ne1.yahoo.com>
Content-Type: text/plain; charset=utf-8

Dennis:
It walks for small datset.

?Peter Maclean
Department of Economics
UDSM

----- Original Message ----
From: Dennis Murphy <djmuser at gmail.com>

Cc: r-help at r-project.org
Sent: Mon, June 27, 2011 8:37:00 PM
Subject: Re: [R] BY GROUP IN GEV

HI:

Since you didn't provide a reproducible example (in particular, what
does str(MA) return?), it's hard to verify what specifically causes
the error, but a look at the gev() function's help page indicates that
the first argument is supposed to be a (numeric) vector, apparently
atomic.

One problem with this code,
CP? <- lapply(MAS, function(x){gev(MAS\$CP1, 100, method = "BFGS", control =
list(maxit = 500))})

is that there is no 'x' in the body of the function. Perhaps you need
to generate a numeric vector for CP1 before feeding it to gev(), but
without a reproducible example this is nothing more than speculation.
Perhaps something like:

CP? <- lapply(MAS, function(x){
? ? ? ? ? ? y <- as.numeric(x\$CP1)
? ? ? ? ? ? gev(y, 100, method = "BFGS", control = list(maxit = 500))
? ? ? ? })

Obviously untested for the reason stated above. A perusal of the
Posting Guide might be beneficial.

Dennis

wrote:
> Hi Dennis:
> I tried your suggestions and I am getting the following errors:
>
> Error in x\$CP1 : \$ operator is invalid for atomic vectors
> In addition: Warning message:
> In sqrt(diag(varcov)) : NaNs produced
>
> ?Peter Maclean
> Department of Economics
> UDSM
>
>
>
> ----- Original Message ----
> From: Dennis Murphy <djmuser at gmail.com>

> Sent: Wed, June 22, 2011 11:37:02 PM
> Subject: Re: [R] BY GROUP IN GEV
>
> Hi:
>
> I think you need
>
> CP ?<- lapply(MAS, function(x){gev(x\$CP1, 100, method = "BFGS", control =
> ? ? ? ? ? ? ? ? ? ? list(maxit = 500))})
>
> See if that works out.
>
> HTH,
> Dennis
>
> On Wed, Jun 22, 2011 at 4:06 PM, Peter Maclean
>> I am trying to run gev (general extreme value) function in ?evir? package. My
>> data is divided by state. I am using the following codes but it is not
> working.
>> I will appreciate any help.
>>
>> #Split data
>> MAS <- split(MA, MA\$states)
>>
>> CP ?<- lapply(MAS, function(x){gev(MAS\$CP1, 100, method = "BFGS", control =
>> list(maxit = 500))})
>>
>> the Error message is:
>>
>> Error in tapply(data, grouping, max) : arguments must have same length
>>
>> I know there are also ?by? function,? but I could not figure it out how to
use
>> it.
>>
>> ______________________________________________
>> R-help at r-project.org mailing list
>> https://stat.ethz.ch/mailman/listinfo/r-help
>> PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
>> and provide commented, minimal, self-contained, reproducible code.
>>
>
>

------------------------------

Message: 57
Date: Wed, 29 Jun 2011 13:29:06 -0700 (PDT)

To: r-help at r-project.org
Subject: Re: [R] DROP OBSEVATION IN A GROUP
Message-ID:
<1309379346.85905.YahooMailRC at web121706.mail.ne1.yahoo.com>
Content-Type: text/plain; charset=iso-8859-1

People with more experience in R I need help on this.
I would like to drop observation if they meet certain condition. In this example
I would like to drop group 2?in "n" because the group in "Y" has more than 2
zeroes.?
#Example
n <- c(1, 1, 1, 1, 1, 1, 2, 2, 2, 2, 2, 2, 3, 3, 3, 3, 3,3)
y <- c(2,3,2,3,4,5,6,1,0,0,0,6, 2, 1, 0, 0,9,3)
z <- as.data.frame(cbind(n,y))
colnames(z) <- c("n","y")

------------------------------

Message: 58
Date: Wed, 29 Jun 2011 16:33:25 -0400
From: Duncan Murdoch <murdoch.duncan at gmail.com>

Cc: r-help at r-project.org
Subject: Re: [R] DROP OBSEVATION IN A GROUP
Message-ID: <4E0B8C15.9000600 at gmail.com>
Content-Type: text/plain; charset=ISO-8859-1; format=flowed

On 29/06/2011 4:29 PM, Peter Maclean wrote:
> People with more experience in R I need help on this.
> I would like to drop observation if they meet certain condition. In this example
> I would like to drop group 2 in "n" because the group in "Y" has more than 2
> zeroes.
> #Example
> n<- c(1, 1, 1, 1, 1, 1, 2, 2, 2, 2, 2, 2, 3, 3, 3, 3, 3,3)
> y<- c(2,3,2,3,4,5,6,1,0,0,0,6, 2, 1, 0, 0,9,3)
> z<- as.data.frame(cbind(n,y))
> colnames(z)<- c("n","y")

The general way to drop observations is to construct a logical vector to
use as an index.  Entries which are FALSE are dropped.

Doing that based on your "more than 2 zeroes" rule looks a little
tricky; I think you want to count zeros first (e.g. using by()), then
construct the TRUE/FALSE vector based on that.

Duncan Murdoch

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

------------------------------

Message: 59
Date: Wed, 29 Jun 2011 16:42:53 -0400
From: David Winsemius <dwinsemius at comcast.net>

Cc: r-help at r-project.org
Subject: Re: [R] DROP OBSErVATIONs IN A GROUP
Message-ID: <AAF3FE14-078F-4353-9B9C-87A9422A8B27 at comcast.net>
Content-Type: text/plain; charset=US-ASCII; format=flowed; delsp=yes

On Jun 29, 2011, at 4:29 PM, Peter Maclean wrote:

> People with more experience in R I need help on this.
> I would like to drop observation if they meet certain condition. In
> this example
> I would like to drop group 2 in "n" because the group in "Y" has
> more than 2
> zeroes.
> #Example
> n <- c(1, 1, 1, 1, 1, 1, 2, 2, 2, 2, 2, 2, 3, 3, 3, 3, 3,3)
> y <- c(2,3,2,3,4,5,6,1,0,0,0,6, 2, 1, 0, 0,9,3)
> z <- as.data.frame(cbind(n,y))

The strategy of cbind vectors as an argument to data.frame and then
naming them seems wasteful and error prone. Why not:

z <- data.frame(n=factor(n),y=y)
# all one step, no issues about every element needing to be the same
mode
# and not removing attributes that matrix class imposes.

The you can use ave() to return a group-computed counts of zeroes:

z> with(z, ave(y, n, FUN=function(x) sum(x==0) ) )
[1] 0 0 0 0 0 0 3 3 3 3 3 3 2 2 2 2 2 2

And us that to test for you condition for not dropping:

> z[ with(z, ave(y, n, FUN=function(x) sum(x==0) ) ) <= 2, ]
n y
1  1 2
2  1 3
3  1 2
4  1 3
5  1 4
6  1 5
13 3 2
14 3 1
15 3 0
16 3 0
17 3 9
18 3 3

> colnames(z) <- c("n","y")
>
>
> ______________________________________________
> R-help at r-project.org mailing list
> https://stat.ethz.ch/mailman/listinfo/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

------------------------------

Message: 60
Date: Wed, 29 Jun 2011 20:42:56 +0000
From: Ben Bolker <bbolker at gmail.com>
To: <r-help at stat.math.ethz.ch>
Subject: Re: [R] lmer() computational performance
Message-ID: <loom.20110629T223417-254 at post.gmane.org>
Content-Type: text/plain; charset="us-ascii"

zubin <binabina <at> bellsouth.net> writes:

>
> Hello, running a mixed model in the package LME4, lmer()
>
> Panel data, have about 322 time periods and 50 states, total data set is
> approx 15K records and about 20  explanatory variables.  Not a very
> large data set.
>
> We run random intercepts as well as random coefficients for about 10 of
> the variables, the rest come in as fixed effects.   We are running into
> a wall of time to execute these models.
>
> A sample specification of all random effects:
>
> lmer(Y ~ 1 + (x_078 + x_079 + growth_st_index  +
>             retail_st_index + Natl + econ_home_st_index +
>             econ_bankruptcy +  index2_HO  + GPND_ST  | state),
>             data = newData, doFit = TRUE)
>
> Computation time is near 15 minutes.
> System        ELAPSED        User
> 21.4            888.63        701.74
>
> Does anyone have any ideas on way's to speed up lmer(), as well any
> parallel implementations, or approaches/options to reduce computation time?
>
>

(1) these kinds of questions will probably get more informed answers
on the r-sig-mixed-models list.  Please direct follow-ups there.
(2) I'm not really sure whether this counts as "large" in the mixed/
multilevel model world.  It's certainly not very large for a
standard linear regression.  For comparison, the 'Chem97' dataset in
the mlmRev package is 31022 observations x 8 variables x 2280 blocks and
is described as "relatively large" -- so the raw data matrix is about
the same size (twice as long, half as wide) but there are many more
blocks.
(3) Fitting 10 random effects (including the intercept)
is very ambitious, it leads to the
estimation of a 10x10 correlation matrix ... I don't know whether you
know that's what you're doing, or whether you need the full correlation
matrix.  You can split it up into independent blocks (in the extreme,
10 uncorrelated random effects) by specifying the REs as separate chunks,
e.g.  (1|state) + (0+x_078|state) + (0|x_079|state) + ... (see some
of the examples in the lmer documentation).  (lme, in the nlme package,
offers more flexibility in specifying structured correlation matrices
of different types, but will in general be slower than lme4 -- but
perhaps it would be faster to fit a structured (simpler) model you're
happy with using lme than the full unstructured model using lmer)
(4) the development version of lme4, lme4a, *might* be faster (but
is less well tested/less stable).
(5) do you have alternatives?  I haven't worked with data sets this
size myself, but anecdotes on the r-sig-mixed-models list suggest that
lmer is faster than most alternatives ... ?

Ben Bolker

------------------------------

Message: 61
Date: Wed, 29 Jun 2011 20:51:12 +0000
From: Ben Bolker <bbolker at gmail.com>
To: <r-help at stat.math.ethz.ch>
Subject: Re: [R] DROP OBSErVATIONs IN A GROUP
Message-ID: <loom.20110629T225018-163 at post.gmane.org>
Content-Type: text/plain; charset="us-ascii"

David Winsemius <dwinsemius <at> comcast.net> writes:

>
> The strategy of cbind vectors as an argument to data.frame and then
> naming them seems wasteful and error prone. Why not:
>
>   z <- data.frame(n=factor(n),y=y)
> # all one step, no issues about every element needing to be the same
> mode
> # and not removing attributes that matrix class imposes.
>

And you don't actually need to name the elements if their names
will match their symbol in the call, i.e.

z <- data.frame(n=factor(n),y)

should give identical results.

------------------------------

Message: 62
Date: Wed, 29 Jun 2011 22:20:06 +0100
From: John C Frain <frainj at gmail.com>
To: Patrick Connolly <p_connolly at slingshot.co.nz>
Cc: Aditya Bhagwat <bhagwataditya at gmail.com>, r-help at r-project.org
Subject: Re: [R] Tell emacs to load new R version
Message-ID: <BANLkTi=qs+e6NzR6e4EZt1VqUko1GjfAhw at mail.gmail.com>
Content-Type: text/plain; charset=ISO-8859-1

If you are using Windows Vincent Goulet has an excellent emacs install
for windows which contains ESS, Auctex and a lot of other extras.  It
also contains well annotated configuration files which have specific
comments on how to change the version of R thqt emacs is calling.  Not
being that expert in the workings of emacs I have used his windows
configuration files to change some aspects of an Ubuntu setup.

Best Regards

John

On 29 June 2011 21:12, Patrick Connolly <p_connolly at slingshot.co.nz> wrote:
> On Wed, 29-Jun-2011 at 02:25PM +0200, Aditya Bhagwat wrote:
>
> |> Dear,
> |>
> |> How do I tell Emacs to update to the new R version I installed? It still
> |> loads the old R version. I already updated the the system path, but that
> |> didn't seem to work.
>
> Depends on information you didn't supply.
>
> |>
> |> Thanks for your help,
> |>
> |>
> |> --
> |> Aditya Bhagwat
> |>
> |> ? ? ?[[alternative HTML version deleted]]
> |>
> |> ______________________________________________
> |> R-help at r-project.org mailing list
> |> https://stat.ethz.ch/mailman/listinfo/r-help
> |> PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
> |> and provide commented, minimal, self-contained, reproducible code.
>
> --
> ~.~.~.~.~.~.~.~.~.~.~.~.~.~.~.~.~.~.~.~.~.~.~.~.~.~.~.~.~.~.~.~.~.~.~.~.
> ? ___ ? ?Patrick Connolly
> ?{~._.~} ? ? ? ? ? ? ? ? ? Great minds discuss ideas
> ?_( Y )_ ? ? ? ? ? ? ? ? Average minds discuss events
> (:_~*~_:) ? ? ? ? ? ? ? ? ?Small minds discuss people
> ?(_)-(_) ? ? ? ? ? ? ? ? ? ? ? ? ? ? ?..... Eleanor Roosevelt
>
> ~.~.~.~.~.~.~.~.~.~.~.~.~.~.~.~.~.~.~.~.~.~.~.~.~.~.~.~.~.~.~.~.~.~.~.~.
>
> ______________________________________________
> R-help at r-project.org mailing list
> https://stat.ethz.ch/mailman/listinfo/r-help
> PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
> and provide commented, minimal, self-contained, reproducible code.
>

--
John C Frain
Economics Department
Trinity College Dublin
Dublin 2
Ireland
www.tcd.ie/Economics/staff/frainj/home.html
mailto:frainj at tcd.ie
mailto:frainj at gmail.com

------------------------------

Message: 63
Date: Wed, 29 Jun 2011 22:22:46 +0100
From: John C Frain <frainj at gmail.com>
To: Patrick Connolly <p_connolly at slingshot.co.nz>
Cc: Aditya Bhagwat <bhagwataditya at gmail.com>, r-help at r-project.org
Subject: Re: [R] Tell emacs to load new R version
Message-ID: <BANLkTimBoUvY22OLUnGTPumQmwYM7N5G6A at mail.gmail.com>
Content-Type: text/plain; charset=ISO-8859-1

I forgot to include Vincent Goulet's web site in my previous email

http://vgoulet.act.ulaval.ca/en/emacs/

Best Regards

John

On 29 June 2011 21:12, Patrick Connolly <p_connolly at slingshot.co.nz> wrote:
> On Wed, 29-Jun-2011 at 02:25PM +0200, Aditya Bhagwat wrote:
>
> |> Dear,
> |>
> |> How do I tell Emacs to update to the new R version I installed? It still
> |> loads the old R version. I already updated the the system path, but that
> |> didn't seem to work.
>
> Depends on information you didn't supply.
>
> |>
> |> Thanks for your help,
> |>
> |>
> |> --
> |> Aditya Bhagwat
> |>
> |> ? ? ?[[alternative HTML version deleted]]
> |>
> |> ______________________________________________
> |> R-help at r-project.org mailing list
> |> https://stat.ethz.ch/mailman/listinfo/r-help
> |> PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
> |> and provide commented, minimal, self-contained, reproducible code.
>
> --
> ~.~.~.~.~.~.~.~.~.~.~.~.~.~.~.~.~.~.~.~.~.~.~.~.~.~.~.~.~.~.~.~.~.~.~.~.
> ? ___ ? ?Patrick Connolly
> ?{~._.~} ? ? ? ? ? ? ? ? ? Great minds discuss ideas
> ?_( Y )_ ? ? ? ? ? ? ? ? Average minds discuss events
> (:_~*~_:) ? ? ? ? ? ? ? ? ?Small minds discuss people
> ?(_)-(_) ? ? ? ? ? ? ? ? ? ? ? ? ? ? ?..... Eleanor Roosevelt
>
> ~.~.~.~.~.~.~.~.~.~.~.~.~.~.~.~.~.~.~.~.~.~.~.~.~.~.~.~.~.~.~.~.~.~.~.~.
>
> ______________________________________________
> R-help at r-project.org mailing list
> https://stat.ethz.ch/mailman/listinfo/r-help
> PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
> and provide commented, minimal, self-contained, reproducible code.
>

--
John C Frain
Economics Department
Trinity College Dublin
Dublin 2
Ireland
www.tcd.ie/Economics/staff/frainj/home.html
mailto:frainj at tcd.ie
mailto:frainj at gmail.com

------------------------------

Message: 64
Date: Wed, 29 Jun 2011 13:35:07 -0700 (PDT)
From: Lisa <lisajca at gmail.com>
To: r-help at r-project.org
Subject: Re: [R] Derivative of a function
Message-ID: <1309379707495-3633947.post at n4.nabble.com>
Content-Type: text/plain; charset=UTF-8

Yes. I need to do implicit differentiation. After rearrangement, I got

(x2 ? x1) * b = log(1 / y - 1)

Take derivative of both sides with respect to y, I have

(x2 ? x1) * b?[y] = - 1/y(1-y)

Since both (x2 ? x1) and b?[y] are vectors, I cannot move (x2 ? x1) to
RHS. This is why I posted my question here to see if there is some R
functions or some idea that can help me solve this problem. Thanks.

Lisa

--
View this message in context: http://r.789695.n4.nabble.com/Derivative-of-a-function-tp3631814p3633947.html
Sent from the R help mailing list archive at Nabble.com.

------------------------------

Message: 65
Date: Wed, 29 Jun 2011 13:47:09 -0700 (PDT)
From: xin123620 <chengxin.dai at gmail.com>
To: r-help at r-project.org
Subject: Re: [R] Error: cannot allocate vector of size
Message-ID: <1309380429567-3633983.post at n4.nabble.com>
Content-Type: text/plain; charset=us-ascii

Thank you for replying. when I've tried to run the R syntax in a 64 bit
computer,the problem is solved.  Thank you for helping out. I totally agree
I would like to answer all your questions in case other people meet the same
problem. The data contains one timestamp column with time zone, one integer
column, and 12 Boolean columns. I tried to run one month sample,
before
>memory.limit()
[1] 3583
> memory.size(max=F)
[1] 156.82
> memory.size(max=T)
[1] 241.06
After
> memory.limit()
[1] 3583
> memory.size(max=F)
[1] 199.97
> memory.size(max=T)
[1] 241.56

--
View this message in context: http://r.789695.n4.nabble.com/Error-cannot-allocate-vector-of-size-tp3629384p3633983.html
Sent from the R help mailing list archive at Nabble.com.

------------------------------

Message: 66
Date: Wed, 29 Jun 2011 17:46:46 -0300
From: "Filipe Leme Botelho" <filipe.botelho at vpar.com.br>
To: "Duncan Murdoch" <murdoch.duncan at gmail.com>,	"Peter Maclean"

Cc: r-help at r-project.org
Subject: [R] RES:  DROP OBSEVATION IN A GROUP
Message-ID:
<07E17EE73DE13B4897BC6FE325CF7A2401834CDB at BRSAOWSEXCL001.votorantim.grupo>

Content-Type: text/plain; charset="utf-8"

An embedded message was scrubbed...
From: "Filipe Leme Botelho" <filipe.botelho at vpar.com.br>
Subject: RES: [R] DROP OBSEVATION IN A GROUP
Date: Wed, 29 Jun 2011 17:46:46 -0300
Size: 3416
URL: <https://stat.ethz.ch/pipermail/r-help/attachments/20110629/1a2fe184/attachment-0001.mht>
-------------- next part --------------
"This message and its attachments may contain confidential and/or privileged information. If you are not the addressee, please, advise the sender immediately by replying to the e-mail and delete this message."

"Este mensaje y sus anexos pueden contener informaci?n confidencial o privilegiada. Si ha recibido este e-mail por error por favor b?rrelo y env?e un mensaje al remitente."

"Esta mensagem e seus anexos podem conter informa??o confidencial ou privilegiada. Caso n?o seja o destinat?rio, solicitamos a imediata notifica??o ao remetente e exclus?o da mensagem."

------------------------------

Message: 67
Date: Wed, 29 Jun 2011 12:37:04 -0700 (PDT)
From: chris20 <bop07crb at sheffield.ac.uk>
To: r-help at r-project.org
Subject: [R] centre two graphs on one plot
Message-ID: <1309376224584-3633788.post at n4.nabble.com>
Content-Type: text/plain; charset=us-ascii

Hi,

I am trying to put together a biplot using symbols and different colours
instead of text as points.

Someone has previously suggested using this code:

PC <- prcomp (iris[,1:4])
lambda <- PC\$sdev * sqrt(nrow(PC\$x))
plot (t(t(PC\$x)/lambda),pch=16,col=as.numeric(iris[,5]))
par (new=T)
Rot <- t(t(PC\$rotation)*lambda)
XLIM <- c(-max(abs(Rot[,1])),max(abs(Rot[,1])))
XLIM <- XLIM+(XLIM*0.7)
plot(Rot,col=4,axes=FALSE,xlim=XLIM,ylim=XLIM,pch="")
arrows
(rep(0,nrow(PC\$rotation)),rep(0,nrow(PC\$rotation)),Rot[,1],Rot[,2],col=4)
text (Rot[,1:2],rownames(Rot),col=6)
axis (3)
axis (4)

But the origin of the arrows does not line up with the origin of the points.
Can anyone suggest how you would get the two graphs to line up?  I think you
have to set a ratio between the two sets of axes so that the origin is in
the centre but I don't know how to do it.

Thanks
Chris

--
View this message in context: http://r.789695.n4.nabble.com/centre-two-graphs-on-one-plot-tp3633788p3633788.html
Sent from the R help mailing list archive at Nabble.com.

------------------------------

Message: 68
Date: Wed, 29 Jun 2011 14:28:05 -0700 (PDT)
From: ahrager <ahrager at gmail.com>
To: r-help at r-project.org
Subject: [R] very large pair() plot
Message-ID: <1309382885395-3634075.post at n4.nabble.com>
Content-Type: text/plain; charset=us-ascii

Hi everyone,

I'm a newbie and this is my first post.

My boss wants me to make a series of scatter plots where 76 variables are
plotted against each other.  I know how to do this using pair()...my problem
is that there are just too many plots to fit in the window.

Is there any way I can get all the plots to fit and make the font size and
marker size scale so it is readable? My goal is to create a *.pdf file that
I can send to our large plotter.

Thank you,
Audrey Rager

--
View this message in context: http://r.789695.n4.nabble.com/very-large-pair-plot-tp3634075p3634075.html
Sent from the R help mailing list archive at Nabble.com.

------------------------------

Message: 69
Date: Wed, 29 Jun 2011 22:43:08 +0200
From: Trying To learn again <tryingtolearnagain at gmail.com>
To: r-help at r-project.org
Subject: [R] Executing a script "hand-made" and time
Message-ID: <BANLkTi=WJjRrKDWrPPLpn4PrMoOEd6cv=Q at mail.gmail.com>
Content-Type: text/plain

Hi all,

I have a function written by me that read a  matrix (data frame) from a txt
with 4 million of rows and 13 columns.

The think is my function works with an input matrix of 100x13 and now I
tried to execute my function with the big "input file" and it is running
form the moment two hours...

There is a way to know (how much time could it cost?)

The second question is...

I want to buy a new computer...to threat files like this (and make on the
if....for....loops and so on)... I need a computer with high RAM or to
"speed" this executing time I need other "technical hardware items"....

I´m sure my programmation can be simplied but anyway I hope someone can give
me his/her opinion.

Many Thaks in advance.

[[alternative HTML version deleted]]

------------------------------

Message: 70
Date: Wed, 29 Jun 2011 13:56:08 -0700 (PDT)
From: katarv <katiasmirn at gmail.com>
To: r-help at r-project.org
Subject: Re: [R] 4D data acsess
Message-ID: <1309380968421-3634004.post at n4.nabble.com>
Content-Type: text/plain; charset=us-ascii

Hi Sarah,

I use readMat function, from R.matlab function.

str(X) tells that

X : num [1:64, 1:64, 1:21, 1:300]  as I said, the first 3 columns are x,y,z
coordinates. And I need all values in the last column correcponding to a
given (x,y,z) coordinate.

if you list the values of X, then they are non zero, but for some reason R
tells that dim(X): NULL

--
View this message in context: http://r.789695.n4.nabble.com/4D-data-acsess-tp3633552p3634004.html
Sent from the R help mailing list archive at Nabble.com.

------------------------------

Message: 71
Date: Wed, 29 Jun 2011 17:04:11 -0300
From: Breno Fragomeni <brenof at gmail.com>
To: r-help at r-project.org
Subject: [R] Fwd: help
Message-ID: <BANLkTi=Yk7CJcFyw_exN02mFRW1u_2oTEg at mail.gmail.com>
Content-Type: text/plain

Hi
I have imported some files to a list, called "importa".
There are 43 files (importa[1], importa[2], ..., importa[43]). Now, I'm
trying to create a new table in "r". Each table will got the data from the
importa partition. Like file1<-importa[1].
I tried two ways:
c<-list()
for (i in 1:43) {
c[i]=paste("prova",a[i],sep="")}
i <- 1
for (j in c)
{
j<-importa[i]
i <- i + 1
}
In this one, the program created only one table, called "j" with the data of
the importa[43].

The second trial:
c<-list()
for (i in 1:43) {
c[i]=paste("prova",a[i],sep="")}

i <- 1
a<-list()
for (j in c)
{
a[j]<-importa[i]
i <- i + 1
}
In this one the program created another list, with the subdivisions just
like the "importa".

Anyone knows what I got to do?
Thank you very much

--
Breno Fragomeni
Mestrando em Genética e Melhoramento Animal - Escola de Veterinária - UFMG
Genetics and Animal Breeding Master's Degree Student - UFMG

[[alternative HTML version deleted]]

------------------------------

Message: 72
Date: Wed, 29 Jun 2011 18:02:14 -0400
From: David Winsemius <dwinsemius at comcast.net>
To: katarv <katiasmirn at gmail.com>
Cc: r-help at r-project.org
Subject: Re: [R] 4D data acsess
Message-ID: <EDCE27E8-D873-42C0-8A49-8CE368082378 at comcast.net>
Content-Type: text/plain; charset=US-ASCII; format=flowed; delsp=yes

On Jun 29, 2011, at 4:56 PM, katarv wrote:

> Hi Sarah,
>
> I use readMat function, from R.matlab function.
>
> str(X) tells that
>
> X : num [1:64, 1:64, 1:21, 1:300]  as I said, the first 3 columns
> are x,y,z
> coordinates. And I need all values in the last column correcponding
> to a
> given (x,y,z) coordinate.

You should be able to access those values with:

X[1,1,1, ]

or equivalently:

X[1,1,1,1:300]

>
> if you list the values of X,

> then they are non zero, but for some reason R
> tells that dim(X): NULL

Now that seems a bit odd. What happens if you try:

Y <- X
dim(Y) <- c(64,64,21,300)
Y[ 1, 1, 1, ]

>
> --
> View this message in context: http://r.789695.n4.nabble.com/4D-data-acsess-tp3633552p3634004.html
> Sent from the R help mailing list archive at Nabble.com.
>
> ______________________________________________
> R-help at r-project.org mailing list
> https://stat.ethz.ch/mailman/listinfo/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

------------------------------

Message: 73
Date: Thu, 30 Jun 2011 08:00:20 +1000 (EST)
From: "David Duffy" <davidD at qimr.edu.au>
To: <r-help at r-project.org>
Cc: Jim Silverton <jim.silverton at gmail.com>
Subject: Re: [R] Hardy Weinberg Simulation
Message-ID: <Pine.LNX.4.64.1106300750400.27787 at orpheus.qimr.edu.au>
Content-Type: TEXT/PLAIN;	format=flowed;	charset="US-ASCII"

>
> I have the code below but the p-values are not what I am expecting. I want
> to use the Cochran Armitage trend test to get the p-values.

What do you expect? Depending on the genetic model, you may not see HWE in the
"cases".

> datamat[h,] <- t(rmultinom(1, size=c(10, 40, 50), prob=c(0.33, 0.33, 0.34)))

"size" should be the total size ie 100.

--
| David Duffy (MBBS PhD)                                         ,-_|\
| email: davidD at qimr.edu.au  ph: INT+61+7+3362-0217 fax: -0101  /     *
| Epidemiology Unit, Queensland Institute of Medical Research   \_,-._/
| 300 Herston Rd, Brisbane, Queensland 4029, Australia  GPG 4D0B994A v

------------------------------

Message: 74
Date: Thu, 30 Jun 2011 10:08:24 +1100
From: Philip Rhoades <phil at pricom.com.au>
To: R help <r-help at stat.math.ethz.ch>
Subject: [R] Converting large JSON data into multidimensional array
Message-ID: <edaab3975c932cf1a6d7cd0a4c0b811d at www.pricom.com.au>
Content-Type: text/plain; charset="UTF-8"; format=flowed

People,

I have output from a Ruby script saved in JSON format and I can import
it into an R vector (list?) that looks like:

> tst
[[1]]
[[1]][[1]]
[1] "01.01.01.00"

[[1]][[2]]
[1] -2.304248

[[2]]
[[2]][[1]]
[1] "01.01.01.01"

[[2]][[2]]
[1] -2.288097

[[3]]
[[3]][[1]]
[1] "01.01.01.02"

[[3]][[2]]
[1] -2.303347

[[4]]
[[4]][[1]]
[1] "01.01.01.03"

[[4]][[2]]
[1] -2.354964

.
.

I would like to convert the data into a:

50.32.20.22 array

and be able to do calculations on the array like:

mean( tst[ 50,,20,00 ] )

etc

Suggestions appreciated.

Thanks,

Phil.

--

GPO Box 3411
Sydney NSW    2001
Australia
E-mail:  phil at pricom.com.au

------------------------------

Message: 75
Date: Wed, 29 Jun 2011 19:51:33 -0400
From: jim holtman <jholtman at gmail.com>
To: Trying To learn again <tryingtolearnagain at gmail.com>
Cc: r-help at r-project.org
Subject: Re: [R] Executing a script "hand-made" and time
Message-ID: <BANLkTimk3uO+obVq71b13dCNio3dvvfD6A at mail.gmail.com>
Content-Type: text/plain; charset=ISO-8859-1

What type of computer do you have now: operating system, memory.

Here is how long it took for me to read in a file with 4M lines and 13
columns of numerics on each line:

> system.time(x <- scan('/temp/large.txt', what = 0))
user  system elapsed
23.67    0.67   24.39
> str(x)
num [1:52614432] 1 1 1 1 1 1 1 1 1 1 ...
>
> object.size(x)
420915496 bytes

So how are you reading it in?  Is your system paging?  It should not
take 2 hours.

On Wed, Jun 29, 2011 at 4:43 PM, Trying To learn again
<tryingtolearnagain at gmail.com> wrote:
> Hi all,
>
> I have a function written by me that read a ?matrix (data frame) from a txt
> with 4 million of rows and 13 columns.
>
> The think is my function works with an input matrix of 100x13 and now I
> tried to execute my function with the big "input file" and it is running
> form the moment two hours...
>
> There is a way to know (how much time could it cost?)
>
> The second question is...
>
> I want to buy a new computer...to threat files like this (and make on the
> if....for....loops and so on)... I need a computer with high RAM or to
> "speed" this executing time I need other "technical hardware items"....
>
> I?m sure my programmation can be simplied but anyway I hope someone can give
> me his/her opinion.
>
> Many Thaks in advance.
>
> ? ? ? ?[[alternative HTML version deleted]]
>
>
> ______________________________________________
> R-help at r-project.org mailing list
> https://stat.ethz.ch/mailman/listinfo/r-help
> PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
> and provide commented, minimal, self-contained, reproducible code.
>
>

--
Jim Holtman
Data Munger Guru

What is the problem that you are trying to solve?

------------------------------

Message: 76
Date: Wed, 29 Jun 2011 17:14:29 -0700
From: Dennis Murphy <djmuser at gmail.com>
To: nejc bergant <nbergant at gmail.com>
Cc: r-help at r-project.org
Subject: Re: [R] R package Forecast
Message-ID: <BANLkTikFuAkBj9ViMzVzryGFaBwZFNeEtA at mail.gmail.com>
Content-Type: text/plain; charset=ISO-8859-1

Hi:

Your object b is a 5 x 12 matrix. The error message says that ets() is
expecting a univariate time series as its first argument.
Try something like

d <- ts(a[, 3], start = c(2005, 1), frequency = 12)
fit <- ets(d)

and see if that works. Untested since no reproducible example was provided.

HTH,
Dennis

On Wed, Jun 29, 2011 at 6:15 AM, nejc bergant <nbergant at gmail.com> wrote:
> Hello all
>
> First of all I must emphasize that I am fascinated about Forecast package.
> However I have difficulty to execute 'ets' procedure. After I write code:
>
> b<-matrix(a[,3], nrow=5, ncol=12,
> dimnames=list(c("2005","2006","2007","2008","2009"),
> c("jan","feb","mar","apr","may","jun","jul","aug","sep","oct","nov","dec")
> ))
> fit<-ets(b)
> plot(forecast(fit))
>
> I get this error note: *'Error in ets(b) : y should be a univariate time
> series'*.
>
> Could you please be so kind as to let me know what could be the problem.
> File 'Test.txt' is database which includes three variables: year, month and
> dependent variable.
>
> I am looking forward to hearing from you.
>
> Kind regards, Nejc.
>
> ? ? ? ?[[alternative HTML version deleted]]
>
> ______________________________________________
> R-help at r-project.org mailing list
> https://stat.ethz.ch/mailman/listinfo/r-help
> PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
> and provide commented, minimal, self-contained, reproducible code.
>

------------------------------

Message: 77
Date: Wed, 29 Jun 2011 17:24:55 -0700
From: Sam Albers <tonightsthenight at gmail.com>
To: r-help at r-project.org
Subject: [R] Italicized greek symbols in PDF plots
Message-ID: <BANLkTinC0F=CDq21AYnVtS+xN_vf17UL+w at mail.gmail.com>
Content-Type: text/plain

I know that this has been asked before in other variations but I just can't
seem to figure out my particular application from previous posts. My
apologies if I have missed the answer to this question somewhere in the
archives. I have indeed looked.

I am running Ubuntu 11.04, with R 2.12.1 and ESS+Emacs.

For journal formatting requirements, I need to italicize all the greek
letters in any plot. This is reasonably straight forward to do and I
accomplished this task like so:

library(ggplot2)

label_parseall <- function(variable, value) {
plyr::llply(value, function(x) parse(text = paste(x)))
}

dat <- data.frame(x = runif(270, 0, 125), z = rep(LETTERS[1:3], each = 3),
yy = 1:9, stringsAsFactors = TRUE)
#unicode italicized delta
dat\$gltr =
factor(c("italic(\u03b4)^14*N","italic(\u03b4)^15*N","italic(\u03b4)^13*C"))

#So this is what I want my plot to look like:
plt <- ggplot(data = dat, aes(x = yy, y = x)) +
geom_point(aes(x= yy, y=x, shape=z, group=z), alpha=0.4,position =
position_dodge(width = 0.8)) +
facet_grid(gltr~.,labeller= label_parseall, scales="free_y")
plt

#So then I exported my plot as a PDF like so:
pdf("Times_regular.pdf", family='Times')
plt
dev.off()
#The problem with this was that the delta symbols turned into dots.

#I solved this problem using Cairo
library(Cairo)
cairo_pdf("Cairo.pdf")
plt
dev.off()

The problem that I face now is that I am unsure how to output a figure that
maintains the greek symbols but outputs everything in the plot as TImes New
Roman, another requirement of the journal. So I can produce a Times New
Roman PDF plot and an italicize greek symbol unicode PDF plot but not both.
Does anoyone have any idea how I might accomplish both of these things
together in a single PDF?

Thanks so much in advance,

Sam

[[alternative HTML version deleted]]

------------------------------

Message: 78
Date: Wed, 29 Jun 2011 18:13:18 -0700
From: Dennis Murphy <djmuser at gmail.com>
To: Breno Fragomeni <brenof at gmail.com>
Cc: r-help at r-project.org
Subject: Re: [R] Fwd: help
Message-ID: <BANLkTinjgPVRP38c+7xFeu4sZWnq7Kt0Vw at mail.gmail.com>
Content-Type: text/plain; charset=ISO-8859-1

Hi:

It's not at all clear to me what you want to do. Is each component of
your list a data frame with the same structure? Are you trying to
combine them into one data frame? If so, then try

mydata <- do.call(rbind, c)

where c is the name of the list. (Not a good choice of name, by the
way - c() is a very common function in R and it's not wise to assign
another object to that name.)

If you want to do something else, perhaps you could clarify your
intentions for the list.

HTH,
Dennis

On Wed, Jun 29, 2011 at 1:04 PM, Breno Fragomeni <brenof at gmail.com> wrote:
> Hi
> I have imported some files to a list, called "importa".
> There are 43 files (importa[1], importa[2], ..., importa[43]). Now, I'm
> trying to create a new table in "r". Each table will got the data from the
> importa partition. Like file1<-importa[1].
> I tried two ways:
> c<-list()
> for (i in 1:43) {
> c[i]=paste("prova",a[i],sep="")}
> i <- 1
> for (j in c)
> {
> j<-importa[i]
> i <- i + 1
> }
> In this one, the program created only one table, called "j" with the data of
> the importa[43].
>
> The second trial:
> c<-list()
> for (i in 1:43) {
> c[i]=paste("prova",a[i],sep="")}
>
> i <- 1
> a<-list()
> for (j in c)
> {
> a[j]<-importa[i]
> i <- i + 1
> }
> In this one the program created another list, with the subdivisions just
> like the "importa".
>
> Anyone knows what I got to do?
> Thank you very much
>
> --
> Breno Fragomeni
> Mestrando em Gen?tica e Melhoramento Animal - Escola de Veterin?ria - UFMG
> Genetics and Animal Breeding Master's Degree Student - UFMG
>
> ? ? ? ?[[alternative HTML version deleted]]
>
>
> ______________________________________________
> R-help at r-project.org mailing list
> https://stat.ethz.ch/mailman/listinfo/r-help
> PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
> and provide commented, minimal, self-contained, reproducible code.
>
>

------------------------------

Message: 79
Date: Wed, 29 Jun 2011 18:14:05 -0700 (PDT)

To: "r-help at r-project.org" <r-help at r-project.org>
Subject: [R] volcano plot.r
Message-ID:
<1309396445.53106.YahooMailNeo at web46310.mail.sp1.yahoo.com>
Content-Type: text/plain

Hello.
My name is Akashah. i work at metabolic laboratory. From my study, i found that volcano plot can help a lot in my section.
i already studied about the volcano plot and get the coding to run in R software, unfortunately, there is may be something wrong with the coding. This is because  no graph appear, but no error (blue color text) was shown on the R console. Below is the coding for volcano plot, i hope anybody can help me to solve the problem.

#    volcano_plot.r
#
#    Author:    Amsha Nahid, Jairus Bowne, Gerard Murray
#    Purpose:    Produces a volcano plot
#
#    Input:    Data matrix as specified in Data-matrix-format.pdf
#    Output:    Plots log2(fold change) vs log10(t-test P-value)
#
#    Notes:    Group value for control must be alphanumerically first
#              Script will return an error if there are more than 2 groups

#
#    Load the data matrix
#
# Read in the .csv file
# Get groups information
groups<-data[,1]
# Get levels for groups
grp_levs<-levels(groups)
if (length(levels(groups)) > 2)
print("Number of groups is greater than 2!") else {

#
#    Split the matrix by group
#
new_mats<-c()
for (ii in 1:length(grp_levs))
new_mats[ii]<-list(data[which(groups==levels(groups)[ii]),])

#
#    Calculate the means
#
# For each matrix, calculate the averages per column
submeans<-c()
# Preallocate a matrix for the means
means<-matrix(
nrow = 2,
ncol = length(colnames(data[,-1])),
dimnames = list(grp_levs,colnames(data[,-1]))
)
# Calculate the means for each variable per sample
for (ii in 1:length(new_mats))
{submeans[ii]<-list(apply(new_mats[[ii]][,-1],2,mean,na.rm=TRUE))
means[ii,]<-submeans[[ii]]}

#
#    Calculate the fold change
#
folds<-matrix(
nrow=length(means[,1]),
ncol=length(means[1,]),
dimnames=list(rownames(means),colnames(means))
)
for (ii in 1:length(means[,1]))
for (jj in 1:length(means[1,]))
folds[ii,jj]<-means[ii,jj]/means[1,jj]

#
#    t-test P value data
#
pvals<-matrix(nrow=ncol(data[,-1]),ncol=1,dimnames=list(colnames(data[-1]),"P-Value"))

#
#    Perform the t-Test
#
for(ii in 1:nrow(pvals)) {
pvals[ii,1]<-t.test(new_mats[[1]][,ii+1],new_mats[[2]][,ii+1])\$p.value
}

m<-length(pvals)
x_range<-range(c(
min(
range(log2(folds[2,])),
range(c(-1.5,1.5))
),
max(
range(log2(folds[2,])),
range(c(-1.5,1.5))
)
))
y_range<-range(c(
min(range(-log10(pvals)),
range(c(0,2))
),
max(range(-log10(pvals)),
range(c(0,2))
)
))

#
#    Plot data
#
# Define a function, since it's rather involved
volcano_plot<-function(fold, pval)
{plot(x_range,                                 # x-dim
y_range,                                   # y-dim
type="n",                                  # empty plot
xlab="log2 Fold Change",                   # x-axis title
ylab="-log10 t-Test P-value",              # y-axis title
main="Volcano Plot",                       # plot title
)
abline(h=-log10(0.05),col="green",lty="44")# horizontal line at P=0.05
abline(v=c(-1,1),col="violet",lty="1343")  # vertical lines at 2-fold
# Plot points based on their values:
for (ii in 1:m)
# If it's below 0.05, we're not overly interested: purple.
if (-log10(pvals[ii])>(-log10(0.05))) {
# Otherwise, more checks;
# if it's greater than 2-fold decrease: blue
if (log2(folds[2,][ii])>(-1)) {
# If it's significant but didn't change much: orange
if (log2(folds[2,][ii])<1) {
points(
log2(folds[2,][ii]),
-log10(pvals[ii]),
col="orange",
pch=20
)
# Otherwise, greater than 2-fold increase: red
} else {
points(
log2(folds[2,][ii]),
-log10(pvals[ii]),
col="red",
pch=20
)
}
} else {
points(
log2(folds[2,][ii]),
-log10(pvals[ii]),
col="blue",
pch=20
)
}
} else {
points(
log2(folds[2,][ii]),
-log10(pvals[ii]),
col="purple",
pch=20
)
}
}
# Plot onscreen via function
x11()
volcano_plot(folds,pvals)

# Return table to analyse results

#
#    Generate figures as image files
#
#    (Uncomment blocks as necessary)

##### jpeg #####
# pic_jpg<-function(filename, fold, pval)
#     {# Start jpeg device with basic settings
#     jpeg(filename,
#         quality=100,                           # image quality (percent)
#         bg="white",                            # background colour
#         res=300,                               # image resolution (dpi)
#         units="in", width=8.3, height=5.8)     # image dimensions (inches)
#     par(mgp=c(5,2,0),                          # axis margins
#                                                # (title, labels, line)
#         mar=c(6,6,4,2),                        # plot margins (b,l,t,r)
#         las=1                                  # horizontal labels
#         )
#     # Draw the plot
#     volcano_plot(folds, pvals)
#     dev.off()
#     }
# pic_jpg("volcano_plot.jpg")
##### end jpeg #####

#### png #####
# pic_png<-function(filename, fold, pval)
#     {# Start png device with basic settings
#     png(filename,
#         bg="white",                            # background colour
#         res=300,                               # image resolution (dpi)
#         units="in", width=8.3, height=5.8)     # image dimensions (inches)
#     par(mgp=c(5,2,0),                          # axis margins
#                                                # (title, labels, line)
#         mar=c(6,6,4,2),                        # plot margins (b,l,t,r)
#         las=1                                  # horizontal labels
#         )
#     # Draw the plot
#     volcano_plot(folds, pvals)
#     dev.off()
#     }
# pic_png("volcano_plot.png")
#### end png #####

# #### tiff #####
# pic_tiff<-function(filename, fold, pval)
#     {# Start tiff device with basic settings
#     tiff(filename,
#         bg="white",                            # background colour
#         res=300,                               # image resolution (dpi)
#         units="in", width=8.3, height=5.8)     # image dimensions (inches)
#         compression="none"                     # image compression
#                                                #  (one of none, lzw, zip)
#     par(mgp=c(5,2,0),                          # axis margins
#                                                # (title, labels, line)
#         mar=c(6,6,4,2),                        # plot margins (b,l,t,r)
#         las=1                                  # horizontal labels
#         )
#     # Draw the plot
#     volcano_plot(folds, pvals)
#     dev.off()
#     }
# pic_tiff("volcano_plot.tif")
# #### end tiff #####

#
#    Legacy code which allows for blue/red to be independent of 0.05
#    (purple is limited to the middle lower region)
#
#####
#     for (ii in 1:m)
#         if (log2(folds[2,][ii])<1) {
#             if (log2(folds[2,][ii])>-1) {
#                 if (-log10(pvals[ii])<(-log10(0.05))) {
#                     points(
#                         log2(folds[2,][ii]),
#                         -log10(pvals[ii]),
#                         col="purple",
#                         pch=20
#                         )
#                     } else {
#                         points(
#                             log2(folds[2,][ii]),
#                             -log10(pvals[ii]),
#                             col="orange",
#                             pch=20
#                             )
#                     }
#                 } else {
#                     points(
#                         log2(folds[2,][ii]),
#                         -log10(pvals[ii]),
#                         col="blue",
#                         pch=20
#                         )
#                     }
#             } else {
#                 points(
#                     log2(folds[2,][ii]),
#                     -log10(pvals[ii]),
#                     col="red",
#                     pch=20
#                     )
#             }

# If function from above needs to be closed
}
[[alternative HTML version deleted]]

------------------------------

Message: 80
Date: Wed, 29 Jun 2011 21:42:30 -0400
From: Gabor Grothendieck <ggrothendieck at gmail.com>
To: Lisa <lisajca at gmail.com>
Cc: r-help at r-project.org
Subject: Re: [R] Derivative of a function
Message-ID: <BANLkTimPPK+Sj24Bfm45V_0zuwLu1CUPOQ at mail.gmail.com>
Content-Type: text/plain; charset=windows-1252

On Wed, Jun 29, 2011 at 4:35 PM, Lisa <lisajca at gmail.com> wrote:
> Yes. I need to do implicit differentiation. After rearrangement, I got
>
> (x2 ? x1) * b = log(1 / y - 1)
>
> Take derivative of both sides with respect to y, I have
>
> (x2 ? x1) * b?[y] = - 1/y(1-y)
>
> Since both (x2 ? x1) and b?[y] are vectors, I cannot move (x2 ? x1) to
> RHS. This is why I posted my question here to see if there is some R
> functions or some idea that can help me solve this problem. Thanks.
>

I am not sure if this counts as an approach that you are trying to exclude but:

db[i]/dy = { dlogit(y)/dy } / { dlogit(y)/db[i] } = { 1/{y(1-y)} / {
x1[i] - x2[i] }

The numerator is taken from your calculation and the denominator is
from linearity.

--
Statistics & Software Consulting
GKX Group, GKX Associates Inc.
tel: 1-877-GKX-GROUP
email: ggrothendieck at gmail.com

------------------------------

Message: 81
Date: Wed, 29 Jun 2011 19:42:33 -0700 (PDT)

To: "r-help at r-project.org" <r-help at r-project.org>
Subject: [R] Fw: volcano plot.r
Message-ID:
<1309401753.77283.YahooMailNeo at web46304.mail.sp1.yahoo.com>
Content-Type: text/plain

----- Forwarded Message -----

To: "r-help at r-project.org" <r-help at r-project.org>
Sent: Thursday, June 30, 2011 9:14 AM
Subject: volcano plot.r

Hello.
My name is Akashah. i work at metabolic laboratory. From my study, i found that volcano plot can help a lot in my section.
i already studied about the volcano plot and get the coding to run in R software, unfortunately, there is may be something wrong with the coding. This is because  no graph appear, but no error (blue color text) was shown on the R console. Below is the coding for volcano plot, i hope anybody can help me to solve the problem.

#    volcano_plot.r
#
#    Author:    Amsha Nahid, Jairus Bowne, Gerard Murray
#    Purpose:    Produces a volcano plot
#
#    Input:    Data matrix as specified in Data-matrix-format.pdf
#    Output:    Plots log2(fold change) vs log10(t-test P-value)
#
#    Notes:    Group value for control must be alphanumerically first
#              Script will return an error if there are more than 2 groups

#
#    Load the data matrix
#
# Read in the .csv file
# Get groups information
groups<-data[,1]
# Get levels for groups
grp_levs<-levels(groups)
if (length(levels(groups)) > 2)
print("Number of groups is greater than 2!") else {

#
#    Split the matrix by group
#
new_mats<-c()
for (ii in 1:length(grp_levs))
new_mats[ii]<-list(data[which(groups==levels(groups)[ii]),])

#
#    Calculate the means
#
# For each matrix, calculate the averages per column
submeans<-c()
# Preallocate a matrix for the means
means<-matrix(
nrow = 2,
ncol = length(colnames(data[,-1])),
dimnames = list(grp_levs,colnames(data[,-1]))
)
# Calculate the means for each variable per sample
for (ii in 1:length(new_mats))
{submeans[ii]<-list(apply(new_mats[[ii]][,-1],2,mean,na.rm=TRUE))
means[ii,]<-submeans[[ii]]}

#
#    Calculate the fold change
#
folds<-matrix(
nrow=length(means[,1]),
ncol=length(means[1,]),
dimnames=list(rownames(means),colnames(means))
)
for (ii in 1:length(means[,1]))
for (jj in 1:length(means[1,]))
folds[ii,jj]<-means[ii,jj]/means[1,jj]

#
#    t-test P value data
#
pvals<-matrix(nrow=ncol(data[,-1]),ncol=1,dimnames=list(colnames(data[-1]),"P-Value"))

#
#    Perform the t-Test
#
for(ii in 1:nrow(pvals)) {
pvals[ii,1]<-t.test(new_mats[[1]][,ii+1],new_mats[[2]][,ii+1])\$p.value
}

m<-length(pvals)
x_range<-range(c(
min(
range(log2(folds[2,])),
range(c(-1.5,1.5))
),
max(
range(log2(folds[2,])),
range(c(-1.5,1.5))
)
))
y_range<-range(c(
min(range(-log10(pvals)),
range(c(0,2))
),
max(range(-log10(pvals)),
range(c(0,2))
)
))

#
#    Plot data
#
# Define a function, since it's rather involved
volcano_plot<-function(fold, pval)
{plot(x_range,                                 # x-dim
y_range,                                   # y-dim
type="n",                                  # empty plot
xlab="log2 Fold Change",                   # x-axis title
ylab="-log10 t-Test P-value",              # y-axis title
main="Volcano Plot",                       # plot title
)
abline(h=-log10(0.05),col="green",lty="44")# horizontal line at P=0.05
abline(v=c(-1,1),col="violet",lty="1343")  # vertical lines at 2-fold
# Plot points based on their values:
for (ii in 1:m)
# If it's below 0.05, we're not overly interested: purple.
if (-log10(pvals[ii])>(-log10(0.05))) {
# Otherwise, more checks;
# if it's greater than 2-fold decrease: blue
if (log2(folds[2,][ii])>(-1)) {
# If it's significant but didn't change much: orange
if (log2(folds[2,][ii])<1) {
points(
log2(folds[2,][ii]),
-log10(pvals[ii]),
col="orange",
pch=20
)
# Otherwise, greater than 2-fold increase: red
} else {
points(
log2(folds[2,][ii]),
-log10(pvals[ii]),
col="red",
pch=20
)
}
} else {
points(
log2(folds[2,][ii]),
-log10(pvals[ii]),
col="blue",
pch=20
)
}
} else {
points(
log2(folds[2,][ii]),
-log10(pvals[ii]),
col="purple",
pch=20
)
}
}
# Plot onscreen via function
x11()
volcano_plot(folds,pvals)

# Return table to analyse results

#
#    Generate figures as image files
#
#    (Uncomment blocks as necessary)

##### jpeg #####
# pic_jpg<-function(filename, fold, pval)
#     {# Start jpeg device with basic settings
#     jpeg(filename,
#         quality=100,                           # image quality (percent)
#         bg="white",                            # background colour
#         res=300,                               # image resolution (dpi)
#         units="in", width=8.3, height=5.8)     # image dimensions (inches)
#     par(mgp=c(5,2,0),                          # axis margins
#                                                # (title, labels, line)
#         mar=c(6,6,4,2),                        # plot margins (b,l,t,r)
#         las=1                                  # horizontal labels
#         )
#     # Draw the plot
#     volcano_plot(folds, pvals)
#     dev.off()
#     }
# pic_jpg("volcano_plot.jpg")
##### end jpeg #####

#### png #####
# pic_png<-function(filename, fold, pval)
#     {# Start png device with basic settings
#     png(filename,
#         bg="white",                            # background colour
#         res=300,                               # image resolution (dpi)
#         units="in", width=8.3, height=5.8)     # image dimensions (inches)
#     par(mgp=c(5,2,0),                          # axis margins
#                                                # (title, labels, line)
#         mar=c(6,6,4,2),                        # plot margins (b,l,t,r)
#         las=1                                  # horizontal labels
#         )
#     # Draw the plot
#     volcano_plot(folds, pvals)
#     dev.off()
#     }
# pic_png("volcano_plot.png")
#### end png #####

# #### tiff #####
# pic_tiff<-function(filename, fold, pval)
#     {# Start tiff device with basic settings
#     tiff(filename,
#         bg="white",                            # background colour
#         res=300,                               # image resolution (dpi)
#         units="in", width=8.3, height=5.8)     # image dimensions (inches)
#         compression="none"                     # image compression
#                                                #  (one of none, lzw, zip)
#     par(mgp=c(5,2,0),                          # axis margins
#                                                # (title, labels, line)
#         mar=c(6,6,4,2),                        # plot margins (b,l,t,r)
#         las=1                                  # horizontal labels
#         )
#     # Draw the plot
#     volcano_plot(folds, pvals)
#     dev.off()
#     }
# pic_tiff("volcano_plot.tif")
# #### end tiff #####

#
#    Legacy code which allows for blue/red to be independent of 0.05
#    (purple is limited to the middle lower region)
#
#####
#     for (ii in 1:m)
#         if (log2(folds[2,][ii])<1) {
#             if (log2(folds[2,][ii])>-1) {
#                 if (-log10(pvals[ii])<(-log10(0.05))) {
#                     points(
#                         log2(folds[2,][ii]),
#                         -log10(pvals[ii]),
#                         col="purple",
#                         pch=20
#                         )
#                     } else {
#                         points(
#                             log2(folds[2,][ii]),
#                             -log10(pvals[ii]),
#                             col="orange",
#                             pch=20
#                             )
#                     }
#                 } else {
#                     points(
#                         log2(folds[2,][ii]),
#                         -log10(pvals[ii]),
#                         col="blue",
#                         pch=20
#                         )
#                     }
#             } else {
#                 points(
#                     log2(folds[2,][ii]),
#                     -log10(pvals[ii]),
#                     col="red",
#                     pch=20
#                     )
#             }

# If function from above needs to be closed
}
[[alternative HTML version deleted]]

------------------------------

Message: 82
Date: Wed, 29 Jun 2011 14:38:32 -0700
From: Edgar Alminar <eaalminar at ucsd.edu>
To: r-help at r-project.org
Subject: [R] Sum Question
Message-ID: <C3B8C5EE-975E-4A83-9966-9C41F5A827F9 at ucsd.edu>
Content-Type: text/plain; charset=us-ascii

Hello,
I have the following dataset (this is a piece of a much larger set):

RID      SCRNO VISCODE RECNO CONTTIME
23    18 HBA0190012      bl     1        5
24    18 HBA0190012      bl     3        5
28    18 HBA0190012      bl     5        5
29    18 HBA0190012      bl     2        5
32    18 HBA0190012      bl     4        5
38    19 HBA0190013      bl     2       35
50    19 HBA0190013      bl     1        5
57    20 HBA0190014      bl     1       10
61    21 HBA0200015      bl     2       30
64    21 HBA0200015      bl     3       90
67    21 HBA0200015      bl     4       90
72    21 HBA0200015      bl     8        2
76    21 HBA0200015      bl     1       60
88    22 HBA0190016      bl     1       25
97    23 HBA0190017      bl     3       85
99    23 HBA0190017      bl     1        5
103   23 HBA0190017      bl     2        5
122   25 HBA0190019      bl     1       20
145   26 HBA0200020      bl     1       60
170   27 HBA0190021      bl     1        3
190   28 HBA0220022      bl     1       40
194   29 HBA0220023      bl     1       25
223   29 HBA0220023      bl     2       25

And I would like to output a list of the sums of CONTTIME for each SCRNO. What is the best way to do that? Any help would be greatly appreciated.

Thanks!
Edgar

------------------------------

Message: 83
Date: Wed, 29 Jun 2011 22:42:18 +0100
From: S Ellison <Stephen.Ellison at lgcgroup.com>
To: Lisa <lisajca at gmail.com>, "r-help at r-project.org"
<r-help at r-project.org>
Subject: Re: [R] Derivative of a function
Message-ID:
<98B156BB22D11342A931E823798D434853E9718198 at GOLD.corp.lgc-group.com>
Content-Type: text/plain; charset="Windows-1252"

If you just want the value of the derivative at a particular point, would numerical derivatives suffice? If so, try (for example) the numDeriv package.

S
________________________________________
From: r-help-bounces at r-project.org [r-help-bounces at r-project.org] On Behalf Of Lisa [lisajca at gmail.com]
Sent: 29 June 2011 21:35
To: r-help at r-project.org
Subject: Re: [R] Derivative of a function

Yes. I need to do implicit differentiation. After rearrangement, I got

(x2 ? x1) * b = log(1 / y - 1)

Take derivative of both sides with respect to y, I have

(x2 ? x1) * b?[y] = - 1/y(1-y)

Since both (x2 ? x1) and b?[y] are vectors, I cannot move (x2 ? x1) to
RHS. This is why I posted my question here to see if there is some R
functions or some idea that can help me solve this problem. Thanks.

Lisa

--
View this message in context: http://r.789695.n4.nabble.com/Derivative-of-a-function-tp3631814p3633947.html
Sent from the R help mailing list archive at Nabble.com.

______________________________________________
R-help at r-project.org mailing list
https://stat.ethz.ch/mailman/listinfo/r-help
PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
and provide commented, minimal, self-contained, reproducible code.
*******************************************************************
This email and any attachments are confidential. Any use...{{dropped:8}}

------------------------------

Message: 84
Date: Wed, 29 Jun 2011 14:47:01 -0700 (PDT)
From: siriustar <qinlangjinan at live.cn>
To: r-help at r-project.org
Subject: Re: [R] optimization in for loop
Message-ID: <1309384021241-3634100.post at n4.nabble.com>
Content-Type: text/plain; charset=us-ascii

Thankyou very much. I think "try" works for me.

I am learning it .

Sirius

--
View this message in context: http://r.789695.n4.nabble.com/optimization-in-for-loop-tp3633638p3634100.html
Sent from the R help mailing list archive at Nabble.com.

------------------------------

Message: 85
Date: Wed, 29 Jun 2011 23:54:39 +0200
From: Trying To learn again <tryingtolearnagain at gmail.com>
To: r-help at r-project.org
Subject: Re: [R] Executing a script "hand-made" and time
Message-ID: <BANLkTi=UTP33Jc5s-B189nkBUbVp_+NYcA at mail.gmail.com>
Content-Type: text/plain

Hi all,

My file that worked with a thin matrix (with few rows and colums) finally
made an error but I can´t comprehed why?

valor ausente donde TRUE/FALSE es necesario (absent value TRUE/FALSE is
necessary?)

Error en if (data[i, j] - last1[1, j] != 0) data2[i, j] = 0 else { :

You recommed to part the file of 4 Million rows x 13 colums?
2011/6/29 Trying To learn again <tryingtolearnagain at gmail.com>

> Hi all,
>
> I have a function written by me that read a  matrix (data frame) from a txt
> with 4 million of rows and 13 columns.
>
> The think is my function works with an input matrix of 100x13 and now I
> tried to execute my function with the big "input file" and it is running
> form the moment two hours...
>
> There is a way to know (how much time could it cost?)
>
> The second question is...
>
> I want to buy a new computer...to threat files like this (and make on the
> if....for....loops and so on)... I need a computer with high RAM or to
> "speed" this executing time I need other "technical hardware items"....
>
> I´m sure my programmation can be simplied but anyway I hope someone can
> give me his/her opinion.
>
> Many Thaks in advance.
>

[[alternative HTML version deleted]]

------------------------------

Message: 86
Date: Wed, 29 Jun 2011 16:52:19 -0700 (PDT)
From: nany23 <anna.botto at gmail.com>
To: r-help at r-project.org
Subject: [R] Numerical integration
Message-ID: <1309391539780-3634365.post at n4.nabble.com>
Content-Type: text/plain; charset=us-ascii

Hello!

I know that probably my question is rather simple  but I' m a very beginner
R-user.

I have to numerically integrate  the product of two function A(x) and B(x).
The integretion limits are [X*; +inf]

Function A(x) is a pdf function while B(x)=e*x is a linear function whose
value is equal to 0 when the  x < X*

Moreover I have to iterate this process for different value of X* and for
different pdf of the same type.

I know the comand INTEGRATE but  I can' t make it work.

Which is the best function to do this and how does it work?

[[elided Yahoo spam]]

--
View this message in context: http://r.789695.n4.nabble.com/Numerical-integration-tp3634365p3634365.html
Sent from the R help mailing list archive at Nabble.com.

------------------------------

Message: 87
Date: Wed, 29 Jun 2011 21:16:15 -0700 (PDT)

To: r-help at r-project.org, fExtremes <Rmetrics-core at r-project.org>
Subject: Re: [R] Saving fExtremes estimates and k-block return level
with	confidence intervals.
Message-ID:
<1309407375.93675.YahooMailRC at web121703.mail.ne1.yahoo.com>
Content-Type: text/plain; charset=iso-8859-1

I am estimating a large model by groups. How do you save the results and?returns
the associated quantiles?
For this example I need a data frame
n?? ?xi??????? mu????????beta
1?? 0.1033614? 2.5389580 0.9092611
2? ?0.3401922? 0.5192882 1.5290615
3?? 0.5130798? 0.5668308 1.2105666
I also want to apply gevrlevelPlot() for each "n" or group.
?
#Example
n <- c(1, 1, 1, 1, 1, 1, 2, 2, 2, 2, 2, 2, 3, 3, 3, 3, 3,3)
y <- c(2,3,2,3,4,5,6,1,0,0,0,6, 2, 1, 0, 0,9,3)
z <- as.data.frame(cbind(n,y))
colnames(z) <- c("n","y")
library(fExtremes)
z <- split(z, z\$n)
res2 <-lapply(z, function(x){
?????????????? m <- as.numeric(x\$y)
?????????????? gevFit(m, block = 1, type = c("pwm"))
??????????????? })
> res2
\$`1`
Title:
?GEV Parameter Estimation
Call:
?gevFit(x = m, block = 1, type = c("pwm"))
Estimation Type:
? gev pwm
Estimated Parameters:
?????? xi??????? mu????? beta
0.1033614 2.5389580 0.9092611
Description
? Wed Jun 29 23:07:48 2011

\$`2`
Title:
?GEV Parameter Estimation
Call:
?gevFit(x = m, block = 1, type = c("pwm"))
Estimation Type:
? gev pwm
Estimated Parameters:
?????? xi??????? mu????? beta
0.3401922 0.5192882 1.5290615
Description
? Wed Jun 29 23:07:48 2011

\$`3`
Title:
?GEV Parameter Estimation
Call:
?gevFit(x = m, block = 1, type = c("pwm"))
Estimation Type:
? gev pwm
Estimated Parameters:
?????? xi??????? mu????? beta
0.5130798 0.5668308 1.2105666
Description
? Wed Jun 29 23:07:48 2011?

------------------------------

Message: 88
Date: Thu, 30 Jun 2011 10:10:35 +0530
From: Ashim Kapoor <ashimkapoor at gmail.com>
To: r-help at r-project.org
Subject: [R] Upgrading R in Ubuntu
Message-ID: <BANLkTimn1Es42uOdjBdj7S-7tDW2m+6b2A at mail.gmail.com>
Content-Type: text/plain

Dear All,

I wanted to install the reshape package which in turn requires the plyr.
When I tried to install plyr it says it needs

ERROR: this R is version 2.10.1, package 'plyr' requires R >= 2.11.0

My question is how do I upgrade my R ? I have Ubuntu 10.04.2 LTS.

Many thanks for your help.

[[alternative HTML version deleted]]

------------------------------

Message: 89
Date: Wed, 29 Jun 2011 22:05:32 -0700 (PDT)

To: Duncan Murdoch <murdoch.duncan at gmail.com>
Cc: r-help at r-project.org
Subject: Re: [R] DROP OBSEVATION IN A GROUP
Message-ID:
<1309410332.60196.YahooMailRC at web121711.mail.ne1.yahoo.com>
Content-Type: text/plain; charset=iso-8859-1

I tried this but did not work:
z0<- by(z, z[,"n"], function(x) subset(x, sum(n==0)>2))
?Peter Maclean
Department of Economics
UDSM

----- Original Message ----
From: Duncan Murdoch <murdoch.duncan at gmail.com>

Cc: r-help at r-project.org
Sent: Wed, June 29, 2011 3:33:25 PM
Subject: Re: [R] DROP OBSEVATION IN A GROUP

On 29/06/2011 4:29 PM, Peter Maclean wrote:
> People with more experience in R I need help on this.
> I would like to drop observation if they meet certain condition. In this
>example
> I would like to drop group 2 in "n" because the group in "Y" has more than 2
> zeroes.
> #Example
> n<- c(1, 1, 1, 1, 1, 1, 2, 2, 2, 2, 2, 2, 3, 3, 3, 3, 3,3)
> y<- c(2,3,2,3,4,5,6,1,0,0,0,6, 2, 1, 0, 0,9,3)
> z<- as.data.frame(cbind(n,y))
> colnames(z)<- c("n","y")
z0<- by(z, z[,"n"], function(x) subset(x, sum(n==0)>2))

The general way to drop observations is to construct a logical vector to use as
an index.? Entries which are FALSE are dropped.

Doing that based on your "more than 2 zeroes" rule looks a little tricky; I
think you want to count zeros first (e.g. using by()), then construct the
TRUE/FALSE vector based on that.

Duncan Murdoch

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

------------------------------

Message: 90
Date: Thu, 30 Jun 2011 06:17:13 +0100 (BST)
From: Prof Brian Ripley <ripley at stats.ox.ac.uk>
To: Sam Albers <tonightsthenight at gmail.com>
Cc: r-help at r-project.org
Subject: Re: [R] Italicized greek symbols in PDF plots
Message-ID:
<alpine.LFD.2.02.1106300611300.10093 at gannet.stats.ox.ac.uk>
Content-Type: TEXT/PLAIN; charset=US-ASCII; format=flowed

On Wed, 29 Jun 2011, Sam Albers wrote:

> I know that this has been asked before in other variations but I just can't
> seem to figure out my particular application from previous posts. My
> apologies if I have missed the answer to this question somewhere in the
> archives. I have indeed looked.
>
> I am running Ubuntu 11.04, with R 2.12.1 and ESS+Emacs.
>
> For journal formatting requirements, I need to italicize all the greek
> letters in any plot. This is reasonably straight forward to do and I
> accomplished this task like so:
>
> library(ggplot2)
>
> label_parseall <- function(variable, value) {
>   plyr::llply(value, function(x) parse(text = paste(x)))
> }
>
> dat <- data.frame(x = runif(270, 0, 125), z = rep(LETTERS[1:3], each = 3),
> yy = 1:9, stringsAsFactors = TRUE)
> #unicode italicized delta
> dat\$gltr =
> factor(c("italic(\u03b4)^14*N","italic(\u03b4)^15*N","italic(\u03b4)^13*C"))
>
> #So this is what I want my plot to look like:
> plt <- ggplot(data = dat, aes(x = yy, y = x)) +
>    geom_point(aes(x= yy, y=x, shape=z, group=z), alpha=0.4,position =
> position_dodge(width = 0.8)) +
>    facet_grid(gltr~.,labeller= label_parseall, scales="free_y")
> plt
>
> #So then I exported my plot as a PDF like so:
> pdf("Times_regular.pdf", family='Times')
> plt
> dev.off()
> #The problem with this was that the delta symbols turned into dots.

You forgot to set the encoding: see the ?pdf help file.  Greek is most
likely not covered by the default encoding (and you also forgot the
'at a minimum' information required by the posting guide, so we don't
know what your defaults would be).

> #I solved this problem using Cairo
> library(Cairo)
> cairo_pdf("Cairo.pdf")
> plt
> dev.off()
>
>
> The problem that I face now is that I am unsure how to output a figure that
> maintains the greek symbols but outputs everything in the plot as TImes New
> Roman, another requirement of the journal. So I can produce a Times New
> Roman PDF plot and an italicize greek symbol unicode PDF plot but not both.
> Does anoyone have any idea how I might accomplish both of these things
> together in a single PDF?

I woud use cairo_pdf() in base R (and not package Cairo).  Use grid
facilities to change font, or use the version in R-devel which has a
family= argument.

>
> Thanks so much in advance,
>
> Sam
>
> 	[[alternative HTML version deleted]]

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

That does mean you!

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

------------------------------

Message: 91
Date: Wed, 29 Jun 2011 22:48:37 -0700
From: Jeff Newmiller <jdnewmil at dcn.davis.ca.us>
To: Ashim Kapoor <ashimkapoor at gmail.com>, r-help at r-project.org
Subject: Re: [R] Upgrading R in Ubuntu
Message-ID: <fb7ca595-f980-42b0-86fb-d5d264a64009 at email.android.com>
Content-Type: text/plain

This is Googlable. You need to add the CRAN repository to your APT sources file.
---------------------------------------------------------------------------
Jeff Newmiller The ..... ..... Go Live...
DCN:<jdnewmil at dcn.davis.ca.us> Basics: ##.#. ##.#. Live Go...
Live: OO#.. Dead: OO#.. Playing
Research Engineer (Solar/Batteries O.O#. #.O#. with
/Software/Embedded Controllers) .OO#. .OO#. rocks...1k
---------------------------------------------------------------------------
Sent from my phone. Please excuse my brevity.

Ashim Kapoor <ashimkapoor at gmail.com> wrote:

Dear All,

I wanted to install the reshape package which in turn requires the plyr.
When I tried to install plyr it says it needs

ERROR: this R is version 2.10.1, package 'plyr' requires R >= 2.11.0

My question is how do I upgrade my R ? I have Ubuntu 10.04.2 LTS.

Many thanks for your help.

[[alternative HTML version deleted]]

_____________________________________________

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

------------------------------

Message: 92
Date: Thu, 30 Jun 2011 18:44:56 +1200
From: Rolf Turner <rolf.turner at xtra.co.nz>
To: Edgar Alminar <eaalminar at ucsd.edu>
Cc: r-help at r-project.org
Subject: Re: [R] Sum Question
Message-ID: <4E0C1B68.3000804 at xtra.co.nz>
Content-Type: text/plain; charset=ISO-8859-1; format=flowed

The simplest way is:

xxx <- with(clyde,tapply(CONTTIME,SCRNO,sum))

You  could also do:

xxx <- by(clyde,clyde[["SCRNO"]],function(x){sum(x[["CONTTIME"]])})

but this gives somewhat messy output; the aforesaid output may be
convenient for some purposes, not for others.

cheers,

Rolf Turner

On 30/06/11 09:38, Edgar Alminar wrote:
> Hello,
> I have the following dataset (this is a piece of a much larger set):
>
>       RID      SCRNO VISCODE RECNO CONTTIME
> 23    18 HBA0190012      bl     1        5
> 24    18 HBA0190012      bl     3        5
> 28    18 HBA0190012      bl     5        5
> 29    18 HBA0190012      bl     2        5
> 32    18 HBA0190012      bl     4        5
> 38    19 HBA0190013      bl     2       35
> 50    19 HBA0190013      bl     1        5
> 57    20 HBA0190014      bl     1       10
> 61    21 HBA0200015      bl     2       30
> 64    21 HBA0200015      bl     3       90
> 67    21 HBA0200015      bl     4       90
> 72    21 HBA0200015      bl     8        2
> 76    21 HBA0200015      bl     1       60
> 88    22 HBA0190016      bl     1       25
> 97    23 HBA0190017      bl     3       85
> 99    23 HBA0190017      bl     1        5
> 103   23 HBA0190017      bl     2        5
> 122   25 HBA0190019      bl     1       20
> 145   26 HBA0200020      bl     1       60
> 170   27 HBA0190021      bl     1        3
> 190   28 HBA0220022      bl     1       40
> 194   29 HBA0220023      bl     1       25
> 223   29 HBA0220023      bl     2       25
>
> And I would like to output a list of the sums of CONTTIME for each SCRNO. What is the best way to do that? Any help would be greatly appreciated.
>
> Thanks!
> Edgar
>
> ______________________________________________
> R-help at r-project.org mailing list
> https://stat.ethz.ch/mailman/listinfo/r-help
> PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
> and provide commented, minimal, self-contained, reproducible code.
>

------------------------------

Message: 93
Date: Thu, 30 Jun 2011 12:24:49 +0530
From: "Anupam" <anupamtg at gmail.com>
To: "'Richard Valliant'" <rvalliant at survey.umd.edu>,
<r-help at r-project.org>
Subject: Re: [R] RWinEdt
Message-ID: <013801cc36f2\$9dcaa230\$d95fe690\$@gmail.com>
Content-Type: text/plain;	charset="us-ascii"

I used R with WinEdt some years ago (I think it was on 98, may be even XP),
and then moved on to other editors --- (X)Emacs, Tinn-R and Rcommander seem
to do the job reasonably well with differing functionality. I had sent
several requests to the WinEdt development team that I may even upgrade to a
newer paid version (I am using paid version 5.5) if they can build in
support for Statistical Computing with popular languages. They do not seem
to be interested. I had thought Alex (the developer) being a Ph.D. in Math
would have seen the market. I still use WinEdt for Stata; that is because
Stata's built in editor is a bad joke for users, and I could never make
(X)Emacs or Notepad++ work for Stata.

Anupam.
-----Original Message-----
From: r-help-bounces at r-project.org [mailto:r-help-bounces at r-project.org] On
Behalf Of Richard Valliant
Sent: Thursday, June 30, 2011 1:05 AM
To: r-help at r-project.org
Subject: [R] RWinEdt

I have a problem using RWinEdt 1.8.2 in Windows 7 Professional (64 bit).
System/software info:
R version 2.13.0 (2011-04-13)
Copyright (C) 2011 The R Foundation for Statistical Computing ISBN
3-900051-07-0
Platform: x86_64-pc-mingw32/x64 (64-bit) WinEdt  Build: 20071003  (v. 5.5)

After installing the R package and attempting to load I get:

> library(RWinEdt)
Warning message:
In shell(paste("\"\"", .gW\$InstallRoot, "\\WinEdt.exe\" -C=\"R-WinEdt\"
-E=",  :
'""C:\Program Files (x86)\WinEdt Team\WinEdt\WinEdt.exe"
-C="R-WinEdt" -E="C:\Users\rvalliant\AppData\Roaming\WinEdt\R.ini""'
execution failed with error code 1
>

The WinEdt window does not open. I can open it manually (since the package
installation created a desktop shortcut ("RWinEdt"). If a line of R code is
highlighted in RWinEdt and sent to the R Console with
Alt+p, the focus shifts to R console but nothing is copied.

This has come up before in a message from John Seers on 2 Mar 2011. Uwe
suggested this:
"One installing RWinEdt the first time, please run R with Administrator

privileges (right click to do so). Then installation should work smoothly
with WinEdt < 6.0."

I'm running WinEdt 5.5. I followed Uwe's suggestion but get the message
above.
Any suggestions?

Thanks,
Richard Valliant
University of Michigan

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

------------------------------

Message: 94
Date: Thu, 30 Jun 2011 03:08:26 -0400
From: Jorge Ivan Velez <jorgeivanvelez at gmail.com>

Cc: R mailing list <r-help at r-project.org>
Subject: Re: [R] DROP OBSEVATION IN A GROUP
Message-ID: <BANLkTi=nLY3z54GrnD=XTiA8d2NdtsvgCA at mail.gmail.com>
Content-Type: text/plain

Hi Peter,

Try this:

r <- with(z, tapply(y, n, function(x) sum(x == 0) > 2))
z[!rep(r, with(z, table(n))), ]

HTH,
Jorge

On Thu, Jun 30, 2011 at 1:05 AM, Peter Maclean <> wrote:

> I tried this but did not work:
> z0<- by(z, z[,"n"], function(x) subset(x, sum(n==0)>2))
>  Peter Maclean
> Department of Economics
> UDSM
>
>
>
> ----- Original Message ----
> From: Duncan Murdoch <>
> To: Peter Maclean <>
> Cc:
> Sent: Wed, June 29, 2011 3:33:25 PM
> Subject: Re: [R] DROP OBSEVATION IN A GROUP
>
> On 29/06/2011 4:29 PM, Peter Maclean wrote:
> > People with more experience in R I need help on this.
> > I would like to drop observation if they meet certain condition. In this
> >example
> > I would like to drop group 2 in "n" because the group in "Y" has more
> than 2
> > zeroes.
> > #Example
> > n<- c(1, 1, 1, 1, 1, 1, 2, 2, 2, 2, 2, 2, 3, 3, 3, 3, 3,3)
> > y<- c(2,3,2,3,4,5,6,1,0,0,0,6, 2, 1, 0, 0,9,3)
> > z<- as.data.frame(cbind(n,y))
> > colnames(z)<- c("n","y")
> z0<- by(z, z[,"n"], function(x) subset(x, sum(n==0)>2))
>
>
> The general way to drop observations is to construct a logical vector to
> use as
> an index.  Entries which are FALSE are dropped.
>
> Doing that based on your "more than 2 zeroes" rule looks a little tricky; I
> think you want to count zeros first (e.g. using by()), then construct the
> TRUE/FALSE vector based on that.
>
> Duncan Murdoch
>
> >
> >
> > ______________________________________________
> > R-help at r-project.org mailing list
> > https://stat.ethz.ch/mailman/listinfo/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 at r-project.org mailing list
> https://stat.ethz.ch/mailman/listinfo/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]]

------------------------------

Message: 95
Date: Thu, 30 Jun 2011 17:28:02 +1000
From: Max Mariasegaram <max.mariasegaram at qut.edu.au>
To: "r-help at r-project.org" <r-help at r-project.org>
Subject: [R] aggregating data
Message-ID:
<6A809CAC3D22EE4AAA41A3EA54B00E0C0D63DEBA3D at QUTEXMBX03.qut.edu.au>
Content-Type: text/plain

Hi,

I am interested in using the cast function in R to perform some aggregation. I did once manage to get it working, but have now forgotten how I did this. So here is my dilemma. I have several thousands of probes (about 180,000) corresponding to each gene; what I'd like to do is obtain is a frequency count of the various occurrences of each probes for each gene.

The data would look something like this:

Gene     ProbeID               Expression_Level
A             1              0.34
A             2              0.21
E              3              0.11
A             4              0.21
F              5              0.56
F              6              0.87
.
.
.
(180000 data points)

In each case, the probeID is unique. The output I am looking for is something like this:

Gene     No.ofprobes      Mean_expression
A             3              0.25

Is there an easy way to do this using "cast" or "melt"? Ideally, I would also like to see the unique probes corresponding to each gene in the wide format.

Max

Maxy Mariasegaram| Reserach Fellow | Australian Prostate Cancer Research Centre| Level 1, Building 33 | Princess Alexandra Hospital | 199 Ipswich Road, Brisbane QLD 4102 Australia | t: 07 3176 3073| f: 07 3176 7440 | e: mariaseg at qut.edu.au

[[alternative HTML version deleted]]

------------------------------

Message: 96
Date: Thu, 30 Jun 2011 03:37:33 -0400
From: Jorge Ivan Velez <jorgeivanvelez at gmail.com>

Cc: R mailing list <r-help at r-project.org>
Subject: Re: [R] Saving fExtremes estimates and k-block return level
with confidence intervals.
Message-ID: <BANLkTim+LSnf7x-sQDROCgjAWaXa4UCYuw at mail.gmail.com>
Content-Type: text/plain

Hi Peter,

Try

data.frame(n = names(res2), t(sapply(res2, function(l) l at fit\$par.ests)))

for the first part.

HTH,
Jorge

On Thu, Jun 30, 2011 at 12:16 AM, Peter Maclean <> wrote:

> I am estimating a large model by groups. How do you save the results
> and returns
> the associated quantiles?
> For this example I need a data frame
> n    xi        mu        beta
> 1   0.1033614  2.5389580 0.9092611
> 2   0.3401922  0.5192882 1.5290615
> 3   0.5130798  0.5668308 1.2105666
> I also want to apply gevrlevelPlot() for each "n" or group.
>
> #Example
> n <- c(1, 1, 1, 1, 1, 1, 2, 2, 2, 2, 2, 2, 3, 3, 3, 3, 3,3)
> y <- c(2,3,2,3,4,5,6,1,0,0,0,6, 2, 1, 0, 0,9,3)
> z <- as.data.frame(cbind(n,y))
> colnames(z) <- c("n","y")
> library(fExtremes)
> z <- split(z, z\$n)
> res2 <-lapply(z, function(x){
>                m <- as.numeric(x\$y)
>                gevFit(m, block = 1, type = c("pwm"))
>                 })
> > res2
> \$`1`
> Title:
>  GEV Parameter Estimation
> Call:
>  gevFit(x = m, block = 1, type = c("pwm"))
> Estimation Type:
>   gev pwm
> Estimated Parameters:
>        xi        mu      beta
> 0.1033614 2.5389580 0.9092611
> Description
>   Wed Jun 29 23:07:48 2011
>
> \$`2`
> Title:
>  GEV Parameter Estimation
> Call:
>  gevFit(x = m, block = 1, type = c("pwm"))
> Estimation Type:
>   gev pwm
> Estimated Parameters:
>        xi        mu      beta
> 0.3401922 0.5192882 1.5290615
> Description
>   Wed Jun 29 23:07:48 2011
>
> \$`3`
> Title:
>  GEV Parameter Estimation
> Call:
>  gevFit(x = m, block = 1, type = c("pwm"))
> Estimation Type:
>   gev pwm
> Estimated Parameters:
>        xi        mu      beta
> 0.5130798 0.5668308 1.2105666
> Description
>   Wed Jun 29 23:07:48 2011
>
>
> ______________________________________________
> R-help at r-project.org mailing list
> https://stat.ethz.ch/mailman/listinfo/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]]

------------------------------

Message: 97
Date: Thu, 30 Jun 2011 18:09:58 +1000
From: Jim Lemon <jim at bitwrit.com.au>
To: Zulima Tablado Almela <zutal at yahoo.es>
Cc: r-help at r-project.org
Subject: Re: [R] Measure the distance/home range along  terrain
surface
Message-ID: <4E0C2F56.1090304 at bitwrit.com.au>
Content-Type: text/plain; charset=ISO-8859-1; format=flowed

On 06/30/2011 01:54 AM, Zulima Tablado Almela wrote:
> Hello all,
>
> I have two questions:
>
> 1)Given two coordinates on a digital elevation model (DEM), I would like
> to measure the actual distance traveled between the two locations,
> assuming a straight line route. Does anyone know the function(if there
> exists) to do that in R?
>
> 2)How can I calculate or correct the home range size taking into account
> the variations in elevation (DEM) within it?
>
> Thank you so much in advance, any suggestion will be very much appreciated,
>
Hi Zulima,
This sounds like a question for the R-sig-geo list.
Jim

------------------------------

Message: 98
Date: Thu, 30 Jun 2011 10:13:19 +0200
From: Janko Thyson <janko.thyson.rstuff at googlemail.com>
To: Duncan Murdoch <murdoch.duncan at gmail.com>
Cc: "r-help at r-project. org" <r-help at r-project.org>
Subject: Re: [R] Update MS Windows PATH variable based on a R script
Message-ID: <4E0C301F.8060909 at googlemail.com>
Content-Type: text/plain; charset=ISO-8859-1; format=flowed

On 29.06.2011 21:24, Duncan Murdoch wrote:
> On 29/06/2011 3:15 PM, Janko Thyson wrote:
>> On 29.06.2011 20:58, Duncan Murdoch wrote:
>>> On 29/06/2011 2:24 PM, Janko Thyson wrote:
>>>> Dear list,
>>>>
>>>> this is not directly an R question, but it is somewhat related to R
>>>> aspects, so I hope it's okay to post it here:
>>>>
>>>> I'd like to update my windows PATH based on a script routine in
>>>> order to
>>>> make sure that crucial components are contained. Much like what
>>>> happens
>>>> at the installation of Rtools (if desired). Now, can you do that from
>>>> within R or do I need some sort of windows batch file or something
>>>> like
>>>> AutoIt script (http://www.autoitscript.com/site/autoit/)? If so, what
>>>> would I need to put in there?
>>>
>>> You need to set the registry entry if you want a persistent change to
>>> the PATH.  Sys.setenv just modifies R's copy of the PATH.  Child
>>> processes will see the modifications, but they don't last beyond the R
>>> session.
>>>
>>> You'll have to check MS docs to find which registry entry to mess
>>> with.  Alternatively, if you feel lucky, just use Control Panel to set
>>> some strange path, then see where your change showed up using regedit.
>>>
>>> R doesn't have a built-in function to write to the registry, but there
>>> are various utilities available outside of R to do it.
>>>
>>> Duncan Murdoch
>>
[[elided Yahoo spam]]
>> Would you mind sharing how you do it with the Rtools Windows installer?
>> Or is that too much bound to installer details and can't be secluded
>> very well?
>
> We use the Inno Setup installer; it has a function for this.  Here's
> the code used:
>
> Root: HKLM; Subkey: SYSTEM\CurrentControlSet\Control\Session
> Manager\Environment; ValueType: expandsz; ValueName: PATH; ValueData:
> "{code:getNewPath}"; Tasks: setPath
>
> So I guess I do know what the registry key is.

Great, thanks a lot!

>
>>
>> The motivation behind this is that I came to love applications that can
>> be run portably (i.e. apps that don't write anything to the Windows
>> registry and can therefore be easily be "installed" on a USB drive, for
>> example). That works just fine with R, my IDE Eclipse and also Rtools.
>> The problem is that I need a batch script that optionally checks under
>> which letter my USB drive is mounted and updates the relevant paths to
>> Rtools binaries in my Windows PATH to make it somewhat "dynamical". Of
>> course I'd like to clean everything up once my R-session terminates so I
>> can reset the Windows PATH to it's original state once I'm finished
>> working at a specific PC.
>>
>> What I also just thought of: is there some way to specify relative and
>> not absolute paths in the windows PATH? I know that this works when you
>> have an .exe as a reference point (e.g. '..\somedir\' goes up one
>> directory relative to the directory where the .exe is called and then
>> moves into 'somedir'). But since there is no such thing as an .exe
>> involved, there's probably no way to do it.
>
> As far as I know that's fine with R.  It uses various .exe's in the
> bin/i386 or bin/x64 directories.  It doesn't use the path for anything
> beyond startup.
>
> Duncan Murdoch
>
>>
>> But thanks for the info, I'll have a look at MS specific documentation
>> to get the job done.
>>
>> Regards,
>> Janko
>>>
>>>>
>>>> Here's what I tried in R:
>>>>
>>>> unlist(strsplit(Sys.getenv("PATH"), ";"))
>>>> PATH.0<- Sys.getenv("PATH")
>>>> PATH.1<- paste(PATH.0, "C:\\blabla\bin")
>>>> Sys.setenv("PATH"=PATH.1)
>>>> unlist(strsplit(Sys.getenv("PATH"), ";"))
>>>>
>>>> The changes seem to be reflected, but when I check my PATH the new
>>>> entry
>>>> isn't there. I guess there is no actual "feedback" to Windows system
>>>> environment variable and that's exactly what I would like to
>>>> accomplish
>>>>
>>>> Thanks a lot for any advice,
>>>> Janko
>>>>
>>>> ______________________________________________
>>>> R-help at r-project.org mailing list
>>>> https://stat.ethz.ch/mailman/listinfo/r-help
>>>> PLEASE do read the posting guide
>>>> http://www.R-project.org/posting-guide.html
>>>> and provide commented, minimal, self-contained, reproducible code.
>>>
>>>
>>
>
>

------------------------------

Message: 99
Date: Thu, 30 Jun 2011 09:23:59 +0100 (BST)
From: Iain Gallagher <iaingallagher at btopenworld.com>
To: "r-help at r-project.org" <r-help at r-project.org>,	Max Mariasegaram
<max.mariasegaram at qut.edu.au>
Subject: Re: [R] aggregating data
Message-ID:
<1309422239.81326.YahooMailClassic at web86702.mail.ird.yahoo.com>
Content-Type: text/plain; charset=iso-8859-1

Hi Max

Using plyr instead of rehsape:

library(plyr)

df <- data.frame(gene=c('A', 'A', 'E', 'A', 'F', 'F'), probe = c(1,2,3,4,5,6))

ddply(df, .(gene), function(df)length(df\$gene))

gene V1
1    A  3
2    E  1
3    F  2

best

iain

--- On Thu, 30/6/11, Max Mariasegaram <max.mariasegaram at qut.edu.au> wrote:

> From: Max Mariasegaram <max.mariasegaram at qut.edu.au>
> Subject: [R] aggregating data
> To: "r-help at r-project.org" <r-help at r-project.org>
> Date: Thursday, 30 June, 2011, 8:28
> Hi,
>
> I am interested in using the cast function in R to perform
> some aggregation. I did once manage to get it working, but
> have now forgotten how I did this. So here is my dilemma. I
> have several thousands of probes (about 180,000)
> corresponding to each gene; what I'd like to do is obtain is
> a frequency count of the various occurrences of each probes
> for each gene.
>
> The data would look something like this:
>
> Gene? ???ProbeID? ? ?
> ? ? ? ???Expression_Level
> A? ? ? ? ?
> ???1? ? ? ? ? ?
> ? 0.34
> A? ? ? ? ?
> ???2? ? ? ? ? ?
> ? 0.21
> E? ? ? ? ? ? ? 3?
> ? ? ? ? ? ? 0.11
> A? ? ? ? ?
> ???4? ? ? ? ? ?
> ? 0.21
> F? ? ? ? ? ? ? 5?
> ? ? ? ? ? ? 0.56
> F? ? ? ? ? ? ? 6?
> ? ? ? ? ? ? 0.87
> .
> .
> .
> (180000 data points)
>
> In each case, the probeID is unique. The output I am
> looking for is something like this:
>
> Gene? ???No.ofprobes? ?
> ? Mean_expression
> A? ? ? ? ?
> ???3? ? ? ? ? ?
> ? 0.25
>
> Is there an easy way to do this using "cast" or "melt"?
> Ideally, I would also like to see the unique probes
> corresponding to each gene in the wide format.
>
> Thanks in advance
> Max
>
> Maxy Mariasegaram| Reserach Fellow | Australian Prostate
> Cancer Research Centre| Level 1, Building 33 | Princess
> Alexandra Hospital | 199 Ipswich Road, Brisbane QLD 4102
> Australia | t: 07 3176 3073| f: 07 3176 7440 | e: mariaseg at qut.edu.au
>
>
> ??? [[alternative HTML version deleted]]
>
> ______________________________________________
> R-help at r-project.org
> mailing list
> https://stat.ethz.ch/mailman/listinfo/r-help
> PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
> and provide commented, minimal, self-contained,
> reproducible code.
>

------------------------------

Message: 100
Date: Thu, 30 Jun 2011 18:25:04 +1000
From: Jim Lemon <jim at bitwrit.com.au>
To: chris20 <bop07crb at sheffield.ac.uk>
Cc: r-help at r-project.org
Subject: Re: [R] centre two graphs on one plot
Message-ID: <4E0C32E0.9010806 at bitwrit.com.au>
Content-Type: text/plain; charset=ISO-8859-1; format=flowed

On 06/30/2011 05:37 AM, chris20 wrote:
> Hi,
>
> I am trying to put together a biplot using symbols and different colours
> instead of text as points.
>
> Someone has previously suggested using this code:
>
> PC<- prcomp (iris[,1:4])
> lambda<- PC\$sdev * sqrt(nrow(PC\$x))
> plot (t(t(PC\$x)/lambda),pch=16,col=as.numeric(iris[,5]))
> par (new=T)
> Rot<- t(t(PC\$rotation)*lambda)
> XLIM<- c(-max(abs(Rot[,1])),max(abs(Rot[,1])))
> XLIM<- XLIM+(XLIM*0.7)
> plot(Rot,col=4,axes=FALSE,xlim=XLIM,ylim=XLIM,pch="")
> arrows
> (rep(0,nrow(PC\$rotation)),rep(0,nrow(PC\$rotation)),Rot[,1],Rot[,2],col=4)
> text (Rot[,1:2],rownames(Rot),col=6)
> axis (3)
> axis (4)
>
> But the origin of the arrows does not line up with the origin of the points.
> Can anyone suggest how you would get the two graphs to line up?  I think you
> have to set a ratio between the two sets of axes so that the origin is in
> the centre but I don't know how to do it.
>
Hi Chris,
In order to get the zeros of the two abscissae at the same horizontal
point, you will have to make both symmetric. Change your third like to:

plot(t(t(PC\$x)/lambda),pch=16,col=as.numeric(iris[,5]),
xlim=c(-0.15,0.15))

and see what happens.

Jim

------------------------------

Message: 101
Date: Thu, 30 Jun 2011 09:28:10 +0100 (BST)
From: Iain Gallagher <iaingallagher at btopenworld.com>
To: "r-help at r-project.org" <r-help at r-project.org>,	Max Mariasegaram
<max.mariasegaram at qut.edu.au>
Subject: Re: [R] aggregating data
Message-ID:
<1309422490.56962.YahooMailClassic at web86705.mail.ird.yahoo.com>
Content-Type: text/plain; charset=iso-8859-1

oops last reply was only half the solution:

library(plyr)
df <- data.frame(gene=c('A', 'A', 'E', 'A', 'F', 'F'), probe = c(1,2,3,4,5,6), exp = c(0.34, 0.21, 0.11, 0.21, 0.56, 0.81))

ddply(df, .(gene), function(df)c(length(df\$gene), median(df\$exp))

gene V1    V2
1    A  3 0.210
2    E  1 0.110
3    F  2 0.685

best

iain

--- On Thu, 30/6/11, Max Mariasegaram <max.mariasegaram at qut.edu.au> wrote:

> From: Max Mariasegaram <max.mariasegaram at qut.edu.au>
> Subject: [R] aggregating data
> To: "r-help at r-project.org" <r-help at r-project.org>
> Date: Thursday, 30 June, 2011, 8:28
> Hi,
>
> I am interested in using the cast function in R to perform
> some aggregation. I did once manage to get it working, but
> have now forgotten how I did this. So here is my dilemma. I
> have several thousands of probes (about 180,000)
> corresponding to each gene; what I'd like to do is obtain is
> a frequency count of the various occurrences of each probes
> for each gene.
>
> The data would look something like this:
>
> Gene? ???ProbeID? ? ?
> ? ? ? ???Expression_Level
> A? ? ? ? ?
> ???1? ? ? ? ? ?
> ? 0.34
> A? ? ? ? ?
> ???2? ? ? ? ? ?
> ? 0.21
> E? ? ? ? ? ? ? 3?
> ? ? ? ? ? ? 0.11
> A? ? ? ? ?
> ???4? ? ? ? ? ?
> ? 0.21
> F? ? ? ? ? ? ? 5?
> ? ? ? ? ? ? 0.56
> F? ? ? ? ? ? ? 6?
> ? ? ? ? ? ? 0.87
> .
> .
> .
> (180000 data points)
>
> In each case, the probeID is unique. The output I am
> looking for is something like this:
>
> Gene? ???No.ofprobes? ?
> ? Mean_expression
> A? ? ? ? ?
> ???3? ? ? ? ? ?
> ? 0.25
>
> Is there an easy way to do this using "cast" or "melt"?
> Ideally, I would also like to see the unique probes
> corresponding to each gene in the wide format.
>
> Thanks in advance
> Max
>
> Maxy Mariasegaram| Reserach Fellow | Australian Prostate
> Cancer Research Centre| Level 1, Building 33 | Princess
> Alexandra Hospital | 199 Ipswich Road, Brisbane QLD 4102
> Australia | t: 07 3176 3073| f: 07 3176 7440 | e: mariaseg at qut.edu.au
>
>
> ??? [[alternative HTML version deleted]]
>
> ______________________________________________
> R-help at r-project.org
> mailing list
> https://stat.ethz.ch/mailman/listinfo/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 at r-project.org mailing list
https://stat.ethz.ch/mailman/listinfo/r-help
PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
and provide commented, minimal, self-contained, reproducible code.

End of R-help Digest, Vol 100, Issue 31

```