Re: [R] Flipping axis 1 in CCA plot - vegan

2011-02-16 Thread Jari Oksanen
esgarbanzo  uw.edu> writes:

> 
> 
> Hello,
> I've successfully run my CCA and the ordination is not displayed quite
> right. Is it possible to flip the x-axis (ie., make it a mirror image of
> itself)?
> 
Howdy,

I don't know wha tyou mean when you say that the ordination is not displayed
"right". Howeveer, you can flip an axis by setting its limits in xlim or ylim.
First axis is flipped by: 

m <- cca(dune)
plot(m, xlim = c(2, -3))

Cheers, Jari Oksanen

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

2011-02-16 Thread Prof Brian Ripley

On Wed, 16 Feb 2011, deborahsills wrote:



Did you find out where one can get the package ChemometricsWithR.


All we *know* is that it is said to be with the book, but it has been 
submitted to CRAN.  If accepted, it will appear there.



Thank you!
Deborah



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


PLEASE do: you are asked to include context and reference past 
postings.


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

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


Re: [R] incomplete final line

2011-02-16 Thread Joshua Wiley
Hi,

On Wed, Feb 16, 2011 at 10:11 AM, mipplor  wrote:
> Hi,
>
> I work like this:
>
>> data<‐read.table('E:/my documents/r/consumer.xls',header=TRUE)
> Warning message:
> In read.table("E:/my documents/r/consumer.xls", header = TRUE) :
>  incomplete final line found by readTableHeader on 'E:/my
> documents/r/consumer.xls'
>
> could someone shoot the trouble for me ? thx

Le'me, just get my six shooter

Although there is some ability to read Excel spreadsheets directly
into R, I think the easiest solution would be to first open the file
in Excel and then save it in a format more amenable to R such as .txt
or .csv.  CSV files have the attractive feature that you can use
read.csv() so its even easier to read in.  The R Import/Export manual
provides more details:

(1) http://cran.r-project.org/doc/manuals/R-data.html#Reading-Excel-spreadsheets

(2) Also see the documentation, which you can access at the console by typing

?read.table

Once you're done with that, I also highly recommend reading

(3) http://cran.r-project.org/doc/manuals/R-intro.html

(4) Install the "sos" package, which provides some very helpful
searching functions.
install.packages("sos")

(5) You can now use findFn() from the R console to look for packages
or functions related to Excel and it will give you a nicely formatted
table.
findFn("Excel")

(6) Once you've done the other steps, check out the R Inferno by
Patrick Burns.  It is an entertaining and informative guide to help
familiarize you with using R.
http://www.burns-stat.com/pages/Tutor/R_inferno.pdf

That ought to send your trouble for a ride on the three legged horse,

Josh

>
> sorry for trouble ,im a newbie.
> --
> View this message in context: 
> http://r.789695.n4.nabble.com/incomplete-final-line-tp3309405p3309405.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.

"If we try ridin' instead of thinkin'... Well, we'd end up hangin' by
a rope by nightfall."


-- 
Joshua Wiley
Ph.D. Student, Health Psychology
University of California, Los Angeles
http://www.joshuawiley.com/

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


Re: [R] logsumexp function in R

2011-02-16 Thread Petr Savicky
On Wed, Feb 16, 2011 at 04:14:38PM -0500, Brian Tsai wrote:
> Hi,
> 
> I was wondering if anyone has implemented a numerically stable function to
> compute log(sum(exp(x))) ?

