[R] Package dependency

2011-09-20 Thread Tyler Rinker

Greetings R community,
 
I am making my first package and have run into the need to use other packages.  
I  pass all the checks in the command prompt running Rcmd check package.name.  
In the Description file I have included:
 
Depends: R (>= 2.13), plotrix
Repository: CRAN
 
Now I create the zip file for windows 7.  I delete my plotrix package from my 
library to create a setup where others might encounter when installing my 
package (perhaps they don't have the package dependency plotrix installed).  I 
now install the zip file in my R library and try to load it in R generating the 
following error:
 
> library(genTools)
Loading required package: plotrix
Error: package ‘plotrix’ could not be loaded
In addition: Warning message:
In library(pkg, character.only = TRUE, logical.return = TRUE, lib.loc = 
lib.loc) :
  there is no package called ‘plotrix’
 
Now the question:  How do I get my package to automatically download 
dependencies from CRAN as other CRAN packages do when I install them to my 
library for the first time?
 
Tyler Rinker
 
R version 2.14 (beta)   
Windows 7 
[[alternative HTML version deleted]]

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


Re: [R] How to transfer variable names to column names?

2011-09-20 Thread Dennis Murphy
Hi:

Using Michael's example data, here's another approach:

x = data.frame(x = 1:5)
y = data.frame(y = 1:10)
z = data.frame(z = 1:3)

# Generate a vector to name the list components
nms <- c('x', 'y', 'z')
# Combine data frames into a list
L <- list(x, y, z)
# name them
names(L) <- nms
# Use lapply() to get the number of rows in each component data frame
as.data.frame(lapply(L, nrow))
  x  y z
1 5 10 3

HTH,
Dennis

On Tue, Sep 20, 2011 at 11:23 AM, Vining, Kelly
 wrote:
> Hello R users,
> I have a set of data frames for which I am tallying row numbers, as shown 
> below.
>
>> nrow(mC_Explant)
> [1] 14480
>> nrow(mC_Callus)
> [1] 23320
>> nrow(mC_RegenPlant)
> [1] 8108
>
> etc.
>
> I want to create a new data frame which has the variable names as column 
> headings, and then a single row with the nrow tallies. My first step was this:
>
> dfIntron <- c(nrow(mC_Explant), nrow(mC_Callus), nrow(mC_RegenPlant))
>
> Then, to set the column names, I tried this, and got the following error:
>
>  colnames(dfIntron) <- c("mC_Explant", "mC_Callus", "mC_RegenPlant")
> Error in `colnames<-`(`*tmp*`, value = c("mC_Explant", "mC_Callus", 
> "mC_RegenPlant" :
>  attempt to set colnames on object with less than two dimensions
>
> Even my first step seems wildly inefficient, and obviously doesn't work. 
> There must be a simple way to do this, but I can't use table(), for example, 
> as there are multiple data frames.
>
> Any help will be appreciated.
>
> --Kelly V.
>
>
> __
> R-help@r-project.org mailing list
> https://stat.ethz.ch/mailman/listinfo/r-help
> PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
> and provide commented, minimal, self-contained, reproducible code.
>

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


[R] glmnet for Binary trait analysis

2011-09-20 Thread Noah
Hello, 

I got an error message saying 

Error in lognet(x, is.sparse, ix, jx, y, weights, offset, alpha, nobs,  : 
  NA/NaN/Inf in foreign function call (arg 5)

when I try to analysis a binary trait using glmnet(R) by running the
following code

library(glmnet)
Xori <- read.table("c:\\SNP.txt", sep='\t');
Yori <- read.table("c:\\Trait.txt", sep=',');
Y=as.matrix(Yori);
X=t(as.matrix(Xori));
fit1=glmnet(X, Y, family="binomial");

in the above, X is a matrix with values 1, 0, and -1; Y is a one column
matrix with values 1 and 0.

I know how to analysis continuous traits using glmnet, but I have no idea
about how to do it for binary dependent variables. I will appreciate it if
you would give me any suggestion about this error or provide an example code
for handling binary trait using glmnet. 

Looking forward for your kindly help.

Thanks!

Noah

--
View this message in context: 
http://r.789695.n4.nabble.com/glmnet-for-Binary-trait-analysis-tp3828547p3828547.html
Sent from the R help mailing list archive at Nabble.com.

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


[R] ARIMA - Skipping intermediate lags

2011-09-20 Thread leighton155
Hello,

I am a new R user.  I am trying to use the arima command, but I have a
question on intermediate lags.  I want to run in R the equivalent Stata
command of ARIMA d.yyy, AR(5) MA(5 7).  This would tell the program I am
interested in AR lag 5, MA lag 5, and MA lag 7, all while skipping the
intermediate lags of AR 1-4, and MA 1-4, 6.  Is there any way to do this in
R?  Thank you.

--
View this message in context: 
http://r.789695.n4.nabble.com/ARIMA-Skipping-intermediate-lags-tp3828449p3828449.html
Sent from the R help mailing list archive at Nabble.com.

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


[R] Data

2011-09-20 Thread barb
Hey everybody,

i am using the rugarch-package and its great! 
I have a pretty easy problem, but i just dont get it, so thanks if you can
help me. 

Normally i use: 
/
data(DATANAME)
spec = ugarchspec()
fit = ugarchfit(data = x[,1], spec = spec)
fit

slotNames(fit)

names(fit@fit)
coef(fit)
infocriteria(fit)
likelihood(fit)
nyblom(fit)
signbias(fit)
head(as.data.frame(fit))
head(sigma(fit))
head(residuals(fit))
head(fitted(fit))
gof(fit,c(20,30,40,50))
uncmean(fit)
uncvariance(fit)
plot(fit,which="all")/
 
I want to use my data now. 

I figured out how to load excel sheets. 

setwd("C:/Users/UserofComputer/Desktop")
data <- read.csv2("Dataname.csv",header=T)
attach(data)
x <- CGE[200:1]
dx <- diff(log(x))

How is my "Dataname" now safed?
I cant use it as data(dataname) unfortunately. 


Where is my mistake?

Thank you

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

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


[R] adding labels to x,y points

2011-09-20 Thread baumeist
Hi,
I am new to R.

I have a matrix that I have assigned to the object “colon”.

> colon<-read.table("c:\\alon.txt",header=T,row.names=1)

attach(colon)
names(colon)

The dimenstions are 2000   62.

Each of the 62 columns (titled norm1, norm2, norm3, etc) has 2000
different numbers (‘continuous’ values) within it.

I have also assigned a name for each of the 2000 rows of the dataframe with
a prefix (i.e. g1 …. g2000) using the code (not sure if I did this right):

> colon<-paste("g",c(1:nrow(colon)),sep="")

I have plotted the first 20 values from two of the columns(samples).

> x<-c(norm1[1:20])

> y<-c(norm2[1:20])

> plot(x,y,type='n',xlab='x norm1 sample',ylab='y norm2 sample',main='Norm1
> vs Norm2 - 20
genes')

> points(x,y,pch=15,col='blue')

Now I wish to assign labels to each point (above each point (i.e. pos=3) in
the plot with “g1 to g20 corresponding to each row but I am having trouble
with this step.

I have tried:

> text(x,y, label = row.names(colon[1:20])) 

but nothing happens. 

Any suggestions?

Thanks in advance
MAB


--
View this message in context: 
http://r.789695.n4.nabble.com/adding-labels-to-x-y-points-tp3828461p3828461.html
Sent from the R help mailing list archive at Nabble.com.

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


Re: [R] Statistics forums

2011-09-20 Thread education2allpeople
hi friend i m david if you are having any type of problem in Statistics then
do visit http://www.transtutors.com/statistics-homework-help/ it has helped
me a lot. thanks. david

http://www.transtutors.com/statistics-homework-help/ Transtutors 

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

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


Re: [R] NLS error

2011-09-20 Thread Diviya Smith
Also I have this problem that many times the method converges to a local
maximum...if I run it a few times, I often get the expected answer.

Is there any way to fix this problem by changing the convergence conditions?
I have tried changing the nls.control {stats} but hasn't helped much. Any
suggestions?


On Tue, Sep 20, 2011 at 5:59 PM, Diviya Smith wrote:

> I dont think *r* is related to the problem. I am not trying to estimate *r
> * and so basically I am giving the model the correct value of *r* and so
> log(1-r) should not go to infinity.
>
> For test data, I generate data from the same model and add noise (using *r
> norm*), with the following parameters -
> A <- 20
> > B <- 500
> > r <- 0.6881
> > d <- (1:1000)/1000
> > y
> <- 
> (rnorm(d)*0.005)+(((log(1-r))*exp(-A*d)*(-1+r+exp(d*(A-B)))/(r*(-A*+d*B+log(1-r)
>
> And then I try estimating A, B and C (Note: C is capturing the noise term,
> and I am specifying r and d) but I get the following error -
> Error in numericDeriv(form[[3L]], names(ind), env) :
> Missing value or an infinity produced when evaluating the model
>
> Any suggestions how to fix this?
>
> Diviya
>
>
> On Tue, Sep 20, 2011 at 2:37 PM, Jean V Adams  wrote:
>
>>
>> Diviya Smith wrote on 09/20/2011 01:03:22 PM:
>>
>> >
>> > Hello there,
>> >
>> > I am using NLS for fitting a complex model to some data to estimate a
>> couple
>> > of the missing parameters. The model is -
>> > y ~
>> (C+((log(1-r))*exp(-A*d)*(-1+r+exp(d*(A-B)))/(r*(-A*d+d*B+log(1-r)
>> > where A, B and C are unknown.
>> >
>> > In order to test the model, I generate data by setting values for all
>> > parameters and add some noise (C).
>> >
>> > A <- 20
>> > B <- 500
>> > r <- 0.6881
>> > d <- (1:1000)/1000
>> > y ~
>> > (rnorm(d)*0.005)+(((log(1-r))*exp(-A*d)*(-1+r+exp(d*(A-B)))/(r*(-A*d
>> > +d*B+log(1-r)
>> >
>> > I use Deoptim package to pick the optimum starting values. The model
>> works
>> > fine in most cases, but every now and again, I get the following error -
>> > Error in numericDeriv(form[[3L]], names(ind), env) :
>> >   Missing value or an infinity produced when evaluating the model
>> >
>> > Any suggestions on how I can resolve this? Can you suggest a better way
>> for
>> > picking the starting parameters?
>> >
>> > Thanks,
>> > Diviya
>>
>>
>> I'm not sure if this is the problem, but if r grows greater than 1,
>> log(1-r) will be undefined, and you'll get an error.  You can impose a
>> constraint on r by rewriting your formula in terms of a variable that can
>> take on any real value:
>> R = log(1-r)
>>
>> So,
>> replace log(1-r) in your formula with R,
>> replace (-1 + r) with -exp(R), and
>> replace r with 1 - exp(R):
>> y ~ (C+(R*exp(-A*d)*(-exp(R)+exp(d*(A-B)))/((1 - exp(R))*(-A*d+d*B+R
>>
>> If that doesn't fix the problem, then you are likely getting infinite
>> values as result of large numbers in your exponents.  Without example data
>> to work through, I can only speculate.
>>
>> Jean
>
>
>

[[alternative HTML version deleted]]

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


Re: [R] Specifying Start/End Dates for X-axis Range in plot()/xyplot()

2011-09-20 Thread David Winsemius


On Sep 20, 2011, at 7:15 PM, Rich Shepard wrote:

 I'm having difficulty finding the syntax to use to specify the  
beginning
and ending dates for the x-axis while plotting a zoo object. I  
thought that

I had seen a message on this list that used start=as.Date("...")
end=as.Date("..."), but I cannot find that message. I've tried ?plot,
?plotxy, ?plot.zoo, and Sarkar's lattice book.

 I am trying to plot the time series for 'Burns Mg' generated by:

sapply(names(z), function(nm) range(time(na.omit(z[, nm]))),  
simplify = FALSE)

$`Burns Mg`[1] "1994-01-20" "2009-11-11"

 This is a typical result of my trial-and-error approach:

plot(z[, $'Burns Mg'], range(time(start = as.Date("1994-01-20"),  
end = as.Date("2009-11-11"

Error in is.matrix(x) : 'x' is missing
  Please point me to documentation on specifying


It seems likely even if you got past that error, you would encounter  
problems from the hashed up syntax in this portion of that plot call:


z[, $'Burns Mg']

For better guessing,  supply the output of:

 dput(z)   # We have no idea what 'Burns Mg' has in it.

Or just use an example from the zoo pages.

Also: wrapping range() around a vector formed from two elements seems  
at the very best unnecessary and at the worst positively fraught with  
downside potential. And the 'time' function does not have arguments  
names start and stop.



--
David



TIA,

Rich

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


David Winsemius, MD
West Hartford, CT

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


[R] Plot map by region using kasc and adehabitat

2011-09-20 Thread Alex Olssen
Dear R-help,

I have a raster map which has a measure of profitability of land by
parcel over several regions of geographic aggregation (think of
counties).  This data is stored in an ASCII file.  If I type

plot(profit)

I get a raster map of profit per parcel for all regions.  I want to
plot separate maps for each county.  I used kasc to combine the profit
map with a county map from a separate ASCII file.

data.kasc <- as.kasc(list(profit, county))

Can anyone help me plot profit maps for each county separately?

Kind regards,
Alex

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


Re: [R] adding labels to x,y points

2011-09-20 Thread B77S
Actually, you appear to have re-assigned your object “colon” (from
"c:\\alon.txt") with a character vector of intended row.names.

so use 

row.names(colon) <-paste("g",c(1:nrow(colon)),sep="")




B77S wrote:
> 
> I don't have access to your "alon.txt" file (see ?dput for future posts),
> but...
> 
> I'm pretty sure the info you want is not in row.names(colon[1:2])
> 
> should just be using:
> 
> text(x,y, label = colon[1:20,])  
> 
> ??
> 
> HTH
> 
> 
> 
> baumeist wrote:
>> 
>> Hi,
>> I am new to R.
>> 
>> I have a matrix that I have assigned to the object “colon”.
>> 
>>> colon<-read.table("c:\\alon.txt",header=T,row.names=1)
>> 
>> attach(colon)
>> names(colon)
>> 
>> The dimenstions are 2000   62.
>> 
>> Each of the 62 columns (titled norm1, norm2, norm3, etc) has 2000
>> different numbers (‘continuous’ values) within it.
>> 
>> I have also assigned a name for each of the 2000 rows of the dataframe
>> with a prefix (i.e. g1 …. g2000) using the code (not sure if I did this
>> right):
>> 
>>> colon<-paste("g",c(1:nrow(colon)),sep="")
>> 
>> I have plotted the first 20 values from two of the columns(samples).
>> 
>>> x<-c(norm1[1:20])
>> 
>>> y<-c(norm2[1:20])
>> 
>>> plot(x,y,type='n',xlab='x norm1 sample',ylab='y norm2
>>> sample',main='Norm1 vs Norm2 - 20
>> genes')
>> 
>>> points(x,y,pch=15,col='blue')
>> 
>> Now I wish to assign labels to each point (above each point (i.e. pos=3)
>> in the plot with “g1 to g20 corresponding to each row but I am having
>> trouble with this step.
>> 
>> I have tried:
>> 
>>> text(x,y, label = row.names(colon[1:20])) 
>> 
>> but nothing happens. 
>> 
>> Any suggestions?
>> 
>> Thanks in advance
>> MAB
>> 
> 


--
View this message in context: 
http://r.789695.n4.nabble.com/adding-labels-to-x-y-points-tp3828461p3828665.html
Sent from the R help mailing list archive at Nabble.com.

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


[R] package / function for monitoring processes?

2011-09-20 Thread Benjamin Tyner

Hi

I recall running across a function a while back which would return 
information about running processes (such as their cpu and memory 
usage), but I cannot seem to locate it. Wondering if someone would be 
kind enough to refresh my memory. I vaguely recall it was parsing the 
output of the 'ps' command.


Thanks,
Ben


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


Re: [R] Tabulating Baseline Characteristics on specific observations

2011-09-20 Thread David Winsemius

On Sep 20, 2011, at 7:37 PM, justin jarvis wrote:

> That still discards the other data columns.  For example, in the  
> data frame
>
> V1 V2 V3 V4
> 1  1  1  NA 1
> 2  1 NA  1  1
> 3  1 NA  1  1
> 4  1  11  1
> 5  1  11  1
>
> Suppose I was running a regression using V1 and V2.  R will remove  
> rows 2 and 3 due to the "NA."  I would like a way to look at only  
> the observations used for the regression, the data frame:
>
> V1 V2 V3 V4
> 1  1  1  NA 1
> 4  1  11  1
> 5  1  11  1

The use this...

dfrm[ complete.cases( subset(dfrm, select=c("V1","V2") ) , ]

complete.cases() returns a lofical vector than can be used for indexing.

-- 
David

>
> If I run na.omit(subset(dataframe, select= c(V1,V2)) it returns
>
> V1 V2
> 1  1  1
> 4  1  1
> 5  1  1
>
> Sorry for being unclear the previous time.
>
> Justin
>
> On Tue, Sep 20, 2011 at 4:54 AM, David Winsemius  > wrote:
>
> On Sep 19, 2011, at 8:49 PM, justin jarvis wrote:
>
> I have a data set with many missing observations.  When I run a
> regression, R of course discards the observations (the whole row) that
> have "NA".  I want to tabulate some baseline characteristics (column
> means) but only for the observations that R used for the regression.
> I tried to recreate this data frame by using na.omit on the original
> data frame, but this will not work as this will discard an observation
> with an "NA" in any column, and not just in the covariates.
>
> In summary, I only want to remove observations that have an "NA" in
> the covariate columns.  Something like Stata's e(sample), as far as I
>
> na.omit(subset(dfrm, select=  )  # or equivalent
>
> can tell.
>
> Justin Jarvis
> PhD student, University of California, Irvine
>
> __
> R-help@r-project.org mailing list
> https://stat.ethz.ch/mailman/listinfo/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
>
>

David Winsemius, MD
West Hartford, CT


[[alternative HTML version deleted]]

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


Re: [R] A question regarding random effects in 'aov' function

2011-09-20 Thread Weidong Gu
If different labs tested different tissue.types, I am not sure you can
effectively partition variance between labs(batches) and tissue.types.

Weidong Gu

On Tue, Sep 20, 2011 at 2:14 PM, karena  wrote:
> Hi,
>
> I am doing an analysis to see if these is tissue specific effects on the
> gene expression data .
>
> Our data were collected from 6 different labs (batch effects). lab 1 has
> tissue type 1 and tissue type 2, lab 2 has tissue 3, 4,5,6. The other labs
> has one tissue type each. The 'sample' data is as below:
>
> 
> Sample.ID     Gene      tissue.type          batch(lab)
> expression.level
> id1                gene1       liver                   batch1
> 0.67
> id1                gene2       liver                   batch1
> 0.89
> id2                gene1       kidney               batch1
> 0.52
> id2                gene2       kidney               batch1
> 0.45
> .
> .
> id10               gene1       brain                 batch4
> 0.56
> id10               gene2       brain                 batch4
> 0.97
> .
> .
> id100              gene1       skin                  batch10
> 0.98
> id100              gene2       skin                  batch 10
> 0.87
> -
>
> I am going to use 'aov' to compare the tissue-specific average of gene
> expression. 'tissue.type' is the fixed effects, 'batch' and 'Sample.ID' are
> the random effects (to control for inter-individual variation and batch
> effects). How should I  write my 'aov' function? I am not sure about the
> 'random effects' part
>
> i.e.
> fm <- aov(expression.level~tissue.type+Error(Sample.ID)+Error(batch),
> data=sample)
> ??
>
> Thank you,
>
> karena
>
> --
> View this message in context: 
> http://r.789695.n4.nabble.com/A-question-regarding-random-effects-in-aov-function-tp3827719p3827719.html
> Sent from the R help mailing list archive at Nabble.com.
>
> __
> R-help@r-project.org mailing list
> https://stat.ethz.ch/mailman/listinfo/r-help
> PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
> and provide commented, minimal, self-contained, reproducible code.
>

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


Re: [R] Strplit code

2011-09-20 Thread William Dunlap
Look at the help file for do.call.  It is
most useful when you don't know how many
arguments will be given to the function you
are calling.  E.g., if you know that the list
x is always 3 long then you can do
   rbind(x[[1]], x[[2]], x[[3]])
to make a matrix out of the components, just as
   do.call("rbind", x)
would.  If you don't know how many rows there
will be then do.call is the way to go.

Bill Dunlap
Spotfire, TIBCO Software
wdunlap tibco.com 

> -Original Message-
> From: MK [mailto:mdkz...@aol.com]
> Sent: Tuesday, September 20, 2011 5:13 PM
> To: William Dunlap
> Cc: Santosh; R help
> Subject: Re: [R] Strplit code
> 
> Pardon my ignorance, but why is the do.call necessary?  why not just execute 
> the rbind function?
> What's the advantage in putting it in a do.call "wrapper"?
> 
> On Sep 20, 2011, at 2:44 PM, William Dunlap  wrote:
> 
> > In S+  do.call's first argument must be a character string
> > that gives the name of the function, so replace
> > do.call(rbind, ...)
> > with
> >  do.call("rbind", ...)
> >
> > Bill Dunlap
> > Spotfire, TIBCO Software
> > wdunlap tibco.com
> > From: Santosh [mailto:santosh2...@gmail.com]
> > Sent: Tuesday, September 20, 2011 2:55 AM
> > To: William Dunlap; R help
> > Subject: Re: [R] Strplit code
> >
> > Dear R- Splus experts,
> > In R, I have frequently used do.call with strsplit. and I have a hard time 
> > with Splus.. any
> suggestions?
> >
> > for example, the R code below:
> >
> > do.call(rbind,strsplit(paste(letters[1:10],c(1:10))," "))
> >
> > Thanks so much,
> > Santosh
> > On Fri, Dec 5, 2008 at 8:51 AM, William Dunlap 
> > mailto:wdun...@tibco.com>> wrote:
> >  [R] Strplit code
> >  pomchip at free.fr pomchip at free.fr
> >  Wed Dec 3 20:52:21 CET 2008
> >
> >  Dear R-users,
> >
> >  The strsplit function does not exist in S-plus and I would like to
> > use it. How
> >  could I reproduce the function in Splus or access to its source code?
> >  Thank you in advance,
> >
> >  Sebastien
> > strsplit() was added to S+ 8.0 (May 2007).  At the same time
> > we changed the default regular expression style from 'basic'
> > (a.k.a. 'obsolete') to 'extended' and we added the string functions
> > sub(), gsub(), and sprintf().
> >
> > S+ 8.1 is now available (as of November 2008).
> >
> > Bill Dunlap
> > TIBCO Software Inc - Spotfire Division
> > wdunlap tibco.com
> >
> > __
> > R-help@r-project.org mailing list
> > https://stat.ethz.ch/mailman/listinfo/r-help
> > PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
> > and provide commented, minimal, self-contained, reproducible code.
> >
> >
> >[[alternative HTML version deleted]]
> >
> > __
> > R-help@r-project.org mailing list
> > https://stat.ethz.ch/mailman/listinfo/r-help
> > PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
> > and provide commented, minimal, self-contained, reproducible code.

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


Re: [R] adding labels to x,y points

2011-09-20 Thread B77S
I don't have access to your "alon.txt" file (see ?dput for future posts),
but...

I'm pretty sure info you want isn't in row.names(colon[1:2])
it should just be 

text(x,y, label = colon[1:20]) 


??
HTH



baumeist wrote:
> 
> Hi,
> I am new to R.
> 
> I have a matrix that I have assigned to the object “colon”.
> 
>> colon<-read.table("c:\\alon.txt",header=T,row.names=1)
> 
> attach(colon)
> names(colon)
> 
> The dimenstions are 2000   62.
> 
> Each of the 62 columns (titled norm1, norm2, norm3, etc) has 2000
> different numbers (‘continuous’ values) within it.
> 
> I have also assigned a name for each of the 2000 rows of the dataframe
> with a prefix (i.e. g1 …. g2000) using the code (not sure if I did this
> right):
> 
>> colon<-paste("g",c(1:nrow(colon)),sep="")
> 
> I have plotted the first 20 values from two of the columns(samples).
> 
>> x<-c(norm1[1:20])
> 
>> y<-c(norm2[1:20])
> 
>> plot(x,y,type='n',xlab='x norm1 sample',ylab='y norm2 sample',main='Norm1
>> vs Norm2 - 20
> genes')
> 
>> points(x,y,pch=15,col='blue')
> 
> Now I wish to assign labels to each point (above each point (i.e. pos=3)
> in the plot with “g1 to g20 corresponding to each row but I am having
> trouble with this step.
> 
> I have tried:
> 
>> text(x,y, label = row.names(colon[1:20])) 
> 
> but nothing happens. 
> 
> Any suggestions?
> 
> Thanks in advance
> MAB
> 


--
View this message in context: 
http://r.789695.n4.nabble.com/adding-labels-to-x-y-points-tp3828461p3828545.html
Sent from the R help mailing list archive at Nabble.com.

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


Re: [R] Tabulating Baseline Characteristics on specific observations

2011-09-20 Thread William Dunlap
You could use the na.action function on the fitted
object to see which observations were omitted.  E.g.,
let's make a data.frame that we can actually do some
regressions with and try na.action():

  > d <- data.frame(V1=11:15, V2=log(c(1,NA,NA,4,5)), V3=sqrt((-1):3), 
V4=sin(1:5))
  Warning message:
  In sqrt((-1):3) : NaNs produced
  > d
V1   V2   V3 V4
  1 11 0.00  NaN  0.8414710
  2 12   NA 0.00  0.9092974
  3 13   NA 1.00  0.1411200
  4 14 1.386294 1.414214 -0.7568025
  5 15 1.609438 1.732051 -0.9589243
  > fit12 <- lm(V1 ~ V2, data=d, na.action=na.omit)
  > if (length(na.action(fit12))>0) d[-na.action(fit12), ] else d
V1   V2   V3 V4
  1 11 0.00  NaN  0.8414710
  4 14 1.386294 1.414214 -0.7568025
  5 15 1.609438 1.732051 -0.9589243

You can also call na.action on the output of na.omit (or
na.exclude) itself, but then you have to remember which
variables were in the model.

Bill Dunlap
Spotfire, TIBCO Software
wdunlap tibco.com 

> -Original Message-
> From: r-help-boun...@r-project.org [mailto:r-help-boun...@r-project.org] On 
> Behalf Of justin jarvis
> Sent: Tuesday, September 20, 2011 4:38 PM
> To: David Winsemius
> Cc: r-help@r-project.org
> Subject: Re: [R] Tabulating Baseline Characteristics on specific observations
> 
> That still discards the other data columns.  For example, in the data frame
> 
> V1 V2 V3 V4
> 1  1  1  NA 1
> 2  1 NA  1  1
> 3  1 NA  1  1
> 4  1  11  1
> 5  1  11  1
> 
> Suppose I was running a regression using V1 and V2.  R will remove rows 2
> and 3 due to the "NA."  I would like a way to look at only the observations
> used for the regression, the data frame:
> 
> V1 V2 V3 V4
> 1  1  1  NA 1
> 4  1  11  1
> 5  1  11  1
> 
> If I run na.omit(subset(dataframe, select= c(V1,V2)) it returns
> 
> V1 V2
> 1  1  1
> 4  1  1
> 5  1  1
> 
> Sorry for being unclear the previous time.
> 
> Justin
> 
> On Tue, Sep 20, 2011 at 4:54 AM, David Winsemius 
> wrote:
> 
> >
> > On Sep 19, 2011, at 8:49 PM, justin jarvis wrote:
> >
> >  I have a data set with many missing observations.  When I run a
> >> regression, R of course discards the observations (the whole row) that
> >> have "NA".  I want to tabulate some baseline characteristics (column
> >> means) but only for the observations that R used for the regression.
> >> I tried to recreate this data frame by using na.omit on the original
> >> data frame, but this will not work as this will discard an observation
> >> with an "NA" in any column, and not just in the covariates.
> >>
> >> In summary, I only want to remove observations that have an "NA" in
> >> the covariate columns.  Something like Stata's e(sample), as far as I
> >>
> >
> > na.omit(subset(dfrm, select=  )  # or equivalent
> >
> >  can tell.
> >>
> >> Justin Jarvis
> >> PhD student, University of California, Irvine
> >>
> >> __**
> >> R-help@r-project.org mailing list
> >> https://stat.ethz.ch/mailman/**listinfo/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
> >
> >
> 
>   [[alternative HTML version deleted]]
> 
> __
> R-help@r-project.org mailing list
> https://stat.ethz.ch/mailman/listinfo/r-help
> PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
> and provide commented, minimal, self-contained, reproducible code.

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


Re: [R] Strplit code

2011-09-20 Thread MK
Pardon my ignorance, but why is the do.call necessary?  why not just execute 
the rbind function?  What's the advantage in putting it in a do.call "wrapper"? 

On Sep 20, 2011, at 2:44 PM, William Dunlap  wrote:

> In S+  do.call's first argument must be a character string
> that gives the name of the function, so replace
> do.call(rbind, ...)
> with
>  do.call("rbind", ...)
> 
> Bill Dunlap
> Spotfire, TIBCO Software
> wdunlap tibco.com
> From: Santosh [mailto:santosh2...@gmail.com]
> Sent: Tuesday, September 20, 2011 2:55 AM
> To: William Dunlap; R help
> Subject: Re: [R] Strplit code
> 
> Dear R- Splus experts,
> In R, I have frequently used do.call with strsplit. and I have a hard time 
> with Splus.. any suggestions?
> 
> for example, the R code below:
> 
> do.call(rbind,strsplit(paste(letters[1:10],c(1:10))," "))
> 
> Thanks so much,
> Santosh
> On Fri, Dec 5, 2008 at 8:51 AM, William Dunlap 
> mailto:wdun...@tibco.com>> wrote:
>  [R] Strplit code
>  pomchip at free.fr pomchip at free.fr
>  Wed Dec 3 20:52:21 CET 2008
> 
>  Dear R-users,
> 
>  The strsplit function does not exist in S-plus and I would like to
> use it. How
>  could I reproduce the function in Splus or access to its source code?
>  Thank you in advance,
> 
>  Sebastien
> strsplit() was added to S+ 8.0 (May 2007).  At the same time
> we changed the default regular expression style from 'basic'
> (a.k.a. 'obsolete') to 'extended' and we added the string functions
> sub(), gsub(), and sprintf().
> 
> S+ 8.1 is now available (as of November 2008).
> 
> Bill Dunlap
> TIBCO Software Inc - Spotfire Division
> wdunlap tibco.com
> 
> __
> R-help@r-project.org mailing list
> https://stat.ethz.ch/mailman/listinfo/r-help
> PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
> and provide commented, minimal, self-contained, reproducible code.
> 
> 
>[[alternative HTML version deleted]]
> 
> __
> R-help@r-project.org mailing list
> https://stat.ethz.ch/mailman/listinfo/r-help
> PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
> and provide commented, minimal, self-contained, reproducible code.

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


Re: [R] Tabulating Baseline Characteristics on specific observations

2011-09-20 Thread justin jarvis
That still discards the other data columns.  For example, in the data frame

V1 V2 V3 V4
1  1  1  NA 1
2  1 NA  1  1
3  1 NA  1  1
4  1  11  1
5  1  11  1

Suppose I was running a regression using V1 and V2.  R will remove rows 2
and 3 due to the "NA."  I would like a way to look at only the observations
used for the regression, the data frame:

V1 V2 V3 V4
1  1  1  NA 1
4  1  11  1
5  1  11  1

If I run na.omit(subset(dataframe, select= c(V1,V2)) it returns

V1 V2
1  1  1
4  1  1
5  1  1

Sorry for being unclear the previous time.

Justin

On Tue, Sep 20, 2011 at 4:54 AM, David Winsemius wrote:

>
> On Sep 19, 2011, at 8:49 PM, justin jarvis wrote:
>
>  I have a data set with many missing observations.  When I run a
>> regression, R of course discards the observations (the whole row) that
>> have "NA".  I want to tabulate some baseline characteristics (column
>> means) but only for the observations that R used for the regression.
>> I tried to recreate this data frame by using na.omit on the original
>> data frame, but this will not work as this will discard an observation
>> with an "NA" in any column, and not just in the covariates.
>>
>> In summary, I only want to remove observations that have an "NA" in
>> the covariate columns.  Something like Stata's e(sample), as far as I
>>
>
> na.omit(subset(dfrm, select=  )  # or equivalent
>
>  can tell.
>>
>> Justin Jarvis
>> PhD student, University of California, Irvine
>>
>> __**
>> R-help@r-project.org mailing list
>> https://stat.ethz.ch/mailman/**listinfo/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
>
>

[[alternative HTML version deleted]]

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


Re: [R] Works from CLI but not from prompt

2011-09-20 Thread Henri-Paul Indiogine
Greetings!

2011/9/20 David Winsemius :

There is probably an environment/scoping problem as you stated.  I am
using ESS and org-mode.

I started a new R code block and the problem disappeared.

Thanks for your kind feedback.

Henri-Paul


-- 
Henri-Paul Indiogine

Curriculum & Instruction
Texas A&M University
TutorFind Learning Centre

Email: hindiog...@gmail.com
Skype: hindiogine
Website: http://people.cehd.tamu.edu/~sindiogine

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


Re: [R] NLS error

2011-09-20 Thread Ben Bolker
Diviya Smith  gmail.com> writes:

> 
> I dont think *r* is related to the problem. I am not trying to 
> estimate *r* and
> so basically I am giving the model the correct value of *r* and so log(1-r)
> should not go to infinity.
> 
> For test data, I generate data from the same model and add noise (using *r
> norm*), with the following parameters -
> A <- 20
> > B <- 500
> > r <- 0.6881
> > d <- (1:1000)/1000

 [snip snip snip snip]

 The quick and dirty way to deal with this would be to wrap your
nls() attempts in try() (see ?try), and throw away any cases where
things went wrong.
  That of course avoids the problem rather than resolving it, which
you might not want to do.
  The way through this if you do need to know exactly what's going on
is to either set.seed() in a systematic way or save the data each time
before you try to run nls() so that you can recover a data set where
nls() fails.  Then instrument your functions, or use any tracing options
in nls(), to figure out at exactly what point the derivative gives
a non-finite value, and then why -- and then you may be able to figure
out how to fix or work around the problem.  It is probably, as Jean
suggested, some sort of underflow/overflow problem.

__
R-help@r-project.org mailing list
https://stat.ethz.ch/mailman/listinfo/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] Specifying Start/End Dates for X-axis Range in plot()/xyplot()

2011-09-20 Thread Rich Shepard

  I'm having difficulty finding the syntax to use to specify the beginning
and ending dates for the x-axis while plotting a zoo object. I thought that
I had seen a message on this list that used start=as.Date("...")
end=as.Date("..."), but I cannot find that message. I've tried ?plot,
?plotxy, ?plot.zoo, and Sarkar's lattice book.

  I am trying to plot the time series for 'Burns Mg' generated by:


sapply(names(z), function(nm) range(time(na.omit(z[, nm]))), simplify = FALSE)

$`Burns Mg`[1] "1994-01-20" "2009-11-11"

  This is a typical result of my trial-and-error approach:


plot(z[, $'Burns Mg'], range(time(start = as.Date("1994-01-20"), end = 
as.Date("2009-11-11"

Error in is.matrix(x) : 'x' is missing

  Please point me to documentation on specifying

TIA,

Rich

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


Re: [R] Works from CLI but not from prompt

2011-09-20 Thread David Winsemius


On Sep 20, 2011, at 6:49 PM, Henri-Paul Indiogine wrote:


My objective is to define a pattern for a grep() statement.

Thanks,
Henri-Paul


You are not illustrating the problem with enough detail to determine  
the source of your errors. The errors do not appear when tested in  
what appears to be the obvious manner:


> pt1  <- "[Aa]ccountability"
> grep(pt1, "accountability")
[1] 1
> grep(pt1, "Accountability")
[1] 1
> grep(pt1, "countability")
integer(0)

An old advertisement in TV in the US used to ask: "Where's the Beef?"

--

David Winsemius, MD
West Hartford, CT

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


Re: [R] Works from CLI but not from prompt

2011-09-20 Thread R. Michael Weylandt
Can you perhaps provide us a minimal working script in which this assignment
doesn't happen? If it really is just the line

pattern <- "[Aa]ccountability"

in the main body of the script, I can't for the life of me guess why it
wouldn't work. General keywords that come to mind are things like
"environment" and "scoping" though

Michael Weylandt



On Tue, Sep 20, 2011 at 6:49 PM, Henri-Paul Indiogine
wrote:

> My objective is to define a pattern for a grep() statement.
>
> Thanks,
> Henri-Paul
>
>
>
> --
> Henri-Paul Indiogine
>
> Curriculum & Instruction
> Texas A&M University
> TutorFind Learning Centre
>
> Email: hindiog...@gmail.com
> Skype: hindiogine
> Website: http://people.cehd.tamu.edu/~sindiogine
>
> __
> R-help@r-project.org mailing list
> https://stat.ethz.ch/mailman/listinfo/r-help
> PLEASE do read the posting guide
> http://www.R-project.org/posting-guide.html
> and provide commented, minimal, self-contained, reproducible code.
>

[[alternative HTML version deleted]]

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


Re: [R] Works from CLI but not from prompt

2011-09-20 Thread Henri-Paul Indiogine
My objective is to define a pattern for a grep() statement.

Thanks,
Henri-Paul



-- 
Henri-Paul Indiogine

Curriculum & Instruction
Texas A&M University
TutorFind Learning Centre

Email: hindiog...@gmail.com
Skype: hindiogine
Website: http://people.cehd.tamu.edu/~sindiogine

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


Re: [R] Works from CLI but not from prompt

2011-09-20 Thread Henri-Paul Indiogine
Hi Sarah!

2011/9/20 Sarah Goslee :
>> What works? Assigning a string to a function, thus replacing the
>> function in your search
>> path?

Bad choice for character variable name on my part.  How about this?

pattern <- "[Aa]ccountability"

If I enter this at the CLI and then type "pattern", R returns
"[Aa]ccountability"

I I put this statement in a script then the variable "pattern" is not created.

Thanks,

-- 
Henri-Paul Indiogine

Curriculum & Instruction
Texas A&M University
TutorFind Learning Centre

Email: hindiog...@gmail.com
Skype: hindiogine
Website: http://people.cehd.tamu.edu/~sindiogine

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


Re: [R] Works from CLI but not from prompt

2011-09-20 Thread Sarah Goslee
My apologies: not the name of a function, despite ?regexp having a return value.

But the rest of my questions are still relevant.

On Tue, Sep 20, 2011 at 6:32 PM, Sarah Goslee  wrote:
> What works? Assigning a string to a function, thus replacing the
> function in your search
> path?
>
> Or is that what doesn't work?
>
> What do you expect? What are you trying to do? Using what commands?
>
> Sarah
>
> On Tue, Sep 20, 2011 at 6:19 PM, Henri-Paul Indiogine
>  wrote:
>> Greegings!
>>
>> Any idea why this works from the command line, but not from a source
>> file?  This is driving me (more) insane.
>>
>> regexp <- "[Aa]ccountability"
>>
>>
>> Thanks!
>>
>> --
>> Henri-Paul Indiogine
>>
> --

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


Re: [R] Works from CLI but not from prompt

2011-09-20 Thread Sarah Goslee
What works? Assigning a string to a function, thus replacing the
function in your search
path?

Or is that what doesn't work?

What do you expect? What are you trying to do? Using what commands?

Sarah

On Tue, Sep 20, 2011 at 6:19 PM, Henri-Paul Indiogine
 wrote:
> Greegings!
>
> Any idea why this works from the command line, but not from a source
> file?  This is driving me (more) insane.
>
> regexp <- "[Aa]ccountability"
>
>
> Thanks!
>
> --
> Henri-Paul Indiogine
>
-- 
Sarah Goslee
http://www.functionaldiversity.org

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


Re: [R] help in interpreting paired t-test

2011-09-20 Thread Ted Harding
Further to the plot suggested below, the plot

  plot(log(A),log(B/A),pch="+",col="blue")

reveals an interesting structure to the data. Distinct curved
sequences are clearly visible. While their curved form is a
consequence of the fact that, for large A, A/B is close to 1
and so they tend to approach 1 "asymptotically" (hence the
curving over towards flatness), what is really interesting
is the appearance of distinct curves, as if there were at least
7 (or at least 8) distinct subsets to the data, each subset
following a different curve. Perhaps these are related to
observed variables?

Ted.

On 20-Sep-11 18:15:50, Ted Harding wrote:
> As can be seen by plotting as follows:
> 
>   plot(A,B,pch="+",col="blue")   ## The raw data
> 
>   plot(A,B-A,pch="+",col="blue") ## The differences versus A
>   lines(c(0,0.7),c(0,0))
> 
> Ted.
> 
> On 20-Sep-11 17:54:15, Timothy Bates wrote:
>> Yes, in over 3/4s of the data points A is > B… which suggests the A
>> measure is reading higher than the B measuring system.
>> 
>> length(A[A>B])/length(A)
>> 
>> 
>> On 20 Sep 2011, at 6:46 PM, Pedro Mardones wrote:
>> 
>>> Dear all;
>>> 
>>> A very basic question. I have the following data:
>>> 
>>> **
>>> *
>>> *
>>> 
>>> A <- 1/1000*c(347,328,129,122,18,57,105,188,57,257,53,108,336,163,
>>> 62,112,334,249,45,244,211,175,174,26,375,346,153,32,
>>> 89,32,358,202,123,131,88,36,30,67,96,135,219,122,
>>> 89,117,86,169,179,54,48,40,54,568,664,277,91,290,
>>> 116,80,107,401,225,517,90,133,36,50,174,103,192,150,
>>> 225,29,80,199,55,258,97,109,137,90,236,109,204,160,
>>> 95,54,50,78,98,141,508,144,434,100,37,22,304,175,
>>> 72,71,111,60,212,73,50,92,70,148,28,63,46,85,
>>> 111,67,234,65,92,59,118,202,21,17,95,86,296,45,
>>> 139,32,21,70,185,172,151,129,42,14,13,75,303,119,
>>> 128,106,224,241,112,395,78,89,247,122,212,61,165,30,
>>> 65,261,415,159,316,182,141,184,124,223,39,141,103,149,
>>> 104,71,259,86,85,214,96,246,306,11,129)
>>> 
>>> B <- 1/1000*c(351,313,130,119,17,50,105,181,58,255,51,98,335,162,
>>> 60,108,325,240,44,242,208,168,170,27,356,341,150,31,
>>> 85,29,363,185,124,131,85,35,27,63,92,147,217,117,
>>> 87,119,81,161,178,53,45,38,50,581,661,254,87,281,
>>> 110,76,100,401,220,507,94,123,36,47,154,99,184,146,
>>> 232,26,77,193,53,264,94,110,128,87,231,110,195,156,
>>> 95,51,50,75,93,134,519,139,435,96,37,21,293,169,
>>> 70,80,104,64,210,70,48,88,67,140,26,52,45,90,
>>> 106,63,219,62,91,56,113,187,18,14,95,86,284,39,
>>> 132,31,22,69,181,167,150,117,42,14,11,73,303,109,
>>> 129,106,227,249,111,409,71,88,256,120,200,60,159,27,
>>> 63,268,389,150,311,175,136,171,116,220,30,145,95,148,
>>> 102,70,251,88,83,199,94,245,305,9,129)
>>> 
>>> **
>>> *
>>> *
>>> 
>>> plot(A,B)
>>> abline(0,1)
>>> 
>>> At a glance, the data look very similar. Data A and B are two
>>> measurements of the same variable but using different devices (on a
>>> same set of subjects). Thus, I thought that a paired t-test could be
>>> appropriate to check if the diff between measurement devices = 0.
>>> 
>>> t.test(A-B)
>>> 
>>> **
>>> *
>>> *
>>> 
>>> One Sample t-test
>>> 
>>> data:  A - B
>>> t = 7.6276, df = 178, p-value = 1.387e-12
>>> alternative hypothesis: true mean is not equal to 0
>>> 95 percent confidence interval:
>>> 0.002451622 0.004162903
>>> sample estimates:
>>>  mean of x
>>> 0.003307263
>>> 
>>> **
>>> *
>>> *
>>> The mean diff is 0.0033 but the p-value indicates a strong evidence
>>> to
>>> reject H0.
>>> 
>>> I was expecting to find no differences so I'm wondering whether the
>>> t-test is the appropriate test to use. I'll appreciate any comments
>>> or
>>> suggestions.
> 
> 
> E-Mail: (Ted Harding) 
> Fax-to-email: +44 (0)870 094 0861
> Date: 20-Sep-11   Time: 19:15:47
> -- XFMail --
> 
> __
> R-help@r-project.org mailing list
> https://stat.ethz.ch/mailman/listinfo/r-help
> PLEASE do read the posting guide
> http://www.R-project.org/posting-guide.html
> and provide commented, minimal, self-contained, reproducible code.


E-Mail: (Ted Harding) 
Fax-to-email: +44 (0)870 094 0861
Date: 20-Sep-11   Time: 23:26:53
-- XFMail --

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

Re: [R] Install Location on Linux Red Hat

2011-09-20 Thread Marc Schwartz
On Sep 20, 2011, at 4:02 PM, Darrel Barbato wrote:

> Hi,
> I'm having some difficulty installing R on our server which is running
> RHEL (Red Hat Enterprise Linux) 5.2. I'm using RPM (Red Hat Package
> Manager) and by default it installs R in /usr/bin. Unfortunately due
> to a very small partition size, I have run out of space in this
> directory. I was hoping to install R in another location such as
> /data. I'm wondering if anyone else has run across this issue and
> knows of anyway around it.
> Thanks.
> Darrel



Typically, the RPMs for RHEL/CentOS and Fedora are not relocatable and will 
only install to the default location.

Thus, you will likely need to compile R from source in order to install 
elsewhere. You should review the R Installation and Administration manual, 
available online:

  http://cran.r-project.org/doc/manuals/R-admin.html

If you require further technical assistance, you should subscribe and post to 
the R-SIG-Fedora list:

  https://stat.ethz.ch/mailman/listinfo/r-sig-fedora

HTH,

Marc Schwartz

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


[R] Works from CLI but not from prompt

2011-09-20 Thread Henri-Paul Indiogine
Greegings!

Any idea why this works from the command line, but not from a source
file?  This is driving me (more) insane.

regexp <- "[Aa]ccountability"


Thanks!

-- 
Henri-Paul Indiogine

Curriculum & Instruction
Texas A&M University
TutorFind Learning Centre

Email: hindiog...@gmail.com
Skype: hindiogine
Website: http://people.cehd.tamu.edu/~sindiogine

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


Re: [R] NLS error

2011-09-20 Thread Diviya Smith
I dont think *r* is related to the problem. I am not trying to estimate *r* and
so basically I am giving the model the correct value of *r* and so log(1-r)
should not go to infinity.

For test data, I generate data from the same model and add noise (using *r
norm*), with the following parameters -
A <- 20
> B <- 500
> r <- 0.6881
> d <- (1:1000)/1000
> y
<- 
(rnorm(d)*0.005)+(((log(1-r))*exp(-A*d)*(-1+r+exp(d*(A-B)))/(r*(-A*+d*B+log(1-r)

And then I try estimating A, B and C (Note: C is capturing the noise term,
and I am specifying r and d) but I get the following error -
Error in numericDeriv(form[[3L]], names(ind), env) :
Missing value or an infinity produced when evaluating the model

Any suggestions how to fix this?

Diviya


On Tue, Sep 20, 2011 at 2:37 PM, Jean V Adams  wrote:

>
> Diviya Smith wrote on 09/20/2011 01:03:22 PM:
>
> >
> > Hello there,
> >
> > I am using NLS for fitting a complex model to some data to estimate a
> couple
> > of the missing parameters. The model is -
> > y ~
> (C+((log(1-r))*exp(-A*d)*(-1+r+exp(d*(A-B)))/(r*(-A*d+d*B+log(1-r)
> > where A, B and C are unknown.
> >
> > In order to test the model, I generate data by setting values for all
> > parameters and add some noise (C).
> >
> > A <- 20
> > B <- 500
> > r <- 0.6881
> > d <- (1:1000)/1000
> > y ~
> > (rnorm(d)*0.005)+(((log(1-r))*exp(-A*d)*(-1+r+exp(d*(A-B)))/(r*(-A*d
> > +d*B+log(1-r)
> >
> > I use Deoptim package to pick the optimum starting values. The model
> works
> > fine in most cases, but every now and again, I get the following error -
> > Error in numericDeriv(form[[3L]], names(ind), env) :
> >   Missing value or an infinity produced when evaluating the model
> >
> > Any suggestions on how I can resolve this? Can you suggest a better way
> for
> > picking the starting parameters?
> >
> > Thanks,
> > Diviya
>
>
> I'm not sure if this is the problem, but if r grows greater than 1,
> log(1-r) will be undefined, and you'll get an error.  You can impose a
> constraint on r by rewriting your formula in terms of a variable that can
> take on any real value:
> R = log(1-r)
>
> So,
> replace log(1-r) in your formula with R,
> replace (-1 + r) with -exp(R), and
> replace r with 1 - exp(R):
> y ~ (C+(R*exp(-A*d)*(-exp(R)+exp(d*(A-B)))/((1 - exp(R))*(-A*d+d*B+R
>
> If that doesn't fix the problem, then you are likely getting infinite
> values as result of large numbers in your exponents.  Without example data
> to work through, I can only speculate.
>
> Jean

[[alternative HTML version deleted]]

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


[R] Can R be installed in a Hyper-V environment?

2011-09-20 Thread McDonough, Tim
We are contemplating the installation of R on a Windows server with Hyper-V but 
we can't find any information on whether it can be done.










This transmission is intended solely for the person or organization to whom it 
is addressed and it may contain privileged and confidential information. If you 
are not the intended recipient you should not copy, distribute or take any 
action in reliance on it. If you believe you received this transmission in 
error please notify the sender.



[[alternative HTML version deleted]]

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


[R] Install Location on Linux Red Hat

2011-09-20 Thread Darrel Barbato
Hi,
I'm having some difficulty installing R on our server which is running
RHEL (Red Hat Enterprise Linux) 5.2. I'm using RPM (Red Hat Package
Manager) and by default it installs R in /usr/bin. Unfortunately due
to a very small partition size, I have run out of space in this
directory. I was hoping to install R in another location such as
/data. I'm wondering if anyone else has run across this issue and
knows of anyway around it.
Thanks.
Darrel

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

2011-09-20 Thread tm
Hi there,

I have the following problem on my macbook air with mac os x lion on it.
when any program tries to load the tcltk library the R GUI or R command line
freezes. also happens if I just use library(tcltk)

changing versions of tcltk and/or R doesn't help. currently I have the
following:
R version 2.13.2 beta (2011-09-19 r57030)
tcltk 8.5.10

any suggestions?

thanks a lot already,
t.

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

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


[R] R Programming and Development - EMBL Heidelberg, 28-29 November 2011

2011-09-20 Thread Laurent Gatto
Might be of interest to list subscribers:

EMBL Advanced Course
R Programming and Development
EMBL Heidelberg, Germany
Monday 28 November - Tuesday 29 November 2011

The course will focus on two aspects of R programming and development.
In the first part, we will introduce object-oriented programming using
R's S3 and S4 system and describe how to define classes, generic
functions and implement specific methods. We will also briefly present
the S4 Reference Classes. The second part will focus on R package
development, including documentation, debugging, code profiling and
unit testing. These topics will be illustrated using a small real-life
bioinformatical case study to produce, at the end of the course, a
fully fledged Bioconductor compliant R package.

http://www.embl.de/training/events/2011/RPD11-01/index.html

The registration deadline is 22 September 2011 (perhaps can be
extended a few days if places are left).


--
Laurent Gatto
University of Cambridge

__
R-help@r-project.org mailing list
https://stat.ethz.ch/mailman/listinfo/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] A question regarding random effects in 'aov' function

2011-09-20 Thread karena
Hi,

I am doing an analysis to see if these is tissue specific effects on the
gene expression data .

Our data were collected from 6 different labs (batch effects). lab 1 has
tissue type 1 and tissue type 2, lab 2 has tissue 3, 4,5,6. The other labs
has one tissue type each. The 'sample' data is as below:


Sample.ID Gene  tissue.type  batch(lab)   
expression.level
id1gene1   liver   batch1 
0.67
id1gene2   liver   batch1 
0.89
id2gene1   kidney   batch1 
0.52
id2gene2   kidney   batch1 
0.45
.
.
id10   gene1   brain batch4 
0.56
id10   gene2   brain batch4 
0.97
.
.
id100  gene1   skin  batch10   
0.98
id100  gene2   skin  batch 10  
0.87
-

I am going to use 'aov' to compare the tissue-specific average of gene
expression. 'tissue.type' is the fixed effects, 'batch' and 'Sample.ID' are
the random effects (to control for inter-individual variation and batch
effects). How should I  write my 'aov' function? I am not sure about the
'random effects' part

i.e.
fm <- aov(expression.level~tissue.type+Error(Sample.ID)+Error(batch),
data=sample) 
??

Thank you,

karena

--
View this message in context: 
http://r.789695.n4.nabble.com/A-question-regarding-random-effects-in-aov-function-tp3827719p3827719.html
Sent from the R help mailing list archive at Nabble.com.

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


Re: [R] Multivariate spline regression and predicted values

2011-09-20 Thread Max Farrell
Thank you for the reply, it looks like the second option (te) will
work perfectly!

Max

On Tue, Sep 20, 2011 at 2:39 PM, Max Farrell  wrote:
> One possibility is
>
> library(mgcv)
>
> ## isotropic thin plate spline smoother
> b <- gam(Y~s(X[,1],X[,2]))
> predict(b,newdata=list(X=W))
>
> ## tensor product smoother
> b <- gam(Y~te(X[,1],X[,2]))
> predict(b,newdata=list(X=W))
>
> ## variant tensor product smoother
> b <- gam(Y~t2(X[,1],X[,2]))
> predict(b,newdata=list(X=W))
>
> ... these would all result in penalized regression spline fits with
> smoothing parameters estimated (by GCV, by default). If you don't want
> penalization then use, e.g. s(X[,1],X[,2],fx=TRUE) to get pure
> regression spline (`k' argument to s, te and t2 controls spline basis
> dimension --- see docs).
>
> best,
> simon
>
> On 09/20/2011 03:11 PM, Max Farrell wrote:
>> Hello,
>>
>> I am trying to estimate a multivariate regression of Y on X with
>> regression splines. Y is (nx1), and X is (nxd), with d>1. I assume the
>> data is generated by some unknown regression function f(X), as in Y =
>> f(X) + u, where u is some well-behaved regression error. I want to
>> estimate f(X) via regression splines (tensor product splines). Then, I
>> want to get the predicted values for some new points W.
>>
>> To be concrete, here is an example of what I want:
>>
>> #dimensions of the model
>> d=2
>> n=1000
>> #some random data
>> X<- matrix(runif(d*n,-2,2),n,d)
>> U<- rnorm(n)
>> Y<- X[,1] + X[,2] + U
>> # a new point for prediction
>> W<- matrix(rep(0),1,d)
>>
>> Now if I wanted to use local polynomials instead of splines, I could
>> load the 'locfit' package and run (something like):
>>
>> lp.results<- 
>> smooth.lf(X,Y,kern="epan",kt="prod",deg=1,alpha=c(0,0.25,0),xev=W,direct=TRUE)$y
>>
>> Or, if X was univariate (ie d=1), I could use (something like):
>>
>> spl.results<- predict(smooth.spline(X,Y, nknots=6),W)
>>
>> But smooth.spline only works for univariate data. I looked at the
>> "crs" package, and it at least will fit the multivariate spline, but I
>> don't see how to predict the new data from this. That is, I run a
>> command like:
>>
>> spl.fit<- crs(Y~X[,1] + X[,2],basis="tensor",
>> degree=c(3,3),segments=c(4,4),degree.min=3,degree.max=3, kernel=FALSE,
>> cv="none",knots="uniform",prune=FALSE)
>>
>> Then what?
>>
>> What I really want is the spline version of the smooth.lf command
>> above, or the multivariate version of smooth.spline. Any ideas/help?
>>
>> Thanks,
>> Max
>>
>> __
>> 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@r-project.org mailing list
https://stat.ethz.ch/mailman/listinfo/r-help
PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
and provide commented, minimal, self-contained, reproducible code.


Re: [R] How to transfer variable names to column names?

2011-09-20 Thread R. Michael Weylandt
The following untested code might also be of some help to you:

x = data.frame(x = 1:5)
y = data.frame(y = 1:10)
z = data.frame(z = 1:3)
a = rnorm(50)
b = function(x) x^2

makeRowFrame <- function(){
n <- ls(envir = .GlobalEnv)
tempFunc <- function(VARIABLE){
VARIABLEM <- get(VARIABLE)
if(!is.data.frame(VARIABLEM)) return(invisible(NULL))
VARIABLEM <- matrix(NROW(VARIABLEM))
colnames(VARIABLEM) <- VARIABLE
return(VARIABLEM)
}
return(unlist(sapply(n, tempFunc)))
}

It provides a function that searches your workspace for all data frames and
produces a new object with names of each of the available data frames and
the number of rows in each of them. It should skip things that aren't data
frames.

Let me know if it doesn't work and I'll debug it further.

Michael Weylandt

On Tue, Sep 20, 2011 at 2:28 PM, Sarah Goslee wrote:

> Hi Kelly,
>
> c() creates a vector. You need data.frame() instead.
>
> dfIntron <- c(mC_Explant=nrow(mC_Explant), mC_Callus=nrow(mC_Callus),
> mC_RegenPlant=nrow(mC_RegenPlant)) # set colnames simultaneously.
>
> Sarah
>
> On Tue, Sep 20, 2011 at 2:23 PM, Vining, Kelly
>  wrote:
> > Hello R users,
> > I have a set of data frames for which I am tallying row numbers, as shown
> below.
> >
> >> nrow(mC_Explant)
> > [1] 14480
> >> nrow(mC_Callus)
> > [1] 23320
> >> nrow(mC_RegenPlant)
> > [1] 8108
> >
> > etc.
> >
> > I want to create a new data frame which has the variable names as column
> headings, and then a single row with the nrow tallies. My first step was
> this:
> >
> > dfIntron <- c(nrow(mC_Explant), nrow(mC_Callus), nrow(mC_RegenPlant))
> >
> > Then, to set the column names, I tried this, and got the following error:
> >
> >  colnames(dfIntron) <- c("mC_Explant", "mC_Callus", "mC_RegenPlant")
> > Error in `colnames<-`(`*tmp*`, value = c("mC_Explant", "mC_Callus",
> "mC_RegenPlant" :
> >  attempt to set colnames on object with less than two dimensions
> >
> > Even my first step seems wildly inefficient, and obviously doesn't work.
> There must be a simple way to do this, but I can't use table(), for example,
> as there are multiple data frames.
> >
> > Any help will be appreciated.
> >
> > --Kelly V.
> >
> >
>
> --
> Sarah Goslee
> http://www.functionaldiversity.org
>
> __
> R-help@r-project.org mailing list
> https://stat.ethz.ch/mailman/listinfo/r-help
> PLEASE do read the posting guide
> http://www.R-project.org/posting-guide.html
> and provide commented, minimal, self-contained, reproducible code.
>

[[alternative HTML version deleted]]

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


Re: [R] Strplit code

2011-09-20 Thread William Dunlap
In S+  do.call's first argument must be a character string
that gives the name of the function, so replace
do.call(rbind, ...)
with
  do.call("rbind", ...)

Bill Dunlap
Spotfire, TIBCO Software
wdunlap tibco.com
From: Santosh [mailto:santosh2...@gmail.com]
Sent: Tuesday, September 20, 2011 2:55 AM
To: William Dunlap; R help
Subject: Re: [R] Strplit code

Dear R- Splus experts,
In R, I have frequently used do.call with strsplit. and I have a hard time with 
Splus.. any suggestions?

for example, the R code below:

do.call(rbind,strsplit(paste(letters[1:10],c(1:10))," "))

Thanks so much,
Santosh
On Fri, Dec 5, 2008 at 8:51 AM, William Dunlap 
mailto:wdun...@tibco.com>> wrote:
  [R] Strplit code
  pomchip at free.fr pomchip at free.fr
  Wed Dec 3 20:52:21 CET 2008

  Dear R-users,

  The strsplit function does not exist in S-plus and I would like to
use it. How
  could I reproduce the function in Splus or access to its source code?
  Thank you in advance,

  Sebastien
strsplit() was added to S+ 8.0 (May 2007).  At the same time
we changed the default regular expression style from 'basic'
(a.k.a. 'obsolete') to 'extended' and we added the string functions
sub(), gsub(), and sprintf().

S+ 8.1 is now available (as of November 2008).

Bill Dunlap
TIBCO Software Inc - Spotfire Division
wdunlap tibco.com

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


[[alternative HTML version deleted]]

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


Re: [R] NLS error

2011-09-20 Thread Jean V Adams
Diviya Smith wrote on 09/20/2011 01:03:22 PM:
> 
> Hello there,
> 
> I am using NLS for fitting a complex model to some data to estimate a 
couple
> of the missing parameters. The model is -
> y ~ 
(C+((log(1-r))*exp(-A*d)*(-1+r+exp(d*(A-B)))/(r*(-A*d+d*B+log(1-r)
> where A, B and C are unknown.
> 
> In order to test the model, I generate data by setting values for all
> parameters and add some noise (C).
> 
> A <- 20
> B <- 500
> r <- 0.6881
> d <- (1:1000)/1000
> y ~
> (rnorm(d)*0.005)+(((log(1-r))*exp(-A*d)*(-1+r+exp(d*(A-B)))/(r*(-A*d
> +d*B+log(1-r)
> 
> I use Deoptim package to pick the optimum starting values. The model 
works
> fine in most cases, but every now and again, I get the following error -
> Error in numericDeriv(form[[3L]], names(ind), env) :
>   Missing value or an infinity produced when evaluating the model
> 
> Any suggestions on how I can resolve this? Can you suggest a better way 
for
> picking the starting parameters?
> 
> Thanks,
> Diviya


I'm not sure if this is the problem, but if r grows greater than 1, 
log(1-r) will be undefined, and you'll get an error.  You can impose a 
constraint on r by rewriting your formula in terms of a variable that can 
take on any real value:
R = log(1-r)

So, 
replace log(1-r) in your formula with R, 
replace (-1 + r) with -exp(R), and 
replace r with 1 - exp(R):
y ~ (C+(R*exp(-A*d)*(-exp(R)+exp(d*(A-B)))/((1 - exp(R))*(-A*d+d*B+R

If that doesn't fix the problem, then you are likely getting infinite 
values as result of large numbers in your exponents.  Without example data 
to work through, I can only speculate.

Jean
[[alternative HTML version deleted]]

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


Re: [R] How to transfer variable names to column names?

2011-09-20 Thread Sarah Goslee
Hi Kelly,

c() creates a vector. You need data.frame() instead.

dfIntron <- c(mC_Explant=nrow(mC_Explant), mC_Callus=nrow(mC_Callus),
mC_RegenPlant=nrow(mC_RegenPlant)) # set colnames simultaneously.

Sarah

On Tue, Sep 20, 2011 at 2:23 PM, Vining, Kelly
 wrote:
> Hello R users,
> I have a set of data frames for which I am tallying row numbers, as shown 
> below.
>
>> nrow(mC_Explant)
> [1] 14480
>> nrow(mC_Callus)
> [1] 23320
>> nrow(mC_RegenPlant)
> [1] 8108
>
> etc.
>
> I want to create a new data frame which has the variable names as column 
> headings, and then a single row with the nrow tallies. My first step was this:
>
> dfIntron <- c(nrow(mC_Explant), nrow(mC_Callus), nrow(mC_RegenPlant))
>
> Then, to set the column names, I tried this, and got the following error:
>
>  colnames(dfIntron) <- c("mC_Explant", "mC_Callus", "mC_RegenPlant")
> Error in `colnames<-`(`*tmp*`, value = c("mC_Explant", "mC_Callus", 
> "mC_RegenPlant" :
>  attempt to set colnames on object with less than two dimensions
>
> Even my first step seems wildly inefficient, and obviously doesn't work. 
> There must be a simple way to do this, but I can't use table(), for example, 
> as there are multiple data frames.
>
> Any help will be appreciated.
>
> --Kelly V.
>
>

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

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


Re: [R] Duplicate Rows in xts

2011-09-20 Thread R. Michael Weylandt
Please keep the list in the loop for the archives:

The data provided looks like this:

V = structure(list(V1 = structure(c(1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L,
1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L,
1L, 1L), .Label = "02/22/2011", class = "factor"), V2 = structure(c(1L,
1L, 2L, 3L, 4L, 5L, 5L, 6L, 7L, 7L, 7L, 8L, 9L, 9L, 9L, 10L,
11L, 12L, 13L, 14L, 14L, 15L, 15L, 15L, 15L, 15L), .Label = c("09:29:30",
"09:30:00", "09:30:06", "09:30:15", "09:30:41", "09:30:42", "09:30:53",
"09:30:58", "09:31:30", "09:31:44", "09:31:50", "09:31:54", "09:32:01",
"09:32:04", "09:32:41"), class = "factor"), V3 = c(63.91, 63.91,
63.82, 63.89, 63.81, 63.81, 63.81, 63.81, 63.85, 63.88, 63.88,
63.89, 63.9, 63.9, 63.9, 63.87, 63.9, 63.85, 63.95, 63.84, 63.84,
63.83, 63.89, 63.87, 63.89, 63.89), V4 = c(100L, 300L, 435L,
100L, 100L, 100L, 100L, 200L, 100L, 100L, 100L, 100L, 100L, 100L,
400L, 100L, 100L, 100L, 142L, 100L, 100L, 18169L, 100L, 100L,
100L, 177L), V5 = c(10554L, 10854L, 11289L, 11389L, 11489L, 11589L,
11689L, 11889L, 11989L, 12089L, 12189L, 12289L, 12389L, 12489L,
12889L, 12989L, 13089L, 13189L, 13331L, 13431L, 13531L, 31700L,
31800L, 31900L, 32000L, 32277L), V6 = c(63.73, 63.73, 63.81,
63.81, 63.81, 63.81, 63.81, 63.81, 63.81, 63.81, 63.81, 63.87,
63.83, 63.83, 63.83, 63.85, 63.85, 63.85, 63.85, 63.84, 63.84,
63.89, 63.84, 63.84, 63.84, 63.85), V7 = c(63.97, 63.97, 63.96,
63.95, 63.9, 63.9, 63.9, 63.9, 63.86, 63.94, 63.94, 64, 63.91,
63.91, 63.91, 63.96, 63.96, 63.96, 63.96, 63.96, 63.96, 63.95,
63.9, 63.9, 63.9, 63.95), V8 = c(3526L, 3527L, 4094L, 5140L,
6549L, 9533L, 9549L, 9636L, 11022L, 11147L, 11148L, 11721L, 16963L,
16964L, 16965L, 18854L, 19843L, 20381L, 21496L, 22384L, 22385L,
28832L, 28833L, 28834L, 28835L, 28849L), V9 = c(0L, 0L, 0L, 0L,
0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L,
0L, 0L, 0L, 0L, 0L, 0L), V10 = c(0L, 0L, 0L, 0L, 0L, 0L, 0L,
0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L,
0L, 0L, 0L)), .Names = c("V1", "V2", "V3", "V4", "V5", "V6",
"V7", "V8", "V9", "V10"), class = "data.frame", row.names = c(NA,
-26L))

It can be made into an appropriate xts in one line

V = xts(V[,3:10], as.POSIXct(paste(V[,1],V[,2]), format = "%m/%d/%Y
%H:%M:%S"), unique=F)

Working from the inside out:

paste(V[,1],V[,2]) # pastes the date and time stamps together
as.POSIXct(...,format = ) # convert to a time object and specify format so R
can read it
xts(V[,3:10],...,unique = F) # convert to xts and tell R not to worry about
non-unique time stamps

As to your problems with reading in the data, I can't help unless you care
to provide an example of your input file. All I'll say is that Excel's
"Date" format doesn't really correspond to standard date objects so you'll
usually have to convert after reading things in.

Hope this helps,

Michael Weylandt


On Tue, Sep 20, 2011 at 2:02 PM, Muhammad Abuizzah wrote:

> Thanks for the reply Michael, I was working on something else in my data
> that's the reason for the delay in my response.  I had looked at your
> advise when I gotten it and tryed it but I couldn't make it work. I am
> attaching a file of my raw data.  I had indicated earlier that I managed to
> concatenate the date and time into one field using excel then uploaded the
> file into R thinking that my issue would be resolved but it didn't.
>
> Although I saved the first field as date formate in excel, when R read it
> it was saved as character format.  I am assuming this could be part of the
> problem because the first column needs to be in a time/date format in R for
> xts to read it.
>
> I tried several pieces of code on the data which I managed to concatenate
> date and time into the first field using excel
> to convert the first column from character format to POSIXct format I
> used :   as.POSIXct(a5[,1], index.TZ = America/EST) #a5 was the data.frame
> with the date time concatenated
> For the entier record I tried:   as.xts(zxzx, index= 1:2, unique =F) ##
> zxzx is the name of the raw data in R.
>
> I am babbiling away, but I rather just send you the record.  And just to
> summarize it was uploaded from a txt file into R, the data has date and
> time in the first 2 fields, I was not able to create an xts object from
> the data.frame, time values are not unique.
>
> Need help
>
> Your help is well appreciated!!
>
>   *From:* R. Michael Weylandt 
> *To:* Muhammad Abuizzah 
> *Cc:* "r-help@r-project.org" 
> *Sent:* Monday, August 22, 2011 11:19 PM
> *Subject:* Re: [R] Duplicate Rows in xts
>
> Without example code or data I can't guarantee this is your problem, but
> have you looked at using xts(...,unique = F) instead of the default true.
>
> Alternatively, let us see what your data actually looks like to R (dput)
> and we'll help. But what you've got sounds like a problem in the date
> format, which is a little hard to see without knowing the exact way it's
> appearing in R.
>
> Michael
>
> On Mon, Aug 22, 2011 at 7:46 PM, Muhammad Abuizzah wrote:
>
> I rea

[R] How to transfer variable names to column names?

2011-09-20 Thread Vining, Kelly
Hello R users,
I have a set of data frames for which I am tallying row numbers, as shown 
below. 

> nrow(mC_Explant)
[1] 14480
> nrow(mC_Callus)
[1] 23320
> nrow(mC_RegenPlant)
[1] 8108

etc.

I want to create a new data frame which has the variable names as column 
headings, and then a single row with the nrow tallies. My first step was this:

dfIntron <- c(nrow(mC_Explant), nrow(mC_Callus), nrow(mC_RegenPlant))

Then, to set the column names, I tried this, and got the following error:

 colnames(dfIntron) <- c("mC_Explant", "mC_Callus", "mC_RegenPlant")
Error in `colnames<-`(`*tmp*`, value = c("mC_Explant", "mC_Callus", 
"mC_RegenPlant" : 
  attempt to set colnames on object with less than two dimensions

Even my first step seems wildly inefficient, and obviously doesn't work. There 
must be a simple way to do this, but I can't use table(), for example, as there 
are multiple data frames.

Any help will be appreciated.

--Kelly V.


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


Re: [R] help in interpreting paired t-test

2011-09-20 Thread Ted Harding
As can be seen by plotting as follows:

  plot(A,B,pch="+",col="blue")   ## The raw data

  plot(A,B-A,pch="+",col="blue") ## The differences versus A
  lines(c(0,0.7),c(0,0))

Ted.

On 20-Sep-11 17:54:15, Timothy Bates wrote:
> Yes, in over 3/4s of the data points A is > B… which suggests the A
> measure is reading higher than the B measuring system.
> 
> length(A[A>B])/length(A)
> 
> 
> On 20 Sep 2011, at 6:46 PM, Pedro Mardones wrote:
> 
>> Dear all;
>> 
>> A very basic question. I have the following data:
>> 
>> ***
>> *
>> 
>> A <- 1/1000*c(347,328,129,122,18,57,105,188,57,257,53,108,336,163,
>> 62,112,334,249,45,244,211,175,174,26,375,346,153,32,
>> 89,32,358,202,123,131,88,36,30,67,96,135,219,122,
>> 89,117,86,169,179,54,48,40,54,568,664,277,91,290,
>> 116,80,107,401,225,517,90,133,36,50,174,103,192,150,
>> 225,29,80,199,55,258,97,109,137,90,236,109,204,160,
>> 95,54,50,78,98,141,508,144,434,100,37,22,304,175,
>> 72,71,111,60,212,73,50,92,70,148,28,63,46,85,
>> 111,67,234,65,92,59,118,202,21,17,95,86,296,45,
>> 139,32,21,70,185,172,151,129,42,14,13,75,303,119,
>> 128,106,224,241,112,395,78,89,247,122,212,61,165,30,
>> 65,261,415,159,316,182,141,184,124,223,39,141,103,149,
>> 104,71,259,86,85,214,96,246,306,11,129)
>> 
>> B <- 1/1000*c(351,313,130,119,17,50,105,181,58,255,51,98,335,162,
>> 60,108,325,240,44,242,208,168,170,27,356,341,150,31,
>> 85,29,363,185,124,131,85,35,27,63,92,147,217,117,
>> 87,119,81,161,178,53,45,38,50,581,661,254,87,281,
>> 110,76,100,401,220,507,94,123,36,47,154,99,184,146,
>> 232,26,77,193,53,264,94,110,128,87,231,110,195,156,
>> 95,51,50,75,93,134,519,139,435,96,37,21,293,169,
>> 70,80,104,64,210,70,48,88,67,140,26,52,45,90,
>> 106,63,219,62,91,56,113,187,18,14,95,86,284,39,
>> 132,31,22,69,181,167,150,117,42,14,11,73,303,109,
>> 129,106,227,249,111,409,71,88,256,120,200,60,159,27,
>> 63,268,389,150,311,175,136,171,116,220,30,145,95,148,
>> 102,70,251,88,83,199,94,245,305,9,129)
>> 
>> ***
>> *
>> 
>> plot(A,B)
>> abline(0,1)
>> 
>> At a glance, the data look very similar. Data A and B are two
>> measurements of the same variable but using different devices (on a
>> same set of subjects). Thus, I thought that a paired t-test could be
>> appropriate to check if the diff between measurement devices = 0.
>> 
>> t.test(A-B)
>> 
>> ***
>> *
>> 
>> One Sample t-test
>> 
>> data:  A - B
>> t = 7.6276, df = 178, p-value = 1.387e-12
>> alternative hypothesis: true mean is not equal to 0
>> 95 percent confidence interval:
>> 0.002451622 0.004162903
>> sample estimates:
>>  mean of x
>> 0.003307263
>> 
>> ***
>> *
>> The mean diff is 0.0033 but the p-value indicates a strong evidence to
>> reject H0.
>> 
>> I was expecting to find no differences so I'm wondering whether the
>> t-test is the appropriate test to use. I'll appreciate any comments or
>> suggestions.


E-Mail: (Ted Harding) 
Fax-to-email: +44 (0)870 094 0861
Date: 20-Sep-11   Time: 19:15:47
-- XFMail --

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


Re: [R] help in interpreting paired t-test

2011-09-20 Thread Jean V Adams
Pedro Mardones wrote on 09/20/2011 12:46:54 PM:
> 
> Dear all;
> 
> A very basic question. I have the following data:
> 
> 

> 
> A <- 1/1000*c(347,328,129,122,18,57,105,188,57,257,53,108,336,163,
> 62,112,334,249,45,244,211,175,174,26,375,346,153,32,
> 89,32,358,202,123,131,88,36,30,67,96,135,219,122,
> 89,117,86,169,179,54,48,40,54,568,664,277,91,290,
> 116,80,107,401,225,517,90,133,36,50,174,103,192,150,
> 225,29,80,199,55,258,97,109,137,90,236,109,204,160,
> 95,54,50,78,98,141,508,144,434,100,37,22,304,175,
> 72,71,111,60,212,73,50,92,70,148,28,63,46,85,
> 111,67,234,65,92,59,118,202,21,17,95,86,296,45,
> 139,32,21,70,185,172,151,129,42,14,13,75,303,119,
> 128,106,224,241,112,395,78,89,247,122,212,61,165,30,
> 65,261,415,159,316,182,141,184,124,223,39,141,103,149,
> 104,71,259,86,85,214,96,246,306,11,129)
> 
> B <- 1/1000*c(351,313,130,119,17,50,105,181,58,255,51,98,335,162,
> 60,108,325,240,44,242,208,168,170,27,356,341,150,31,
> 85,29,363,185,124,131,85,35,27,63,92,147,217,117,
> 87,119,81,161,178,53,45,38,50,581,661,254,87,281,
> 110,76,100,401,220,507,94,123,36,47,154,99,184,146,
> 232,26,77,193,53,264,94,110,128,87,231,110,195,156,
> 95,51,50,75,93,134,519,139,435,96,37,21,293,169,
> 70,80,104,64,210,70,48,88,67,140,26,52,45,90,
> 106,63,219,62,91,56,113,187,18,14,95,86,284,39,
> 132,31,22,69,181,167,150,117,42,14,11,73,303,109,
> 129,106,227,249,111,409,71,88,256,120,200,60,159,27,
> 63,268,389,150,311,175,136,171,116,220,30,145,95,148,
> 102,70,251,88,83,199,94,245,305,9,129)
> 
> 

> 
> plot(A,B)
> abline(0,1)
> 
> At a glance, the data look very similar. Data A and B are two
> measurements of the same variable but using different devices (on a
> same set of subjects). Thus, I thought that a paired t-test could be
> appropriate to check if the diff between measurement devices = 0.
> 
> t.test(A-B)
> 
> 

> 
> One Sample t-test
> 
> data:  A - B
> t = 7.6276, df = 178, p-value = 1.387e-12
> alternative hypothesis: true mean is not equal to 0
> 95 percent confidence interval:
>  0.002451622 0.004162903
> sample estimates:
>   mean of x
> 0.003307263
> 
> 

> The mean diff is 0.0033 but the p-value indicates a strong evidence to
> reject H0.
> 
> I was expecting to find no differences so I'm wondering whether the
> t-test is the appropriate test to use. I'll appreciate any comments or
> suggestions.
> 
> BR,
> PM


The paired t-test could very well be an appropriate test to use, depending 
on the design of the study.

If you look at the distribution of difference between A and B it certainly 
looks like the mean of that distribution is not 0:

hist(A-B, nclass=50)
abline(v=0, lwd=2)

Perhaps what you need to think about is the difference between statistical 
significance and "practical" significance.  Is a difference of about 2% 
between measurement devices "important"?

Jean

[[alternative HTML version deleted]]

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


[R] NLS error

2011-09-20 Thread Diviya Smith
Hello there,

I am using NLS for fitting a complex model to some data to estimate a couple
of the missing parameters. The model is -
y ~ (C+((log(1-r))*exp(-A*d)*(-1+r+exp(d*(A-B)))/(r*(-A*d+d*B+log(1-r)
where A, B and C are unknown.

In order to test the model, I generate data by setting values for all
parameters and add some noise (C).

A <- 20
B <- 500
r <- 0.6881
d <- (1:1000)/1000
y ~
(rnorm(d)*0.005)+(((log(1-r))*exp(-A*d)*(-1+r+exp(d*(A-B)))/(r*(-A*d+d*B+log(1-r)

I use Deoptim package to pick the optimum starting values. The model works
fine in most cases, but every now and again, I get the following error -
Error in numericDeriv(form[[3L]], names(ind), env) :
  Missing value or an infinity produced when evaluating the model

Any suggestions on how I can resolve this? Can you suggest a better way for
picking the starting parameters?

Thanks,
Diviya

[[alternative HTML version deleted]]

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


Re: [R] help in interpreting paired t-test

2011-09-20 Thread Marc Schwartz
On Sep 20, 2011, at 12:46 PM, Pedro Mardones wrote:

> Dear all;
> 
> A very basic question. I have the following data:
> 
> 
> 
> A <- 1/1000*c(347,328,129,122,18,57,105,188,57,257,53,108,336,163,
> 62,112,334,249,45,244,211,175,174,26,375,346,153,32,
> 89,32,358,202,123,131,88,36,30,67,96,135,219,122,
> 89,117,86,169,179,54,48,40,54,568,664,277,91,290,
> 116,80,107,401,225,517,90,133,36,50,174,103,192,150,
> 225,29,80,199,55,258,97,109,137,90,236,109,204,160,
> 95,54,50,78,98,141,508,144,434,100,37,22,304,175,
> 72,71,111,60,212,73,50,92,70,148,28,63,46,85,
> 111,67,234,65,92,59,118,202,21,17,95,86,296,45,
> 139,32,21,70,185,172,151,129,42,14,13,75,303,119,
> 128,106,224,241,112,395,78,89,247,122,212,61,165,30,
> 65,261,415,159,316,182,141,184,124,223,39,141,103,149,
> 104,71,259,86,85,214,96,246,306,11,129)
> 
> B <- 1/1000*c(351,313,130,119,17,50,105,181,58,255,51,98,335,162,
> 60,108,325,240,44,242,208,168,170,27,356,341,150,31,
> 85,29,363,185,124,131,85,35,27,63,92,147,217,117,
> 87,119,81,161,178,53,45,38,50,581,661,254,87,281,
> 110,76,100,401,220,507,94,123,36,47,154,99,184,146,
> 232,26,77,193,53,264,94,110,128,87,231,110,195,156,
> 95,51,50,75,93,134,519,139,435,96,37,21,293,169,
> 70,80,104,64,210,70,48,88,67,140,26,52,45,90,
> 106,63,219,62,91,56,113,187,18,14,95,86,284,39,
> 132,31,22,69,181,167,150,117,42,14,11,73,303,109,
> 129,106,227,249,111,409,71,88,256,120,200,60,159,27,
> 63,268,389,150,311,175,136,171,116,220,30,145,95,148,
> 102,70,251,88,83,199,94,245,305,9,129)
> 
> 
> 
> plot(A,B)
> abline(0,1)
> 
> At a glance, the data look very similar. Data A and B are two
> measurements of the same variable but using different devices (on a
> same set of subjects). Thus, I thought that a paired t-test could be
> appropriate to check if the diff between measurement devices = 0.
> 
> t.test(A-B)
> 
> 
> 
> One Sample t-test
> 
> data:  A - B
> t = 7.6276, df = 178, p-value = 1.387e-12
> alternative hypothesis: true mean is not equal to 0
> 95 percent confidence interval:
> 0.002451622 0.004162903
> sample estimates:
>  mean of x
> 0.003307263
> 
> 
> The mean diff is 0.0033 but the p-value indicates a strong evidence to
> reject H0.
> 
> I was expecting to find no differences so I'm wondering whether the
> t-test is the appropriate test to use. I'll appreciate any comments or
> suggestions.
> 
> BR,
> PM


You should look at:

  http://www-users.york.ac.uk/~mb55/meas/meas.htm

which provides insights into how to compare measurement methods. You might 
start with the FAQ.

The paired t-test does not tell you if there are systematic differences across 
the range of measures.

HTH,

Marc Schwartz

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


Re: [R] help in interpreting paired t-test

2011-09-20 Thread Timothy Bates
Yes, in over 3/4s of the data points A is > B… which suggests the A measure is 
reading higher than the B measuring system.

length(A[A>B])/length(A)


On 20 Sep 2011, at 6:46 PM, Pedro Mardones wrote:

> Dear all;
> 
> A very basic question. I have the following data:
> 
> 
> 
> A <- 1/1000*c(347,328,129,122,18,57,105,188,57,257,53,108,336,163,
> 62,112,334,249,45,244,211,175,174,26,375,346,153,32,
> 89,32,358,202,123,131,88,36,30,67,96,135,219,122,
> 89,117,86,169,179,54,48,40,54,568,664,277,91,290,
> 116,80,107,401,225,517,90,133,36,50,174,103,192,150,
> 225,29,80,199,55,258,97,109,137,90,236,109,204,160,
> 95,54,50,78,98,141,508,144,434,100,37,22,304,175,
> 72,71,111,60,212,73,50,92,70,148,28,63,46,85,
> 111,67,234,65,92,59,118,202,21,17,95,86,296,45,
> 139,32,21,70,185,172,151,129,42,14,13,75,303,119,
> 128,106,224,241,112,395,78,89,247,122,212,61,165,30,
> 65,261,415,159,316,182,141,184,124,223,39,141,103,149,
> 104,71,259,86,85,214,96,246,306,11,129)
> 
> B <- 1/1000*c(351,313,130,119,17,50,105,181,58,255,51,98,335,162,
> 60,108,325,240,44,242,208,168,170,27,356,341,150,31,
> 85,29,363,185,124,131,85,35,27,63,92,147,217,117,
> 87,119,81,161,178,53,45,38,50,581,661,254,87,281,
> 110,76,100,401,220,507,94,123,36,47,154,99,184,146,
> 232,26,77,193,53,264,94,110,128,87,231,110,195,156,
> 95,51,50,75,93,134,519,139,435,96,37,21,293,169,
> 70,80,104,64,210,70,48,88,67,140,26,52,45,90,
> 106,63,219,62,91,56,113,187,18,14,95,86,284,39,
> 132,31,22,69,181,167,150,117,42,14,11,73,303,109,
> 129,106,227,249,111,409,71,88,256,120,200,60,159,27,
> 63,268,389,150,311,175,136,171,116,220,30,145,95,148,
> 102,70,251,88,83,199,94,245,305,9,129)
> 
> 
> 
> plot(A,B)
> abline(0,1)
> 
> At a glance, the data look very similar. Data A and B are two
> measurements of the same variable but using different devices (on a
> same set of subjects). Thus, I thought that a paired t-test could be
> appropriate to check if the diff between measurement devices = 0.
> 
> t.test(A-B)
> 
> 
> 
> One Sample t-test
> 
> data:  A - B
> t = 7.6276, df = 178, p-value = 1.387e-12
> alternative hypothesis: true mean is not equal to 0
> 95 percent confidence interval:
> 0.002451622 0.004162903
> sample estimates:
>  mean of x
> 0.003307263
> 
> 
> The mean diff is 0.0033 but the p-value indicates a strong evidence to
> reject H0.
> 
> I was expecting to find no differences so I'm wondering whether the
> t-test is the appropriate test to use. I'll appreciate any comments or
> suggestions.
> 
> BR,
> PM
> 
> __
> R-help@r-project.org mailing list
> https://stat.ethz.ch/mailman/listinfo/r-help
> PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
> and provide commented, minimal, self-contained, reproducible code.

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


[R] randomForest - NaN in %IncMSE

2011-09-20 Thread Katharine Miller
Hi

I am having a problem using varImpPlot in randomForest.  I get the error
message "Error in plot.window(xlim = xlim, ylim = ylim, log = "") :   need
finite 'xlim' values"

When print $importance, several variables have NaN under %IncMSE.   There
are no NaNs in the original data.  Can someone help me figure out what is
happening here?

Thanks!

[[alternative HTML version deleted]]

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


[R] ksvm and predict

2011-09-20 Thread Juan
Hello,

I am using the kernlab package to do regression.
I have a data frame called Data6 which looks like this:

head(Data6)

WA   PO   ZA   ZB   ZC   ZD  KL
1 2.955447 6.378324 14.10622 0.134343 0.247120 0.734810 4.05988
2 2.939718 6.344122 14.03528 0.127512 0.00 0.955253 4.02952
3 2.907939 6.254080 13.89342 0.111573 0.247120 3.674050 3.99476
4 2.884506 6.221972 13.82095 0.052371 0.00 3.600569 3.95384
5 2.880333 6.257570 13.85795 0.031878 0.160628 0.587848 3.96000
6 2.897667 6.285490 14.01370 0.138897 0.049424 1.616582 4.00048

up to 999 rows of data.

I wrote the following function

train.KL <- ksvm(KL~., data=Data6, C=100,
epsilon=0.001,kpar="automatic",cross=10)
pred.KL<-predict(train.KL,WA)

pred.KL
4.0599
4.0302
3.9949
3.9545
3.9604
4.0004
3.9607

Now, suppose I have a new data for WA=2.8488. If I write:

predict(train.KL,2.8488)

I get a matrix with 1 column and 999 rows while I expected to have a single
value.

Could anyone tell me what I am doing wrong?

I don´t even know if I am using the ksvm and the predict funtions
correctrly, since I
wrote the ksvm fuction to model a parameter as a funtion of all the remaning
columns
(I did it because I get better results that if I use just WA) but I whant to
make a
prediction of KL using just the first of them (WA). Any suggestions?

Thanks a lot for your help.

Regards,

Juan

--
View this message in context: 
http://r.789695.n4.nabble.com/ksvm-and-predict-tp3827634p3827634.html
Sent from the R help mailing list archive at Nabble.com.

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


[R] help in interpreting paired t-test

2011-09-20 Thread Pedro Mardones
Dear all;

A very basic question. I have the following data:



A <- 1/1000*c(347,328,129,122,18,57,105,188,57,257,53,108,336,163,
62,112,334,249,45,244,211,175,174,26,375,346,153,32,
89,32,358,202,123,131,88,36,30,67,96,135,219,122,
89,117,86,169,179,54,48,40,54,568,664,277,91,290,
116,80,107,401,225,517,90,133,36,50,174,103,192,150,
225,29,80,199,55,258,97,109,137,90,236,109,204,160,
95,54,50,78,98,141,508,144,434,100,37,22,304,175,
72,71,111,60,212,73,50,92,70,148,28,63,46,85,
111,67,234,65,92,59,118,202,21,17,95,86,296,45,
139,32,21,70,185,172,151,129,42,14,13,75,303,119,
128,106,224,241,112,395,78,89,247,122,212,61,165,30,
65,261,415,159,316,182,141,184,124,223,39,141,103,149,
104,71,259,86,85,214,96,246,306,11,129)

B <- 1/1000*c(351,313,130,119,17,50,105,181,58,255,51,98,335,162,
60,108,325,240,44,242,208,168,170,27,356,341,150,31,
85,29,363,185,124,131,85,35,27,63,92,147,217,117,
87,119,81,161,178,53,45,38,50,581,661,254,87,281,
110,76,100,401,220,507,94,123,36,47,154,99,184,146,
232,26,77,193,53,264,94,110,128,87,231,110,195,156,
95,51,50,75,93,134,519,139,435,96,37,21,293,169,
70,80,104,64,210,70,48,88,67,140,26,52,45,90,
106,63,219,62,91,56,113,187,18,14,95,86,284,39,
132,31,22,69,181,167,150,117,42,14,11,73,303,109,
129,106,227,249,111,409,71,88,256,120,200,60,159,27,
63,268,389,150,311,175,136,171,116,220,30,145,95,148,
102,70,251,88,83,199,94,245,305,9,129)



plot(A,B)
abline(0,1)

At a glance, the data look very similar. Data A and B are two
measurements of the same variable but using different devices (on a
same set of subjects). Thus, I thought that a paired t-test could be
appropriate to check if the diff between measurement devices = 0.

t.test(A-B)



One Sample t-test

data:  A - B
t = 7.6276, df = 178, p-value = 1.387e-12
alternative hypothesis: true mean is not equal to 0
95 percent confidence interval:
 0.002451622 0.004162903
sample estimates:
  mean of x
0.003307263


The mean diff is 0.0033 but the p-value indicates a strong evidence to
reject H0.

I was expecting to find no differences so I'm wondering whether the
t-test is the appropriate test to use. I'll appreciate any comments or
suggestions.

BR,
PM

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


Re: [R] Boxplots from 4 dimensional array

2011-09-20 Thread Jean V Adams
Tarmo Remmel wrote on 09/20/2011 09:51:45 AM:
> 
> Hello list members,
> 
> I am working with simulated data for landscape pattern analysis.  I have
> 1000 replicates of binary (2 colour) gridded landscapes at each 
combination
> of 9 levels of class proportion and 11 levels of spatial 
autocorrelation.
> The results are stored in an array as follows:
> 
> > dim(surfaces)
> [1]   389   11 1000
> 
> The dimensions are defined as follows:
> [x,,,] 1:38, integers that identify a measurement type (landscape 
pattern
> metrics)
> [,x,,] 1:9, integers that identify levels of class proportion
> [,,x,] 1:11, integers that identify levels of spatial autocorrelation
> [,,,x] floating point values for the specific landscape metric
> 
> I would like a simple way to produce boxplots of the 1000 metric values 
for
> a specific landscape metric and level of spatial autocorrelation across 
the
> 9 levels of proportion.  Thus, I want to fix the first dimension (say as 
10)
> and fix the third dimension (say as 1), and then use the second 
dimension as
> factors (1:9) to produce boxplots of the values in the 4th dimension. Is
> there a simple way to do this? 
> 
> I have been playing with boxplot() and apply() but am getting some
> dimensions mixed up and thought that this would be a good time to seek 
some
> help.  Any help with this would be greatly appreciated.
> 
> Thank you,
> 
> Tarmo
> 
> 
> _
> Tarmo K Remmel PhD
> Associate Professor, Department of Geography
> York University, N413A Ross Building
> 4700 Keele Street, Toronto, Ontario, M3J 1P3
> Tel: 416-736-2100 x22496, Fax: 416-736-5988
> Skype: tarmoremmel


Try this:

mybox <- function(arr, type, autocorr) {
y <- arr[type, , autocorr, ]
class <- as.factor(as.vector(row(y)))
metric <- as.vector(y)
plot(class, metric)
}

mybox(surfaces, 10, 1)

Jean

[[alternative HTML version deleted]]

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


Re: [R] Converting ID Numbers to Unique ID Number

2011-09-20 Thread jim holtman
something like this should work:

> oldIDs <- c(1234, 1235, 1236)
> newIDs <- c(5000, 1234, 7000, 1236)
> # really new ones -- don't match the old ones
> (reallyNew <- setdiff(newIDs, oldIDs))
[1] 5000 7000
> # assign these back to the oldIDs for the next month
> (oldIDs <- c(oldIDs, reallyNew))
[1] 1234 1235 1236 5000 7000
>


On Tue, Sep 20, 2011 at 11:50 AM, Totally Inept
 wrote:
> First off, let me apologize for the elementary question. I'm obviously a
> novice.
>
> Here's a stripped version of my problem.
>
> March
> foreign id = 1234, my id = 1
> foreign id = 1235, my id = 2
> foreign id = 1236, my id = 3
>
> So we are adding new people for April, and things don't necessarily come in
> order:
>
> April
> foreign id = 1236
> foreign id = 5000
> foreign id = 1234
> foreign id = 1235
> foreign id = 
>
> I need to create a vector of my own IDs. "1236" would obviously need to be
> translated to my id = 3 but I would also need to incrementally add a new "my
> id" for our new entry, so I'd want foreign id 5000 to be translated to my id
> 4, and foreign id =  to be translated into my id 5.
>
> Please help! I have puzzled over this for far longer than I'd care to admit,
> late into last night and now all morning.
>
> --
> View this message in context: 
> http://r.789695.n4.nabble.com/Converting-ID-Numbers-to-Unique-ID-Number-tp3827281p3827281.html
> Sent from the R help mailing list archive at Nabble.com.
>
> __
> R-help@r-project.org mailing list
> https://stat.ethz.ch/mailman/listinfo/r-help
> PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
> and provide commented, minimal, self-contained, reproducible code.
>



-- 
Jim Holtman
Data Munger Guru

What is the problem that you are trying to solve?

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


Re: [R] Converting ID Numbers to Unique ID Number

2011-09-20 Thread Sarah Goslee
A reproducible example would be useful, as yours isn't entirely clear.

But maybe something like this?

id.info <- data.frame(foreign=sort(unique(foreign.id)),
local=1:length(unique(foreign.id)))

and then use merge() to combine that with your actual data.

Sarah

On Tue, Sep 20, 2011 at 11:50 AM, Totally Inept
 wrote:
> First off, let me apologize for the elementary question. I'm obviously a
> novice.
>
> Here's a stripped version of my problem.
>
> March
> foreign id = 1234, my id = 1
> foreign id = 1235, my id = 2
> foreign id = 1236, my id = 3
>
> So we are adding new people for April, and things don't necessarily come in
> order:
>
> April
> foreign id = 1236
> foreign id = 5000
> foreign id = 1234
> foreign id = 1235
> foreign id = 
>
> I need to create a vector of my own IDs. "1236" would obviously need to be
> translated to my id = 3 but I would also need to incrementally add a new "my
> id" for our new entry, so I'd want foreign id 5000 to be translated to my id
> 4, and foreign id =  to be translated into my id 5.
>
> Please help! I have puzzled over this for far longer than I'd care to admit,
> late into last night and now all morning.
>


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

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


Re: [R] package documentation of S4 methods

2011-09-20 Thread Hassaan Aamir
El Gorgonzola  hotmail.com> writes:

> My question: how do you document methods of S4-classes in a package? 
> It works fine for the method "show" but it does not work for "showall",
> for which I had to define the generic function first. What can I do to
> fix this, or is it better to just define "showall" as a function and not
> as a method?

Hey I have this same problem and I too just started R. 
Did you ever found out how to make the warnings go away?

- Hassaan

__
R-help@r-project.org mailing list
https://stat.ethz.ch/mailman/listinfo/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] Converting ID Numbers to Unique ID Number

2011-09-20 Thread Totally Inept
First off, let me apologize for the elementary question. I'm obviously a
novice.

Here's a stripped version of my problem.

March
foreign id = 1234, my id = 1
foreign id = 1235, my id = 2
foreign id = 1236, my id = 3

So we are adding new people for April, and things don't necessarily come in
order:

April
foreign id = 1236 
foreign id = 5000
foreign id = 1234
foreign id = 1235
foreign id = 

I need to create a vector of my own IDs. "1236" would obviously need to be
translated to my id = 3 but I would also need to incrementally add a new "my
id" for our new entry, so I'd want foreign id 5000 to be translated to my id
4, and foreign id =  to be translated into my id 5.

Please help! I have puzzled over this for far longer than I'd care to admit,
late into last night and now all morning.

--
View this message in context: 
http://r.789695.n4.nabble.com/Converting-ID-Numbers-to-Unique-ID-Number-tp3827281p3827281.html
Sent from the R help mailing list archive at Nabble.com.

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


Re: [R] Problem with legend

2011-09-20 Thread Komine
Thank you Sarah and Petit bleu for your help.
I solved my problem with the code of Sarah.

Komine



--
View this message in context: 
http://r.789695.n4.nabble.com/Problem-with-legend-tp3826973p3827461.html
Sent from the R help mailing list archive at Nabble.com.

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


Re: [R] open source editor for r for beginners

2011-09-20 Thread Ken Hutchison
Rstudio and Rcmdr are very popular and for good reason, find a good book
while the latter is installing though.
 IF you are using linux, rkward is fantastic to woRk with.
   Ken Hutchison

On Tue, Sep 20, 2011 at 11:21 AM, Steve Lianoglou <
mailinglist.honey...@gmail.com> wrote:

> I just wanted to second Rstudio:
>
> http://rstudio.org/
>
> Honestly, try this first -- it's an easy install, it just works, and
> there's no real learning curve to the editor itself.  Very n00b
> friendly.
>
> -steve
>
>
> On Tue, Sep 20, 2011 at 9:28 AM, R. Michael Weylandt
>  wrote:
> > RStudio
> >
> >
> > Hope this helps,
> > Michael Weylandt
> >
> > On Tue, Sep 20, 2011 at 9:26 AM, Marion Wenty  >wrote:
> >
> >> Hello all,
> >>
> >> I am looking for an editor for R which has got functions beyond the
> normal
> >> R
> >> editor that is included in the program.
> >>
> >> I had a look at VIM but I think it's difficult if you are just starting
> >> programming.
> >>
> >> Could anyone recommend an editor that is suitable for beginners?
> >>
> >> Thanks for your help.
> >>
> >> Marion
> >>
> >>[[alternative HTML version deleted]]
> >>
> >> __
> >> R-help@r-project.org mailing list
> >> https://stat.ethz.ch/mailman/listinfo/r-help
> >> PLEASE do read the posting guide
> >> http://www.R-project.org/posting-guide.html
> >> and provide commented, minimal, self-contained, reproducible code.
> >>
> >
> >[[alternative HTML version deleted]]
> >
> > __
> > R-help@r-project.org mailing list
> > https://stat.ethz.ch/mailman/listinfo/r-help
> > PLEASE do read the posting guide
> http://www.R-project.org/posting-guide.html
> > and provide commented, minimal, self-contained, reproducible code.
> >
>
>
>
> --
> Steve Lianoglou
> Graduate Student: Computational Systems Biology
>  | Memorial Sloan-Kettering Cancer Center
>  | Weill Medical College of Cornell University
> Contact Info: http://cbio.mskcc.org/~lianos/contact
>
> __
> R-help@r-project.org mailing list
> https://stat.ethz.ch/mailman/listinfo/r-help
> PLEASE do read the posting guide
> http://www.R-project.org/posting-guide.html
> and provide commented, minimal, self-contained, reproducible code.
>

[[alternative HTML version deleted]]

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


Re: [R] Help writing basic loop

2011-09-20 Thread David L Carlson
You did ask for a loop, but if you are willing to consider sapply(), the
result you want can be obtained with a single (admittedly long) command:

> slope<-sapply(1:100, function(x) lm(c(rnorm(1, mean=.01, sd=.001),
rnorm(1, mean=.1, sd=.01))~c(10,400))$coefficients[2])
> head(slope)
  c(10, 400)   c(10, 400)   c(10, 400)   c(10, 400)   c(10, 400)   c(10,
400)
0.0001994346 0.0002118383 0.0002729246 0.0002249865 0.0002323564
0.0002113820

If the "c(10, 400)" labels are distracting, you can replace them with
consecutive integers:

> names(slope)<-1:100
> head(slope)
   12345
6
0.0001994346 0.0002118383 0.0002729246 0.0002249865 0.0002323564
0.0002113820

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



-Original Message-
From: r-help-boun...@r-project.org [mailto:r-help-boun...@r-project.org] On
Behalf Of MacQueen, Don
Sent: Friday, September 16, 2011 6:58 PM
To: Luke Miller; beaulieu.j...@epamail.epa.gov
Cc: r-help@r-project.org
Subject: Re: [R] Help writing basic loop

Just a minor aside; I would have done

  my.slopes <- numeric(100)

Note that:
> class(numeric(5))
[1] "numeric"

-Don


-- 
Don MacQueen

Lawrence Livermore National Laboratory
7000 East Ave., L-627
Livermore, CA 94550
925-423-1062





On 9/16/11 12:37 PM, "Luke Miller"  wrote:

>Create an output vector to hold your slopes before starting the loop, then
>use your index i to place each new slope in the appropriate position in
>your
>vector.
>
>y1<-rnorm(100, mean=0.01, sd=0.001)
>y2<-rnorm(100, mean=0.1, sd=0.01)
>
>x<-(c(10,400))
>
>my.slopes = vector("numeric",100)  #  initialize a numeric vector, length
>100, filled with zeros initially
>
>for (i in 1:100) {
>
>#create the linear model for each data set
>model1<-lm(c(y1[i],y2[i])~x)
>slope1<-model1$coefficients[2]
>my.slopes[i] = slope1 #  stick each new slope value into my.slopes[i]
>}
>
>You could skip the slope1 <- model1$coefficients[2]  step and just put the
>slope directly into my.slopes[i] as well.
>
>On Fri, Sep 16, 2011 at 3:25 PM,  wrote:
>
>> Hello,
>>
>> I would like to write a loop to 1) run 100 linear regressions, and 2)
>> compile the slopes of all regression into one vector.  Sample input data
>> are:
>>
>> y1<-rnorm(100, mean=0.01, sd=0.001)
>> y2<-rnorm(100, mean=0.1, sd=0.01)
>>
>> x<-(c(10,400))
>>
>> #I have gotten this far with the loop
>>
>> for (i in 1:100) {
>>
>> #create the linear model for each data set
>> model1<-lm(c(y1[i],y2[i])~x)
>> slope1<-model1$coefficients[2]
>> }
>>
>> How can I compile the slopes from all 100 regressions into one vector?
>>
>> Thanks,
>> Jake
>>[[alternative HTML version deleted]]
>>
>> __
>> R-help@r-project.org mailing list
>> https://stat.ethz.ch/mailman/listinfo/r-help
>> PLEASE do read the posting guide
>> http://www.R-project.org/posting-guide.html
>> and provide commented, minimal, self-contained, reproducible code.
>>
>
>
>
>-- 
>___
>Luke Miller
>Postdoctoral Researcher
>Marine Science Center
>Northeastern University
>Nahant, MA
>(781) 581-7370 x318
>
>   [[alternative HTML version deleted]]
>
>__
>R-help@r-project.org mailing list
>https://stat.ethz.ch/mailman/listinfo/r-help
>PLEASE do read the posting guide
>http://www.R-project.org/posting-guide.html
>and provide commented, minimal, self-contained, reproducible code.

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

__
R-help@r-project.org mailing list
https://stat.ethz.ch/mailman/listinfo/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] Odp: means across list of data frames

2011-09-20 Thread Petr PIKAL
Hi

> 
> I have a list of data frames like the following:
> 
> set.seed(123)
> a<- data.frame(x=runif(10), y = runif(10), sample = seq(1,10))
> b<- data.frame(x=runif(10), y = runif(10), sample = seq(1,10))
> L<- list(a,b)
> 
> All data frames in the list have the same dimensions.  I need to 
calculate
> the sample means for x and y.  The real data are lists of several 
thousand
> quite large dataframes, so I need something that is pretty fast.  Here 
is
> what I have so far:
> 
> y<- rowMeans(sapply(L,'[[','y'))
> x<- rowMeans(sapply(L,'[[','x'))
> 
> this works great, but I'm only able to get the sample means for one 
column
> at a time.  Is there a way to automate things a bit so that I can get 
the
> sample means for several columns with one call?

I am not sure if it is suitable for you but plyr package can be used. 
Maybe somebody could do better

aaply(laply(L, as.matrix), 3, colMeans)

shall give you an array with rows of means for columns of your data 
frames.

Regards
Petr



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

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


Re: [R] Multivariate spline regression and predicted values

2011-09-20 Thread Simon Wood

One possibility is

library(mgcv)

## isotropic thin plate spline smoother
b <- gam(Y~s(X[,1],X[,2]))
predict(b,newdata=list(X=W))

## tensor product smoother
b <- gam(Y~te(X[,1],X[,2]))
predict(b,newdata=list(X=W))

## variant tensor product smoother
b <- gam(Y~t2(X[,1],X[,2]))
predict(b,newdata=list(X=W))

... these would all result in penalized regression spline fits with 
smoothing parameters estimated (by GCV, by default). If you don't want 
penalization then use, e.g. s(X[,1],X[,2],fx=TRUE) to get pure 
regression spline (`k' argument to s, te and t2 controls spline basis 
dimension --- see docs).


best,
simon

On 09/20/2011 03:11 PM, Max Farrell wrote:

Hello,

I am trying to estimate a multivariate regression of Y on X with
regression splines. Y is (nx1), and X is (nxd), with d>1. I assume the
data is generated by some unknown regression function f(X), as in Y =
f(X) + u, where u is some well-behaved regression error. I want to
estimate f(X) via regression splines (tensor product splines). Then, I
want to get the predicted values for some new points W.

To be concrete, here is an example of what I want:

#dimensions of the model
d=2
n=1000
#some random data
X<- matrix(runif(d*n,-2,2),n,d)
U<- rnorm(n)
Y<- X[,1] + X[,2] + U
# a new point for prediction
W<- matrix(rep(0),1,d)

Now if I wanted to use local polynomials instead of splines, I could
load the 'locfit' package and run (something like):

lp.results<- 
smooth.lf(X,Y,kern="epan",kt="prod",deg=1,alpha=c(0,0.25,0),xev=W,direct=TRUE)$y

Or, if X was univariate (ie d=1), I could use (something like):

spl.results<- predict(smooth.spline(X,Y, nknots=6),W)

But smooth.spline only works for univariate data. I looked at the
"crs" package, and it at least will fit the multivariate spline, but I
don't see how to predict the new data from this. That is, I run a
command like:

spl.fit<- crs(Y~X[,1] + X[,2],basis="tensor",
degree=c(3,3),segments=c(4,4),degree.min=3,degree.max=3, kernel=FALSE,
cv="none",knots="uniform",prune=FALSE)

Then what?

What I really want is the spline version of the smooth.lf command
above, or the multivariate version of smooth.spline. Any ideas/help?

Thanks,
Max

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



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


Re: [R] open source editor for r for beginners

2011-09-20 Thread Steve Lianoglou
I just wanted to second Rstudio:

http://rstudio.org/

Honestly, try this first -- it's an easy install, it just works, and
there's no real learning curve to the editor itself.  Very n00b
friendly.

-steve


On Tue, Sep 20, 2011 at 9:28 AM, R. Michael Weylandt
 wrote:
> RStudio
>
>
> Hope this helps,
> Michael Weylandt
>
> On Tue, Sep 20, 2011 at 9:26 AM, Marion Wenty wrote:
>
>> Hello all,
>>
>> I am looking for an editor for R which has got functions beyond the normal
>> R
>> editor that is included in the program.
>>
>> I had a look at VIM but I think it's difficult if you are just starting
>> programming.
>>
>> Could anyone recommend an editor that is suitable for beginners?
>>
>> Thanks for your help.
>>
>> Marion
>>
>>        [[alternative HTML version deleted]]
>>
>> __
>> R-help@r-project.org mailing list
>> https://stat.ethz.ch/mailman/listinfo/r-help
>> PLEASE do read the posting guide
>> http://www.R-project.org/posting-guide.html
>> and provide commented, minimal, self-contained, reproducible code.
>>
>
>        [[alternative HTML version deleted]]
>
> __
> R-help@r-project.org mailing list
> https://stat.ethz.ch/mailman/listinfo/r-help
> PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
> and provide commented, minimal, self-contained, reproducible code.
>



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

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


Re: [R] Problem with legend

2011-09-20 Thread Sarah Goslee
You're passing a vector of length 3 to the legend argument of legend(), so R is
assuming that you have three things you want to display.

There are two alternatives:
1. Provide legend() a legend that's a single character vector.
2. Specify that you don't want symbols for the last two of the three legend
components by using pch=c(21, NA, NA).

Sarah

On Tue, Sep 20, 2011 at 10:13 AM, Komine  wrote:
> HI,
> This code is part of a code I used to do a linear regression:
>
>>points(var1~var2,data=Regress,pch=21,bg="grey")
>>reg11<-lm(var1~var2,data=Regress)
>>abline(lm(var1~var2,data=Regress),lty=2,lwd=2,col="grey")
>>legend("topleft",legend=
>>c("NDII from composite",
>>"y= 0.0007x - 0.1156",expression(paste(r^2 == 0.88)),"p-value <0.001"),
>>pch=21,
>>bty="n")
>
> But I have a problem to complete the legend.
> Indeed, on the legend, I want to display a point  in front "Ndii from
> composite images." But when I run my code I get a point in front, "Ndii from
> composite images" but also before "y = 0.0007x - 0.1156", "r ^ 2 == 0.88," "
> and " p-value <0.001 "."
> How can I do to obtain only one point in front "Ndii from composite images"?
> Thank you in advance
>
>



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

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


[R] R: open source editor for r for beginners

2011-09-20 Thread Nai Ruscone Marta
Maybe you can use Rcmdr
http://socserv.mcmaster.ca/jfox/Misc/Rcmdr/
It is a very easy program.


Da: r-help-boun...@r-project.org [r-help-boun...@r-project.org] per conto di 
Jack Siegrist [jack...@eden.rutgers.edu]
Inviato: martedì 20 settembre 2011 16.07
A: r-help@r-project.org
Oggetto: Re: [R] open source editor for r for beginners

Marion Wenty wrote:
>
> ...Could anyone recommend an editor that is suitable for beginners?...
>

I had trouble with this for a long time. I tried several different programs,
but couldn't get any to work properly—they were either too complicated or
broken. I recently started using Notepad++ with NppToR. Everything works
fine, and it is easy enough for beginners to use.

Notepad++ is a free editor.

There is a download called NppToR, which runs down in the notification area
of the toolbar in Windows. This will allow you to send code directly to the
R console from the text editor using a keyboard shortcut, and to have your
text color-coded for R.

I would recommend starting with this. If, after a few years, you find
yourself limited by this setup, then you can think about things like emacs.



--
View this message in context: 
http://r.789695.n4.nabble.com/open-source-editor-for-r-for-beginners-tp3826797p3826958.html
Sent from the R help mailing list archive at Nabble.com.

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


Re: [R] fitting a sinus curve

2011-09-20 Thread maaariiianne
Dear all,
Thanks a lot for the help. It worked very well in the end.
Best regards,
Marianne

--
View this message in context: 
http://r.789695.n4.nabble.com/fitting-a-sinus-curve-tp3700833p3827044.html
Sent from the R help mailing list archive at Nabble.com.

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


Re: [R] Problem with legend

2011-09-20 Thread PtitBleu
Maybe by adding
col=c("grey","white","white"), bg="white
but not sure ...

Have a nice end of day,
Ptit Bleu.

--
View this message in context: 
http://r.789695.n4.nabble.com/Problem-with-legend-tp3826973p3827120.html
Sent from the R help mailing list archive at Nabble.com.

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


[R] Multivariate spline regression and predicted values

2011-09-20 Thread Max Farrell
Hello,

I am trying to estimate a multivariate regression of Y on X with
regression splines. Y is (nx1), and X is (nxd), with d>1. I assume the
data is generated by some unknown regression function f(X), as in Y =
f(X) + u, where u is some well-behaved regression error. I want to
estimate f(X) via regression splines (tensor product splines). Then, I
want to get the predicted values for some new points W.

To be concrete, here is an example of what I want:

#dimensions of the model
d=2
n=1000
#some random data
X <- matrix(runif(d*n,-2,2),n,d)
U <- rnorm(n)
Y <- X[,1] + X[,2] + U
# a new point for prediction
W <- matrix(rep(0),1,d)

Now if I wanted to use local polynomials instead of splines, I could
load the 'locfit' package and run (something like):

lp.results <- 
smooth.lf(X,Y,kern="epan",kt="prod",deg=1,alpha=c(0,0.25,0),xev=W,direct=TRUE)$y

Or, if X was univariate (ie d=1), I could use (something like):

spl.results <- predict(smooth.spline(X,Y, nknots=6),W)

But smooth.spline only works for univariate data. I looked at the
"crs" package, and it at least will fit the multivariate spline, but I
don't see how to predict the new data from this. That is, I run a
command like:

spl.fit <- crs(Y~X[,1] + X[,2],basis="tensor",
degree=c(3,3),segments=c(4,4),degree.min=3,degree.max=3, kernel=FALSE,
cv="none",knots="uniform",prune=FALSE)

Then what?

What I really want is the spline version of the smooth.lf command
above, or the multivariate version of smooth.spline. Any ideas/help?

Thanks,
Max

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


[R] rtmvnorm performance issues

2011-09-20 Thread Martin C. Steinwand
When sampling from a multi-variate truncated normal using rtmvnorm from 
the tmvnorm-package, I experience extreme performance differences between 
two of my computers. On my laptop computer, draws take ~5s, on my desktop 
~30s. I need to run MCMCs with repeat calls to rtmvnorm on my desktop. The 
code in both cases is exactly the same. rtmvnorm seems not to have any 
machine dependent defaults built in.

The function call is:
rtmvnorm(1, mean =as.numeric(A.i %*% (X%*%b.c[r,])), sigma = solve(t(A) 
%*% A),
lower = as.numeric(0^Y * -Inf^(1-Y)), upper= 
as.numeric(0^(1-Y)*Inf^(Y)),
algorithm = "gibbs", burn.in.samples=ys.burn, start.value 
= ys.old) 

The laptop computer is: 
Dell Latitude E4300 with Intel Core2 P9600 @ 2.53GHz, 4GB of RAM (not sure 
what type), Windows 7 Professional, 64 bit.
The desktop:
Dell Precision T3500 with Intel Xeon W3565 @ 3.20Ghz, 6GB DDR3 RAM, 
Windows 7 Professional, 64 bit.

Many thanks for any hints.

Martin Steinwand

[[alternative HTML version deleted]]

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


[R] Problems using predict from GAM model averaging (MuMIn)

2011-09-20 Thread Vernon Visser
I am struggling to get GAM model predictions from the top models calculated
using model.avg in the package "MuMIn".

My model looks something like the following:
gamp <- gam(log10(y)~s(x1,bs="tp",k=3)+s(x2,bs="tp",k=3)+
  s(x3,bs="tp",k=3)+s(x4,bs="tp",k=3)+s(x5,bs="tp",k=3)+
  s(x6,bs="tp",k=3)+x7,data=dat, family="gaussian")

I am trying to follow the example given in the help for "predict.averaging":

I can calculate the top models etc. without problem:

dd<-dredge(gamp)
top.models <- get.models(dd, subset=cumsum(weight) <= .95)
mavg<-model.avg(top.models) # get averaged coefficients

I then calculate means of all the data:

newdata <- as.data.frame(lapply(lapply(dat[1:6], mean), rep, 27))

And use the helper function to get my variable of interest at regular
intervals:

# helper function
nseq <- function(x, len=length(x)) seq(min(x, na.rm=TRUE),max(x,
na.rm=TRUE), length=len)
newdata$x1 <- nseq(dat$x1, nrow(newdata))


The problem comes in when I try do the following:

pred <- cbind(sapply(top.models, predict,
newdata=newdata),averaged=predict(model.avg(top.models), newdata))

I get the following error: "Error in reformulate(allNames) :
  'termlabels' must be a character vector of length at least one"

I think the problem has something to do with the fact that I have used 3
knots in the GAM and therefore I land up with two coefficients for each
factor, but I have no idea how to get around this problem.

-- 
Vernon Visser
Post-doctoral Research Associate
Centre of Excellence for Invasion Biology
Department of Botany and Zoology
Natural Sciences Building
Private Bag X1
University of Stellenbosch
Matieland
7602
South Africa

[[alternative HTML version deleted]]

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


[R] means across list of data frames

2011-09-20 Thread Matthew Finkbeiner
I have a list of data frames like the following:

set.seed(123)
a<- data.frame(x=runif(10), y = runif(10), sample = seq(1,10))
b<- data.frame(x=runif(10), y = runif(10), sample = seq(1,10))
L<- list(a,b)

All data frames in the list have the same dimensions.  I need to calculate
the sample means for x and y.  The real data are lists of several thousand
quite large dataframes, so I need something that is pretty fast.  Here is
what I have so far:

y<- rowMeans(sapply(L,'[[','y'))
x<- rowMeans(sapply(L,'[[','x'))

this works great, but I'm only able to get the sample means for one column
at a time.  Is there a way to automate things a bit so that I can get the
sample means for several columns with one call?

Thanks for any suggestions,

Matthew

[[alternative HTML version deleted]]

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


[R] Problem with legend

2011-09-20 Thread Komine
HI,
This code is part of a code I used to do a linear regression:

>points(var1~var2,data=Regress,pch=21,bg="grey")
>reg11<-lm(var1~var2,data=Regress)
>abline(lm(var1~var2,data=Regress),lty=2,lwd=2,col="grey")
>legend("topleft",legend=
>c("NDII from composite",  
>"y= 0.0007x - 0.1156",expression(paste(r^2 == 0.88)),"p-value <0.001"),
>pch=21,
>bty="n")

But I have a problem to complete the legend.
Indeed, on the legend, I want to display a point  in front "Ndii from
composite images." But when I run my code I get a point in front, "Ndii from
composite images" but also before "y = 0.0007x - 0.1156", "r ^ 2 == 0.88," "
and " p-value <0.001 "."
How can I do to obtain only one point in front "Ndii from composite images"?
Thank you in advance 


--
View this message in context: 
http://r.789695.n4.nabble.com/Problem-with-legend-tp3826973p3826973.html
Sent from the R help mailing list archive at Nabble.com.

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


[R] Using method = "aic" with pspline & survreg (survival library)

2011-09-20 Thread Carina Salt
Hi everybody.  I'm trying to fit a weibull survival model with a spline
basis for the predictor, using the survival library.  I've noticed that it
doesn't seem to be possible to use the aic method to choose the degrees of
freedom for the spline basis in a parametric regression (although it's
fine with the cox model, or if the degrees of freedom are specified directly
by the user), and I was wondering if there is some reason for this?


Simple example:

library(survival)
attach(cancer)
# cox model with specified degs of freedom - works fine
fit1 <- coxph(Surv(time, status) ~ ph.ecog + pspline(age,3), cancer)
# cox model with aic - works fine
fit1 <- coxph(Surv(time, status) ~ ph.ecog + pspline(age,method="aic"),
cancer)
# weibull model with specified degs of freedom - works fine
fit1 <- survreg(Surv(time, status) ~ ph.ecog + pspline(age,3), cancer,
dist="weibull")
# weibull model with aic - gives an error
fit1 <- survreg(Surv(time, status) ~ ph.ecog +
pspline(age,method="aic"),dist="weibull", cancer)
Error in (cfun[[1]])(parmlist[[1]], iter, iterlist[[1]], n.eff, pdf[1],  :
  object 'loglik' not found

I also get a similar error about "object 'loglik' not found" if I try to use
method="aic" in the specification of a frailty term in a survreg model.

Thanks for your help - apologies in advance if I'm missing something very
obvious. I'm using R2.13.0 btw, with survival v2.39-9.

Regards
Carina

[[alternative HTML version deleted]]

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


Re: [R] open source editor for r for beginners

2011-09-20 Thread Jack Siegrist

Marion Wenty wrote:
> 
> ...Could anyone recommend an editor that is suitable for beginners?...
> 

I had trouble with this for a long time. I tried several different programs,
but couldn't get any to work properly—they were either too complicated or
broken. I recently started using Notepad++ with NppToR. Everything works
fine, and it is easy enough for beginners to use.

Notepad++ is a free editor.

There is a download called NppToR, which runs down in the notification area
of the toolbar in Windows. This will allow you to send code directly to the
R console from the text editor using a keyboard shortcut, and to have your
text color-coded for R.

I would recommend starting with this. If, after a few years, you find
yourself limited by this setup, then you can think about things like emacs.



--
View this message in context: 
http://r.789695.n4.nabble.com/open-source-editor-for-r-for-beginners-tp3826797p3826958.html
Sent from the R help mailing list archive at Nabble.com.

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


[R] Boxplots from 4 dimensional array

2011-09-20 Thread Tarmo Remmel
Hello list members,

I am working with simulated data for landscape pattern analysis.  I have
1000 replicates of binary (2 colour) gridded landscapes at each combination
of 9 levels of class proportion and 11 levels of spatial autocorrelation.
The results are stored in an array as follows:

> dim(surfaces)
[1]   389   11 1000

The dimensions are defined as follows:
[x,,,] 1:38, integers that identify a measurement type (landscape pattern
metrics)
[,x,,] 1:9, integers that identify levels of class proportion
[,,x,] 1:11, integers that identify levels of spatial autocorrelation
[,,,x] floating point values for the specific landscape metric

I would like a simple way to produce boxplots of the 1000 metric values for
a specific landscape metric and level of spatial autocorrelation across the
9 levels of proportion.  Thus, I want to fix the first dimension (say as 10)
and fix the third dimension (say as 1), and then use the second dimension as
factors (1:9) to produce boxplots of the values in the 4th dimension.  Is
there a simple way to do this?  

I have been playing with boxplot() and apply() but am getting some
dimensions mixed up and thought that this would be a good time to seek some
help.  Any help with this would be greatly appreciated.

Thank you,

Tarmo


_
Tarmo K Remmel PhD
Associate Professor, Department of Geography
York University, N413A Ross Building
4700 Keele Street, Toronto, Ontario, M3J 1P3
Tel: 416-736-2100 x22496, Fax: 416-736-5988
Skype: tarmoremmel

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


Re: [R] question concerning the acf function

2011-09-20 Thread Jean-Christophe BOUËTTÉ
Hi Samir,
I do vaguely understand your intention. However I'm not sure taking
the mean of acf's makes any sense.
I do not know what your final goal is (what do you want to do with the
data?) but here is a suggestion. Instead of trying to aggregate acfs
computed on different series, why don't you:
1. define properly what your goal is for each series
2. find a way to reduce this series to a small set of number using an
automated procedure (for example, the coefficients of an AR, the order
of which has been determined via a rule of thumb or in a more
scientific way. see ?ar)
3. apply this automated procedure to each series to get 3000 small
sets of numbers.
This way, you'll be more able to capture the peculiarities of each series.

This approach leaves open the question of correlation between
different series, of course, but this is a first step. ar handles
multivariate series too.
Jean-Christophe

PS: since this conversation started on R-help, I reply to the list.
Others may offer more meaningful advice!

2011/9/20 Samir Benzerfa :
> Actually, you are right. Autocorrelation is simply cross-correlation with
> itself. However, what I would like to have is, instead of
> calculating/plotting the acf for 3000 different series (I have 3000 stocks
> in my dataset) which would take too much time, simply to take something like
> the mean of all acf's. My goal is to see how large the autocorrelation in my
> whole dataset is, in order to apply an autoregressive model to my data.
>
> Do you understand my intention?
>
> THX, SB
>
> -Ursprüngliche Nachricht-
> Von: Jean-Christophe BOUËTTÉ [mailto:jcboue...@gmail.com]
> Gesendet: Freitag, 16. September 2011 17:31
> An: Samir Benzerfa
> Cc: r-help@r-project.org
> Betreff: Re: [R] question concerning the acf function
>
> Hi Samir,
> to me, autocorrelation is the cross-correlation of a signal with
> itself. Which is why I don't really understand the meaning of your
> question.
> Are you looking for cross-correlation, for example the ccf function
> documented in the same help page as acf ?
>
> JC
>
>
> 2011/9/16 Samir Benzerfa :
>> Below you can see a sample of my data.
>>
>> I learned that I can calculate the autocorrelation of such time series by
>> using the function acf(Stock A) or pacf(Stock A) and the same for the
> other
>> stocks. What I would like to do, is to calculate the overall
> autocorrelation
>> in the whole set (so for all stocks together).
>>
>> Any ideas?
>>
>> Thanks,
>> SB
>>
>>
>> Date    Stock A         Stock B
>> 01.01.1980      0                       0
>> 02.01.1980      0                       0
>> 03.01.1980      0.002149977             0
>> 04.01.1980      -0.002149977    0.003966489
>> 07.01.1980      0                       0
>> 08.01.1980      0.007478811             0
>> 09.01.1980      0.007352198             0.00393059
>> 10.01.1980      0.003113235             0.009673601
>> 11.01.1980      -0.008352074    -0.003843623
>> 14.01.1980      0                       0
>> 15.01.1980      -0.006371182    -0.009760568
>> 16.01.1980      0.007424018             0.00393059
>> 17.01.1980      0.007299239             0.001952035
>> 18.01.1980      -0.008352074    -0.001952035
>>
>>
>>
>> -Ursprüngliche Nachricht-
>> Von: Jean-Christophe BOUËTTÉ [mailto:jcboue...@gmail.com]
>> Gesendet: Freitag, 16. September 2011 15:20
>> An: Samir Benzerfa
>> Cc: r-help@r-project.org
>> Betreff: Re: [R] question concerning the acf function
>>
>> Hi,
>> you did not supply a reproducible example. We do not know what your
>> data nor your code looks like.
>> Please follow the recommandations found at the bottom of this email!
>> You're more likely to get a quick and meaningful reply.
>> JC
>>
>> 2011/9/16 Samir Benzerfa :
>>> Hi everyone,
>>>
>>>
>>>
>>> I've got a question concerning the function acf(.) in R for calculating
>> the
>>> autocorrelation in my data.
>>>
>>>
>>>
>>> I have a table with daily returns of several stocks over time and I would
>>> like to calculate the autocorrelation for all the series (not only for
> one
>>> time series). How can I do this?
>>>
>>> After that I want to apply an autoregressive model based on the estimated
>>> lag in the data and finally extract the residuals for further
>> calculations.
>>>
>>>
>>>
>>> Many thanks & best regards
>>>
>>> Benzerfa
>>>
>>>
>>>        [[alternative HTML version deleted]]
>>>
>>> __
>>> R-help@r-project.org mailing list
>>> https://stat.ethz.ch/mailman/listinfo/r-help
>>  PLEASE do read the posting guide
>> http://www.R-project.org/posting-guide.html
>>  and provide commented, minimal, self-contained, reproducible code.
>>
>>
>
>

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


Re: [R] closeness of codes

2011-09-20 Thread Henri-Paul Indiogine
Hi Jean and Jim!

Thanks for your suggestions.

Best,
Henri-Paul


-- 
Henri-Paul Indiogine

Curriculum & Instruction
Texas A&M University
TutorFind Learning Centre

Email: hindiog...@gmail.com
Skype: hindiogine
Website: http://people.cehd.tamu.edu/~sindiogine

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


Re: [R] open source editor for r for beginners

2011-09-20 Thread Bert Gunter
Marion:

You should always first search CRAN for such queries. Had you done so, you
would have been led to:

http://www.sciviews.org/_rgui/

There is an extensive list of editors/IDE's there.

-- Bert

On Tue, Sep 20, 2011 at 6:26 AM, Marion Wenty wrote:

> Hello all,
>
> I am looking for an editor for R which has got functions beyond the normal
> R
> editor that is included in the program.
>
> I had a look at VIM but I think it's difficult if you are just starting
> programming.
>
> Could anyone recommend an editor that is suitable for beginners?
>
> Thanks for your help.
>
> Marion
>
>[[alternative HTML version deleted]]
>
> __
> R-help@r-project.org mailing list
> https://stat.ethz.ch/mailman/listinfo/r-help
> PLEASE do read the posting guide
> http://www.R-project.org/posting-guide.html
> and provide commented, minimal, self-contained, reproducible code.
>



-- 
"Men by nature long to get on to the ultimate truths, and will often be
impatient with elementary studies or fight shy of them. If it were possible
to reach the ultimate truths without the elementary studies usually prefixed
to them, these would not be preparatory studies but superfluous diversions."

-- Maimonides (1135-1204)

Bert Gunter
Genentech Nonclinical Biostatistics
467-7374
http://pharmadevelopment.roche.com/index/pdb/pdb-functional-groups/pdb-biostatistics/pdb-ncb-home.htm

[[alternative HTML version deleted]]

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


Re: [R] open source editor for r for beginners

2011-09-20 Thread Rich Shepard

On Tue, 20 Sep 2011, Marion Wenty wrote:


I am looking for an editor for R which has got functions beyond the normal
R editor that is included in the program.



I had a look at VIM but I think it's difficult if you are just starting
programming.


Marion,

  VIM (Vi) is a line-oriented editor. The other standard is Emacs (page
oriented) which has been described as the only editor that includes an
operating system. :-) I know folks that open emacs in their console when
they log into their system in the morning and do all their work within it,
including processing mail and news groups, searching the Web, coding, and
writing letters and documents.

  All editors have a learning curve; the more powerful and capable the
editor the longer the learning curve. Pick one and work with it until you
learn enough to do what you want.

  I use emacs (and have for years for all sorts of text editing and data
manipulation tasks) and have recently added ess (Emacs Speaks Statistics)
since I'm starting to learn to use R. I find it highly productive; YMMV.

Rich

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


Re: [R] Add a function in rq

2011-09-20 Thread David Winsemius


On Sep 20, 2011, at 4:50 AM, mael wrote:


Hi,

I am trying to add a function in a linear quantile regresion to find a
breakpoint. The function I want to add is:

y=(k+ax)(xB)

How do I write it in the rq() function? Do I need to define the  
parameters

in any way and how do I do that? I'm a biologist new to R.


You have not offered a test dataset, so no tested example from me but  
why not use an indicator term in a formula:


(You also have not defined your model very clearly. What are the roles  
of the different terms? There appear to be some superfluous constants.  
The (a-d) expression would not fit into regression formula conventions  
very well. (Either that or a linear model is not what you are asking  
about.)  This is just a wild guess:


You will get an intercept term by default which I take to be the "k"  
term in your expression. I doubt the final form will be exactly as you  
expected, but it may be able to recast it in you preferred form (once  
you make clear what those terms mean). The estimate for the first term  
should come out as an interaction with an x-term and an I(BThe estimate for the second term should likewise yield two  
coefficients. So (I thought) you should get 5 coefficients ...but   
When I did it on a simple linear regression model I got 6, so I guess  
my understanding of how many are linearly dependent was wrong.


> lm(y ~ x*I(x < 1) + dx*I(x >1), data=dat)

Call:
lm(formula = y ~ x * I(x < 1) + dx * I(x > 1), data = dat)

Coefficients:
(Intercept)x I(x < 1)TRUE   dx
  2.9202.185  -25.026   49.833
   I(x > 1)TRUE   x:I(x < 1)TRUE  dx:I(x > 1)TRUE
 NA  -33.605  -50.870


If that "dx" term is from a differential equation, then scratch all of  
the above and instead use software appropriate to the task or perhaps  
use the diff() function to create a delta-x. Or if you are trying to  
do the very non-linear operation of estimating the B coefficient,  
which is not "linear quantile regression". "Linear" in the regression  
context means linear in the coefficients and the expression (xwould be non-linear when B is a coefficient to be estimated. In his  
book "Quantile regression Koenker says changepoints can be estimated  
with  the nonparametric methods offered in `rqss`


I did try the above formula in package quantreg, but I get an error  
from a singular design matrix:


require(quantreg)
rq( y ~ x*I(x < 1) + dx*I(x > 1), data=dat)
Error in rq.fit.br(x, y, tau = tau, ...) : Singular design matrix

So `rq` seems to be less capable of identifying and discarding  
dependencies in the design matrix than is `lm`.



I think some exploratory analysis might be your best first choice,  
using lowess. To see many types of regression methods illustrated you  
might want to look at Vincent Zoonekynd pages:

http://zoonek2.free.fr/UNIX/48_R/10.html

(it's too bad Vincent still has quantreg examples on his TODO list,  
but he does illustrate from package segmented and uses base `lowess`  
and a couple of other to show the exploratory methods in action.)


And finishing back at rq with e advice to use exploratory methods as  
in Koenker's example on p 16 of

http://cran.r-project.org/web/packages/quantreg/vignettes/rq.pdf

... where he used a 15-knot spline function inside an rq call.

--

David Winsemius, MD
West Hartford, CT

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


[R] seqinr-dist.alignment?

2011-09-20 Thread Betty Schirrmeister
Hi everyone

I have got a quick question:

I the "seqinr" package:

*dist.alignment(x,"identity")*

This is calculating the square root of pairwise distances. Does anyone know
whether/how gaps are counted in this function?

Thank you.

Best wishes,

Bettina

[[alternative HTML version deleted]]

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


Re: [R] open source editor for r for beginners

2011-09-20 Thread R. Michael Weylandt
RStudio


Hope this helps,
Michael Weylandt

On Tue, Sep 20, 2011 at 9:26 AM, Marion Wenty wrote:

> Hello all,
>
> I am looking for an editor for R which has got functions beyond the normal
> R
> editor that is included in the program.
>
> I had a look at VIM but I think it's difficult if you are just starting
> programming.
>
> Could anyone recommend an editor that is suitable for beginners?
>
> Thanks for your help.
>
> Marion
>
>[[alternative HTML version deleted]]
>
> __
> R-help@r-project.org mailing list
> https://stat.ethz.ch/mailman/listinfo/r-help
> PLEASE do read the posting guide
> http://www.R-project.org/posting-guide.html
> and provide commented, minimal, self-contained, reproducible code.
>

[[alternative HTML version deleted]]

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


[R] open source editor for r for beginners

2011-09-20 Thread Marion Wenty
Hello all,

I am looking for an editor for R which has got functions beyond the normal R
editor that is included in the program.

I had a look at VIM but I think it's difficult if you are just starting
programming.

Could anyone recommend an editor that is suitable for beginners?

Thanks for your help.

Marion

[[alternative HTML version deleted]]

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


[R] Poisson-Gamma computation (parameters and likelihood)

2011-09-20 Thread Sebastiano Putoto
Good afternoon/morning readers. This is the first time I am trying to run
some Bayesian computation in R, and am experiencing a few problems.

I am working on a Poisson model for cancer rates which has a conjugate Gamma
prior.

1) The first question is precisely how I work out the parameters.

#Suppose I assign values to theta with *seq()*
*theta<-seq(0,1,len=500)*

#Then I try out the parameters that seem to fit with a certain prior idea on
theta (see next)
*a=182*
*b=3530*
*gaprior<-dgamma(theta,a,b)*
*
*
It should work by trial-and-error (according to "Bayesian Computation with
R") , but how can I check the parameters turned out well: should I just look
at the plot, or evaluate it through the *1 - pgamma(x,a,b) *function, having
knowledge of the 5th percentile (data from US Cancer Statistics)?

2) Then, the next problem I have regards the likelihood distribution.

#Having the *react* table, I name the columns (with y=deaths, and
x=exposures)
*
react
x  y
1   6 15
2   5 16
3   3 12
4   4  6
5  27 77
6   7 17
7   4 11
8   5 10
9  23 63
10 11 29

*
*yr <- react[,2]*
*xr <- react[,1]*



#I then compute the likelihood
*poislike=dpois(yr, theta*xr)*

#And this is what I come up with, which I really don't understand.
*poislike*
*[1] 0 0 0 0 0 0 0 0 0 0*

The values shouldn't be all null, otherwise my posterior cannot be computed
properly. Does anyone have any idea on where I could possibly have messed it
up?

Thank you very much for your attention.

Regards,

Sebastiano Putoto (University of Pavia, Italy)

[[alternative HTML version deleted]]

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


Re: [R] pasting elements of one character vector together

2011-09-20 Thread Marion Wenty
hi eik, mark and sarah,

thank you for your help!

i was looking for the t-command but in the end the apply-command did the
trick.

marion

2011/9/20 Sarah Goslee 

> It isn't entirely clear to me what you want, but here are all the
> possibilities
> I could think of. I hope one of them does what you want.
>
> > testmat <- matrix(1:8, ncol=2)
> > testmat
> [,1] [,2]
> [1,]15
> [2,]26
> [3,]37
> [4,]48
> > paste(testmat, collapse=" ")
> [1] "1 2 3 4 5 6 7 8"
> > paste(t(testmat), collapse=" ")
> [1] "1 5 2 6 3 7 4 8"
> > apply(testmat, 1, paste, collapse=" ")
> [1] "1 5" "2 6" "3 7" "4 8"
> > apply(testmat, 2, paste, collapse=" ")
> [1] "1 2 3 4" "5 6 7 8"
>
> Sarah
>
> On Tue, Sep 20, 2011 at 5:55 AM, Marion Wenty 
> wrote:
> > I have another question concerning the paste command:
> >
> > now instead of a vector I would like to paste the elements of a matrix
> > together, which works in the same:
> >
> > Mypastedmatrix <- paste(Mymatrix,collapse="")
> >
> > My problem now is that the program does this BY COLUMN, but I would like
> to
> > have the elements pasted together BY ROW.
> >
> > Could anybody help me with this?
> >
> > Marion
> >
> --
> Sarah Goslee
> http://www.functionaldiversity.org
>

[[alternative HTML version deleted]]

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


Re: [R] closeness of codes

2011-09-20 Thread Jean V Adams
Jim Lemon wrote on 09/20/2011 04:15:46 AM:
> 
> On 09/19/2011 04:46 PM, Henri-Paul Indiogine wrote:
> > Greetings!
> >
> > I am using the R library RQDA to assign certain codes to paragraphs of
> > documents in a collection.   Several paragraphs are assigned more than
> > 1 code.  E.g. often the codes "poverty" and "education" will be
> > assigned to the same paragraph.   Often also "math" and "career" will
> > be given to the same paragraphs.  Other codes are never given to the
> > same paragraphs.
> >
> > I would like to calculate the relationship or "closeness" of certain
> > codes.  RQDA will generate a cross-codes table.  It has the form of an
> > upper triangular matrix where the upper triangle has the number of
> > cross occurrences of 2 codes at their intersection.  The lower
> > triangle is filled with NA.  The diagonal simply has the number of
> > occurrences of the codes by themselves.
> >
> > The row names are the names of the codes and the column names are the
> > IDs of the codes.  E.g.
> >
> > 1 2 34
> > code1  3 0  21
> > code2  NA  4 1 0
> > code3  NA NA   2 0
> > code4  NA NA  NA   3
> >
> > We can see that code1 is associated 2 out of 3 times with code3.
> > Code2 is present 1 out of 4 times with code3.  Code2 is never assigned
> > to the same paragraph as Code1 and Code4 are, and so on.
> >
> > I am trying to understand how to create some sort of graph or diagram
> > to represent this.  Should I use a cluster diagram or a network graph?
> >   Also, what sort of R code could I use?
> 
> Hi Henri,
> The intersectDiagram function in the plotrix package displays the 
> intersections of sets as rectangles with widths (and areas) proportional 

> to the number of members of each set intersection. This may be a way for 

> you to represent your codes. For your example, you could proceed like 
> this. Create a file ("hp.csv")containing the following:
> 
> paragraph,attribute
> p1,code1
> p1,code3
> p2,code1
> p2,code3
> p3,code1
> p3,code4
> p4,code2
> p5,code2
> p6,code2
> p7,code2
> p7,code3
> p8,code3
> p9,code3
> p10,code4
> p11,code4
> p12,code4
> 
> then:
> 
> library(plotrix)
> hp<-read.csv("hp.csv")
> intersectDiagram(hp,main="Combinations of codes")
> 
> There are other ways to represent your original data that 
> intersectDiagram will read in that you might like to try.
> 
> Jim


Another approach would be to redefine the cross-codes table as distances.
For example, if the cross-codes table is a matrix called m ...

# convert to "distances"
d <- 1 - m/diag(m)

# fill in the complete matrix
d[lower.tri(d)] <- d[upper.tri(d)]

# use multidimensional scaling to represent the distances in two 
dimensions
twodim <- cmdscale(d)
plot(twodim, type="n")
text(twodim, rownames(twodim))

Jean
[[alternative HTML version deleted]]

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


Re: [R] Tabulating Baseline Characteristics on specific observations

2011-09-20 Thread David Winsemius


On Sep 19, 2011, at 8:49 PM, justin jarvis wrote:


I have a data set with many missing observations.  When I run a
regression, R of course discards the observations (the whole row) that
have "NA".  I want to tabulate some baseline characteristics (column
means) but only for the observations that R used for the regression.
I tried to recreate this data frame by using na.omit on the original
data frame, but this will not work as this will discard an observation
with an "NA" in any column, and not just in the covariates.

In summary, I only want to remove observations that have an "NA" in
the covariate columns.  Something like Stata's e(sample), as far as I


na.omit(subset(dfrm, select=  )  # or equivalent


can tell.

Justin Jarvis
PhD student, University of California, Irvine

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


David Winsemius, MD
West Hartford, CT

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


[R] predict() of garchFit

2011-09-20 Thread user84
Hi,
could anyone tell me how predict() predicts the meanError or
standardDerivation of a garchFit(1,1)-model,
knowing the coefficients mu, omega, alpha1, beta1 and of course all
datapoints?

Thanks and sorry for my poor english. 

--
View this message in context: 
http://r.789695.n4.nabble.com/predict-of-garchFit-tp3826335p3826335.html
Sent from the R help mailing list archive at Nabble.com.

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


Re: [R] Displaying str(zoo) in Sweave

2011-09-20 Thread Ashim Kapoor
On Tue, Sep 20, 2011 at 4:31 PM, Duncan Murdoch wrote:

> On 11-09-20 3:08 AM, Ashim Kapoor wrote:
>
>> Dear R-helpers,
>>
>> Please look at the following minimal code.
>>
>> \documentclass[a4paper]{**article}
>> \begin{document}
>> <<>>==
>> library(zoo)
>> a<-zoo(1:4,order.by=Sys.time()**+1:4)
>> str(a)
>> @
>> \end{document}
>>
>> When I do R CMD Sweave,followed by pdflatex ,and view the final pdf, the
>> letter surrounding the phrase zoo,
>>
>> a ***zoo*** series
>>
>> are messed up.
>>
>> They are messed up even inside Emacs now that I think of it but not inside
>> the R Terminal.
>>
>> How can I fix this inside Sweave / Emacs.
>>
>
> Sounds like one of these possibilities:
>
>  - in one case you have "smart quotes", i.e. directional quotes.  Those may
> not be supported by your pdflatex, or your viewer
>
>  - (unlikely) something in the display is a special sequence that ESS in
> Emacs is reacting to badly.  I think this is unlikely, because the developer
> of str() uses ESS.
>
> To change the type of quotes, set options(useFancyQuotes=FALSE) or one of
> the other options listed in ?options.
>

The above useFancyQuotes option did the trick in BOTH pdf AND Emacs. Many
thanks.
Ashim

[[alternative HTML version deleted]]

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


Re: [R] Problem with converting factors to numbers

2011-09-20 Thread Duncan Murdoch

On 11-09-20 7:25 AM, _Luc_ wrote:

ok great, as.numeric(as.character(data$x)) works perfectly.

I am sorry that i did not find this before making this post.


@ peter
what did not work was:
data$x2<- as.character(data$x)
data$x3<- as.numeric(data$x2)


That should have worked.  Can you put together a simple example where it 
doesn't?


Duncan Murdoch

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


Re: [R] Problem with converting factors to numbers

2011-09-20 Thread _Luc_
ok great, as.numeric(as.character(data$x)) works perfectly.

I am sorry that i did not find this before making this post. 


@ peter
what did not work was:
data$x2 <- as.character(data$x) 
data$x3 <- as.numeric(data$x2) 

--
View this message in context: 
http://r.789695.n4.nabble.com/Problem-with-converting-factors-to-numbers-tp3826061p3826480.html
Sent from the R help mailing list archive at Nabble.com.

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


Re: [R] Displaying str(zoo) in Sweave

2011-09-20 Thread Duncan Murdoch

On 11-09-20 3:08 AM, Ashim Kapoor wrote:

Dear R-helpers,

Please look at the following minimal code.

\documentclass[a4paper]{article}
\begin{document}
<<>>==
library(zoo)
a<-zoo(1:4,order.by=Sys.time()+1:4)
str(a)
@
\end{document}

When I do R CMD Sweave,followed by pdflatex ,and view the final pdf, the
letter surrounding the phrase zoo,

a ***zoo*** series

are messed up.

They are messed up even inside Emacs now that I think of it but not inside
the R Terminal.

How can I fix this inside Sweave / Emacs.


Sounds like one of these possibilities:

 - in one case you have "smart quotes", i.e. directional quotes.  Those 
may not be supported by your pdflatex, or your viewer


 - (unlikely) something in the display is a special sequence that ESS 
in Emacs is reacting to badly.  I think this is unlikely, because the 
developer of str() uses ESS.


To change the type of quotes, set options(useFancyQuotes=FALSE) or one 
of the other options listed in ?options.


Duncan Murdoch

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


Re: [R] R-help Digest, Vol 103, Issue 19

2011-09-20 Thread mihalicza . peter
Szeptember 12-től 26-ig irodán kívül vagyok, és az emailjeimet nem érem el.

Sürgős esetben kérem forduljon Kárpáti Edithez (karpati.e...@gyemszi.hu).

Üdvözlettel,
Mihalicza Péter


I will be out of the office from 12 till 26 September with no access to my 
emails.

In urgent cases please contact Ms. Edit Kárpáti (karpati.e...@gyemszi.hu).

With regards,
Peter Mihalicza

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


Re: [R] The CRAN packages webpages are not found

2011-09-20 Thread Stefan Theussl

On 09/20/2011 10:57 AM, Achim Zeileis wrote:

On Tue, 20 Sep 2011, Tal Galili wrote:


I am not sure who to send this to - so I am writing this here.

It seems that the "index.html" pages on CRAN are gone.
For example:
http://cran.r-project.org/web/packages/ggplot2/index.html
Is gone.  But the directory is accessible:
http://cran.r-project.org/web/packages/ggplot2/

Who should this be forwarded to?


The CRAN maintainers, now cc.
The package list is currently being updated. Please wait 1 or 2 minutes 
as this can take time for several thousands of packages.


Best,
st


Thanks,
Z




Cheers,
Tal


Contact
Details:---
Contact me: tal.gal...@gmail.com |  972-52-7275845
Read me: www.talgalili.com (Hebrew) | www.biostatistics.co.il (Hebrew) |
www.r-statistics.com (English)
-- 



[[alternative HTML version deleted]]

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

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





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


Re: [R] pasting elements of one character vector together

2011-09-20 Thread Sarah Goslee
It isn't entirely clear to me what you want, but here are all the possibilities
I could think of. I hope one of them does what you want.

> testmat <- matrix(1:8, ncol=2)
> testmat
 [,1] [,2]
[1,]15
[2,]26
[3,]37
[4,]48
> paste(testmat, collapse=" ")
[1] "1 2 3 4 5 6 7 8"
> paste(t(testmat), collapse=" ")
[1] "1 5 2 6 3 7 4 8"
> apply(testmat, 1, paste, collapse=" ")
[1] "1 5" "2 6" "3 7" "4 8"
> apply(testmat, 2, paste, collapse=" ")
[1] "1 2 3 4" "5 6 7 8"

Sarah

On Tue, Sep 20, 2011 at 5:55 AM, Marion Wenty  wrote:
> I have another question concerning the paste command:
>
> now instead of a vector I would like to paste the elements of a matrix
> together, which works in the same:
>
> Mypastedmatrix <- paste(Mymatrix,collapse="")
>
> My problem now is that the program does this BY COLUMN, but I would like to
> have the elements pasted together BY ROW.
>
> Could anybody help me with this?
>
> Marion
>
-- 
Sarah Goslee
http://www.functionaldiversity.org

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


[R] Add a function in rq

2011-09-20 Thread mael
Hi,

I am trying to add a function in a linear quantile regresion to find a
breakpoint. The function I want to add is:

y=(k+ax)(xB) 

How do I write it in the rq() function? Do I need to define the parameters
in any way and how do I do that? I'm a biologist new to R.

Thanks!


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

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


Re: [R] pasting elements of one character vector together

2011-09-20 Thread Eik Vettorazzi
Hi marion,
just transpose the matrix:
mm<-matrix(LETTERS[1:20],nrow=5)
paste(t(mm),collapse="")
or - if you want the result seperated by rows

apply(mm,1,paste,collapse="")

cheers

Am 20.09.2011 11:55, schrieb Marion Wenty:
> I have another question concerning the paste command:
> 
> now instead of a vector I would like to paste the elements of a matrix
> together, which works in the same:
> 
> Mypastedmatrix <- paste(Mymatrix,collapse="")
> 
> My problem now is that the program does this BY COLUMN, but I would like to
> have the elements pasted together BY ROW.
> 
> Could anybody help me with this?
> 
> Marion
> 
> 2011/9/19 Marion Wenty 
> 
>> hello michael and dimitris,
>> yes, this was it!
>> now i understand this collapse-argument.
>> thank you very much.
>> marion
>>
>>
>> 2011/9/19 Dimitris Rizopoulos 
>>
>>> Try this:
>>>
>>> object <- c("Hello", "World")
>>> paste(object, collapse = " ")
>>>
>>>
>>> I hope it helps.
>>>
>>> Best,
>>> Dimitris
>>>
>>>
>>>
>>>
>>> On 9/19/2011 3:58 PM, Marion Wenty wrote:
>>>
 hello,

 i am familiar with the paste command with which i can paste for exaple:

 object<- "Hello"
 paste(object,"World")

 now i would like to be able to paste all the elements of the same vector
 together e.g:

 object<- c("Hello","World")

 getting as a result also:

 "Hello World".

 Does anyone know the solution to this problem?

 Thank you very much in advance.

 Marion

[[alternative HTML version deleted]]

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


>>> --
>>> Dimitris Rizopoulos
>>> Assistant Professor
>>> Department of Biostatistics
>>> Erasmus University Medical Center
>>>
>>> Address: PO Box 2040, 3000 CA Rotterdam, the Netherlands
>>> Tel: +31/(0)10/7043478
>>> Fax: +31/(0)10/7043014
>>> Web: 
>>> http://www.erasmusmc.nl/**biostatistiek/
>>>
>>
>>
> 
>   [[alternative HTML version deleted]]
> 
> __
> R-help@r-project.org mailing list
> https://stat.ethz.ch/mailman/listinfo/r-help
> PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
> and provide commented, minimal, self-contained, reproducible code.


-- 
Eik Vettorazzi
Institut für Medizinische Biometrie und Epidemiologie
Universitätsklinikum Hamburg-Eppendorf

Martinistr. 52
20246 Hamburg

T ++49/40/7410-58243
F ++49/40/7410-57790

--
Pflichtangaben gemäß Gesetz über elektronische Handelsregister und 
Genossenschaftsregister sowie das Unternehmensregister (EHUG):

Universitätsklinikum Hamburg-Eppendorf; Körperschaft des öffentlichen Rechts; 
Gerichtsstand: Hamburg

Vorstandsmitglieder: Prof. Dr. Jörg F. Debatin (Vorsitzender), Dr. Alexander 
Kirstein, Joachim Prölß, Prof. Dr. Dr. Uwe Koch-Gromus 

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


Re: [R] pasting elements of one character vector together

2011-09-20 Thread Marion Wenty
I have another question concerning the paste command:

now instead of a vector I would like to paste the elements of a matrix
together, which works in the same:

Mypastedmatrix <- paste(Mymatrix,collapse="")

My problem now is that the program does this BY COLUMN, but I would like to
have the elements pasted together BY ROW.

Could anybody help me with this?

Marion

2011/9/19 Marion Wenty 

> hello michael and dimitris,
> yes, this was it!
> now i understand this collapse-argument.
> thank you very much.
> marion
>
>
> 2011/9/19 Dimitris Rizopoulos 
>
>> Try this:
>>
>> object <- c("Hello", "World")
>> paste(object, collapse = " ")
>>
>>
>> I hope it helps.
>>
>> Best,
>> Dimitris
>>
>>
>>
>>
>> On 9/19/2011 3:58 PM, Marion Wenty wrote:
>>
>>> hello,
>>>
>>> i am familiar with the paste command with which i can paste for exaple:
>>>
>>> object<- "Hello"
>>> paste(object,"World")
>>>
>>> now i would like to be able to paste all the elements of the same vector
>>> together e.g:
>>>
>>> object<- c("Hello","World")
>>>
>>> getting as a result also:
>>>
>>> "Hello World".
>>>
>>> Does anyone know the solution to this problem?
>>>
>>> Thank you very much in advance.
>>>
>>> Marion
>>>
>>>[[alternative HTML version deleted]]
>>>
>>> __**
>>> R-help@r-project.org mailing list
>>> https://stat.ethz.ch/mailman/**listinfo/r-help
>>> PLEASE do read the posting guide http://www.R-project.org/**
>>> posting-guide.html 
>>> and provide commented, minimal, self-contained, reproducible code.
>>>
>>>
>> --
>> Dimitris Rizopoulos
>> Assistant Professor
>> Department of Biostatistics
>> Erasmus University Medical Center
>>
>> Address: PO Box 2040, 3000 CA Rotterdam, the Netherlands
>> Tel: +31/(0)10/7043478
>> Fax: +31/(0)10/7043014
>> Web: 
>> http://www.erasmusmc.nl/**biostatistiek/
>>
>
>

[[alternative HTML version deleted]]

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


Re: [R] Strplit code

2011-09-20 Thread Santosh
Dear R- Splus experts,
In R, I have frequently used do.call with strsplit. and I have a hard time
with Splus.. any suggestions?

for example, the R code below:

do.call(rbind,strsplit(paste(letters[1:10],c(1:10))," "))

Thanks so much,
Santosh

On Fri, Dec 5, 2008 at 8:51 AM, William Dunlap  wrote:

>   [R] Strplit code
>   pomchip at free.fr pomchip at free.fr
>   Wed Dec 3 20:52:21 CET 2008
>
>   Dear R-users,
>
>   The strsplit function does not exist in S-plus and I would like to
> use it. How
>   could I reproduce the function in Splus or access to its source code?
>
>Thank you in advance,
>
>   Sebastien
>
> strsplit() was added to S+ 8.0 (May 2007).  At the same time
> we changed the default regular expression style from 'basic'
> (a.k.a. 'obsolete') to 'extended' and we added the string functions
> sub(), gsub(), and sprintf().
>
> S+ 8.1 is now available (as of November 2008).
>
> Bill Dunlap
> TIBCO Software Inc - Spotfire Division
> wdunlap tibco.com
>
> __
> R-help@r-project.org mailing list
> https://stat.ethz.ch/mailman/listinfo/r-help
> PLEASE do read the posting guide
> http://www.R-project.org/posting-guide.html
> and provide commented, minimal, self-contained, reproducible code.
>

[[alternative HTML version deleted]]

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


Re: [R] switching off commands within character vector

2011-09-20 Thread Marion Wenty
hello,
thank you for your answer!
yes, now it is working!
marion

2011/9/19 Duncan Murdoch 

> On 11-09-19 7:30 AM, Marion Wenty wrote:
>
>> Hello,
>>
>> could someone help me with this problem?:
>>
>> I would like to create a latex-script inside of a character vector in
>> order
>> to being able to compilate it within latex in the end.
>>
>> if i try the following commands:
>>
>> l1<- "Hello world"
>> latexscript<- paste("\c",l1,"\c")
>>
>> ... I get an error message. I think the problem is that r sees \c as a
>> command.
>>
>> How can I get
>>
>> "\c Hello world \c"
>>
>> as a result without getting the error message?
>>
>
> Here's the long answer:
>
> R uses \ as an "escape character", which is different from the way LaTeX
> uses it.  The string "\n" contains a single character (a newline character.
>  When you say "\c", the parser thinks you are asking for a single character
> which is written as \c, but there isn't one, so you get the error message.
>
> To put the characters \c into a string, you need to escape the backslash,
> i.e. use "\\c".  That's a two character string.  It will print as "\\c"
> using print(), but if you use cat() you will see the actual characters \c.
>
> The short answer is:
>
>
> latexscript <- paste("\\c", l1, "\\c")
> cat(latexscript, "\n")
>
> Duncan Murdoch
>

[[alternative HTML version deleted]]

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


  1   2   >