Try the following

   log(sum(exp(x - max(x + max(x)

If this is not sufficient, consider using CRAN package Rmpfr with
extended arithmetic.

Petr Savicky.

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

2011-02-16 Thread Simon Blomberg

On 17/02/11 09:44, Sam Steingold wrote:

summary() in functions seems to print nothing.
str() does print something.
why?
   
summary() returns the summary information as its value. If you want to 
see this value from inside a function, use print(summary()). The reason 
you see the summary information at the top level is because R implicitly 
assumes that you want to print() the summary() output. This is the same 
for any object. Typing obj at the prompt is really the same as doing 
print(obj). In contrast, str() does not return a value, and you see the 
output printed because it is a side-effect of calling the function. 
(This behaviour irks me as it is not good functional programming style, 
although ?str says that it does not return a value for "efficiency 
reasons").


Cheers,

Simon.

--
Simon Blomberg, BSc (Hons), PhD, MAppStat, AStat
Lecturer and Consultant Statistician
School of Biological Sciences
The University of Queensland
St. Lucia Queensland 4072
Australia
T: +61 7 3365 2506
email: S.Blomberg1_at_uq.edu.au
http://www.uq.edu.au/~uqsblomb/

Policies:
1.  I will NOT analyse your data for you.
2.  Your deadline is your problem

Statistics is the grammar of science - Karl Pearson.

__
R-help@r-project.org mailing list
https://stat.ethz.ch/mailman/listinfo/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] Timeseries Data Plotted as Monthly Boxplots

2011-02-16 Thread Thomas Adams
Katrina,

What I have done, if I understand what you are after, was to create a list for 
each month of data - in order. Then, create a boxplot - in order - by 
month/year. I do this for our ensemble streamflow forecasts. The key us to 
create the list of values by month.

Regards,
Tom

Sent from my iPhone

On Feb 16, 2011, at 3:31 PM, Katrina Bennett  wrote:

> Hello, I'm trying to develop a box plot of time series data to look at the
> range in the data values over the entire period of record.
> 
> My data initially starts out as a list of hourly data, and then I've been
> using this code to make this data into the final ts array.
> 
> # Read in the station list
> stn.list <- read.csv("/home/kbennett/fews/stnlist3", as.is=T, header=F)
> 
> # Read in all three variables.
> vars <- c("MAT", "MAP", "MAP06")
> 
> for (stn in stn.list) {
>  for (v in 1:length(vars) {
># Read in year month start and end dates table & name it
>ym.table <- read.csv("/home/kbennett/fews/", stn, var, ".ym.txt", as.is=T,
> header=F)
>names(ym.table) <- c("yearstart", "monthstart", "yearend", "monthend")
> 
>fn <- paste(stn, ".", vars[v], ".FIN", sep="")
>  if(file.exists(fn)) {
>clim.dat <- read.csv(fn, header=F)
>names(clim.dat) <- c("cdata")
>year.start <- ym.table$yearstart
>year.end <- ym.table$yearend
> 
>mo.start <- ym.table$monthstart
>mo.end <- ym.table$monthend
> 
>regts.start = ISOdatetime(year.start, mo.start, 1, hour=0, min=0,
> sec=0, tz="GMT")
>regts.end = ISOdatetime(year.end, mo.end, 1, hour=18, min=0, sec=0,
> tz="GMT")
> 
>zts <- zooreg(clim.dat$cdata, start = regts.start, end = regts.end,
> frequency = 4, deltat = 21600)
> 
>#Create a daily average from the timeseries
>zta <- aggregate(zts, as.POSIXct(cut(time(zts), "24 hours",
> include=T)), mean)
> 
>#Select hourly data from the timeseries based on a specific time
>zt.hr <- aggregate(zts, as.Date, head, 4)
>zt.hr.ym <- aggregate(zt.hr, as.yearmon, head, 4)
>zt.hr.1 <- zt.hr.ym[,1]
>zt.hr.2 <- zt.hr.ym[,2]
>zt.hr.3 <- zt.hr.ym[,3]
>zt.hr.4 <- zt.hr.ym[,4]
> 
>zt.hr.1a <- aggregate(zt.hr.1, as.yearmon)
>min.y <- min(zt.hr)
>max.y <- max(zt.hr)
> 
>frequency(zt.hr.1) <- 12
>zt.1.mo <-  as.ts(zt.hr.1)
> 
>#Monthly boxplots of daily averages, for the months
>boxplot(zt.1.mo ~ month,   ##THIS IS WHAT DOESN'T
> WORK HERE
> boxwex=0.25, at=(1:12)-0.2,
> outline = F,
> col = "gray",
> xlab = "Month",
> ylab = expression(paste("( ",T^o,"C )") ),
> ylim = c(min.y-5,max.y+5),
> yaxs = "i",
> xaxt = "n",
> main = vars)
>axis(1, at=c(1:12), labels=month.abb, cex.axis = 0.65)
>legend("topright", c("Hour 00"), fill = c("gray"))
>}
> 
> 
> 
>#write the results to a csv file
>write.csv(cdat, paste(stn, "_", vars[v], ".csv", sep=""),
> row.names=T, col.names=T)
> 
>}
> }
> 
> 
> The final array looks like this:
> 
>JanFebMarAprMayJunJulAugSep
> OctNovDec
> 1948 28.719  4.977 39.037  9.746  8.348 36.672 47.660 54.076 38.062 34.486
> 11.938 39.666
> 1949 11.698 -6.675 16.844  0.950 10.349 38.752 39.785 40.544 57.603 35.476
> 2.308 -7.960
> 1950  0.340 45.206  6.385 17.132 19.074 38.465 48.711 54.686 48.743 33.978
> 23.090 10.007
> 1951 12.398 31.304 47.182  4.539 23.223 45.668 50.516 53.239 59.402 28.081
> 16.427 14.839
> 1952 -7.693 30.561 33.478 14.799 12.750 35.359 43.180 57.840 44.593 43.768
> 8.574 14.587
> 1953 -9.875 38.726 26.393 12.881 19.228 48.833 49.903 56.224 48.829 23.783
> 19.308 14.292
> 1954 35.943 16.706 16.021  7.806 23.593 40.418 45.310 53.113 49.203 29.480
> 17.228 33.068
> 1955 23.363 15.706 14.100 17.271 19.258 36.969 47.301 51.826 40.446 35.201
> 16.463 11.132
> 1956 45.868 -8.504 48.167 10.746 25.024 36.247 47.741 52.160 41.781 29.115
> 25.414 21.954
> 
> 
> 
> My main problem is that I can't access the rows (i.e. months) to subset the
> data by.
> 
> Could someone point out how I am able to get at the months in this array and
> subset them for plotting using the boxplot function?
> 
> 
> Thank you,
> 
> Katrina
> 
> -- 
> Katrina E. Bennett
> PhD Student
> University of Alaska Fairbanks
> International Arctic Research Center
> 930 Koyukuk Drive, PO Box 757340
> Fairbanks, Alaska 99775-7340
> 907-474-1939 office
> 907-385-7657 cell
> kebenn...@alaska.edu
> 
> 
> Personal Address:
> UAF, PO Box 752525
> Fairbanks, Alaska 99775-2525
> bennett.katr...@gmail.com
> 
>[[alternative HTML version deleted]]
> 
> __
> R-help@r-project.org mailing list
> https://stat.ethz.ch/mailman/listinfo/r-help
> PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
> and provide commented, minimal, self-contained, reprodu

Re: [R] leap years in temporal series command ts

2011-02-16 Thread Gabor Grothendieck
On Wed, Feb 16, 2011 at 11:37 AM, Peter Zorglub  wrote:
> Ok thanks. I got now a temporal series of 2557 elements thanks to the below
> code:
>
>> seriezoo=zooreg(serie, start=as.Date("2002-01-01"))
>> seriezooTS=as.ts(seriezoo)
>
> The structure of seriezooTS is then the following one (str command):
>
>> str(seriezooTS)
>              Time-Series [1:2557] from 11688 to 14244: 0.03424657 0.03881249
> 0.03078472 0.03536114 ...
>
> When applying the "decompose" command to get a seasonal decomposition, I got
> the following message:
>
>> decompose(seriezooTS, "mult")
>              Error in decompose(seriezooTS, "mult") :
>              time series has no or less than 2 periods
>
> So, I think I have to transform the first and last days of the temporal
> series in terms of Date or some kind of POSIXct number. Am I wrong? And how
> can I do that?

You must supply it a series with equal length cycles.  You can't
decompose the years into ordinary dates since there are not a constant
number of days in a year.  You could remove one day in any leap year
or you could summarize the series into a monthly series.

library(zoo)

# sample input
z <- zooreg(1:2557, start = as.Date("2002-01-01"))

# remove Feb 29's
zz <- z[format(time(z), "%m %d") != "02 29"]

# now each year has 365 points so
# make it into a series with freq 365
TS <- ts(coredata(zz), freq = 365)
d <- decompose(TS)

# put dates (without Feb 29's) back to view
d.mts <- do.call(cbind, d[1:3])
zd <- zoo(coredata(d.mts), time(zz))
View(zd)

# alternative: create monthly series
z.ag <- aggregate(z, as.yearmon, mean)
frequency(z.ag) <- 12
t.ag <- as.ts(z.ag)
d.ag <- decompose(t.ag)



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

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


[R] 3 questions about the poisson regression of contingency table

2011-02-16 Thread Lao Meng
Hi all:
I have 3 questions about the poisson regression of contingency table.
Q1¡¢How to understand the "independent poisson process"as many books or paper
mentioned?
For instance:
   Table1
   ---
   treat  canernon-cancersum
   ---
   treat1 52(57.18)   19(13.82) 71
   treat2 39(33.82)   3 (8.18)  42
   ---
   sum   91  22113
   ---
   The numbers in parentheses are the expected frequency,which are computed
by(57.18 for instance):
   71*91/113=57.18

   But according to poisson distribution,the distribution function is:
   pr<-exp(-mu)*mu^x/x!.But I can't find this function in the computation of
expected frequency of Table1.
   In other words,how the underdstand the"independent poisson process" from
Table1?
Q2¡¢How to understand "zero-inflated"?
For instance:
 area nation frequency
 1 1 10
 1 2 0
 1 3 0
 1 4 0
 2 1 20
 2 2 0
 2 3 0
 2 4 5
 3 1 15
 3 2 6
 3 3 20
 3 4 0
Since most of the frequencies(6/12) are zero,so I can simply consider the
dataset is "zero-inflated"?
In other words, can I judge the dataset is "zero-inflated" simply by the
proportion of "zero frequency"?
Or,how to judge whether the dataset is "zero-inflated" or not?

Q3¡¢How to understand "over-dispersion"?
For instance:
 area nation frequency
 1 1 10
 1 2 0
 1 3 0
 1 4 0
 2 1 20
 2 2 0
 2 3 0
 2 4 5
 3 1 15
 3 2 6
 3 3 20
 3 4 0
Obviously, the frequencies' distribution is of great skewness.So can I judge
the dataset is "over-dispersion"?
In other words, can I judge the dataset is "over-dispersion" simply by the
distribution of all the frequencies?
Or,how to judge whether the dataset is "over-dispersion" or not?

Thanks a lot for your help.
My best.

[[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] calling pairs of variables into a function

2011-02-16 Thread squamous

Hi,
I have imported three text files into R using read.table.  Their variables
are called d, e and f.

I want to run a function on all the possible combinations of these three
files.  The only way I know how to do that is like this:

bigfunction(d,e)
bigfunction(d,f)
bigfunction(e,d) 
bigfunction(e,f)
bigfunction(f,e)
bigfunction(f,d)

Is there an easier way?  I will have five files later on, so it would be
useful to know!  I'd imagine I can use a loop somehow, and I have installed
a package (gregmisc) so that typing permutations(3,2) gives all the possible
pairs of three numbers, but I don't know how to combine these things to make
it work.
-- 
View this message in context: 
http://r.789695.n4.nabble.com/calling-pairs-of-variables-into-a-function-tp3309993p3309993.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] vector splicing

2011-02-16 Thread Sam Steingold
the following seems to work for numeric but not for times:

parse.vec <- function (vec, parser = as.numeric, vmode = "numeric",
   na.string = "N/A") {
  bad <- (vec == na.string);
  ret <- vector(mode = vmode, length = length(vec));
  if (some(bad))
ret[bad] <- NA;
  if (some(!bad))
ret[!bad] <- parser(vec[!bad]);
  ret;
}

data[[2]] <- parse.vec(data[,2]); # works!

but not with times:

parse.vec(df$Time, vmode = "list", na.string = "",
  parser = function (s) strptime(s,format = "%H:%M:%OS"));
Warning message:
In ret[!bad] <- strptime(vec[!bad], format = "%H:%M:%OS") :
  number of items to replace is not a multiple of replacement length

why?

(just in case:
> length(ret)
[1] 2022
> length(vec)
[1] 2022
> length(bad)
[1] 2022
> all(!bad)
[1] TRUE


-- 
Sam Steingold (http://sds.podval.org/) on CentOS release 5.3 (Final)
http://mideasttruth.com http://jihadwatch.org http://truepeace.org
http://dhimmi.com http://memri.org http://pmw.org.il http://camera.org
If it has syntax, it isn't user friendly.

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

2011-02-16 Thread poisontonic


Uwe Ligges-3 wrote:
> 
> If the available space got too fragmented, there is not single 3.8 block 
> of memory available any more
> 

Is there anything I can do to prevent this? I've restarted and rerun the
whole thing straight up, and still the error...?

Ben
-- 
View this message in context: 
http://r.789695.n4.nabble.com/Cannot-allocate-memory-block-tp3307526p3309790.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] create a data frame with the given column names

2011-02-16 Thread Sam Steingold
how do I create a data frame with the given column names
_NOT KNOWN IN ADVANCE_?
i.e., I have a vector of strings for names and I want to get an _EMPTY_
data frame with these column names.
is it at all possible?

-- 
Sam Steingold (http://sds.podval.org/) on CentOS release 5.3 (Final)
http://openvotingconsortium.org http://pmw.org.il http://memri.org
http://mideasttruth.com http://palestinefacts.org
I don't like cats! -- Come on, you just don't know how to cook them!

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

2011-02-16 Thread cosmokramer

take this code

library(dynlm)
test=dynlm(diff(log(y))~ lag(x, -1) + lag(z, -1))
fc=predict(test)
fc 

when I run this and look at "fc", the values there only go as long as the
sample (of y) goes, but it should be one further, right? since the other
values are lagged. 

Is predict the wrong function to reach this?

Thank you
-- 
View this message in context: 
http://r.789695.n4.nabble.com/predict-not-complete-tp3309756p3309756.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] string parsing

2011-02-16 Thread Sam Steingold
> * David Winsemius  [2011-02-16 13:33:32 -0500]:
>
>> parse.num <- function (s) {
>> as.numeric(gsub("M$","e6",gsub("B$","e9",s))); }
>
> data[1] <- parse.num( data[[1]] )  # as.numeric and gsub are vectorized

because parse.num turned out to not be as simple as that: I need to
handle "N/A" specially.

parse.num1 <- function (s) {
  if (length(s) != 1) stop("parse.num",s);
  s <- as.character(s);
  if (s == "N/A") return(NA);
  as.numeric(gsub("M$","e6",gsub("B$","e9",s)));
}

parse.num <- function (v) {
  for (i in 1:length(v)) v[[i]] <- parse.num1(v[[i]])
  v;
}

actually... wait a sec...
shouldn't this work?

  bad <- (data[1] == "N/A")
  data[1][bad] <- NA
  data[1][!bad] <- as.numeric(gsub("M$","e6",gsub("B$","e9",data[1])));


-- 
Sam Steingold (http://sds.podval.org/) on CentOS release 5.3 (Final)
http://dhimmi.com http://memri.org http://truepeace.org http://camera.org
http://thereligionofpeace.com http://palestinefacts.org http://www.memritv.org
Heck is a place for people who don't believe in gosh.

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

2011-02-16 Thread mipplor


Hi,

I work like this:

> data<‐read.table('E:/my documents/r/consumer.xls',header=TRUE)
Warning message:
In read.table("E:/my documents/r/consumer.xls", header = TRUE) :
  incomplete final line found by readTableHeader on 'E:/my
documents/r/consumer.xls'

could someone shoot the trouble for me ? thx 

sorry for trouble ,im a newbie.
-- 
View this message in context: 
http://r.789695.n4.nabble.com/incomplete-final-line-tp3309405p3309405.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] confused by lapply

2011-02-16 Thread Sam Steingold
Description:

 'lapply' returns a list of the same length as 'X', each element of
 which is the result of applying 'FUN' to the corresponding element
 of 'X'.

I expect that when I do
> lapply(vec,f)
f would be called _once_ for each component of vec.

this is not what I see:

parse.num <- function (s) {
  cat("parse.num1\n"); str(s)
  s <- as.character(s)
  cat("parse.num2\n"); str(s)
  if (s == "N/A") return(s);
  as.numeric(gsub("M$","e6",gsub("B$","e9",s)));
}


> vec
 mcap
1  200.5B
2   19.1M
3  223.7B
4  888.0M
5  141.7B
6  273.5M
7 55.649B
> str(vec)
'data.frame':   7 obs. of  1 variable:
 $ mcap: Factor w/ 7 levels "141.7B","19.1M",..: 3 2 4 7 1 5 6
> vec<-lapply(vec,parse.num)
parse.num1
 Factor w/ 7 levels "141.7B","19.1M",..: 3 2 4 7 1 5 6
parse.num2
 chr [1:7] "200.5B" "19.1M" "223.7B" "888.0M" "141.7B" "273.5M" ...
Warning message:
In if (s == "N/A") return(s) :
  the condition has length > 1 and only the first element will be used

i.e., somehow parse.num is called on the whole vector vec, not its
components.

what am I doing wrong?

-- 
Sam Steingold (http://sds.podval.org/) on CentOS release 5.3 (Final)
http://dhimmi.com http://mideasttruth.com http://truepeace.org
http://camera.org http://memri.org http://palestinefacts.org http://iris.org.il
Despite the raising cost of living, it remains quite popular.

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

2011-02-16 Thread Sébastien Bihorel
Dear R-users,

I have some questions about the scope of functions, which I would like to
illustrate with the following example:

### First example
require(Hmisc)

combine.levels <- function(x,y) browser()
whatever <- function(x,y) combine.levels(x,y)

x <- 1:5
names(x) <- LETTERS[x]
y <- 6: 10
names(y) <- LETTERS[y-2]

combine(x,y)  # no debugging break
whatever(x,y)  # debugging break


The Hmisc package contains the two original functions 'combine' and
'combine.levels': 'combine' calls 'combine.levels' to perform some
operations. Now, by defining my own (useless) 'combine.levels' function, I
thought I would mask Frank Harrell's function for all functions calling
'combine.levels' in my downstream code. This is obviously not the case, as
illustrated by the two last calls of the script above. Therefore, my
questions are:
- how can I completely mask the Hmisc 'combine.levels' function in my
example above, while still making the remaining function of Hmisc available?
- if I pack the function 'whatever' and my version of 'combine.levels' in a
new package and modify my example as follows, will I get the same problem of
scope?

### Second example
require(Hmisc)
require(myUselessPackage) # contains custom functions: whatever and
combine.levels

x <- 1:5
names(x) <- LETTERS[x]
y <- 6: 10
names(y) <- LETTERS[y-2]

combine(x,y)
whatever(x,y)

Thanks in advance of your help.

Sebastien

[[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] leap years in temporal series command ts

2011-02-16 Thread Peter Zorglub
Ok thanks. I got now a temporal series of 2557 elements thanks to the 
below code:


> seriezoo=zooreg(serie, start=as.Date("2002-01-01"))
> seriezooTS=as.ts(seriezoo)

The structure of seriezooTS is then the following one (str command):

> str(seriezooTS)
  Time-Series [1:2557] from 11688 to 14244: 0.03424657 
0.03881249 0.03078472 0.03536114 ...


When applying the "decompose" command to get a seasonal decomposition, I 
got the following message:


> decompose(seriezooTS, "mult")
  Error in decompose(seriezooTS, "mult") :
  time series has no or less than 2 periods

So, I think I have to transform the first and last days of the temporal 
series in terms of Date or some kind of POSIXct number. Am I wrong? And 
how can I do that?



Thanks in advance,




Peter

On 02/16/2011 04:21 PM, Gabor Grothendieck wrote:

On Wed, Feb 16, 2011 at 6:51 AM, Peter Zorglub  wrote:

Hi R community!

I'd like to create a temporal series with ts command for the interval 1st
January 2002 - 31 December 2008. I have daily values, so this is a 2557 days
temporal series. I'm using this command :

ts(observations, start=2002, end=2009, freq=365)

However, I don't get the correct temporal series since both frequency (365
OR 366 for leap years) and deltat (1/365 OR 1/366) are varying with the year
considered.

So, is there a specific way to deal with leap years in the ts command or
have I to use another package?

You could do this with an implied frequency of 1

tt<- ts(1:10, start=as.Date("2000-01-01"))

which would represent the times as days since the Epoch. You can
recover the Date class dates with:

as.Date(tt, origin = "1970-01-01")

You might be better off using zoo or xts. e.g.

library(zoo)
z<- zooreg(1:10, start = as.Date("2000-01-01"))

Its also possible to move back and forth:

as.ts(z)
as.zoo(tt)
aggregate(as.zoo(tt), identity, as.Date)





__
R-help@r-project.org mailing list
https://stat.ethz.ch/mailman/listinfo/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] caret::train() and ctree()

2011-02-16 Thread Max Kuhn
Andrew,

ctree only tunes over mincriterion and ctree2 tunes over maxdepth
(while fixing mincriterion = 0).

Seeing both listed as the function is being executed is a bug. I'll
setup checks to make sure that the columns specified in tuneGrid are
actually the tuning parameters that are used.

Max

On Wed, Feb 16, 2011 at 12:01 PM, Andrew Ziem  wrote:
> Like earth can be trained simultaneously for degree and nprune, is there a 
> way to train ctree simultaneously for mincriterion and maxdepth?
>
> Also, I notice there are separate methods ctree and ctree2, and if both 
> options are attempted to tune with one method, the summary averages the 
> option it doesn't support.  The full log is attached, and notice these lines 
> below for method="ctree" where maxdepth=c(2,4) are averaged to maxdepth=3.
>
> Fitting: maxdepth=2, mincriterion=0.95
> Fitting: maxdepth=4, mincriterion=0.95
> Fitting: maxdepth=2, mincriterion=0.99
> Fitting: maxdepth=4, mincriterion=0.99
>
>  mincriterion  Accuracy  Kappa  maxdepth  Accuracy SD  Kappa SD  maxdepth SD
>  0.95          0.939     0.867  3         0.0156       0.0337    1.01
>  0.99          0.94      0.868  3         0.0157       0.0337    1.01
>
> I use R 2.12.1 and caret 4.78.
>
> Andrew
>
>
>
> __
> R-help@r-project.org mailing list
> https://stat.ethz.ch/mailman/listinfo/r-help
> PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
> and provide commented, minimal, self-contained, reproducible code.
>
>



-- 

Max

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


Re: [R] A Math question

2011-02-16 Thread rex.dwyer
If y'all want to discuss this more, do it somewhere else, please.
This has little to do with R except that both depend on Peano's Axioms.

-Original Message-
From: r-help-boun...@r-project.org [mailto:r-help-boun...@r-project.org] On 
Behalf Of jlu...@ria.buffalo.edu
Sent: Tuesday, February 15, 2011 12:46 PM
To: Kjetil Halvorsen
Cc: r-help@r-project.org; r-help-boun...@r-project.org; Maithula Chandrashekhar
Subject: Re: [R] A Math question

Kjetil et al,
Unlike finite sums, infinite sums are not commutative. To have
commutativity, one must have absolute summability, that is, the sum of the
absolute values of the terms must be finite.  If one has absolute
summability, the infinite sum exists and is unique. This sum is not
absolutely summable and thus undefined.   If one does not require
commutativity, then the order of the summation must be specified.  The
order is often implicitly assumed to be the order of the integers. The sum
of the negative integers is negative infinity, the sum of the positive
integers  is infinity, and the sum of these two sums is undefined.
However, Riemann's rearrangement theorem shows that the terms can be
re-ordered to yield any sum whatsoever.  In particular, if one creates
pairs of terms consisting of  a positive integer and its negative, then
the infinite sum is zero.   So the unique sum is undefined; otherwise the
sum depends on the order of addition.
Joe



David Winsemius 
Sent by: r-help-boun...@r-project.org
02/15/2011 09:17 AM

To
Kjetil Halvorsen 
cc
r-help@r-project.org, Maithula Chandrashekhar

Subject
Re: [R] A Math question







On Feb 14, 2011, at 7:33 PM, Kjetil Halvorsen wrote:

> or even better:
>
> http://mathoverflow.net/

I beg to differ. That is designated in its FAQ as expecting "research
level questions", while the forum I offered is labeled as "Welcome to
Q&A for people studying math at any level and professionals in related
fields". I don't think the proffered question could be considered
"research level".

>
> On Sun, Feb 13, 2011 at 8:02 PM, David Winsemius  > wrote:
>>
>> On Feb 13, 2011, at 4:47 PM, Maithula Chandrashekhar wrote:
>>
>>> Dear all, I admit this is not anything to do R and even with
>>> Statistics perhaps. Strictly speaking this is a math related
>>> question.
>>> However I have some reasonable feeling that experts here would
>>> come up
>>> with some elegant suggestion to my question.
>>>
>>> Here my question is: What is sum of all Integers? I somewhere heard
>>> that it is Zero as positive and negative integers will just cancel
>>> each other out. However want to know is it correct?
>>
>> There are more appropriate places to pose such questions:
>> http://math.stackexchange.com/
>>

David Winsemius, MD
West Hartford, CT

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


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




message may contain confidential information. If you are not the designated 
recipient, please notify the sender immediately, and delete the original and 
any copies. Any use of the message by you is prohibited. 
__
R-help@r-project.org mailing list
https://stat.ethz.ch/mailman/listinfo/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 with spatstat ppp transformation data

2011-02-16 Thread Ana María Prieto
Hello

 I am currently studying spatial distribution of lizards in Spain and
Germany. For this I am using the spatstat package of R to make a
Kolmogorov-Smirnov
test of CSR of unmarked points data.

I have problems transforming the data to ppp class, and I would like to know
if you can help me. I have already made the test with the data of
 'japanesepines' that comes with the package, and is very easy, I could do
it. But when trying with my own dataframe, I cannot transform them to ppp
class, this is what appears:

p<-ppp(x,y, c(0,40), c(0,80))
Error en ppp(x, y, c(0, 40), c(0, 80)) :
  coordinate vectors x and y are not of equal length


So, I checked the manuals, the R book and also the summary of the
'japanesepines' file, to know how to make the .txt table, for the data to be
already read as ppp class, but it doesn´t result neither. I made a table
with a "w" column with the coordenates written (0,40,0,0,80), another column
"n" with the number of individuals, and the columns "x" and "y" with the
coordinates. But it doesn´t work. I am not using any mask

I'd really appreciate if you can help me solving this problem, that for sure
is not complicated, but for me is tricky cause is my first time analysing
spatial data with R.

All the best,

-- 
Ana María Prieto Ramírez
Bsc. Biology
Universidad Militar Nueva Granada
Bogotá, Colombia
Student, Msc. Ecology
University of Bremen, Germany

[[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] summary in functions

2011-02-16 Thread Sam Steingold
summary() in functions seems to print nothing.
str() does print something.
why?
-- 
Sam Steingold (http://sds.podval.org/) on CentOS release 5.3 (Final)
http://mideasttruth.com http://truepeace.org http://iris.org.il
http://pmw.org.il http://jihadwatch.org http://ffii.org
A year spent in artificial intelligence is enough to make one believe in God.

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

2011-02-16 Thread Marta Lachowska

Hello, 
I would like to estimate a VAR model with HAC corrected standard errors. I 
tried to do this by using the sandwich package, for example: 
 
> library(vars)
> data(Canada)
> myvar = VAR(Canada, p = 2, type = "const")
> coeftest(myvar, vcov = vcovHAC)
Error in umat - res : non-conformable arrays
 
Which suggests that this function is not compatible with the VAR command. Has 
anyone tried to modify the code to get HAC corrected standard errors with VAR? 
Any suggestions are welcome. 
 
Thank you. 
 
Marta

[[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] 3 questions about the poisson regression of contingency table

2011-02-16 Thread Lao Meng
Hi all:
I have 3 questions about the poisson regression of contingency table.

Q1¡¢How to understand the "independent poisson process"as many books or paper
mentioned?
For instance:

   Table1
   ---
   treat  canernon-cancersum
   ---
   treat1 52(57.18)   19(13.82) 71
   treat2 39(33.82)   3 (8.18)  42
   ---
   sum   91  22113
   ---
   The numbers in parentheses are the expected frequency,which are computed
by(57.18 for instance):
   71*91/113=57.18

   But according to poisson distribution,the distribution function is:
   pr<-exp(-mu)*mu^x/x!.But I can't find this function in the computation of
expected frequency of Table1.
   In other words,how the underdstand the"independent poisson process" from
Table1?

Q2¡¢How to understand "zero-inflated"?
For instance:
 area nation frequency
 1 1 10
 1 2 0
 1 3 0
 1 4 0
 2 1 20
 2 2 0
 2 3 0
 2 4 5
 3 1 15
 3 2 6
 3 3 20
 3 4 0

Since most of the frequencies(6/12) are zero,so I can simply consider the
dataset is "zero-inflated"?
In other words, can I judge the dataset is "zero-inflated" simply by the
proportion of "zero frequency"?
Or,how to judge whether the dataset is "zero-inflated" or not?


Q3¡¢How to understand "over-dispersion"?
For instance:
 area nation frequency
 1 1 10
 1 2 0
 1 3 0
 1 4 0
 2 1 20
 2 2 0
 2 3 0
 2 4 5
 3 1 15
 3 2 6
 3 3 20
 3 4 0

Obviously, the frequencies' distribution is of great skewness.So can I judge
the dataset is "over-dispersion"?
In other words, can I judge the dataset is "over-dispersion" simply by the
distribution of all the frequencies?
Or,how to judge whether the dataset is "over-dispersion" or not?


Thanks a lot for your help.

My best.

[[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] Linear regressions: producing multiple outputs

2011-02-16 Thread RTSlider

Hello all,
I’m running simple linear regressions on multiple species of plants,
comparing abiotic factor X against plant trait Y (e.g. Species1: leaf length
vs air temperature).

Ideally, what I’m looking for is an output giving me the R2, p value,
coefficient, and Y intercept for each regression. Something like the example
below:   

Species1: leaf length vs air temperature
R2 = 0.10   p = 0.50m = 5.23b = 12.2
Species2: leaf length vs air temperature
R2 = 0.10   p = 0.50m = 5.23b = 12.2

Species1: leaf length vs snow-free date
R2 = 0.10   p = 0.50m = 5.23b = 12.2
Species2: leaf length vs snow-free date
R2 = 0.10   p = 0.50m = 5.23b = 12.2

I currently have my data in this form:
Species LeafLength  AirTemp.SnowFreeDate
Species11.1 20  160
Species24.5 20  160
Species35.4 20  160

And thought I could try this formula:
lm(formula = LeafLength~AirTemp, SnowFreeDate | Species)

But R is not a fan of it. 
Is there a way to do this (or get something remotely close to this)? 
I realize the output will probably be a bit messier than this, but what I’m
really looking to avoid is running these regressions individually.

-- 
View this message in context: 
http://r.789695.n4.nabble.com/Linear-regressions-producing-multiple-outputs-tp3309411p3309411.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] speed up the code

2011-02-16 Thread Hui Du

Hi All,

The following is a snippet of my code. It works fine but it is very slow. Is it 
possible to speed it up by using different data structure or better solution? 
For 4 runs, it takes 8 minutes now. Thanks a lot



fun_activation = function(s_k, s_hat, x_k, s_hat_len)
{
common = intersect(s_k, s_hat);
if(length(common) != 0)
{
index  = match(common, s_k);
round(sum(x_k[index]) * length(common) / (s_hat_len * length(s_k)), 3);
}
else
{
0;
}

}

fun_x = function(a)
{
round(runif(length(a), 0, 1), 2);
}

symbol_len = 50;
PHI_set = 1:symbol_len;

S = matrix(replicate(M * M, sort(sample(PHI_set, sample(symbol_len, 1, M, 
M);
X = matrix(mapply(fun_x, S), M, M);

S_hat = c(28, 34, 35)
S_hat_len = length(S_hat);

  S_hat_matrix = matrix(list(S_hat), M, M);

system.time(
for(I in 1:4)
{
A = matrix(mapply(fun_activation, S, S_hat_matrix, X, S_hat_len), M, M);
}
)



HXD


[[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] R package error

2011-02-16 Thread ycherkas

It worked!
Many-many thanks!

On Wed, Feb 16, 2011 at 11:49 AM, Uwe Ligges-3 [via R] <
ml-node+3309233-468204624-213...@n4.nabble.com> wrote:

>
>
> On 15.02.2011 19:20, ycherkas wrote:
> >
> > Hi,
> > I have a package I was previously able to compile and use for R 2.6.
> > In the newer versions of R it did not work, so I am making it from
> scratch
> > using Rtools and new R version.
>
> Looks like you have designed "mypack" in a way that it is supposed to
> run only under the Windows GUI version of R, since there is a call to
>winMenuAdd()
> in the startup code.
>
> In that case the load check does not work and you have to disable it and
> build the binary via
>
> R CMD INSTALL --build --no-test-load
>
>
> Best,
> Uwe Ligges
>
>
>
>
>
> > However, I keep getting error after Rcmd build –binary mypack
> >
> > Here is the complete log:
> > * checking for file ‘mypack/DESCRIPTION’ … OK
> > * preparing ‘mypack’:
> > * checking DESCRIPTION meta-information … OK
> > * removing junk files
> > * checking for LF line-endings in source and make files
> > * checking for empty or unneeded directories
> > * building binary distribution
> > * installing *source* package ‘mypack’ …
> > ** R
> > ** preparing package for lazy loading
> > ** help
> > Warning: ./man/mypack-package.Rd:34: All text must be in a section
> > Warning: ./man/mypack-package.Rd:35: All text must be in a section
> > *** installing help indices
> > ** building package indices …
> > ** testing if installed package can be loaded
> > gdata: read.xls support for ‘XLS’ (Excel 97-2004) files ENABLED.
> >
> > gdata: Unable to load perl libaries needed by read.xls()
> > gdata: to support ‘XLSX’ (Excel 2007+) files.
> >
> > gdata: Run the function ‘installXLSXsupport()’
> > gdata: to automatically download and install the perl
> > gdata: libaries needed to support Excel XLS and XLSX formats.
> > Error in winMenuAdd(menuname, NULL, NULL) :
> > Menu functions can only be used in the GUI
> > ERROR: loading failed
> > * removing ‘C:/DOCUME~1/…/mypack’
> > ERROR
> > * installation failed
> >
> >
> > Thank you,
> > Zhenya
> >
>
> __
> [hidden email] mailing 
> list
> https://stat.ethz.ch/mailman/listinfo/r-help
> PLEASE do read the posting guide
> http://www.R-project.org/posting-guide.html
> and provide commented, minimal, self-contained, reproducible code.
>
>
> --
>  If you reply to this email, your message will be added to the discussion
> below:
> http://r.789695.n4.nabble.com/R-package-error-tp3307320p3309233.html
>  To unsubscribe from R package error, click 
> here.
>
>

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

[[alternative HTML version deleted]]

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


Re: [R] package ChemometricsWithR

2011-02-16 Thread deborahsills

Did you find out where one can get the package ChemometricsWithR.
Thank you!
Deborah
-- 
View this message in context: 
http://r.789695.n4.nabble.com/package-ChemometricsWithR-tp3264902p3309927.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] Evaluating model fits for ordinal multinomial regressions with polr()

2011-02-16 Thread Ben Haller
  Hi all.  I'm just starting to explore ordinal multinomial regression.  I've 
been doing logistic regression in the past, and I've gotten used to various 
functions for getting pseudo-R2 metrics and other metrics to evaluate the 
quality of a model.  For example:

val.prob()
NagelkerkeR2()
ClassLog() 
LogRegR2()

  But these don't seem to work for the models generated by polr().  Does anyone 
have any recommendations for ways to evaluate the goodness-of-fit and such 
things for ordinal multinomial regression models?  I've searched Google and 
looked at the docs for the package (MASS) that defines polr(), but haven't 
discovered anything.

  Thanks!

Ben Haller
McGill University

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


[R] Flipping axis 1 in CCA plot - vegan

2011-02-16 Thread esgarbanzo

Hello,
I've successfully run my CCA and the ordination is not displayed quite
right. Is it possible to flip the x-axis (ie., make it a mirror image of
itself)?

Thanks!
Jeremy
-- 
View this message in context: 
http://r.789695.n4.nabble.com/Flipping-axis-1-in-CCA-plot-vegan-tp3309726p3309726.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] error in optim, within polr(): "initial value in 'vmmin' is not finite"

2011-02-16 Thread Ben Haller
  Hi all.  I'm just starting to explore ordinal multinomial regression.  My 
dataset is 300,000 rows, with an outcome (ordinal factor from 1 to 9) and five 
independent variables (all continuous).  My first stab at it was this:

pomod <- polr(Npf ~ o_stddev + o_skewness + o_kurtosis + o_acl_1e + dispersal, 
rlc, Hess=TRUE)

  And that worked; I got a good model fit.  However, a variety of other things 
that I've tried give me this error:

Error in optim(s0, fmin, gmin, method = "BFGS", ...) : 
  initial value in 'vmmin' is not finite

  This occurs, for example, when I try to use the method="probit" option of 
polr().  It also occurs when I try a regression involving interactions, such as:

pomod <- polr(Npf ~ o_stddev * o_skewness * o_kurtosis * o_acl_1e * dispersal, 
rlc, Hess=TRUE)

  I have good reason to believe that interactions are important here, so I'd 
very much like to be able to fit such models.  I have been doing that 
successfully with logistic regression (considering my outcome variable to be 
binary, either "1" or "2-9") using glm(), but now using polr() it gives me this 
error.  I've searched Google and the R lists for information about this error, 
and while I did find a couple of other people asking about it, I didn't find 
any advice about what to do about it that I can apply to my situation.

  I'd be happy to share my dataset with anyone willing to help me on this, but 
300,000 rows is a bit large to include in this email.  :->

  Thanks!

Ben Haller
McGill University

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


Re: [R] string parsing

2011-02-16 Thread rex.dwyer
It's only "awfully" inefficient if it's a bottleneck.  You're not doing this 
more than once per item fetched from the network, and the time is insignificant 
relative to the fetch.  If it were somehow in your inner loop, it would be 
worth worrying about, but your purpose is to eliminate Ms and Bs so that you'll 
never ever see them again. If performance is a problem, look at your inner 
loop, not here.


-Original Message-
From: r-help-boun...@r-project.org [mailto:r-help-boun...@r-project.org] On 
Behalf Of Mike Marchywka
Sent: Tuesday, February 15, 2011 9:01 PM
To: s...@gnu.org; r-h...@stat.math.ethz.ch
Subject: Re: [R] string parsing








> To: r-h...@stat.math.ethz.ch
> From: s...@gnu.org
> Date: Tue, 15 Feb 2011 17:20:11 -0500
> Subject: [R] string parsing
>
> I am trying to get stock metadata from Yahoo finance (or maybe there is
> a better source?)

search this for "yahoo",

http://cran.r-project.org/web/packages/quantmod/quantmod.pdf

as a perennial page scraper, I was amazed this existed :)


> here is what I did so far:
>
> yahoo.url <- "http://finance.yahoo.com/d/quotes.csv?f=j1jka2&s=";;
> stocks <- c("IBM","NOIZ","MSFT","LNN","C","BODY","F"); # just some samples
> socket <- url(paste(yahoo.url,sep="",paste(stocks,collapse="+")),open="r");
> data <- read.csv(socket, header = FALSE);
> close(socket);
> data is now:
> V1 V2 V3 V4
> 1 200.5B 116.00 166.25 4965150
> 2 19.1M 3.75 5.47 8521
> 3 226.6B 22.73 31.58 57127000
> 4 886.4M 30.80 74.54 226690
> 5 142.4B 3.21 5.15 541804992
> 6 276.4M 11.98 21.30 149656
> 7 55.823B 9.75 18.97 89369000
>
> now I need to do this:
>
> --> convert 55.823B to 55e9 and 19.1M to 19e6
>
> parse.num <- function (s) { as.numeric(gsub("M$","e6",gsub("B$","e9",s))); }
> data[1]<-lapply(data[1],parse.num);
>
> seems like awfully inefficient (two regexp substitutions),
> is there a better way?
>
> --> iterate over stocks & data at the same time and put the results into
> a hash table:
> for (i in 1:length(stocks)) cache[[stocks[i]]] <- data[i,];
>
> I do get the right results,
> but I am wondering if I am doing it "the right R way".
> E.g., the hash table value is a data frame.
> A structure(record?) seems more appropriate.
>
> thanks!
>
> --
> Sam Steingold (http://sds.podval.org/) on CentOS release 5.3 (Final)
> http://pmw.org.il http://ffii.org http://camera.org http://honestreporting.com
> http://iris.org.il http://mideasttruth.com http://thereligionofpeace.com
> I haven't lost my mind -- it's backed up on tape somewhere.
>
> __
> R-help@r-project.org mailing list
> https://stat.ethz.ch/mailman/listinfo/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.




message may contain confidential information. If you are not the designated 
recipient, please notify the sender immediately, and delete the original and 
any copies. Any use of the message by you is prohibited. 
__
R-help@r-project.org mailing list
https://stat.ethz.ch/mailman/listinfo/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] Timeseries Data Plotted as Monthly Boxplots

2011-02-16 Thread Katrina Bennett
Hello, I'm trying to develop a box plot of time series data to look at the
range in the data values over the entire period of record.

My data initially starts out as a list of hourly data, and then I've been
using this code to make this data into the final ts array.

# Read in the station list
stn.list <- read.csv("/home/kbennett/fews/stnlist3", as.is=T, header=F)

# Read in all three variables.
vars <- c("MAT", "MAP", "MAP06")

for (stn in stn.list) {
  for (v in 1:length(vars) {
# Read in year month start and end dates table & name it
ym.table <- read.csv("/home/kbennett/fews/", stn, var, ".ym.txt", as.is=T,
header=F)
names(ym.table) <- c("yearstart", "monthstart", "yearend", "monthend")

fn <- paste(stn, ".", vars[v], ".FIN", sep="")
  if(file.exists(fn)) {
clim.dat <- read.csv(fn, header=F)
names(clim.dat) <- c("cdata")
year.start <- ym.table$yearstart
year.end <- ym.table$yearend

mo.start <- ym.table$monthstart
mo.end <- ym.table$monthend

regts.start = ISOdatetime(year.start, mo.start, 1, hour=0, min=0,
sec=0, tz="GMT")
regts.end = ISOdatetime(year.end, mo.end, 1, hour=18, min=0, sec=0,
tz="GMT")

zts <- zooreg(clim.dat$cdata, start = regts.start, end = regts.end,
frequency = 4, deltat = 21600)

#Create a daily average from the timeseries
zta <- aggregate(zts, as.POSIXct(cut(time(zts), "24 hours",
include=T)), mean)

#Select hourly data from the timeseries based on a specific time
zt.hr <- aggregate(zts, as.Date, head, 4)
zt.hr.ym <- aggregate(zt.hr, as.yearmon, head, 4)
zt.hr.1 <- zt.hr.ym[,1]
zt.hr.2 <- zt.hr.ym[,2]
zt.hr.3 <- zt.hr.ym[,3]
zt.hr.4 <- zt.hr.ym[,4]

zt.hr.1a <- aggregate(zt.hr.1, as.yearmon)
min.y <- min(zt.hr)
max.y <- max(zt.hr)

frequency(zt.hr.1) <- 12
zt.1.mo <-  as.ts(zt.hr.1)

#Monthly boxplots of daily averages, for the months
boxplot(zt.1.mo ~ month,   ##THIS IS WHAT DOESN'T
WORK HERE
 boxwex=0.25, at=(1:12)-0.2,
 outline = F,
 col = "gray",
 xlab = "Month",
 ylab = expression(paste("( ",T^o,"C )") ),
 ylim = c(min.y-5,max.y+5),
 yaxs = "i",
 xaxt = "n",
 main = vars)
axis(1, at=c(1:12), labels=month.abb, cex.axis = 0.65)
legend("topright", c("Hour 00"), fill = c("gray"))
}



#write the results to a csv file
write.csv(cdat, paste(stn, "_", vars[v], ".csv", sep=""),
row.names=T, col.names=T)

}
}


The final array looks like this:

JanFebMarAprMayJunJulAugSep
OctNovDec
1948 28.719  4.977 39.037  9.746  8.348 36.672 47.660 54.076 38.062 34.486
11.938 39.666
1949 11.698 -6.675 16.844  0.950 10.349 38.752 39.785 40.544 57.603 35.476
2.308 -7.960
1950  0.340 45.206  6.385 17.132 19.074 38.465 48.711 54.686 48.743 33.978
23.090 10.007
1951 12.398 31.304 47.182  4.539 23.223 45.668 50.516 53.239 59.402 28.081
16.427 14.839
1952 -7.693 30.561 33.478 14.799 12.750 35.359 43.180 57.840 44.593 43.768
8.574 14.587
1953 -9.875 38.726 26.393 12.881 19.228 48.833 49.903 56.224 48.829 23.783
19.308 14.292
1954 35.943 16.706 16.021  7.806 23.593 40.418 45.310 53.113 49.203 29.480
17.228 33.068
1955 23.363 15.706 14.100 17.271 19.258 36.969 47.301 51.826 40.446 35.201
16.463 11.132
1956 45.868 -8.504 48.167 10.746 25.024 36.247 47.741 52.160 41.781 29.115
25.414 21.954



My main problem is that I can't access the rows (i.e. months) to subset the
data by.

Could someone point out how I am able to get at the months in this array and
subset them for plotting using the boxplot function?


Thank you,

Katrina

-- 
Katrina E. Bennett
PhD Student
University of Alaska Fairbanks
International Arctic Research Center
930 Koyukuk Drive, PO Box 757340
Fairbanks, Alaska 99775-7340
907-474-1939 office
907-385-7657 cell
kebenn...@alaska.edu


Personal Address:
UAF, PO Box 752525
Fairbanks, Alaska 99775-2525
bennett.katr...@gmail.com

[[alternative HTML version deleted]]

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


[R] logsumexp function in R

2011-02-16 Thread Brian Tsai
Hi,

I was wondering if anyone has implemented a numerically stable function to
compute log(sum(exp(x))) ?

Thanks!

Brian

[[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 ignore data

2011-02-16 Thread agent dunham

Hi, 

I have tried what you suggest here, and it seems not to work, can you help
me?

I want to do a lm regression, some of the variables are going to be affected
with log, I would like not no take into account those rows which imply doing
log(0)

for just one variable I have done the following but it doesn't work:

lmod1.lm <- lm(log(dat$inaltu)~log(dat$indiam),subset=(!(dat$indiam %in%
c(0,1)))

and obtain:

Error en lm.fit(x, y, offset = offset, singular.ok = singular.ok, ...) : 
  0 (non-NA) cases

lmod1.lm <- lm(log(dat$inaltu)~log(dat$indiam),subset=(!(dat$indiam = 0)),
na.action=na.exclude)

and obtain

Error en lm.fit(x, y, offset = offset, singular.ok = singular.ok, ...) : 
  NA/NaN/Inf en llamada a una función externa (arg 1)u...@host.com
-- 
View this message in context: 
http://r.789695.n4.nabble.com/How-to-ignore-data-tp3085593p3309666.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] Fwd: D parameter on qqplots

2011-02-16 Thread Chiara Della Libera

Hello everyone,

I would like to plot (or highlight in some way) the D parameter of KS
tests in qqplots displaying the distributions of my two data sets, and
get a result similar to this:
http://www.physics.csbsju.edu/stats/bothB_log_a.gif

Is there a way to do it with R?

Thank you all,

Chiara

__
R-help@r-project.org mailing list
https://stat.ethz.ch/mailman/listinfo/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] Parzen fractional degree of differencing estimator

2011-02-16 Thread Fologo Dubois
Does R have a function for Parzen fractional degree of differencing estimator? 
I am referring to the non-parametric kernel density estimator set forth by 
Parzen in Parzen (1983)
 


  
[[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] ParallelR Lite on Mac OSX?

2011-02-16 Thread Scott Chamberlain
Dear R users, 


I tried to use the built in parallelization in RevolutionR 2.10.0 on my Mac 
OSX, with i5 processor (so 4 cores). Nothing happens when I use %dopar% for 
parallelization in RevolutionR 2.10.0, and using 2.12.1 I just get errors:


library(doMC)
registerDoMC()
getDoParWorkers()
x <- iris[which(iris[,5] != "setosa"), c(1,5)]
trials <- 1000

# %do% works fine
ptime <- system.time({
r <- foreach(icount(trials), .combine=cbind) %do% {
ind <- sample(100, 100, replace=TRUE)
result1 <- glm(x[ind,2]~x[ind,1], family=binomial(logit))
coefficients(result1)
}
})[3]

> ptime
elapsed 
 8.54 

# %dopar% does not work
ptime <- system.time({
r <- foreach(icount(trials), .combine=cbind) %dopar% {
ind <- sample(100, 100, replace=TRUE)
result1 <- glm(x[ind,2]~x[ind,1], family=binomial(logit))
coefficients(result1)
}
})[3]

> ptime
elapsed 
11.978 
The process has forked and you cannot use this CoreFoundation functionality 
safely. You MUST exec().
Break on 
__THE_PROCESS_HAS_FORKED_AND_YOU_CANNOT_USE_THIS_COREFOUNDATION_FUNCTIONALITY___YOU_MUST_EXEC__()
 to debug.




Any ideas? 



Thanks! Scott 
[[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 set chart output size in rgl (surface3d)?

2011-02-16 Thread cuass

You can put the following at the beginning
library(rgl)
r3dDefaults$windowRect <- c(0,50, 700, 700)
-- 
View this message in context: 
http://r.789695.n4.nabble.com/how-to-set-chart-output-size-in-rgl-surface3d-tp2066054p3309628.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] Returning NA from lm

2011-02-16 Thread agent dunham

Hi, thanks for your post, I tried what you said, and it runs, however when I
type summary ... I obtain the following: What's
happening? How can I solve it? 

 lmod1.lm <-
tryCatch(lm(log(dat$inaltu)~log(dat$indiam),na.action=na.fail),error=function(err){NA})

 summary(lmod1.lm, corr= TRUE)
   ModeNA's 
logical   1 

> anova(lmod1.lm)
Error en UseMethod("anova") : 
  no applicable method for 'anova' applied to an object of class "logical"
u...@host.com
plot(lmod1.lm, which=1:4)u...@host.com
Error en plot.window(...) : se necesitan valores finitos de 'ylim'
Además: Mensajes de aviso perdidos
1: In min(x) : ningún argumento finito para min; retornando Inf
2: In max(x) : ningun argumento finito para max; retornando -Inf
3: In plot.window(...) : "which" is not a graphical parameter

-- 
View this message in context: 
http://r.789695.n4.nabble.com/Returning-NA-from-lm-tp880442p3309163.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] Rjdbc dbGetquery execution error

2011-02-16 Thread Hasan Diwan
Rjdbc consistently gives me an execution error with postgresql 9.0s JDBC4
driver. It's probably something trivial so am including my code below:

library("RJDBC")
param <- 249
param2 <- 188129
postgres <- JDBC("org.postgresql.Driver",
".m2/repository/postgresql/postgresql/9.0-801.jdbc4/postgresql-9.0-801.jdbc4.jar")
con <- dbConnect(postgres, "jdbc:postgresql://hq.d8u.us/erm", user =
"hdiwan")
sql <- "select id, startdate, value from dists where profileid = ?"
data1 <- dbGetQuery(conn, sql, param) # Dies here, no matter what the query,
tried with "select 1+1" as well as the one above
data2 <- dbGetQuery(conn, sql, param2)
cor(data1$V3, data2$V3)

[[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] tikzDevice compiling problem

2011-02-16 Thread cuass

Hi guys.
The tex file which compile the following graphic has many problems. I don't
know what's happening. Any input would be really appreciated.  

# Cargo el prgrama que produce el código en Latex
require(tikzDevice)

# Establezco directorio del programa
setwd('/Users/fabiangarcia/Documents/R') 

# El siguiente programa produce el archivo tex
tikz('CobbGRAF.tex', standAlone = TRUE, width=5, height=5)

# La gráfica de la función de utilidad
f = function(x, y) ((y)^1*(x)^1)
x = seq(0,5,len=40)
y = seq(0,5,len=40)
z = outer(x, y, f)
 showsurface = function(x, y, z) 
 persp3d(x,y,z, col="blue", alpha=0.3, axes=
 F)+{ 
 contours = contourLines(x,y,z)
 for (i in 1:length(contours)) {
  with(contours[[i]], lines3d(x, y, level, col="darkred"))
 }
 }
 open3d()
 showsurface(x,y,z)
 
 # Cierro el device
dev.off()

# Compilo el archivo tex
tools::texi2dvi('CobbGRAF.tex',pdf=F)
-- 
View this message in context: 
http://r.789695.n4.nabble.com/tikzDevice-compiling-problem-tp3309028p3309028.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] hel on leveneTest

2011-02-16 Thread netrunner

Dear all,
For my research I need to perform a Levene's test on my data.I have not
large experience with this test and with R,so  I have some problems to use
the leveneTest function. I read some previous posts on this topic but I
cannot understand what I have to do. 
I have a five-columns data frame organised in the following way:
number of observation, number of subject, score, type of treatment (I have 4
of them), number of replication (3 replications).

My idea was:

leveneTest(score~treatm*rep,data.ex,center=median)

where:
treatm is the treatments' column
rep is the replications' column
data.ex is the data frame.

thank you

giovanna



-- 
View this message in context: 
http://r.789695.n4.nabble.com/hel-on-leveneTest-tp3309158p3309158.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] y-axis slightly cut-off after printing plots to tiff

2011-02-16 Thread alfredo

Hi Folks,

I'm hoping someone could help me a bit. I have plotted the following:

###
tiff("plot7.tiff",units="cm",width=15,height=36,res=700)
layout(matrix(c(1,2,3,4,5,6),3,1),widths=lcm(c(15)),heights=lcm(c(12,12,12)),respect=TRUE)

plot.t1<-plot(data.dist,flot1.bray.hell,xlab="",ylab="Bray-Curtis
dissimilarity
index",cex.lab=2,cex.axis=1.7,pch=20,cex=2,col="darkgray",font=2,font.lab=2);text(0,0.34,"a",font=2,cex=1.7);text(1.5,0.07,"y=0.041x
+
0.113",cex=1.7,font=2);text(1.3,0.05,"R2=0.1785",cex=1.7,font=2);text(1.75,0.05,"p<0.001",cex=1.7,font=2);abline(0.113737,0.041476,lwd=2)

plot.t2<-plot(data.dist,flot2.bray.hell,xlab="",ylab="Bray-Curtis
dissimilarity
index",cex.lab=2,cex.axis=1.7,pch=20,cex=2,col="darkgray",font=2,font.lab=2);text(0,0.34,"b",font=2,cex=1.7);text(1.5,0.10,"y=0.046x
+
0.145",cex=1.7,font=2);text(1.3,0.08,"R2=0.2439",cex=1.7,font=2);text(1.75,0.08,"p<0.001",cex=1.7,font=2);abline(0.145498,0.046005,lwd=2)

plot.t3<-plot(data.dist,flot3.bray.hell,xlab="log10(FFC+1)",ylab="Bray-Curtis
dissimilarity
index",cex.lab=2,cex.axis=1.7,pch=20,cex=2,col="darkgray",font=2,font.lab=2);text(0,0.31,"c",font=2,cex=1.7);text(1.5,0.07,"y=0.024
+
0.162",cex=1.7,font=2);text(1.3,0.05,"R2=0.080",cex=1.7,font=2);text(1.75,0.05,"p<0.001",cex=1.7,font=2);abline(0.162675,0.02420,lwd=2)

dev.off()
##

My graph (3 in 1) looks great, but my y-axis label is slightly cut-off and
thus it is unsuitable for publication/presentation. I could reduce the
cex.lab value, but it's not something I want to do. I have tried tweaking
the widths parameter for both tiff() and layout(), but without success. Any
help would be most appreciated.

Thanks in advance for your help!

Best Regards,

A
-- 
View this message in context: 
http://r.789695.n4.nabble.com/y-axis-slightly-cut-off-after-printing-plots-to-tiff-tp3309466p3309466.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] caret::train() and ctree()

2011-02-16 Thread Andrew Ziem
Like earth can be trained simultaneously for degree and nprune, is there a way 
to train ctree simultaneously for mincriterion and maxdepth?  

Also, I notice there are separate methods ctree and ctree2, and if both options 
are attempted to tune with one method, the summary averages the option it 
doesn't support.  The full log is attached, and notice these lines below for 
method="ctree" where maxdepth=c(2,4) are averaged to maxdepth=3.

Fitting: maxdepth=2, mincriterion=0.95 
Fitting: maxdepth=4, mincriterion=0.95 
Fitting: maxdepth=2, mincriterion=0.99 
Fitting: maxdepth=4, mincriterion=0.99

  mincriterion  Accuracy  Kappa  maxdepth  Accuracy SD  Kappa SD  maxdepth SD
  0.95  0.939 0.867  3 0.0156   0.03371.01   
  0.99  0.94  0.868  3 0.0157   0.03371.01   

I use R 2.12.1 and caret 4.78.

Andrew


> require(party)
> require(mlbench)
> data(BreastCancer)
> BreastCancer$Id <- NULL
> grid <- expand.grid(.maxdepth=c(2:6), .mincriterion=c(0.95, 0.97, 0.99))
> print(grid)
   .maxdepth .mincriterion
1  2  0.95
2  3  0.95
3  4  0.95
4  5  0.95
5  6  0.95
6  2  0.97
7  3  0.97
8  4  0.97
9  5  0.97
10 6  0.97
11 2  0.99
12 3  0.99
13 4  0.99
14 5  0.99
15 6  0.99
> ct.best <- train(Class ~ . , data=BreastCancer, method="ctree", tuneGrid=grid)
Loading required package: class

Attaching package: 'class'

The following object(s) are masked from 'package:reshape':

condense


Attaching package: 'e1071'

The following object(s) are masked from 'package:gtools':

permutations

Fitting: maxdepth=2, mincriterion=0.95 
Fitting: maxdepth=3, mincriterion=0.95 
Fitting: maxdepth=4, mincriterion=0.95 
Fitting: maxdepth=5, mincriterion=0.95 
Fitting: maxdepth=6, mincriterion=0.95 


> grid <- expand.grid(.maxdepth=c(2, 4), .mincriterion=c(0.95, 0.99))
> print(grid)
  .maxdepth .mincriterion
1 2  0.95
2 4  0.95
3 2  0.99
4 4  0.99
> ct.best <- train(Class ~ . , data=BreastCancer, method="ctree", tuneGrid=grid)
Fitting: maxdepth=2, mincriterion=0.95 
Fitting: maxdepth=4, mincriterion=0.95 
Fitting: maxdepth=2, mincriterion=0.99 
Fitting: maxdepth=4, mincriterion=0.99 
Aggregating results
Selecting tuning parameters
Fitting model on full training set
> print(ct.best)
683 samples
 80 predictors

Pre-processing: None 
Resampling: Bootstrap (25 reps) 

Summary of sample sizes: 683, 683, 683, 683, 683, 683, ... 

Resampling results across tuning parameters:

  mincriterion  Accuracy  Kappa  maxdepth  Accuracy SD  Kappa SD  maxdepth SD
  0.95  0.939 0.867  3 0.0156   0.03371.01   
  0.99  0.94  0.868  3 0.0157   0.03371.01   

Accuracy was used to select the optimal model using  the largest value.
The final value used for the model was mincriterion = 0.99. 
> 
> 
> 
> 
> grid <- expand.grid(.maxdepth=c(2, 4), .mincriterion=c(0.95, 0.99))
> print(grid)
  .maxdepth .mincriterion
1 2  0.95
2 4  0.95
3 2  0.99
4 4  0.99
> ct.best <- train(Class ~ . , data=BreastCancer, method="ctree2", 
> tuneGrid=grid)
Fitting: maxdepth=2, mincriterion=0.95 
Fitting: maxdepth=4, mincriterion=0.95 
Fitting: maxdepth=2, mincriterion=0.99 
Fitting: maxdepth=4, mincriterion=0.99 
Aggregating results
Selecting tuning parameters
Fitting model on full training set
> print(ct.best)
683 samples
 80 predictors

Pre-processing: None 
Resampling: Bootstrap (25 reps) 

Summary of sample sizes: 683, 683, 683, 683, 683, 683, ... 

Resampling results across tuning parameters:

  maxdepth  Accuracy  Kappa  mincriterion  Accuracy SD  Kappa SD  mincriterion 
SD
  2 0.935 0.858  0.97  0.0163   0.03430.0202
 
  4 0.935 0.857  0.97  0.0142   0.03220.0202
 

Accuracy was used to select the optimal model using  the largest value.
The final value used for the model was maxdepth = 4. __
R-help@r-project.org mailing list
https://stat.ethz.ch/mailman/listinfo/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] which functions are being debugged?

2011-02-16 Thread Henrique Dallazuanna
Try this:

isDebug <- lapply(sapply(search(), lapply, ls), function(f)sapply(f,
function(.f)tryCatch(isdebugged(.f), error = function(...)FALSE)))
which(unlist(isDebug))

On Wed, Feb 16, 2011 at 10:28 PM, Shi, Tao  wrote:

> Hi list,
>
> Is there a function that can let me know which functions are being
> debugged?  I
> know I'm probably not doing a very good job of keeping track of things, but
> it
> does get messier when you dig into different layers of a function.  I know
> there
> is "isdebugged", but it only works on one function at a time.
>
> Thanks!
>
> ...Tao
>
>
>
>
>[[alternative HTML version deleted]]
>
> __
> R-help@r-project.org mailing list
> https://stat.ethz.ch/mailman/listinfo/r-help
> PLEASE do read the posting guide
> http://www.R-project.org/posting-guide.html
> and provide commented, minimal, self-contained, reproducible code.
>



-- 
Henrique Dallazuanna
Curitiba-Paraná-Brasil
25° 25' 40" S 49° 16' 22" O

[[alternative HTML version deleted]]

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


[R] which functions are being debugged?

2011-02-16 Thread Shi, Tao
Hi list,

Is there a function that can let me know which functions are being debugged?  I 
know I'm probably not doing a very good job of keeping track of things, but it 
does get messier when you dig into different layers of a function.  I know 
there 
is "isdebugged", but it only works on one function at a time.

Thanks!

...Tao



  
[[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] Saturated model in binomial glm

2011-02-16 Thread Bill.Venables
This is a very good question.  You have spotted something that not many people 
see and it is important.

The bland assertion that the "deviance can be used as a test of fit" can be 
seriously misleading.

For this data the response is clearly binary, "Admitted" (success) or 
"Rejected" (failure) and the other two factors are explanatory variables.  

Any binomial model can be fitted by expressing the data as a binary response.  
In this case there are

> sum(UCBAd$Freq)
[1] 4526
> 

4526 trials, corresponding to the individual applicants for admission.  We can 
expand the data frame right out to this level and fit the model with the data 
in that form, and in this case the weights will be the default, ie. all 1's.

We can also *group* the data into subsets which are homogeneous with respect to 
the explanatory variables.  

The most succinct grouping would be into 12 groups corresponding to the 2 x 6 
distinct classes defined by the two explanatory variables.  In this case you 
would specify the response either as a two-column matrix of successes/failures, 
or as a proportion with the totals for each of the 12 cases as weights.

Another succince grouping is into 2 x 2 x 6 classes as you do in your example.  
In this case your response is the factor and the weights are the frequencies.

For all three cases a) the estimates will be the same, and so the predictions 
will be identical, b) the deviance will also be the same, but c) the degrees of 
freedom attributed to the deviance will be different.

The reason for c) is, as you have intuited, the saturated model is different.  
Literally, the saturated model is a model with one mean parameter for each 
value taken as an observation when the model is fitted.  So the saturated model 
is *not* invariant with respect to grouping.

Let's look at two of these cases computationally:


> UCB_Expanded <- UCBAd[rep(1:24, UCBAd$Freq), 1:3] ## expand the data frame
> dim(UCB_Expanded)
[1] 45263

>  ### now fit your model

> m1 <- glm(Admit ~ Gender + Dept, binomial, UCBAd, weights = Freq)

>  ### and the same model using the binary data form

> m2 <- glm(Admit ~ Gender + Dept, binomial, UCB_Expanded)

>  ### as predicted, the coefficients are identical (up to round off)

> coef(m1)
 (Intercept) GenderFemaleDeptBDeptCDeptDDeptE 
 -0.58205140  -0.09987009   0.04339793   1.26259802   1.29460647   1.73930574 
   DeptF 
  3.30648006 
> coef(m2)
 (Intercept) GenderFemaleDeptBDeptCDeptDDeptE 
 -0.58205140  -0.09987009   0.04339793   1.26259802   1.29460647   1.73930574 
   DeptF 
  3.30648006 

>   ### and so are the deviances, perhaps surprisingly:

> deviance(m1)
[1] 5187.488
> deviance(m2)
[1] 5187.488

>   ### but the degrees of freedom attributed to the deviance are different!

> m1$df.resid
[1] 17
> m2$df.resid
[1] 4519
> 
 
If you were to fit the model in the most succinct form, with 12 relative 
frequencies, then you would get the same deviance again, but the degrees of 
freedom would be only 5.

So you need to be very careful in taking the deviance, even in binomial models, 
as a test of fit.  The way the data are grouped is relevant.

If you have two fixed models, e.g. Admit ~ Gender, and Admit ~ Gender + Dept, 
then

The estimated coefficients, and their standard errors, vcov matrix,
The deviance, and so
*Differences* in deviances and
*Differences* in degrees of freedom

will be the same however the data are grouped, and so the usual tests and CI 
processes go ahead fine.

But the deviance itself can be misleading as a test of fit, since the outer 
hypothesis, the saturated model, is not fixed and depends on grouping.  For the 
ungrouped binary case it is *usually* misleading when taken simply at face 
value as chi-squared distributed under the null hypothesis.

I think there is a book or two around that discusses this issue, but probably 
not well enough.

Bill Venables.


-Original Message-
From: r-help-boun...@r-project.org [mailto:r-help-boun...@r-project.org] On 
Behalf Of Giovanni Petris
Sent: Thursday, 17 February 2011 7:58 AM
To: r-help@r-project.org
Subject: [R] Saturated model in binomial glm


Hi all,

Could somebody be so kind to explain to me what is the saturated model
on which deviance and degrees of freedom are calculated when fitting a
binomial glm?

Everything makes sense if I fit the model using as response a vector of
proportions or a two-column matrix. But when the response is a factor
and counts are specified via the "weights" argument, I am kind of lost
as far as what is the implied saturated model. 

Here is a simple example, based on the UCBAdmissions data.

> UCBAd <- as.data.frame(UCBAdmissions)
> UCBAd <- glm(Admit ~ Gender + Dept, family = binomial,
+ weights = Freq, data = UCBAd)
> UCBAd$deviance
[1] 5187.488
> UCBAd$df.residual
[1] 17

I can see that the data frame UCBAd has 24 rows and using 1+1+5
parameters to fit the model lea

Re: [R] Confidence interval of Survival Curve of Weighted Cox Regression

2011-02-16 Thread Terry Therneau
--- begin included message ---
May I know how to obtain the confidence interval of the survival curve
of
weighted Cox regression model?
I tried coxph, cph, and coxphw, but they did not work.
Any help would be much appreciated. 

 end inclusion ---

Use the latest version of the survival pacakge from CRAN, coxph now
supports weighted survival curves.

Terry Therneau

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


Re: [R] error with demo in gsubfn on Mac; Re: string parsing

2011-02-16 Thread Gabor Grothendieck
On Wed, Feb 16, 2011 at 5:09 PM, David Winsemius  wrote:
>
 require(gsubfn)
>>>
>>> Loading required package: gsubfn
>>> Loading required package: proto

 demo("gsubfn-si")
>>>
>>>
>>>       demo(gsubfn-si)
>>>        ~
>>>
>>> Type     to start :
>>> Error in source(available, echo = echo, max.deparse.length = Inf,
>>> keep.source = TRUE) :
>>>  invalid multibyte character in parser at line 8

>
>        demo(gsubfn-si)
>         ~
>
> Type     to start :
>
>> # given number possibly followed by SI letter (e.g. 32.5k where k means
>> 1000)
>> # replace letter with e followed by appropriate digits.
>> # (see formatEng2R by Hans-Joerg Bibiko in the R Wiki)
>>
>> conv <- list(y = "e-24", z = "e-21", a = "e-18", f = "e-15", p = "e-12",
> +     n = "e-9", `µ` = "e-6", m = "e-3", d = "e-1", c = "e-2", k = "e3",
> +     M = "e6", G = "e9", T = "e12", P = "e15", E = "e18", Z = "e21", Y =
> "e24")
>
>> gsubfn(".$", conv, c("19", "32.5M"))
> Loading required package: tcltk
> Loading Tcl/Tk interface ... done
> [1] "19"     "32.5e6"
>
> I don't see any unusual characters in that output... ooops, there is it
> is... that "mu".

Thanks. I will change it to just plain u in the next release.

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

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


Re: [R] error with demo in gsubfn on Mac; Re: string parsing

2011-02-16 Thread David Winsemius


On Feb 16, 2011, at 4:13 PM, Gabor Grothendieck wrote:

On Wed, Feb 16, 2011 at 3:42 PM, David Winsemius > wrote:


On Feb 16, 2011, at 3:25 PM, Gabor Grothendieck wrote:


On Tue, Feb 15, 2011 at 5:20 PM, Sam Steingold  wrote:





Check the example at the end of section 2 of the gsubfn vignette:

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


OK. I'm impressed. So I loaded gsubfn to do some self study and got:


require(gsubfn)

Loading required package: gsubfn
Loading required package: proto

demo("gsubfn-si")



   demo(gsubfn-si)
    ~

Type to start :
Error in source(available, echo = echo, max.deparse.length = Inf,
keep.source = TRUE) :
 invalid multibyte character in parser at line 8

sessionInfo()

R version 2.12.1 (2010-12-16)
Platform: x86_64-apple-darwin9.8.0/x86_64 (64-bit)

locale:
[1] en_US.UTF-8/en_US.UTF-8/C/C/en_US.UTF-8/en_US.UTF-8

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

other attached packages:
[1] gsubfn_0.5-5proto_0.3-8 rms_3.1-0   Hmisc_3.8-3
[5] survival_2.36-2 sos_1.3-0   brew_1.0-4  lattice_0.19-13

loaded via a namespace (and not attached):
[1] cluster_1.13.2 grid_2.12.1tools_2.12.1



I can't reproduce this on my Windows system. I assume its a character
set issue associated with the Mac.  What happens when you try this
first (or some variation):

Sys.setlocale("LC_ALL","C")



> demo("gsubfn-si")
First it loads X11() and then I get:

demo(gsubfn-si)
 ~

Type   to start :

> # given number possibly followed by SI letter (e.g. 32.5k where k  
means 1000)

> # replace letter with e followed by appropriate digits.
> # (see formatEng2R by Hans-Joerg Bibiko in the R Wiki)
>
> conv <- list(y = "e-24", z = "e-21", a = "e-18", f = "e-15", p =  
"e-12",

+ n = "e-9", `µ` = "e-6", m = "e-3", d = "e-1", c = "e-2", k = "e3",
+ M = "e6", G = "e9", T = "e12", P = "e15", E = "e18", Z = "e21",  
Y = "e24")


> gsubfn(".$", conv, c("19", "32.5M"))
Loading required package: tcltk
Loading Tcl/Tk interface ... done
[1] "19" "32.5e6"

I don't see any unusual characters in that output... ooops, there is  
it is... that "mu".


--
David.



?

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


David Winsemius, MD
West Hartford, CT

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


[R] Saturated model in binomial glm

2011-02-16 Thread Giovanni Petris

Hi all,

Could somebody be so kind to explain to me what is the saturated model
on which deviance and degrees of freedom are calculated when fitting a
binomial glm?

Everything makes sense if I fit the model using as response a vector of
proportions or a two-column matrix. But when the response is a factor
and counts are specified via the "weights" argument, I am kind of lost
as far as what is the implied saturated model. 

Here is a simple example, based on the UCBAdmissions data.

> UCBAd <- as.data.frame(UCBAdmissions)
> UCBAd <- glm(Admit ~ Gender + Dept, family = binomial,
+ weights = Freq, data = UCBAd)
> UCBAd$deviance
[1] 5187.488
> UCBAd$df.residual
[1] 17

I can see that the data frame UCBAd has 24 rows and using 1+1+5
parameters to fit the model leaves me with 17 degrees of freedom. 

What is not clear to me is what is the saturated model? 

Is it the model that fits a probability zero to each row corresponding
to failures and a probability one to each row corresponding to
successes? If this is so, it seems to me that looking at the deviance as
a goodness-of-fit statistic does not make much sense in this case. Am I
missing something?

Thank you in advance,
Giovanni


-- 

Giovanni Petris  
Associate Professor
Department of Mathematical Sciences
University of Arkansas - Fayetteville, AR 72701
Ph: (479) 575-6324, 575-8630 (fax)
http://definetti.uark.edu/~gpetris/

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

2011-02-16 Thread Mark Heckmann
I am looking for an R package for formal concept analysis 
(http://en.wikipedia.org/wiki/Formal_concept_analysis).
I want to produce concept lattices 
(http://en.wikipedia.org/wiki/File:Concept_lattice.svg). 
I was wondering if there are packages that can produce similar graphics?

Thanks,
Mark

–––
Mark Heckmann
Blog: www.markheckmann.de
R-Blog: http://ryouready.wordpress.com





[[alternative HTML version deleted]]

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


Re: [R] error with demo in gsubfn on Mac; Re: string parsing

2011-02-16 Thread Gabor Grothendieck
On Wed, Feb 16, 2011 at 3:42 PM, David Winsemius  wrote:
>
> On Feb 16, 2011, at 3:25 PM, Gabor Grothendieck wrote:
>
>> On Tue, Feb 15, 2011 at 5:20 PM, Sam Steingold  wrote:
>>>
>>>
>>
>> Check the example at the end of section 2 of the gsubfn vignette:
>>
>> http://cran.r-project.org/web/packages/gsubfn/vignettes/gsubfn.pdf
>
> OK. I'm impressed. So I loaded gsubfn to do some self study and got:
>
>> require(gsubfn)
> Loading required package: gsubfn
> Loading required package: proto
>> demo("gsubfn-si")
>
>
>        demo(gsubfn-si)
>         ~
>
> Type     to start :
> Error in source(available, echo = echo, max.deparse.length = Inf,
> keep.source = TRUE) :
>  invalid multibyte character in parser at line 8
>> sessionInfo()
> R version 2.12.1 (2010-12-16)
> Platform: x86_64-apple-darwin9.8.0/x86_64 (64-bit)
>
> locale:
> [1] en_US.UTF-8/en_US.UTF-8/C/C/en_US.UTF-8/en_US.UTF-8
>
> attached base packages:
> [1] splines   stats     graphics  grDevices utils     datasets
> [7] methods   base
>
> other attached packages:
> [1] gsubfn_0.5-5    proto_0.3-8     rms_3.1-0       Hmisc_3.8-3
> [5] survival_2.36-2 sos_1.3-0       brew_1.0-4      lattice_0.19-13
>
> loaded via a namespace (and not attached):
> [1] cluster_1.13.2 grid_2.12.1    tools_2.12.1
>

I can't reproduce this on my Windows system. I assume its a character
set issue associated with the Mac.  What happens when you try this
first (or some variation):

Sys.setlocale("LC_ALL","C")

?

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

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


[R] error with demo in gsubfn on Mac; Re: string parsing

2011-02-16 Thread David Winsemius


On Feb 16, 2011, at 3:25 PM, Gabor Grothendieck wrote:


On Tue, Feb 15, 2011 at 5:20 PM, Sam Steingold  wrote:





Check the example at the end of section 2 of the gsubfn vignette:

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


OK. I'm impressed. So I loaded gsubfn to do some self study and got:

> require(gsubfn)
Loading required package: gsubfn
Loading required package: proto
> demo("gsubfn-si")


demo(gsubfn-si)
 ~

Type   to start :
Error in source(available, echo = echo, max.deparse.length = Inf,  
keep.source = TRUE) :

  invalid multibyte character in parser at line 8
> sessionInfo()
R version 2.12.1 (2010-12-16)
Platform: x86_64-apple-darwin9.8.0/x86_64 (64-bit)

locale:
[1] en_US.UTF-8/en_US.UTF-8/C/C/en_US.UTF-8/en_US.UTF-8

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

other attached packages:
[1] gsubfn_0.5-5proto_0.3-8 rms_3.1-0   Hmisc_3.8-3
[5] survival_2.36-2 sos_1.3-0   brew_1.0-4  lattice_0.19-13

loaded via a namespace (and not attached):
[1] cluster_1.13.2 grid_2.12.1tools_2.12.1




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

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


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] string parsing

2011-02-16 Thread Gabor Grothendieck
On Tue, Feb 15, 2011 at 5:20 PM, Sam Steingold  wrote:
> I am trying to get stock metadata from Yahoo finance (or maybe there is
> a better source?)
> here is what I did so far:
>
> yahoo.url <- "http://finance.yahoo.com/d/quotes.csv?f=j1jka2&s=";;
> stocks <- c("IBM","NOIZ","MSFT","LNN","C","BODY","F"); # just some samples
> socket <- url(paste(yahoo.url,sep="",paste(stocks,collapse="+")),open="r");
> data <- read.csv(socket, header = FALSE);
> close(socket);
> data is now:
>       V1     V2     V3        V4
> 1  200.5B 116.00 166.25   4965150
> 2   19.1M   3.75   5.47      8521
> 3  226.6B  22.73  31.58  57127000
> 4  886.4M  30.80  74.54    226690
> 5  142.4B   3.21   5.15 541804992
> 6  276.4M  11.98  21.30    149656
> 7 55.823B   9.75  18.97  89369000
>
> now I need to do this:
>
> --> convert 55.823B to 55e9 and 19.1M to 19e6
>
> parse.num <- function (s) { as.numeric(gsub("M$","e6",gsub("B$","e9",s))); }
> data[1]<-lapply(data[1],parse.num);
>
> seems like awfully inefficient (two regexp substitutions),
> is there a better way?
>
> --> iterate over stocks & data at the same time and put the results into
> a hash table:
> for (i in 1:length(stocks)) cache[[stocks[i]]] <- data[i,];
>
> I do get the right results,
> but I am wondering if I am doing it "the right R way".
> E.g., the hash table value is a data frame.
> A structure(record?) seems more appropriate.
>

Check the example at the end of section 2 of the gsubfn vignette:

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


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

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


Re: [R] help needed for strptime "000000" !

2011-02-16 Thread Dieter Menne


JESSICA wrote:
> 
> 
> I have a text file stored in notepad:
> 
> DATE TIME Q
> 2004-11-01233311  1
> 2004-11-01234227  1
> ...
> I  run 
> 
> x<-read.table("C:/R/Sample.txt",header=T)
> then get a table 
> 
> ...
> I am trying to 
> 
> strptime(x$TIME,"%H%M%S")
> 
> and get : 
> 
>  [1] "2011-02-16 23:33:11" "2011-02-16 23:42:27" "2011-02-16 23:43:27"
>  [4] "2011-02-16 23:47:34" NANA   
>  [7] NANANA   
> [10] NANANA  
> 
> 
Try (but I a note sure what to do with the DATE column.
Dieter

x<-read.table("datesample.txt",
  colClasses=c("Date","character","integer"), header=T) 
class(x$TIME)= "POSIXct"
strptime(x$TIME,"%H%M%S") 

-- 
View this message in context: 
http://r.789695.n4.nabble.com/help-needed-for-strptime-00-tp3309588p3309664.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] covar

2011-02-16 Thread Val
Hi all,

I want to construct relatedness among individuals and have a look at the
following script.

#
rm(list=ls())

N=5
id   = c(1:N)
dad = c(0,0,0,3,3)
mom  = c(0,0,2,1,1)
sex  = c(2,2,1,2,2) # 1= M and 2=F

   A=diag(nrow = N)
   for(i in 1:N){
  for(j in i:N)  {
 ss = dad[j]
 dd = mom[j]
 sx = sex[j]
  if( ss > 0 && dd > 0 )
{
  if(i == j)
   { A[i,i] = 1 + 0.5*A[ss,dd] }
 else
  { A[i,j] = A[i,ss] + 0.5*(A[i,dd])
A[j,i] = A[i,j] }
}

  } #inner for loop
 } # outer for loop
  A

If the sex is male ( sex=1)  then I want to set A[i,i]=0.5*A[ss,dd]
If it is female ( sex=2) then A[i,i] = 1 + 0.5*A[ss,dd]


How do I do it ?

I tried several cases but it did not work from me. Your assistance is
highly  appreciated  in advance

Thanks

[[alternative HTML version deleted]]

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


Re: [R] string parsing

2011-02-16 Thread David Winsemius


On Feb 16, 2011, at 2:26 PM, David Winsemius wrote:



On Feb 16, 2011, at 2:09 PM, Sam Steingold wrote:

* David Winsemius  [2011-02-16 13:33:32  
-0500]:



parse.num <- function (s) {
as.numeric(gsub("M$","e6",gsub("B$","e9",s))); }


data[1] <- parse.num( data[[1]] )  # as.numeric and gsub are  
vectorized


because parse.num turned out to not be as simple as that: I need to
handle "N/A" specially.

parse.num1 <- function (s) {
if (length(s) != 1) stop("parse.num",s);
s <- as.character(s);
if (s == "N/A") return(NA);


Ouch! That can be simplified to:


I meant to say (and at one time did):

is.na(s) <- (s == "N/A")


  #  and then all done inside one function.


But then failed to notice that my drag and drop moved it to the  
version below (since usually I get tripped up when the Mac Mail.app  
duplicates rather than moves.)



as.numeric(gsub("M$","e6",gsub("B$","e9",s)));
}

parse.num <- function (v) {
for (i in 1:length(v)) v[[i]] <- parse.num1(v[[i]])
v;
}

actually... wait a sec...
shouldn't this work?

bad <- (data[1] == "N/A")
data[1][bad] <- NA
data[1][!bad] <- as.numeric(gsub("M$","e6",gsub("B$","e9",data[1])))


It might not, since at this point you should have different length  
vectors.


(I'm also not sure that the  listobj[][] <-   
construction would work, but I really don't know about that one.)


parse.num2 <- function (s) {
is.na(s) <- (s == "N/A")
as.numeric(gsub("M$","e6",gsub("B$","e9",s)))
 }

Then call as I suggested




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] command history in slave mode

2011-02-16 Thread Jannis
Dear list,


I am running R in slave mode to run some calculations on a remote cluster and 
would like to somehow retrieve the last command in the case that it causes an 
error. When an error occours, my job is just quitted and it takes me a lot of 
work to find out which command in my rather lengthy scripts caused the problem. 
With the following I manage to save the workspace in case of an error:

save.ws.error = function()
{
last.error <- paste('Last error: ',geterrmessage(),sep='')
save.image(file='filename.RData')
}
options(error=quote({save.ws.error()})) 

I would like to include

history() or savehistory() in this call to get the command that caused the 
error but when I run my script with:

R --slave < scriptname.R  > text_output.out

i get the error message that there is no command history available.

Is there any way to achieve this? 


Cheers
Jannis



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

2011-02-16 Thread Dennis Murphy
Hi:

There are some reasonably efficient ways to do this if you're a little
clever. If you use 16 histograms per page, you can get 928 of them onto 58
pages - with 4 per page, with one left over, that would generate 233 pages
of output. I could think of something like the following (pseudocode):

1. Create a matrix or list of file names, such that each row of the matrix,
or component of the list, contains the names of the files whose
histograms
you want on a particular page.
2. Write a function that takes a generic row/component of file names as the
input.
Make sure that the input argument gets converted to a vector, and then
write
code creating the histograms and corresponding density plots for a
single page
of output.
3. Use apply() or lapply() to generate the plots, or suitable alternatives
from packages.

I was a little curious how one could pull this off. This is far from
elegant, but it should give you an idea of how it can be done.

# Create 16 files of data, each consisting of 1000 normal random deviates
nams <- sprintf(paste('y%02d.dat', sep = ''), 1:16)
for(i in 1:16)   write(rnorm(1000), file = nams[i])
# or
# sapply(nams, function(x) write(rnorm(1000), file = x) )

# Create a matrix of file names, in this case four per row:
namelist <- matrix(nams, ncol = 4, byrow = TRUE)
namelist

# Create a plot function that will generate k histograms,
# one per data set, and plot them with the variable names in panel strips
# This uses the lattice graphics package and the plyr package

pltfun <- function(filelist, nintervals = 100, col = 'cornsilk') {
require(lattice)
require(plyr)
options(warn = -1)   # suppress warnings
ll <- lapply(filelist, scan, what = 0)   # read in data from each file
-> list
st <- strsplit(filelist, '\\.')# split input file names -
pick out part before . as varname
vnames <- sapply(st, function(x) x[1], simplify = TRUE)   # flatten to
vector
names(ll) <- vnames# assign vector of names to list
df <- ldply(ll, cbind)  # flatten list to data frame
print(histogram( ~ V1 | .id, data = df, nint = nintervals, col = col,
 xlab = '', type = 'density', as.table = TRUE,
 panel = function(x, ...) {
panel.histogram(x, ...)
panel.mathdensity(dmath = dnorm, col = "black", lwd
= 2,
  args = list( mean=mean(x),
sd=sd(x) ) )
  } ) )
   Sys.sleep(2)# Period to wait before next function call (secs)
invisible()
   }

# To see the plots run by, call
apply(namelist, 1, pltfun)

###
### To export the plots to files, I used the following:

# Create a vector of output file names for plots:
plotnames <- sprintf(paste('plot%02d.pdf', sep = ''), 1:4)

# Tag it on as an extra column of the namelist matrix
allfiles <- cbind(namelist, unname(plotnames))

# Create a generic function to read in the data from a given row of
# namelist, convert it into a data frame, pass it into histogram() and
# export the output to the corresponding plotname file.

pltout <- function(files, nintervals = 100, col = 'cornsilk') {
options(warn = -1)
require(lattice)
require(plyr)
filelist <- files[-length(files)]# list of files to read
plotfile <- files[length(files)]# name of output file
ll <- lapply(filelist, scan, what = 0)  # read the data in
st <- strsplit(filelist, '\\.')   # use the part before the . as
variable names
vnames <- sapply(st, function(x) x[1], simplify = TRUE)  # flatten to
vector
names(ll) <- vnames# apply names to list components
df <- ldply(ll, cbind)  # flatten to data frame with names as a
variable (.id)
pdf(file = plotfile) # open the graphics device
print(histogram( ~ V1 | .id, data = df, nint = nintervals, col = col,
 xlab = '', type = 'density', as.table = TRUE,
 panel = function(x, ...) {
panel.histogram(x, ...)
panel.mathdensity(dmath = dnorm, col = "black", lwd
= 2,
  args = list( mean=mean(x),
sd=sd(x) ) )
  } ) )
dev.off()   # close it
invisible()
   }

# Apply the function to each row of the allfiles matrix
apply(allfiles, 1, pltout)

This is a comparatively small example, but it gives you a general idea of
how to do this sort of thing. For 929 input files, it would be a good idea
to put them all in one directory. See ?list.files for an easy way to get all
the filenames in a single directory in one call. You can then create a
matrix from that vector and use the above ideas to generate plots.

Part of the reason I did it this way was to economize on memory usage in the
global environment. When each input file is a vec

Re: [R] string parsing

2011-02-16 Thread David Winsemius


On Feb 16, 2011, at 2:09 PM, Sam Steingold wrote:

* David Winsemius  [2011-02-16 13:33:32  
-0500]:



parse.num <- function (s) {
as.numeric(gsub("M$","e6",gsub("B$","e9",s))); }


data[1] <- parse.num( data[[1]] )  # as.numeric and gsub are  
vectorized


because parse.num turned out to not be as simple as that: I need to
handle "N/A" specially.

parse.num1 <- function (s) {
 if (length(s) != 1) stop("parse.num",s);
 s <- as.character(s);
 if (s == "N/A") return(NA);


Ouch! That can be simplified to:

   #  and then all done inside one function.


 as.numeric(gsub("M$","e6",gsub("B$","e9",s)));
}

parse.num <- function (v) {
 for (i in 1:length(v)) v[[i]] <- parse.num1(v[[i]])
 v;
}

actually... wait a sec...
shouldn't this work?

 bad <- (data[1] == "N/A")
 data[1][bad] <- NA
 data[1][!bad] <- as.numeric(gsub("M$","e6",gsub("B$","e9",data[1])))


It might not, since at this point you should have different length  
vectors.


(I'm also not sure that the  listobj[][] <-   
construction would work, but I really don't know about that one.)


parse.num2 <- function (s) {
 is.na(s) <- (s == "N/A")
 as.numeric(gsub("M$","e6",gsub("B$","e9",s)))
  }

Then call as I suggested





--
Sam Steingold (http://sds.podval.org/) on CentOS release 5.3 (Final)
http://dhimmi.com http://memri.org http://truepeace.org http://camera.org
http://thereligionofpeace.com http://palestinefacts.org http://www.memritv.org
Heck is a place for people who don't believe in gosh.


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] string parsing

2011-02-16 Thread David Winsemius


On Feb 15, 2011, at 5:20 PM, Sam Steingold wrote:

I am trying to get stock metadata from Yahoo finance (or maybe there  
is

a better source?)
here is what I did so far:

yahoo.url <- "http://finance.yahoo.com/d/quotes.csv?f=j1jka2&s=";;
stocks <- c("IBM","NOIZ","MSFT","LNN","C","BODY","F"); # just some  
samples
socket <-  
url(paste(yahoo.url,sep="",paste(stocks,collapse="+")),open="r");

data <- read.csv(socket, header = FALSE);
close(socket);
data is now:
  V1 V2 V3V4
1  200.5B 116.00 166.25   4965150
2   19.1M   3.75   5.47  8521
3  226.6B  22.73  31.58  57127000
4  886.4M  30.80  74.54226690
5  142.4B   3.21   5.15 541804992
6  276.4M  11.98  21.30149656
7 55.823B   9.75  18.97  89369000

now I need to do this:

--> convert 55.823B to 55e9 and 19.1M to 19e6

parse.num <- function (s) { as.numeric(gsub("M$","e6",gsub("B 
$","e9",s))); }



seems like awfully inefficient (two regexp substitutions),
is there a better way?


I haven't come up with a better approach at least for a two  
substitution task, having considered using strapply from pkg gsubfn  
but deciding it would be just as much, if not more, code. But why are  
you using lapply on a single vector. Why not:


data[1] <- parse.num( data[[1]] )  # as.numeric and gsub are vectorized



--> iterate over stocks & data at the same time and put the results  
into

a hash table:
for (i in 1:length(stocks)) cache[[stocks[i]]] <- data[i,];

I do get the right results,
but I am wondering if I am doing it "the right R way".
E.g., the hash table value is a data frame.
A structure(record?) seems more appropriate.



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] string parsing

2011-02-16 Thread jim holtman
try this:

> x <- c('15.5B', '13.6M')
> x <- sub("B", 'e9', x)
> x <- sub("M", 'e6', x)
> as.numeric(x)
[1] 1551360


On Tue, Feb 15, 2011 at 5:20 PM, Sam Steingold  wrote:
> I am trying to get stock metadata from Yahoo finance (or maybe there is
> a better source?)
> here is what I did so far:
>
> yahoo.url <- "http://finance.yahoo.com/d/quotes.csv?f=j1jka2&s=";;
> stocks <- c("IBM","NOIZ","MSFT","LNN","C","BODY","F"); # just some samples
> socket <- url(paste(yahoo.url,sep="",paste(stocks,collapse="+")),open="r");
> data <- read.csv(socket, header = FALSE);
> close(socket);
> data is now:
>       V1     V2     V3        V4
> 1  200.5B 116.00 166.25   4965150
> 2   19.1M   3.75   5.47      8521
> 3  226.6B  22.73  31.58  57127000
> 4  886.4M  30.80  74.54    226690
> 5  142.4B   3.21   5.15 541804992
> 6  276.4M  11.98  21.30    149656
> 7 55.823B   9.75  18.97  89369000
>
> now I need to do this:
>
> --> convert 55.823B to 55e9 and 19.1M to 19e6
>
> parse.num <- function (s) { as.numeric(gsub("M$","e6",gsub("B$","e9",s))); }
> data[1]<-lapply(data[1],parse.num);
>
> seems like awfully inefficient (two regexp substitutions),
> is there a better way?
>
> --> iterate over stocks & data at the same time and put the results into
> a hash table:
> for (i in 1:length(stocks)) cache[[stocks[i]]] <- data[i,];
>
> I do get the right results,
> but I am wondering if I am doing it "the right R way".
> E.g., the hash table value is a data frame.
> A structure(record?) seems more appropriate.
>
> thanks!
>
> --
> Sam Steingold (http://sds.podval.org/) on CentOS release 5.3 (Final)
> http://pmw.org.il http://ffii.org http://camera.org http://honestreporting.com
> http://iris.org.il http://mideasttruth.com http://thereligionofpeace.com
> I haven't lost my mind -- it's backed up on tape somewhere.
>
> __
> R-help@r-project.org mailing list
> https://stat.ethz.ch/mailman/listinfo/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] read.table - reading text variables as text

2011-02-16 Thread Ista Zahn
Hi Nick,

On Wed, Feb 16, 2011 at 7:28 AM, Nick Riches  wrote:
> Hi
>
> I've resolved the following query by adding the option "stringsAsFactors =
> FALSE"

Sure, that works, but it doesn't explain why as.is="stim" didn't work.
Unfortunately I cannot reproduce:

> dat <- data.frame(stim=letters[10], x=1:10)
> write.table(dat, file="test.dat", sep=",")
> tmp1 <- read.table(file="test.dat", header=T, sep=",")
> tmp2 <- read.table(file="test.dat", header=T, sep=",", as.is="stim")
> str(tmp1)
'data.frame':   10 obs. of  2 variables:
 $ stim: Factor w/ 1 level "j": 1 1 1 1 1 1 1 1 1 1
 $ x   : int  1 2 3 4 5 6 7 8 9 10
> str(tmp2)
'data.frame':   10 obs. of  2 variables:
 $ stim: chr  "j" "j" "j" "j" ...
 $ x   : int  1 2 3 4 5 6 7 8 9 10
>

> sessionInfo()
R version 2.11.1 (2010-05-31)
i386-pc-mingw32

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

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

other attached packages:
[1] ggplot2_0.8.9 proto_0.3-8   reshape_0.8.3 plyr_1.2.1

loaded via a namespace (and not attached):
[1] digest_0.4.2 tools_2.11.1

Best,
Ista

>
> Thanks
>
> Nick Riches
>
> -- Forwarded message --
> From: Nick Riches 
> Date: 16 February 2011 12:16
> Subject: read.table - reading text variables as text
> To: r-help@r-project.org
>
>
> Hi
>
> I'm reading a CSV file using read.table, and it keeps importing a text
> variable as a factor. To overcome this, I've used the as.is command
> referring to the variable in question (called "stim")
>
> data<-read.table(file.choose(), header=T, sep=",", as.is = "stim")
>
> However, "stim" is still imported as a factor. I notice there are other
> read.table options related to this issue, but the help files don't appear to
> contain much detail on these.
>
> Any help would be greatly appreciated.
>
> Best wishes
>
> Nick Riches
>
> --
> Lecturer in Speech and Language Pathology
> Room 1.9
> King George VI Building
> Queen Victoria Road
> University of Newcastle-upon Tyne
> NE1 7RU
>
> 0191 222 8720
>
>
>
> --
> Lecturer in Speech and Language Pathology
> Room 1.9
> King George VI Building
> Queen Victoria Road
> University of Newcastle-upon Tyne
> NE1 7RU
>
> 0191 222 8720
>
>        [[alternative HTML version deleted]]
>
> __
> R-help@r-project.org mailing list
> https://stat.ethz.ch/mailman/listinfo/r-help
> PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
> and provide commented, minimal, self-contained, reproducible code.
>



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

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


Re: [R] problem running scripts

2011-02-16 Thread Uwe Ligges



On 14.02.2011 19:58, jose Bartolomei wrote:



Dear all,


I have encounter an odd situation.


I have various R scripts interconnected via the source () function.


After examining the results I noticed that not all the functions or procedures 
within a script were adequately conducted.
Especially with the longest script ( about 180 lines)


Then, I ran every scripts individually (not using source () ) selecting all 
(Ctrl + a) and running the selection (Ctrl + r).


R read every line in my script but, again, not all of the procedures were 
executed.


For example:


X$DATEACCI<-as.Date(X$DATEACCI) stayed as a factor.


Or

X$AgeG bellow was not created


ageg<-c(0, 4, 11, 50, Inf)


X$AgeG<-cut(X$AGE, ageg, include.lowest=TRUE,
labels=c("0-4", "5-11", "12-50", "51+"))




X data.set is approximately dim( 345,000, 33) for year one but I will need to 
run the scripts on 10 years.


I tried it using attach and the function use() from epicalc but did not work 
neither.



Well, you need to give us a reproducible example, if my following guess 
is incorrect: You have not looked at the error messages!
Please report the error messages and whatch out after which lines they 
appear if you run it as a whole. You certainly made a mistake, but we 
cannot know.


Uwe Ligges








Nonetheless, if I ran every line of my script individually, everything was OK.




Any insight on this?
What I have missed from R Manuals?


I am using R 2.12.0 embedded within eclipse Helios via StatET 0.9.1


In addition I ran the scripts using R console: 2.12.0, 32 bit (not within 
eclipse)


I conducted the same procedure in two different HP Z400 running in Window 7, 
4Gb of RAM


I'll try under Linux in my home, if different I'll report it.


Thanks,


Jose


[[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] R not working after loading lattice

2011-02-16 Thread Uwe Ligges



On 14.02.2011 16:50, Rita Carreira wrote:


Hello!
Happy Valentine's Day...

After I loaded the package lattice in R, it did not work. Then when I closed R 
and restarted it, R started with an error message and here is the feedback that 
I got from the R Console:

Loading required package: Hmisc
Loading required package: survival
Loading required package: stats
Loading required package: graphics
Loading required package: splines
Error in loadNamespace(i[[1L]], c(lib.loc, .libPaths())) :
   there is no package called 'lattice'



This means lattice is not even found on the search path (which indicates 
a broken installation). Hence the recommendation would be to reinstall R.


Uwe Ligges




Error: package 'Hmisc' could not be loaded

I cannot do anything in R now; it does not even read the data in. When I try 
it, it gives me the following error:


source(.trPaths[5], echo=TRUE, max.deparse.length=150)

Error in source(.trPaths[5], echo = TRUE, max.deparse.length = 150) :
   object '.trPaths' not found

What is the solution? Should I just reinstall R and make sure I do not load 
lattice?

Thank you all!
Rita
P.S. I am very new to R and I still have trouble understanding some of the 
language and how it all works. I've been using it for about 1.5 weeks.



[[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] Cannot allocate memory block

2011-02-16 Thread Uwe Ligges



On 15.02.2011 21:05, poisontonic wrote:


Hi, I'm using the latest version of 64-bit R for Windows: R x64 2.12.1

I'm using it because I currently need to do hierarchical clustering on a
very large object (too big for MATLAB, which I normally use).
When I try to cluster my distance matrix d (obtained using dist on my design
matrix):
hc<- hclust(d, method = 'average')

I get an errror:
Error in hclust(d, method = "average") :
   cannot allocate memory block of size 3.8 Gb

However, the memory limits appear to be 16GB:

memory.limit()

[1] 16378

Does anyone know why R cannot allocate a memory block of size 3.8 GB, even
though this is well within its memory limits??


If the available space got too fragmented, there is not single 3.8 block 
of memory available any more


Uwe Ligges







Any help would be greatly appreciated!
Thanks alot,

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] R package error

2011-02-16 Thread Uwe Ligges



On 15.02.2011 19:20, ycherkas wrote:


Hi,
I have a package I was previously able to compile and use for R 2.6.
In the newer versions of R it did not work, so I am making it from scratch
using Rtools and new R version.


Looks like you have designed "mypack" in a way that it is supposed to 
run only under the Windows GUI version of R, since there is a call to

  winMenuAdd()
in the startup code.

In that case the load check does not work and you have to disable it and 
build the binary via


R CMD INSTALL --build --no-test-load


Best,
Uwe Ligges






However, I keep getting error after Rcmd build –binary mypack

Here is the complete log:
* checking for file ‘mypack/DESCRIPTION’ … OK
* preparing ‘mypack’:
* checking DESCRIPTION meta-information … OK
* removing junk files
* checking for LF line-endings in source and make files
* checking for empty or unneeded directories
* building binary distribution
* installing *source* package ‘mypack’ …
** R
** preparing package for lazy loading
** help
Warning: ./man/mypack-package.Rd:34: All text must be in a section
Warning: ./man/mypack-package.Rd:35: All text must be in a section
*** installing help indices
** building package indices …
** testing if installed package can be loaded
gdata: read.xls support for ‘XLS’ (Excel 97-2004) files ENABLED.

gdata: Unable to load perl libaries needed by read.xls()
gdata: to support ‘XLSX’ (Excel 2007+) files.

gdata: Run the function ‘installXLSXsupport()’
gdata: to automatically download and install the perl
gdata: libaries needed to support Excel XLS and XLSX formats.
Error in winMenuAdd(menuname, NULL, NULL) :
Menu functions can only be used in the GUI
ERROR: loading failed
* removing ‘C:/DOCUME~1/…/mypack’
ERROR
* installation failed


Thank you,
Zhenya



__
R-help@r-project.org mailing list
https://stat.ethz.ch/mailman/listinfo/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] boot.ci error with large data sets

2011-02-16 Thread Peter Ehlers

On 2011-02-16 04:44, Lars Dalby wrote:

Dear List

I have run into some problems with boot.ci from package boot. When I
try to obtain a confidence interval of type bca, boot.ci() returns the
following error when the data set i large:
Error in bca.ci(boot.out, conf, index[1L], L = L, t = t.o, t0 =
t0.o,  :
   estimated adjustment 'a' is NA

Below is an example that produces the above mentioned error on my
machine.

library(boot)
#The wrapper function:
w.mean<- function(x, d) {
E<- x[d,]
return(weighted.mean(E$A, E$B))}
#Some fake data:
test<- data.frame(rnorm(1000, 5), rnorm(1000, 3))
test1<- data.frame(rnorm(1, 5), rnorm(1, 3))
names(test)<- c("A", "B")
names(test1)<- c("A", "B")
# Getting the boot object and the CI, seem to works fine
bootout<- boot(test, w.mean, R=1000, stype="i")
(bootci<- boot.ci(bootout, conf = 0.95, type = "bca"))
# Now with a bigger data set, boot.ci returns an error.
bootout1<- boot(test1, w.mean, R=1000, stype="i")
(bootci1<- boot.ci(bootout1, conf = 0.95, type = "bca"))

Does anyone have an idea as to why this happens? (Session info below)


Well, someone wiser than I with regard to boot()
will be able to give a more definitive answer.

In the meantime, note that you get the same 'problem'
with your smaller dataset if you set the number of
bootstrap replicates to less than the row dimension
of your data.frame:

 bootout <- boot(test, w.mean, R=999, stype="i")
 (bootci <- boot.ci(bootout, type = "bca"))

So one way to handle your larger dataset is to
use R = 1. Of course, you'll have to be
patient - the result may take a while.

Peter Ehlers



Best,
Lars


sessionInfo()

R version 2.12.1 (2010-12-16)
Platform: x86_64-apple-darwin9.8.0/x86_64 (64-bit)

locale:
[1] da_DK.UTF-8/da_DK.UTF-8/C/C/da_DK.UTF-8/da_DK.UTF-8

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

other attached packages:
[1] boot_1.2-43

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

__
R-help@r-project.org mailing list
https://stat.ethz.ch/mailman/listinfo/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] retrieving partial residuals of gam fit (mgcv)

2011-02-16 Thread Simon Wood
The partial residuals for a smooth term are just the whole model residuals + 
the corresponding estimate of the smooth term. You can use predict to access 
the latter and compute them quite easily. For example...

 set.seed(0) ## simulate some data...
 dat <- gamSim(1,n=400,dist="normal",scale=2)
 ## fit a model...
 b <- gam(y~s(x0)+s(x1)+s(x2)+s(x3),data=dat)
 fv <- predict(b,type="terms") ## get term estimates
 ## compute partial residuals for first smooth...  
 prsd1 <- residuals(b,type="working") + fv[,1]
 plot(b,select=1) ## plot first smooth
 ## add random selection of partial residuals
 ind <- sample(1:length(prsd1),100)
 points(dat$x0[ind],prsd1[ind],pch=19,col="pink") 


On Wednesday 16 February 2011 12:35, Jannis wrote:
> Dear list,
>
>
> does anybody know whether there is a way to easily retrieve the so called
> "partial residuals" of a gam fit with package mgcv? The partial residuals
> are the residuals you would get if you would "leave out" a particular
> predictor and are the dots in the plots created by
>
> plot(gam.object,residuals=TRUE)
>
> residuals.gam() gives me whole model residuals and
> predict.gam(...,type='terms') only gives me the response function and its
> standard deviation.
>
> I would like to retrieve the values of these residuals as I would like to
> only plot a random sample of the residuals to avoid overloading the plot
> (>10 data points).
>
>
> Thanks a lot in advance
> Jannis
>
>
>
> __
> R-help@r-project.org mailing list
> https://stat.ethz.ch/mailman/listinfo/r-help
> PLEASE do read the posting guide
> http://www.R-project.org/posting-guide.html and provide commented, minimal,
> self-contained, reproducible code.

-- 
> Simon Wood, Mathematical Sciences, University of Bath, Bath, BA2 7AY UK
> +44 1225 386603  www.maths.bath.ac.uk/~sw283

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

2011-02-16 Thread Ben Bolker
Arnau Mir  uib.es> writes:

> Somebody knows if there exists some R package that it is capable of 
> doing the same of the software ExpertFit
> (see http://www.averill-law.com/ExpertFit-distribution-fitting-software.htm)?

Not that I'm aware of: see e.g.



for some discussion of why not.

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

2011-02-16 Thread JLucke
I just found out that the sum of 1+2+3+...  is  -1/12. !?!   Crazy. 
Not really.  Google on divergent series or Euler summation.  The result 
explains why bosonic string theory must operate only in 26 dimensions!  It 
would then appear that  ... -3 - 2 - 1 + 0 +1 +2 +3 + ... is zero. 





peter dalgaard  
Sent by: r-help-boun...@r-project.org
02/15/2011 11:53 AM

To
David Winsemius 
cc
r-help@r-project.org, Kjetil Halvorsen 
, Maithula Chandrashekhar 

Subject
Re: [R] A Math question







On Feb 15, 2011, at 15:17 , David Winsemius wrote:

> 
> On Feb 14, 2011, at 7:33 PM, Kjetil Halvorsen wrote:
> 
>> or even better:
>> 
>> http://mathoverflow.net/
> 
> I beg to differ. That is designated in its FAQ as expecting "research 
level questions", while the forum I offered is labeled as "Welcome to Q&A 
for people studying math at any level and professionals in related 
fields". I don't think the proffered question could be considered 
"research level".

Yep. 

As for the stats contents, we do actually touch upon the question in basic 
probability. This is the reason that sums over infinite index sets are 
only defined if the corresponding sum of the absolute value is finite: 
Otherwise the result depends on the order of summation. (Think 
0+1+2+(-1)+3+4+(-2)+5+6+(-3)+)

> 
>> 
>> On Sun, Feb 13, 2011 at 8:02 PM, David Winsemius 
 wrote:
>>> 
>>> On Feb 13, 2011, at 4:47 PM, Maithula Chandrashekhar wrote:
>>> 
 Dear all, I admit this is not anything to do R and even with
 Statistics perhaps. Strictly speaking this is a math related 
question.
 However I have some reasonable feeling that experts here would come 
up
 with some elegant suggestion to my question.
 
 Here my question is: What is sum of all Integers? I somewhere heard
 that it is Zero as positive and negative integers will just cancel
 each other out. However want to know is it correct?
>>> 
>>> There are more appropriate places to pose such questions:
>>> http://math.stackexchange.com/
>>> 
> 
> David Winsemius, MD
> West Hartford, CT
> 
> __
> R-help@r-project.org mailing list
> https://stat.ethz.ch/mailman/listinfo/r-help
> PLEASE do read the posting guide 
http://www.R-project.org/posting-guide.html
> and provide commented, minimal, self-contained, reproducible code.

-- 
Peter Dalgaard
Center for Statistics, Copenhagen Business School
Solbjerg Plads 3, 2000 Frederiksberg, Denmark
Phone: (+45)38153501
Email: pd@cbs.dk  Priv: pda...@gmail.com

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


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

2011-02-16 Thread Achim Zeileis

On Wed, 16 Feb 2011, stif...@gmx.de wrote:


Hey everyone,

For an investment strategy I built some portfolios of historical stock returns 
(every 6 month for 10 years->20observations). To get more observations I´m 
using overlapping observations(40obs. which means lag=1).The goal is to test 
whether the reruns are positiv or market efficient(=0).

To correct for autocorrelation I would like to use NeweyWest(sandwich)in 
R, to get the correct standard deviation for the t-test, but NeweyWest 
requires a regression model (lm or glm) which I dont have. Is there a 
possibility to do this without a linear model??


Use the trivial linear model lm(y ~ 1) whose only coefficient then 
corresponds to the estimated mean of y.


Furthermore, if I understand you correctly, you induce a strong 
autocorrelation by using the overlapping observations. So you may be 
better off modeling this explicitly in an arima() model, or maybe a gls() 
approach.


hth,
Z


Thanks!!! solari
--
GMX DSL Doppel-Flat ab 19,99 Euro/mtl.! Jetzt mit 
gratis Handy-Flat! http://portal.gmx.net/de/go/dsl


__
R-help@r-project.org mailing list
https://stat.ethz.ch/mailman/listinfo/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] id number by group and correlative

2011-02-16 Thread Sarah Goslee
You don't really need to do all of that, since you can
use group directly. But if you want to have a numeric
value for some reason, here's one possible way:

group <- c("A", "A", "A", "A", "B", "B", "B", "C", "C", "C", "C", "C")
id_group <- as.numeric(as.factor(group))
correlative_group <- unlist(lapply(rle(group)$lengths,
function(x)seq(1, x, by=1)))

cbind.data.frame(group, id_group, correlative_group)


As for your last question:
> PD: Last question. Is there any way to save in a variable the internal that
> R uses (those numbers that appear on left side of a dataframe)?

You mean the row names? See ?row.names

Sarah

2011/2/16 Sebastián Daza :
> Hello everyone,
> I am new in R and I am trying to create a id number (a correlative sequence
> of numbers) by group, and a correlative sequence of numbers inside each
> group (my idea is to get statistics by group  without having to aggregate
> the database). Here an example:
>
> group   id_group        correlative_group
> A               1               1
> A               1               2
> A               1               3
> A               1               4
> B               2               1
> B               2               2
> B               2               3
> C               3               1
> C               3               2
> C               3               3
> C               3               4
> C               3               5
>
> Unfortunately, I have been able to find an explicit lag function to get
> id_group (I know I can get it using aggregate and merge but I'm just
> wondering if there is another way to do it). With regard to the
> correlative_group, I don't have any clue about how to do it.
>
> PD: Last question. Is there any way to save in a variable the internal that
> R uses (those numbers that appear on left side of a dataframe)?
>
> Thank you,
> Sebastian.
> --
> Sebastián Daza
> sebastian.d...@gmail.com
>



-- 
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] Arima contents

2011-02-16 Thread Downey, Patrick
Hello,

I'm running a number of arima models using the "arima" function. Often,
when lag length gets too high, these model don't converge and an error
message appears as this:
> reg <- arima(y,order=c(7,0,7),xreg=isr)
Warning message:
In arima(y, order = c(7, 0, 7), xreg = isr) :
  possible convergence problem: optim gave code=1


In this case, when you print the results from the arima model, the error
message appears again:
> reg

Call:
arima(x = y, order = c(7, 0, 7), xreg = isr)

Coefficients:
  ar1 ar2  ar3 ar4 ar5 ar6 ar7 ma1
ma2
  -0.3356  0.0282  -0.0124  0.0604  0.1608  0.7949  0.2286  0.4461
0.0099
s.e.  NaN  0.2140   0.1711  0.2545  0.1547  0.0725 NaN NaN
0.1842
 ma3 ma4 ma5  ma6  ma7  intercept  isr
  0.0841  0.0773  -0.054  -0.7227  -0.1322 6.1433  -0.0818
s.e.  0.1911  0.2689 NaN   0.1774  NaN 5.0604   0.2110

sigma^2 estimated as 4.542:  log likelihood = -651.68,  aic = 1337.36
Warning message:
In sqrt(diag(x$var.coef)) : NaNs produced


I'm writing a loop to run several of these models and I would like to
include an if statement with instructions in case there is a possible
convergence problem. Is there any way to automatically detect a warning
like this without visually inspecting each result? I tried
warnings(arima(y,order=c(7,0,7),isr), but I don't think that will get me
what I want.

The contents of an arima object are below. I was hoping one of them would
include error messages, but I haven't been able to find it.
> summary(reg)
  Length Class  Mode 
coef   16-none- numeric  
sigma2  1-none- numeric  
var.coef  256-none- numeric  
mask   16-none- logical  
loglik  1-none- numeric  
aic 1-none- numeric  
arma7-none- numeric  
residuals 299ts numeric  
call4-none- call 
series  1-none- character
code1-none- numeric  
n.cond  1-none- numeric  
model  10-none- list 

Thanks in advance for any help.

-Mitch

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

2011-02-16 Thread Duncan Murdoch

On 16/02/2011 9:04 AM, Jan van der Laan wrote:

One possible solution is to use something like:

a<- 0
for (i in 1:1E6) {
  old.a<- a

  # do something e.g.
  a<- runif(1)<  1E-6

  if (a != old.a) browser()
}


Another solution is to write your output to file (using sink for
example) and to watch this file using a tool like tail.



The trace() function provides this kind of thing temporarily, with a lot 
of flexibility.  setBreakpoint() provides a slightly more friendly way 
to construct arguments to it -- you can say to set the breakpoint at 
line 7, not having to work out that line 7 is the 3rd statement within 
the 2nd statement block in the function.


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] leap years in temporal series command ts

2011-02-16 Thread Gabor Grothendieck
On Wed, Feb 16, 2011 at 6:51 AM, Peter Zorglub  wrote:
> Hi R community!
>
> I'd like to create a temporal series with ts command for the interval 1st
> January 2002 - 31 December 2008. I have daily values, so this is a 2557 days
> temporal series. I'm using this command :
>
>    ts(observations, start=2002, end=2009, freq=365)
>
> However, I don't get the correct temporal series since both frequency (365
> OR 366 for leap years) and deltat (1/365 OR 1/366) are varying with the year
> considered.
>
> So, is there a specific way to deal with leap years in the ts command or
> have I to use another package?

You could do this with an implied frequency of 1

tt <- ts(1:10, start=as.Date("2000-01-01"))

which would represent the times as days since the Epoch. You can
recover the Date class dates with:

as.Date(tt, origin = "1970-01-01")

You might be better off using zoo or xts. e.g.

library(zoo)
z <- zooreg(1:10, start = as.Date("2000-01-01"))

Its also possible to move back and forth:

as.ts(z)
as.zoo(tt)
aggregate(as.zoo(tt), identity, as.Date)



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

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


[R] Hartley's table

2011-02-16 Thread Silvano

Hi,

I used the commands below to make Hartley's table,
but some values are NA.

require(SuppDists)
trat = seq(2, 15, 1)
gl = seq(2, 40, 1)

har = matrix(0, nr=length(gl), nc=length(trat))

for(i in 1:length(gl))
for(j in 1:length(trat))
har[i,j] <- qmaxFratio(.95, df=gl[i], k=trat[j])

rownames(har) <- gl
colnames(har) <- trat

head(har)


The output (head):

 2 3  4  5 6 
7
2 39.00 87.488567 142.502114 202.378010 266.16460 
333.18651
3 15.439182 27.758294  39.503063  50.885084  46.75297 
72.83358
4  9.604530 15.457596  20.559223  25.211423  29.54387 
33.62982
5  7.146382 10.751785  13.723953 NA  10.14968 
20.87902
6  5.819757  8.362843  10.380280  12.108103  13.64260 
15.03555
7  4.994909  6.939901   8.439993   9.697305  10.80480 
11.79569
 8  9101112 
13
2 403.07945 475.372389 549.84302 626.22781 704.41272 
784.22483
3  83.47794  93.943236 104.24551 114.40008 124.41965 
80.84930
4  37.51656  41.237201  44.81356  48.26765  51.61274 
54.86066
5NA   2.173131  26.64526NANA 
31.62688
6  16.31888  17.514001  18.63614  19.69659  20.70403 
21.66528
7  12.6  13.535307  14.31403  15.04529  15.73600 
16.39159

1415
2 865.53893 948.24795
3  82.18823  83.40749
4  58.02112  61.10224
5  19.09581  34.64536
6  22.58582  23.46946
7  17.01639  17.61392

What's wrong?

Thanks.

--
Silvano Cesar da Costa
Departamento de Estatística
Universidade Estadual de Londrina
Fone: 3371-4346

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

2011-02-16 Thread stiff83
Hey everyone,

For an investment strategy I built some portfolios of historical stock returns 
(every 6 month for 10 years->20observations). To get more observations I´m 
using overlapping observations(40obs. which means lag=1).The goal is to test 
whether the reruns are positiv or market efficient(=0).

To correct for autocorrelation I would like to use NeweyWest(sandwich)in R,
to get the correct standard deviation for the t-test, but NeweyWest requires a 
regression model (lm or glm) which I dont have.
Is there a possibility to do this without a linear model??

Thanks!!! solari
-- 
GMX DSL Doppel-Flat ab 19,99 Euro/mtl.! Jetzt mit 
gratis Handy-Flat! http://portal.gmx.net/de/go/dsl

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

2011-02-16 Thread Michela Ferron

Many thanks Mikhail,
aggregate() is fine!

Il 14/02/2011 20.42, Mikhail Titov ha scritto:

It depends what would you like to get at the end. Perhaps you don't
necessary need this type of numbering. For instance, if you'd like to
calculate daily average.

london$id<- as.Date(london$id)

For sum by day you could use, let's say, this

aggregate(words~id,london,FUN=sum)

If you really want what you've asked:

london$one=1
u=unique(london$id)
z=aggregate(one~id,london,FUN=sum)
london$day=rep(seq(along.with=z$one),z$one)

Mikhail



-Original Message-
From: r-help-boun...@r-project.org [mailto:r-help-bounces@r-
project.org] On Behalf Of Michela Ferron
Sent: Monday, February 14, 2011 11:09 AM
To: r-help@r-project.org
Subject: [R] How to group data by day

Hi everybody,

I'm a beginner in R and I'm having a hard time grouping my data by day.
The data are in this format:

id; words
2005-07-07T09:59:56Z; 35
2005-07-07T10:01:39Z; 13
2005-07-08T10:02:22Z; 1
2005-07-09T10:03:16Z; 23
2005-07-10T10:04:23Z; 39
2005-07-10T10:04:39Z; 15

I've transformed the date strings in dates with the function:
london$id<- transform(london$id, as.Date(london$id, format="%Y-%m-
%d%T%H:%M:%S%Z"))
and it seems to work.

Now I would like to add a new "day" variable to group data by day, like
this:

id; words; day
2005-07-07T09:59:56Z; 35; 1
2005-07-07T10:01:39Z; 13; 1
2005-07-08T10:02:22Z; 1; 2
2005-07-09T10:03:16Z; 23; 3
2005-07-10T10:04:23Z; 39; 4
2005-07-10T10:04:39Z; 15; 4

How can I do that?

Many thanks!

Michela

__
R-help@r-project.org mailing list
https://stat.ethz.ch/mailman/listinfo/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] leap years in temporal series command ts

2011-02-16 Thread Peter Zorglub

Hi R community!

I'd like to create a temporal series with ts command for the interval 
1st January 2002 - 31 December 2008. I have daily values, so this is a 
2557 days temporal series. I'm using this command :


ts(observations, start=2002, end=2009, freq=365)

However, I don't get the correct temporal series since both frequency 
(365 OR 366 for leap years) and deltat (1/365 OR 1/366) are varying with 
the year considered.


So, is there a specific way to deal with leap years in the ts command or 
have I to use another package?



Thanks in advance,



Peter

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

2011-02-16 Thread rex.dwyer
A quick way to do this is to replace \d and \D with character classes [0-9.]
and [^0-9.] .  This assumes that there is no scientific notation and that there 
is nothing like 123.45.678 in the string.  You did not account for a leading 
minus sign.
The book Mastering Regular Expressions is probably worth the expense if you are 
going to be doing a lot of this, even though similar content can be gleaned 
from on line.

-Original Message-
From: r-help-boun...@r-project.org [mailto:r-help-boun...@r-project.org] On 
Behalf Of Megh Dal
Sent: Sunday, February 13, 2011 4:42 PM
To: Gabor Grothendieck
Cc: r-help@r-project.org
Subject: Re: [R] String manipulation

Hi Gabor, thanks (and Jim as well) for your suggestion. However this is not
working properly for following string:

> MyString <- "ABCFR34564IJVEOJC3434.36453"
> strapply(MyString, "(\\D+)(\\d+)(\\D+)(\\d +)",
c)[[1]]
[1] "ABCFR"   "34564"   "IJVEOJC" "3434"

Therefore there is decimal number in the 4th group, which is numeric then
that is not taken care off...

Similarly same kind of unintended result here as well:

> MyString <- "ABCFR34564.354IJVEOJC3434.36453"
> strapply(MyString, "(\\D+)(\\d+)(\\D+)(\\d +)",
c)[[1]]
[1] "ABCFR"   "34564"   "."   "354" "IJVEOJC" "3434""."
"36453"
Can you please tell me how can I modify that?

Thanks,


On Sun, Feb 13, 2011 at 11:10 PM, Gabor Grothendieck <
ggrothendi...@gmail.com> wrote:

>  On Sun, Feb 13, 2011 at 10:27 AM, Megh Dal  wrote:
> > Please consider following string:
> >
> > MyString <- "ABCFR34564IJVEOJC3434"
> >
> > Here you see that, there are 4 groups in above string. 1st and 3rd groups
> > are for english letters and 2nd and 4th for numeric. Given a string, how
> can
> > I separate out those 4 groups?
> >
>
> Try this.  "\\D+" and "\\d+" match non-digits and digits respectively.
>  The portions within parentheses are captures and passed to the c
> function.  It returns a list with a component for each element of
> MyString.  Like R's split it returns a list with a component per
> element of MyString but MyString only has one element so we get its
> contents using  [[1]].
>
> > library(gsubfn)
> > strapply(MyString, "(\\D+)(\\d+)(\\D+)(\\d+)", c)[[1]]
> [1] "ABCFR"   "34564"   "IJVEOJC" "3434"
>
> Alternately we could convert the relevant portions to numbers at the
> same time.  ~ list(...) is interpreted as a  function whose body is
> the right hand side of the ~ and whose arguments are the free
> variables, i.e. s1, s2, s3 and s4.
>
> strapply(MyString, "(\\D+)(\\d+)(\\D+)(\\d+)", ~ list(s1,
> as.numeric(s2), s3, as.numeric(s4)))[[1]]
>
> See http://gsubfn.googlecode.com for more.
>
> --
> Statistics & Software Consulting
> GKX Group, GKX Associates Inc.
> tel: 1-877-GKX-GROUP
> email: ggrothendieck at gmail.com
>

[[alternative HTML version deleted]]

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




message may contain confidential information. If you are not the designated 
recipient, please notify the sender immediately, and delete the original and 
any copies. Any use of the message by you is prohibited. 
__
R-help@r-project.org mailing list
https://stat.ethz.ch/mailman/listinfo/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] read.table - reading text variables as text

2011-02-16 Thread Nick Riches
Hi

I've resolved the following query by adding the option "stringsAsFactors =
FALSE"

Thanks

Nick Riches

-- Forwarded message --
From: Nick Riches 
Date: 16 February 2011 12:16
Subject: read.table - reading text variables as text
To: r-help@r-project.org


Hi

I'm reading a CSV file using read.table, and it keeps importing a text
variable as a factor. To overcome this, I've used the as.is command
referring to the variable in question (called "stim")

data<-read.table(file.choose(), header=T, sep=",", as.is = "stim")

However, "stim" is still imported as a factor. I notice there are other
read.table options related to this issue, but the help files don't appear to
contain much detail on these.

Any help would be greatly appreciated.

Best wishes

Nick Riches

-- 
Lecturer in Speech and Language Pathology
Room 1.9
King George VI Building
Queen Victoria Road
University of Newcastle-upon Tyne
NE1 7RU

0191 222 8720



-- 
Lecturer in Speech and Language Pathology
Room 1.9
King George VI Building
Queen Victoria Road
University of Newcastle-upon Tyne
NE1 7RU

0191 222 8720

[[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] Need Assistance in Stacked Area plot

2011-02-16 Thread Kishorenalluri

Dear All,

I need the assistance to plot the staked area plot using ggplot2

What i am expecting is to plot in X-axis the time(Shown in column1) from
range of 0 to 100 seconds, and in the y axis the stable increment in area in
both directions (less than and greater than zero) for columns 3, 4, 5 (
Column1, Column2, column3). The example as follows
TIME  concentration   Column1   
Column2   Column3
0. 0.E+000.E+000.E+00   
0.E+00
0. 0.E+001.06339151E-16   -1.45858050E-21  
-5.91725566E-19
0. 5.38792107E-161.02157781E-17   -1.64419026E-20  
-7.66233765E-19
1. 2.59545931E-153.42126227E-18   -1.98776066E-20  
-3.72669548E-19
1. 2.91310885E-152.81003039E-18   -1.91286265E-20  
-2.38608440E-19
2. 3.07852570E-152.50631096E-18   -1.81194864E-20  
-1.86739453E-19
3. 3.23261641E-15   -5.56403736E-16   -1.77552840E-20  
-1.70484122E-19
3. 3.35382008E-151.54158070E-17   -2.34217089E-20  
-2.07658923E-19
4. 3.82413183E-15   -9.70815457E-130.E+00  
-6.79571364E-19
4. 5.95542983E-156.80013097E-16   -4.50874919E-19  
-2.66777428E-19
5. 4.39175250E-142.47867332E-15   -1.01608288E-18  
-9.76030255E-19
6. 1.38894685E-135.61681417E-15   -3.93770327E-18  
-3.49248490E-18
6. 3.68692195E-131.16035253E-14   -1.41445363E-17  
-1.22159013E-17
7. 8.73269040E-131.79082686E-14   -3.66076039E-17  
-2.95735768E-17
7. 1.76597984E-122.12332352E-14   -6.62184833E-17  
-4.70513477E-17
8. 2.95030081E-122.25656057E-14   -9.60506242E-17  
-5.97356578E-17
9. 4.26108735E-121.34254419E-14   -1.25090653E-16  
-6.95633425E-17
9. 5.63056757E-122.32612717E-14   -1.53348074E-16  
-8.54969359E-17
   10. 7.01928856E-122.31851800E-14   -1.82546609E-16  
-1.02043519E-16
   10. 8.39638583E-122.31701226E-14   -2.11755800E-16  
-1.18810066E-16
   11. 9.76834605E-12   -5.45647674E-13   -2.40796726E-16  
-1.35796249E-16
   12. 1.11376775E-11   -9.78639513E-13   -2.69731656E-16  
-1.53027433E-16
   12. 1.25059438E-112.32773795E-14   -2.98461854E-16  
-1.70614303E-16
   13. 1.38742114E-112.33364991E-14   -3.27081730E-16  
-1.88394094E-16
   13. 1.52430947E-112.33958407E-14   -3.55573728E-16  
-2.06350128E-16
   14. 1.66127832E-112.34487161E-14   -3.83935678E-16  
-2.24396442E-16
   15. 1.79830524E-112.34906687E-14   -4.12155560E-16  
-2.42441983E-16
   15. 1.93533963E-112.26377072E-14   -4.39950727E-16  
-2.90534988E-16
   16. 2.06980593E-112.17171727E-14   -4.70446135E-16  
-3.56228328E-16
   16. 2.19820310E-111.87207801E-14   -4.98853596E-16  
-4.46861939E-16
   17. 2.32023004E-111.94966974E-14   -5.22695187E-16  
-5.78943073E-16
   18. 2.43484124E-111.78879137E-14   -5.38143362E-16  
-7.87629728E-16
   18. 2.54003017E-113.09723082E-11   -5.36126990E-16  
-1.16329436E-15
   19. 2.63149519E-119.87861573E-15   -4.79610661E-16  
-2.06287085E-15
   19. 2.69770178E-11   -8.01983206E-14   -6.65787469E-17  
-3.62969106E-15
   20. 2.50814500E-111.40265746E-09   -4.91364111E-17  
-3.37932814E-15
   21. 2.23899790E-11   -1.55489960E-14   -4.45522315E-17  
-3.35597818E-15
   21. 2.09705026E-11   -1.20672358E-14   -5.22849137E-17  
-3.35854728E-15
   22. 1.99397498E-11   -1.67958460E-14   -6.01502858E-17  
-3.24838081E-15
   22. 1.91117367E-11   -1.08397245E-14   -6.67337987E-17  
-3.01352774E-15
   23. 1.84409696E-11   -3.92677717E-15   -7.10576594E-17  
-2.67668939E-15
   24. 1.78951028E-11   -2.97739441E-15   -7.26367637E-17  
-2.28204667E-15
   24. 1.74505303E-11   -2.59241020E-15   -7.15967013E-17  
-1.88057466E-15
   25. 1.70886909E-11   -2.22676101E-11   -6.90344927E-17  
-1.51430500E-15
   25. 1.67938004E-11   -2.43300435E-15   -6.45959094E-17  
-1.20480757E-15
   26. 1.65527898E-11   -2.00735751E-15   -6.04828745E-17  
-9.62120866E-16
   27. 1.63547265E-11   -1.67859253E-15   -5.68950146E-17  
-7.80733120E-16
   27. 1.61904094E-11   -1.41262089E-15   -5.41786960E-17  
-6.51168814E-16
   28. 1.60527139E-11   -2.49439678E-12   -5.23952425E-17  
-5.62375603E-16
   28. 1.59360400E-112.62881626E-10   -5.15606096E-17  
-5.03612687E-16
   29. 1.58357080E-11   -8.39976609E-16   -5.14627740E-17  
-4.67073407E-16
   30. 1.57487181E-11

[R] while loop / ICA

2011-02-16 Thread jankov
Hello,

after (1) getting independent components from the (200*20) data matrix X_t   by 
applying

PearsonICA(data matrix, n.comp = 2, row.norm = FALSE, maxit = 200, tol = 1e-04, 
border.base = c(2.6, 4), border.slope = c(0, 1), verbose = FALSE, w.init = 
NULL, na.rm = FALSE, whitening.only = FALSE, PCA.only = FALSE)

I am (2) trying to let the ICA-components converge (abs($S_1-$S_0)<0) in the 
relation

X_t=Lambda*F+Lambda1*Y

with F as estimated factors obtained from the observed time series X_t 
(200*1-vector)  and Y_t(2*1-vector). The goal is to obtain final estimate of F 
and then to estimate VAR in F and Y, FAVAR.

My version is:

#multiplicate the rows (20 time periods) of the column-ordered by variables 
matrix X_ with the column of the two independent components from the step (1), 
get the initial #estimate F_0

#print (F_0)

while (abs(F_0-F_1)<0,01) {
regression<-lm(X_t~F_0,Y_t) 
#here is the place for beta_y_t, obtained regression coefficient relating to Y_t
beta_y_t<-regression$coefficients[2] 
X_1_t<-X_t-beta_y_t*Y_t #new data
F_0<-PearsonICA(X_1_t, n.comp = 2, row.norm = FALSE, maxit = 200, tol = 1e-04, 
border.base = c(2.6, 4), border.slope = c(0, 1), verbose = FALSE, w.init = 
NULL, na.rm = FALSE, whitening.only = FALSE, PCA.only = FALSE)
F_1<-F_0
}
F_1

Thanks in advance
Viktor

__
R-help@r-project.org mailing list
https://stat.ethz.ch/mailman/listinfo/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] read.table - reading text variables as text

2011-02-16 Thread Nick Riches
Hi

I'm reading a CSV file using read.table, and it keeps importing a text
variable as a factor. To overcome this, I've used the as.is command
referring to the variable in question (called "stim")

data<-read.table(file.choose(), header=T, sep=",", as.is = "stim")

However, "stim" is still imported as a factor. I notice there are other
read.table options related to this issue, but the help files don't appear to
contain much detail on these.

Any help would be greatly appreciated.

Best wishes

Nick Riches

-- 
Lecturer in Speech and Language Pathology
Room 1.9
King George VI Building
Queen Victoria Road
University of Newcastle-upon Tyne
NE1 7RU

0191 222 8720

[[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] leap years in temporal series command ts

2011-02-16 Thread Peter Zorglub

Hi R community!

I'd like to create a temporal series with ts command for the interval 
1st January 2002 - 31 December 2008. I have daily values, so this is a 
2557 days temporal series. I'm using this command :


ts(observations, start=2002, end=2009, freq=365)

However, I don't get the correct temporal series since both frequency 
(365 OR 366 for leap years) and deltat (1/365 OR 1/366) are varying with 
the year considered.


So, is there a specific way to deal with leap years in the ts command or 
have I to use another package?



Thanks in advance,



Peter

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

2011-02-16 Thread Roger Bordoy

Dears,

I would like to know how could I change the shading type of a box plot.

Thanks a lot.

Sincerely,

Roger Bordoy

__
R-help@r-project.org mailing list
https://stat.ethz.ch/mailman/listinfo/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 the bootstrap method for latent class analysis

2011-02-16 Thread Debbie Naudi
Hi

I was wondering whether anyone can provide any help or suggestions on the
boostrap method for latent class analysis please.

My main question is: can the bootstrap procedure sometimes be less precise
than the non-bootstrap procedure when carrying out latent class analysis?

I am asking this question because I carried out some analyses and when I *did
not* use the bootstrap procedure I found adequate fit for one of the
models but when I did use the bootstrap none of the models indicated
adequate fit to the data. I know that usually the bootstrap is used with
sparse data, however, I'm not sure whether I should use it or not in my
case.

I would greatly appreciate any feedback!!

Thanks!!


Debbie

[[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] id number by group and correlative

2011-02-16 Thread Sebastián Daza

Hello everyone,
I am new in R and I am trying to create a id number (a correlative 
sequence of numbers) by group, and a correlative sequence of numbers 
inside each group (my idea is to get statistics by group  without having 
to aggregate the database). Here an example:


group   id_groupcorrelative_group
A   1   1
A   1   2
A   1   3
A   1   4
B   2   1
B   2   2
B   2   3
C   3   1
C   3   2
C   3   3
C   3   4
C   3   5

Unfortunately, I have been able to find an explicit lag function to get 
id_group (I know I can get it using aggregate and merge but I'm just 
wondering if there is another way to do it). With regard to the 
correlative_group, I don't have any clue about how to do it.


PD: Last question. Is there any way to save in a variable the internal 
that R uses (those numbers that appear on left side of a dataframe)?


Thank you,
Sebastian.
--
Sebastián Daza
sebastian.d...@gmail.com

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


Re: [R] monitor variable change

2011-02-16 Thread Rainer M Krug
-BEGIN PGP SIGNED MESSAGE-
Hash: SHA1

On 02/16/2011 03:29 PM, Hadley Wickham wrote:
> One way to implement this functionality is with a task manager callback:
> 
> watch <- function(varname) {
>   old <- get(varname)
> 
>   changed <- function(...) {
> new <- get(varname)
> if (!identical(old, new)) {
>   message(varname, " is now ", new)
>   old <<- new
> }
> TRUE
>   }
>   invisible(addTaskCallback(changed))
> }
> 
> a <- 1
> watch("a")
> a <- 2

Wow - I was looking for something like that for a long time - this is
absolutely perfect for debugging. I guess I will use it quite often.

Thanks,

Rainer


> 
> 
> Hadley
> 
> On Wed, Feb 16, 2011 at 9:38 AM, Alaios  wrote:
>> Dear all I would like to ask you if there is a way in R to monitor in R when 
>> a value changes.
>>
>> Right now I use the sprintf('my variables is %d \n, j) to print the value of 
>> the variable.
>>
>> Is it possible when a 'big' for loop executes to open in a new window to 
>> dynamically check only the variable I want to.
>>
>> If I put all the sprintf statements inside my loop then I get flooded with 
>> so many messages that makes it useless.
>>
>> Best 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.
>>
> 
> 
> 


- -- 
Rainer M. Krug, PhD (Conservation Ecology, SUN), MSc (Conservation
Biology, UCT), Dipl. Phys. (Germany)

Centre of Excellence for Invasion Biology
Natural Sciences Building
Office Suite 2039
Stellenbosch University
Main Campus, Merriman Avenue
Stellenbosch
South Africa

Tel:+33 - (0)9 53 10 27 44
Cell:   +27 - (0)8 39 47 90 42
Fax (SA):   +27 - (0)8 65 16 27 82
Fax (D) :   +49 - (0)3 21 21 25 22 44
Fax (FR):   +33 - (0)9 58 10 27 44
email:  rai...@krugs.de

Skype:  RMkrug
-BEGIN PGP SIGNATURE-
Version: GnuPG v1.4.10 (GNU/Linux)
Comment: Using GnuPG with Mozilla - http://enigmail.mozdev.org/

iEUEARECAAYFAk1b4+4ACgkQoYgNqgF2egp5sQCVEey8FukKl5tLxpnNHwelKoWj
YACbBAX9pw9yGT7RRSi9hMU7qQ4Dv2o=
=05Mi
-END PGP SIGNATURE-

__
R-help@r-project.org mailing list
https://stat.ethz.ch/mailman/listinfo/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] boot.ci error with large data sets

2011-02-16 Thread Matthew Dowle

Hello Lars, (cc'd)

Did you ask maintainer("boot") first, as requested by the posting guide?

If you did, but didn't hear back, then please say so, so that we know
you did follow the guide. That maintainer is particularly active, and
particularly efficient though, so I doubt you didn't hear back.

We can tell it's your first post to r-help, and we can tell you have at
least read the posting guide and done very well in following almost all
of it. I can't see anything else wrong with your post (and the subject
line is good) ... other than where you sent it :-)

Matthew


"Lars Dalby"  wrote in message 
news:fef4d63e-90f6-43aa-90a6-872792faa...@s11g2000yqc.googlegroups.com...
> Dear List
>
> I have run into some problems with boot.ci from package boot. When I
> try to obtain a confidence interval of type bca, boot.ci() returns the
> following error when the data set i large:
> Error in bca.ci(boot.out, conf, index[1L], L = L, t = t.o, t0 =
> t0.o,  :
>  estimated adjustment 'a' is NA
>
> Below is an example that produces the above mentioned error on my
> machine.
>
> library(boot)
> #The wrapper function:
> w.mean <- function(x, d) {
> E <- x[d,]
> return(weighted.mean(E$A, E$B))}
> #Some fake data:
> test <- data.frame(rnorm(1000, 5), rnorm(1000, 3))
> test1 <- data.frame(rnorm(1, 5), rnorm(1, 3))
> names(test) <- c("A", "B")
> names(test1) <- c("A", "B")
> # Getting the boot object and the CI, seem to works fine
> bootout <- boot(test, w.mean, R=1000, stype="i")
> (bootci <- boot.ci(bootout, conf = 0.95, type = "bca"))
> # Now with a bigger data set, boot.ci returns an error.
> bootout1 <- boot(test1, w.mean, R=1000, stype="i")
> (bootci1 <- boot.ci(bootout1, conf = 0.95, type = "bca"))
>
> Does anyone have an idea as to why this happens? (Session info below)
>
> Best,
> Lars
>
>> sessionInfo()
> R version 2.12.1 (2010-12-16)
> Platform: x86_64-apple-darwin9.8.0/x86_64 (64-bit)
>
> locale:
> [1] da_DK.UTF-8/da_DK.UTF-8/C/C/da_DK.UTF-8/da_DK.UTF-8
>
> attached base packages:
> [1] stats graphics  grDevices utils datasets  methods
> base
>
> other attached packages:
> [1] boot_1.2-43
>
> loaded via a namespace (and not attached):
> [1] tools_2.12.1
>

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

2011-02-16 Thread Hadley Wickham
One way to implement this functionality is with a task manager callback:

watch <- function(varname) {
  old <- get(varname)

  changed <- function(...) {
new <- get(varname)
if (!identical(old, new)) {
  message(varname, " is now ", new)
  old <<- new
}
TRUE
  }
  invisible(addTaskCallback(changed))
}

a <- 1
watch("a")
a <- 2


Hadley

On Wed, Feb 16, 2011 at 9:38 AM, Alaios  wrote:
> Dear all I would like to ask you if there is a way in R to monitor in R when 
> a value changes.
>
> Right now I use the sprintf('my variables is %d \n, j) to print the value of 
> the variable.
>
> Is it possible when a 'big' for loop executes to open in a new window to 
> dynamically check only the variable I want to.
>
> If I put all the sprintf statements inside my loop then I get flooded with so 
> many messages that makes it useless.
>
> Best 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.
>



-- 
Assistant Professor / Dobelman Family Junior Chair
Department of Statistics / Rice University
http://had.co.nz/

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

2011-02-16 Thread Arnau Mir
Hello.

Somebody knows if there exists some R package that it is capable of doing the 
same of the software ExpertFit (see 
http://www.averill-law.com/ExpertFit-distribution-fitting-software.htm)?

Thanks,

Arnau.

Arnau Mir Torres
Edifici A. Turmeda
Campus UIB
Ctra. Valldemossa, km. 7,5
07122 Palma de Mca.
tel: (+34) 971172987
fax: (+34) 971173003
email: arnau@uib.es
URL: http://dmi.uib.es/~arnau



[[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] monitor variable change

2011-02-16 Thread Rainer M Krug
-BEGIN PGP SIGNED MESSAGE-
Hash: SHA1

On 02/16/2011 03:24 PM, Hadley Wickham wrote:
>> You can replace the previous line by:
>>
>> browser(expr=(a!=old.a)
>>
>> see ?browser for details.
> 
> I don't understand why you'd want to do that - using if is much more
> readable to me (and is much more general!)

True - and I probably would use that one as well - but there is the
syntax which is like a "conditional breakpoint" - so I just pointed it out.

Cheers,

Rainer

> 
> Hadley
> 


- -- 
Rainer M. Krug, PhD (Conservation Ecology, SUN), MSc (Conservation
Biology, UCT), Dipl. Phys. (Germany)

Centre of Excellence for Invasion Biology
Natural Sciences Building
Office Suite 2039
Stellenbosch University
Main Campus, Merriman Avenue
Stellenbosch
South Africa

Tel:+33 - (0)9 53 10 27 44
Cell:   +27 - (0)8 39 47 90 42
Fax (SA):   +27 - (0)8 65 16 27 82
Fax (D) :   +49 - (0)3 21 21 25 22 44
Fax (FR):   +33 - (0)9 58 10 27 44
email:  rai...@krugs.de

Skype:  RMkrug
-BEGIN PGP SIGNATURE-
Version: GnuPG v1.4.10 (GNU/Linux)
Comment: Using GnuPG with Mozilla - http://enigmail.mozdev.org/

iEYEARECAAYFAk1b3o0ACgkQoYgNqgF2egriOQCdHzuptDK+N/OPrzE7wBI9Omjs
fVgAn20cjAGGPZ+qz70cmjoGqhCixUj0
=hU1/
-END PGP SIGNATURE-

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

2011-02-16 Thread Hadley Wickham
> You can replace the previous line by:
>
> browser(expr=(a!=old.a)
>
> see ?browser for details.

I don't understand why you'd want to do that - using if is much more
readable to me (and is much more general!)

Hadley

-- 
Assistant Professor / Dobelman Family Junior Chair
Department of Statistics / Rice University
http://had.co.nz/

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

2011-02-16 Thread Erich Neuwirth
You could use any of the gui toolkits (tcltk, gWidgets ...)
and create a watch window which displays the changing value of your
variable in a popup widged.

On 2/16/2011 10:54 AM, Rainer M Krug wrote:
> On 02/16/2011 10:38 AM, Alaios wrote:
>> Dear all I would like to ask you if there is a way in R to monitor in R when 
>> a value changes. 
> 
>> Right now I use the sprintf('my variables is %d \n, j) to print the value of 
>> the variable. 
> 
>> Is it possible when a 'big' for loop executes to open in a new window to 
>> dynamically check only the variable I want to.
> 
> I don't think that this functionality is implemented.
> 
> But I guess you can implement it - would it be possible to re-define th
> "<-" to check if a certain variable is to be changed, and then print it?
> 
> Might be tricky and would slow everything considerably down.
> 
> Just a thought,
> 
> Rainer
> 
> 
>> If I put all the sprintf statements inside my loop then I get flooded with 
>> so many messages that makes it useless.  
> 
>> Best 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.
> 
> 

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

2011-02-16 Thread Rainer M Krug
-BEGIN PGP SIGNED MESSAGE-
Hash: SHA1

On 02/16/2011 03:04 PM, Jan van der Laan wrote:
> 
> One possible solution is to use something like:
> 
> a <- 0
> for (i in 1:1E6) {
> old.a <- a
> 
> # do something e.g.
> a <- runif(1) < 1E-6
> 
> if (a != old.a) browser()
You can replace the previous line by:

browser(expr=(a!=old.a)

see ?browser for details.

> }
> 
> 
> Another solution is to write your output to file (using sink for
> example) and to watch this file using a tool like tail.
> 
> Jan
> 
> 
> 
> 
> 
> 
> Quoting Alaios :
> 
>> I think we are both talking for watchpoints-breakpoints
>>
>> --- On Wed, 2/16/11, Rainer M Krug  wrote:
>>
>>> From: Rainer M Krug 
>>> Subject: Re: [R] monitor variable change
>>> To: "Alaios" 
>>> Cc: R-help@r-project.org
>>> Date: Wednesday, February 16, 2011, 9:54 AM
> On 02/16/2011 10:38 AM, Alaios wrote:
>> Dear all I would like to ask you if there is a way in
> R to monitor in R when a value changes.
> 
>> Right now I use the sprintf('my variables is %d \n, j)
> to print the value of the variable.
> 
>> Is it possible when a 'big' for loop executes to open
> in a new window to dynamically check only the variable I
> want to.
> 
> I don't think that this functionality is implemented.
> 
> But I guess you can implement it - would it be possible to
> re-define th
> "<-" to check if a certain variable is to be changed,
> and then print it?
> 
> Might be tricky and would slow everything considerably
> down.
> 
> Just a thought,
> 
> Rainer
> 
> 
>> If I put all the sprintf statements inside my loop
> then I get flooded with so many messages that makes it
> useless. 
> 
>> Best 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.
> 
> 
>>>
>>
>>
>>
>>
>> __
>> R-help@r-project.org mailing list
>> https://stat.ethz.ch/mailman/listinfo/r-help
>> PLEASE do read the posting guide
>> http://www.R-project.org/posting-guide.html
>> and provide commented, minimal, self-contained, reproducible code.
>>

- -- 
Rainer M. Krug, PhD (Conservation Ecology, SUN), MSc (Conservation
Biology, UCT), Dipl. Phys. (Germany)

Centre of Excellence for Invasion Biology
Natural Sciences Building
Office Suite 2039
Stellenbosch University
Main Campus, Merriman Avenue
Stellenbosch
South Africa

Tel:+33 - (0)9 53 10 27 44
Cell:   +27 - (0)8 39 47 90 42
Fax (SA):   +27 - (0)8 65 16 27 82
Fax (D) :   +49 - (0)3 21 21 25 22 44
Fax (FR):   +33 - (0)9 58 10 27 44
email:  rai...@krugs.de

Skype:  RMkrug
-BEGIN PGP SIGNATURE-
Version: GnuPG v1.4.10 (GNU/Linux)
Comment: Using GnuPG with Mozilla - http://enigmail.mozdev.org/

iEYEARECAAYFAk1b2wQACgkQoYgNqgF2ego2XwCfbGgvNHskD1GI+fIO+wB0vvw0
aDAAnigi9/D1abrquA0sIOWdPHS9rEAl
=F71G
-END PGP SIGNATURE-

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

2011-02-16 Thread Jan van der Laan


One possible solution is to use something like:

a <- 0
for (i in 1:1E6) {
old.a <- a

# do something e.g.
a <- runif(1) < 1E-6

if (a != old.a) browser()
}


Another solution is to write your output to file (using sink for  
example) and to watch this file using a tool like tail.


Jan






Quoting Alaios :


I think we are both talking for watchpoints-breakpoints

--- On Wed, 2/16/11, Rainer M Krug  wrote:


From: Rainer M Krug 
Subject: Re: [R] monitor variable change
To: "Alaios" 
Cc: R-help@r-project.org
Date: Wednesday, February 16, 2011, 9:54 AM
-BEGIN PGP SIGNED MESSAGE-
Hash: SHA1

On 02/16/2011 10:38 AM, Alaios wrote:
> Dear all I would like to ask you if there is a way in
R to monitor in R when a value changes.
>
> Right now I use the sprintf('my variables is %d \n, j)
to print the value of the variable.
>
> Is it possible when a 'big' for loop executes to open
in a new window to dynamically check only the variable I
want to.

I don't think that this functionality is implemented.

But I guess you can implement it - would it be possible to
re-define th
"<-" to check if a certain variable is to be changed,
and then print it?

Might be tricky and would slow everything considerably
down.

Just a thought,

Rainer

>
> If I put all the sprintf statements inside my loop
then I get flooded with so many messages that makes it
useless. 
>
> Best 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.


- --
Rainer M. Krug, PhD (Conservation Ecology, SUN), MSc
(Conservation
Biology, UCT), Dipl. Phys. (Germany)

Centre of Excellence for Invasion Biology
Natural Sciences Building
Office Suite 2039
Stellenbosch University
Main Campus, Merriman Avenue
Stellenbosch
South Africa

Tel:        +33 - (0)9 53 10 27 44
Cell:       +27 - (0)8 39 47 90
42
Fax (SA):   +27 - (0)8 65 16 27 82
Fax (D) :   +49 - (0)3 21 21 25 22 44
Fax (FR):   +33 - (0)9 58 10 27 44
email:      rai...@krugs.de

Skype:      RMkrug
-BEGIN PGP SIGNATURE-
Version: GnuPG v1.4.10 (GNU/Linux)
Comment: Using GnuPG with Mozilla - http://enigmail.mozdev.org/

iEYEARECAAYFAk1bnsoACgkQoYgNqgF2egr53gCffKAK4FnRxm/H371ANg8ONs6E
NF8AoIyIGoAsdWu6a0HpE0BPqVD0fV+n
=1MOY
-END PGP SIGNATURE-






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


  1   2   >