Re: [R] aggregate factor

2007-09-07 Thread ONKELINX, Thierry
Try this. as.numeric(levels(fishdata$Age))[fishdata$Age] HTH, Thierry ir. Thierry Onkelinx Instituut voor natuur- en bosonderzoek / Research Institute for Nature and Forest Cel biometrie, methodologie en

[R] Legend issue with ggplot2

2007-09-03 Thread ONKELINX, Thierry
Dear useRs, I'm struggling with the new version of ggplot2. In the previous version I did something like this. But now this yield an error (object fill not found). library(ggplot2) dummy - data.frame(x = rep(1:10, 4), group = gl(4, 10)) dummy$y - dummy$x * rnorm(4)[dummy$group] + 5 *

Re: [R] Legend issue with ggplot2

2007-09-03 Thread ONKELINX, Thierry
] Verzonden: maandag 3 september 2007 15:15 Aan: ONKELINX, Thierry CC: r-help@stat.math.ethz.ch Onderwerp: Re: [R] Legend issue with ggplot2 On 9/3/07, ONKELINX, Thierry [EMAIL PROTECTED] wrote: Dear useRs, I'm struggling with the new version of ggplot2. In the previous version I did

Re: [R] How to signal the end of the table?

2007-08-30 Thread ONKELINX, Thierry
Have you tried read.table() and the similar functions? I think they would provide a much more simple solution for your problem. HTH, Thierry ir. Thierry Onkelinx Instituut voor natuur- en bosonderzoek / Research

Re: [R] sql query over local tables

2007-08-29 Thread ONKELINX, Thierry
Jorge, I'm assuming that you mean dataframes of matrices. Then you could use merge to join both dataframes into a new one. See ?merge for more detail. HTH, Thierry ir. Thierry Onkelinx Instituut voor natuur- en

Re: [R] several plots on several pages - bug in par(mfg())?

2007-08-18 Thread ONKELINX, Thierry
Dear Rainer, Your could try something like this. test - try( plot(runif(ff)) ) if(class(test) == try-error){ #put here code for an empty plot } Cheers, Thierry ir. Thierry Onkelinx Instituut voor natuur- en

Re: [R] several plots on several pages

2007-08-16 Thread ONKELINX, Thierry
Dear Rainer, Have you considered using Sweave? HTH, Thierry ir. Thierry Onkelinx Instituut voor natuur- en bosonderzoek / Research Institute for Nature and Forest Cel biometrie, methodologie en kwaliteitszorg /

Re: [R] Linear Regression with slope equals 0

2007-08-14 Thread ONKELINX, Thierry
Dear Ed, In my opinion you don't need to set the slope to zero. Just test if the slope in lm(d ~ t) is significant. If it is significant then you have evidence that the slope is NOT zero. But when it is not significant (and in your example it is), you can't say that it is zero. But doing some

Re: [R] Find out the workspace name

2007-08-08 Thread ONKELINX, Thierry
?getwd() ir. Thierry Onkelinx Instituut voor natuur- en bosonderzoek / Research Institute for Nature and Forest Cel biometrie, methodologie en kwaliteitszorg / Section biometrics, methodology and quality assurance

Re: [R] ggplot2 qplot and add

2007-08-02 Thread ONKELINX, Thierry
I think you need something like. qplot(appetitive.stimulus, graphLabels, data=related.differences, size=variance, colour=Appetitive Stimulus, xlim=c(-20,20), main=Title here, xlab=Differences, ylab=Header Concepts) + geom_point(aes(colour = Aversive Stimulus)) HTH, Thierry

Re: [R] Plotting a smooth curve from predict

2007-07-31 Thread ONKELINX, Thierry
What you need is b - data.frame(x = 1:10, y = c(10,9,8,7,6,6.5,7,8,9,10)) w - gls(y ~ I(x)+I(x^2),correlation=corARMA(p=1),method=ML,data=b) Newdata - data.frame(x = seq(1, 10, length = 41)) plot(predict(w, newdata = Newdata), type=l)

Re: [R] Tabs in PDF documents

2007-07-30 Thread ONKELINX, Thierry
I think you need to escape the '\' character in your string by adding an extra '\' in front of it. So try pdf(junk.pdf) par(family=mono) plot(1,1) text(1,1, \\txx) mtext(\\txx) dev.off() HTH, Thierry -Oorspronkelijk bericht- Van: [EMAIL

Re: [R] Strange warning in summary.lm

2007-07-25 Thread ONKELINX, Thierry
:[EMAIL PROTECTED] Namens ONKELINX, Thierry Verzonden: donderdag 19 juli 2007 13:56 Aan: Peter Dalgaard CC: r-help@stat.math.ethz.ch; Uwe Ligges Onderwerp: Re: [R] Strange warning in summary.lm Dear Peter, Here's an example. Notice the warning in the last two lines of the summary

[R] Ggplot2 equivalent of axis and problem with log scale

2007-07-25 Thread ONKELINX, Thierry
Dear useRs, Recently I've discorved ggplot2 and I must say that I really like it, although the documentation still is a working in progress. My first question: How can I change the position of the labels and the text of the labels? With a basic plot I would use axis(2, at =

Re: [R] Strange warning in summary.lm

2007-07-25 Thread ONKELINX, Thierry
-Oorspronkelijk bericht- Van: Prof Brian Ripley [mailto:[EMAIL PROTECTED] Verzonden: woensdag 25 juli 2007 12:20 Aan: ONKELINX, Thierry CC: r-help@stat.math.ethz.ch Onderwerp: Re: [R] Strange warning in summary.lm On Wed, 25 Jul 2007, ONKELINX, Thierry wrote: Dear Peter, Uwe

Re: [R] values from a linear model

2007-07-24 Thread ONKELINX, Thierry
It's not very clear to me but I think summary(mod)$coef[, Std. Error] is wat you need? Cheers, Thierry ir. Thierry Onkelinx Instituut voor natuur- en bosonderzoek / Research Institute for Nature and Forest Cel

Re: [R] Strange warning in summary.lm

2007-07-19 Thread ONKELINX, Thierry
] Verzonden: donderdag 19 juli 2007 10:39 Aan: ONKELINX, Thierry CC: r-help@stat.math.ethz.ch Onderwerp: Re: [R] Strange warning in summary.lm ONKELINX, Thierry wrote: Dear useRs, Lately I noticed a strange warning in the summary of a lm-object. Any idea what this warning is about

Re: [R] Strange warning in summary.lm

2007-07-19 Thread ONKELINX, Thierry
. ~William W. Watt A statistical analysis, properly conducted, is a delicate dissection of uncertainties, a surgery of suppositions. ~M.J.Moroney -Oorspronkelijk bericht- Van: Peter Dalgaard [mailto:[EMAIL PROTECTED] Verzonden: donderdag 19 juli 2007 13:37 Aan: ONKELINX, Thierry

[R] Strange warning in summary.lm

2007-07-18 Thread ONKELINX, Thierry
Dear useRs, Lately I noticed a strange warning in the summary of a lm-object. Any idea what this warning is about? I'm using R 2.5.1 on Win XP pro. x - rnorm(100) y - rnorm(100) summary(lm(y~x)) Call: lm(formula = y ~ x) Residuals: Min 1Q Median 3Q Max -1,77809

[R] Problem with Sweave and pdf version 1.4

2007-07-09 Thread ONKELINX, Thierry
Dear useRs, I'm trying to use ggplot2 in Sweave (R 2.5.1). The plots use the alpha channel, so I need to use pdf version 1.4. Search the mailinglist archive I found two solutions: \SweaveOpts{echo = FALSE, pdf.version=1.4} and explicit writing to a pdf 1.4 file. The latter works but the first

Re: [R] Speeding up

2007-07-09 Thread ONKELINX, Thierry
Dear Bjorn, Do you know that mean(xy*ind)+mean(xy*!ind) yields the same value for all i? Maybe you meant mean(xy[ind]) + mean(xy[!ind]) sapply(xord, function(xordi, xy = x){ ind - xy xordi mean(xy*ind)+mean(xy*!ind) }) Cheers, Thierry

Re: [R] Loop and cbind

2007-07-04 Thread ONKELINX, Thierry
A more elegant way to do this is standard - sapply(calm, function(calmi){calmi / sqrt(emaTA(calmi ^ 2, 0.03))}) Cheers, Thierry ir. Thierry Onkelinx Instituut voor natuur- en bosonderzoek / Research Institute for

Re: [R] A More efficient method?

2007-07-04 Thread ONKELINX, Thierry
Cat - c('a','a','a','b','b','b','a','a','b') C1 - ifelse(Cat == 'a', -1, 1) ir. Thierry Onkelinx Instituut voor natuur- en bosonderzoek / Research Institute for Nature and Forest Cel biometrie, methodologie en

Re: [R] select row

2007-07-03 Thread ONKELINX, Thierry
Assuming that id is a character. tab[tab$id == 25-2006, ] Cheers, Thierry ir. Thierry Onkelinx Instituut voor natuur- en bosonderzoek / Research Institute for Nature and Forest Cel biometrie, methodologie en

Re: [R] how to get the position of an element in a vector ?

2007-07-03 Thread ONKELINX, Thierry
?which.max ir. Thierry Onkelinx Instituut voor natuur- en bosonderzoek / Research Institute for Nature and Forest Cel biometrie, methodologie en kwaliteitszorg / Section biometrics, methodology and quality assurance

Re: [R] multiple return

2007-06-22 Thread ONKELINX, Thierry
Put the return values in a vector or list somma - function (a, b) { c - a+b return (c(a = a, b = b, c = c)) } somma(5,7) a b c 5 7 12 somma - function (a, b) { c - a+b return (list(a = a, b = b, c = c)) } somma(5,7) $a [1] 5 $b [1] 7 $c [1] 12 Cheers, Thierry

Re: [R] sorting data

2007-06-21 Thread ONKELINX, Thierry
Why don't you use a package like RODBC and read the data directly from the Excel file? Then you probably won't have to worry on how to get the dates in the right format. Another, maybe easier, solution is to export the Excel to CSV and then use read.csv(). Cheers, Thierry

Re: [R] Got Unexpected ELSE error

2007-06-20 Thread ONKELINX, Thierry
You need to put the else statement on the same line as the closing curly bracket. a - TRUE if ( a ){ cat(TRUE,\n) } else { cat(FALSE,\n) } Cheers, Thierry ir. Thierry Onkelinx Instituut voor natuur-

Re: [R] Conditional Sequential Gaussian Simulation

2007-06-08 Thread ONKELINX, Thierry
Steve, You can do this with the package gstat. Look for ?krige of ?predict.gstat Post further question on this topic on the R-sig-geo list. You'll get more response. Cheers, Thierry ir. Thierry Onkelinx Instituut

Re: [R] list

2007-06-06 Thread ONKELINX, Thierry
Sure you can. list(list(), list(), list()) library(fortunes) fortune(Yoda) Evelyn Hall: I would like to know how (if) I can extract some of the information from the summary of my nlme. Simon Blomberg: This is R. There is no if. Only how. -- Evelyn Hall and Simon 'Yoda' Blomberg

Re: [R] Lines to plots with a for-loop

2007-06-05 Thread ONKELINX, Thierry
Dear Taija, You want lines but use points? Try for(i in levels(fHCGB$code)){ with(subset(fHCGB,code==i), plot(pooledPlateIntra, type=b, ylim=ylim, xlab=code, ylab=CV%) lines(fHCGB$limitVarC, col=green)) } Cheers, Thierry

Re: [R] getting t.test to work with apply()

2007-06-04 Thread ONKELINX, Thierry
Since you are using function(x) the apply function is passing values to x. So you need to use x inside the function. Try something like this: apply(raw.sample,1,function(x){t.test(x[alive],x[dead])}) Cheers, Thierry

Re: [R] Abstract plot

2007-06-04 Thread ONKELINX, Thierry
You can do than. You just need to specify the strings in the axis-labels. plot(y~x, axes = F) axis(1, at = range(x), labels = c(Xmin, Xmax)) axis(2) Cheers, Thierry ir. Thierry Onkelinx Instituut voor natuur- en

Re: [R] getting t.test to work with apply()

2007-06-04 Thread ONKELINX, Thierry
Apply passes the row as a vector, not as a dataframe. So you need to remove the colons in x[, alive] and x[, dead] results -apply(raw.sample,1,function(x) t.test(x[alive],x[dead])) Cheers, Thierry ir. Thierry Onkelinx

Re: [R] R-help with apply and ccf

2007-05-22 Thread ONKELINX, Thierry
You could combine them with cbind, and then split the rows again inside the function you're calling with apply. Mat - cbind(mat1, mat2) apply(Mat, 1, function(x){ row.mat1 - x[seq_len(length(x)/2)] row.mat2 - x[length(x)/2 + seq_len(length(x)/2)] cor(row.mat1, row.mat2) })

Re: [R] more woes trying to convert a data.frame to a numerical matrix

2007-05-16 Thread ONKELINX, Thierry
?as.numeric ir. Thierry Onkelinx Instituut voor natuur- en bosonderzoek / Reseach Institute for Nature and Forest Cel biometrie, methodologie en kwaliteitszorg / Section biometrics, methodology and quality assurance

Re: [R] Help with saptial analysis (cluster)

2007-04-25 Thread ONKELINX, Thierry
Dear Fransico, The distance matrix would be 102000 x 102000. So it would contain 1040400 values. If you need one bit for each value, this would requier 9,7 GB. So the distance matrix won't fit in the RAM of your computer. Cheers, Thierry

Re: [R] program avail. for simulating spatial patterns?

2007-04-25 Thread ONKELINX, Thierry
Have a look at packages in the spatial taskview (spatstat, splancs). Cheers, Thierry ir. Thierry Onkelinx Instituut voor natuur- en bosonderzoek / Reseach Institute for Nature and Forest Cel biometrie, methodologie en

Re: [R] Matrix or grid conversion of spatial data

2007-04-20 Thread ONKELINX, Thierry
Marco, I've done something similar with spatial data. I defined the points as SpatialPoints, the grid as SpatialGrid (using the sp package). Then table(overlay(grid, points)) will give you the number of points inside each gridcell. library(sp) points - SpatialPoints(your.data.frame) cellsize - 1

Re: [R] Help on averaging sets of rows defined by row name

2007-04-20 Thread ONKELINX, Thierry
Dear Marije, I think that aggregate() would make your life a lot easier. aggregate(table.imputed, by = table.imputed[, 1], FUN = mean) Cheers, Thierry ir. Thierry Onkelinx Instituut voor natuur- en bosonderzoek /

Re: [R] Suggestions for statistical computing course

2007-04-20 Thread ONKELINX, Thierry
2. I do most of my work in R using Emacs and ESS. That means that I keep a file in an emacs window and I submit it to R one line at a time or one region at a time, making corrections and iterating as needed. When I am done, I just save the file with the last, working, correct

Re: [R] matrix construction

2007-03-26 Thread ONKELINX, Thierry
Have a look at ?cbind, ?rbind and ?matrix C - cbind(A, B) C - rbind(A, B) C - matrix(c(0:3, 0:3), ncol = 2) Cheers, Thierry ir. Thierry Onkelinx Instituut voor natuur- en bosonderzoek / Reseach Institute for Nature

Re: [R] Change Axis Size

2007-03-23 Thread ONKELINX, Thierry
You need to sed the ylim parameter in the plot function to the range that you need. Cheers, Thierry ir. Thierry Onkelinx Instituut voor natuur- en bosonderzoek / Reseach Institute for Nature and Forest Cel biometrie,

Re: [R] for loop in assigning column names

2007-03-21 Thread ONKELINX, Thierry
Have you tried something like df - cbind(df, ObJeCT[, 1:10]) Cheers, Thierry ir. Thierry Onkelinx Instituut voor natuur- en bosonderzoek / Reseach Institute for Nature and Forest Cel biometrie, methodologie en

Re: [R] Row wise solving an equation

2007-03-20 Thread ONKELINX, Thierry
Dear Gunter, I've rewritten your functions. But allow me to give you a few tips: - don't be affraid to use some spacing and indentation. It makes code a lot more readable - I prefer to define all variables in a function or I pass them to the function. In your case would recommend to define the

Re: [R] Power calculation for detecting linear trend

2007-03-14 Thread ONKELINX, Thierry
Erik, I haven't seen an answer to your question, so I'll try to answer it. The problem is that you switched the degrees of freedom. You had: 1 - pf(qf(.95, Vl, 1, ncp = 0), Vl, 1, ncp = Dl) [1] 0.05472242 But it should be: 1 - pf(qf(.95, 1, Vl, ncp = 0), 1, Vl, ncp = Dl) [1] 0.532651 Cheers,

Re: [R] How to open more windows to make more graphs at once!

2007-03-07 Thread ONKELINX, Thierry
Creating more than one graphic windows is, as far as I know, not possible in R. But it's no problem to run a script which create multiply jpeg's. See ?jpeg on how to create jpeg's. Cheers, Thierry ir. Thierry

Re: [R] Test of Presence Matrix HOWTO?

2007-02-26 Thread ONKELINX, Thierry
a - c(A,B,C,D) b - c(A,B,E,F) c - c(A,C,E,G) Df - cbind(a, b, c) apply(Df, 2, function(x)(LETTERS[1:7] %in% x)) a b c [1,] TRUE TRUE TRUE [2,] TRUE TRUE FALSE [3,] TRUE FALSE TRUE [4,] TRUE FALSE FALSE [5,] FALSE TRUE TRUE [6,] FALSE TRUE FALSE [7,] FALSE FALSE

Re: [R] TRUE/FALSE as numeric values

2007-02-23 Thread ONKELINX, Thierry
RSF_EU$AREA[RSF_EU$AREA=x] ir. Thierry Onkelinx Instituut voor natuur- en bosonderzoek / Reseach Institute for Nature and Forest Cel biometrie, methodologie en kwaliteitszorg / Section biometrics, methodology and

Re: [R] Trying to get an apply to work with a list in applying names totables

2007-02-21 Thread ONKELINX, Thierry
John, Two things. You don't need to pout the cc variable in the apply. Use instead something like this. apply(cc, 2, fn1, y = mylist) But this still doesn't solve your problem. You'll need to rewrite your function like this. fn2 - function(x, y, i){ + tt - table(x[, i]) + names(tt) -

Re: [R] categorical column to numeric column

2007-02-19 Thread ONKELINX, Thierry
Maybe this isn't the most elegant way, but it should work. dd$g - -1 dd$g[dd$aa == a] - 1 Cheers, Thierry ir. Thierry Onkelinx Instituut voor natuur- en bosonderzoek / Reseach Institute for Nature and Forest Cel

Re: [R] plotting

2007-02-16 Thread ONKELINX, Thierry
See ?points, ?lines and ?par (especially par(new = T)). Reading an introduction book about R might be a good idea if you're new. Dalgaard (Introductory Statistics with R) Everitt Hothorn (A Handbook of Statistical Analyses Using R) Cheers, Thierry

Re: [R] Is this a correct forum to discuss basic R problem?

2007-02-14 Thread ONKELINX, Thierry
?aggregate ?by ir. Thierry Onkelinx Instituut voor natuur- en bosonderzoek / Reseach Institute for Nature and Forest Cel biometrie, methodologie en kwaliteitszorg / Section biometrics, methodology and quality

Re: [R] Fatigued R

2007-02-13 Thread ONKELINX, Thierry
Dear Shubha, The error message tells you that the error occurs in the line: merge(d_mer,cdaily) And the problem is that d_mer and cdaily have a different class. It looks as you need to convert cdaily to the correct class (same class as d_mer). Don't forget to use traceback() when

Re: [R] Polygon triangulation?

2007-02-13 Thread ONKELINX, Thierry
Have you tried the tri-package? Cheers, Thierry ir. Thierry Onkelinx Instituut voor natuur- en bosonderzoek / Reseach Institute for Nature and Forest Cel biometrie, methodologie en kwaliteitszorg / Section

Re: [R] Fatigued R

2007-02-13 Thread ONKELINX, Thierry
A statistical analysis, properly conducted, is a delicate dissection of uncertainties, a surgery of suppositions. ~M.J.Moroney -Oorspronkelijk bericht- Van: Shubha Vishwanath Karanth [mailto:[EMAIL PROTECTED] Verzonden: dinsdag 13 februari 2007 16:06 Aan: ONKELINX, Thierry; r-help

Re: [R] RE2: Suddenly Subscript out of bounds

2007-02-13 Thread ONKELINX, Thierry
, is a delicate dissection of uncertainties, a surgery of suppositions. ~M.J.Moroney -Oorspronkelijk bericht- Van: [EMAIL PROTECTED] [mailto:[EMAIL PROTECTED] Verzonden: dinsdag 13 februari 2007 18:04 Aan: ONKELINX, Thierry CC: r-help@stat.math.ethz.ch Onderwerp: RE2: [R] Suddenly Subscript out

Re: [R] Linking R with Microsoft SQL Server / Client

2007-02-12 Thread ONKELINX, Thierry
Dear Steve, Reading the data shouldn't be a problem with RODBC. I've been doing that plenty of times. I'm not sure about writing, but I suppose you probably will. Cheers, Thierry ir. Thierry Onkelinx Instituut voor

Re: [R] Finding not-matching rows in tables

2007-02-07 Thread ONKELINX, Thierry
That's something for the %in% command. Try this (untested!) tab[(tab$id %in% tabella$id) == FALSE, ] Cheers, Thierry ir. Thierry Onkelinx Instituut voor natuur- en bosonderzoek / Reseach Institute for Nature and

Re: [R] Check for presence of object in group of objects

2007-01-31 Thread ONKELINX, Thierry
You need %in% a %in% x d %in% x ir. Thierry Onkelinx Instituut voor natuur- en bosonderzoek / Reseach Institute for Nature and Forest Cel biometrie, methodologie en kwaliteitszorg / Section biometrics, methodology

Re: [R] Conversion of column matrix into a vector without duplicates

2007-01-24 Thread ONKELINX, Thierry
?unique unique(A[, 2]) ir. Thierry Onkelinx Instituut voor natuur- en bosonderzoek / Reseach Institute for Nature and Forest Cel biometrie, methodologie en kwaliteitszorg / Section biometrics, methodology and

Re: [R] graph results of logistic regression

2007-01-15 Thread ONKELINX, Thierry
The code of the function plot.logi.hist is defined in appendix A of the article you referred to. Cheers, Thierry ir. Thierry Onkelinx Instituut voor natuur- en bosonderzoek / Reseach Institute for Nature and Forest

Re: [R] R editor vs. Tinn-R

2007-01-12 Thread ONKELINX, Thierry
Instead of discussing this odd behaviour of TINN-R, I would prefer a discussion on importing data through the clipboard. In my opinion it isn't a good a idea to import data with the clipboard. I know that it's a quick and dirty way to get your data fast into R. But I see two major drawbacks.

Re: [R] dimensions of a all objects

2007-01-09 Thread ONKELINX, Thierry
You need something like this: sapply(objects() , function(x)(dim(eval(parse(text = x) a - rnorm(1) b - matrix(rnorm(4), ncol = 2, nrow = 2) sapply(objects() , function(x)(dim(eval(parse(text = x) $a NULL $b [1] 2 2 Cheers, Thierry

Re: [R] setting new working directories

2007-01-04 Thread ONKELINX, Thierry
See ?getwd and ?setwd to set the working directory See ?load and ?save to read the workspace. Cheers, Thierry ir. Thierry Onkelinx Instituut voor natuur- en bosonderzoek / Reseach Institute for Nature and Forest

Re: [R] export many plots to one file

2007-01-04 Thread ONKELINX, Thierry
I can think of two options: 1. Use R2HTML and save the html output as PDF 2. Use Sweave and compile the LaTeX file to PDF. Search the mailing list archive on how to save the graphs as png or jpeg (as Sweave will standard generate eps or pdf graphs). Cheers, Thierry

Re: [R] understanding integer divide (%/%)

2007-01-03 Thread ONKELINX, Thierry
This is due to the internal representation of 0.1, which is not exactly 0.1 but very close to it. If you want to do an integer divide, you should only use integers to divide with. Cheers, Thierry ir. Thierry Onkelinx

Re: [R] error: too many open devices

2006-12-05 Thread ONKELINX, Thierry
dev.list() will give a list with all open devices. dev.off() will close the current device. Cheers, Thierry ir. Thierry Onkelinx Instituut voor natuur- en bosonderzoek / Reseach Institute for Nature and Forest Cel

Re: [R] barplot help needed

2006-11-24 Thread ONKELINX, Thierry
Is the length of all your datasets equal? If not try etype - rep(c(sd1, sd2, sd3, sd4), c(length(data1), length(data2), length(data3), length(data4)) Cheers, Thierry ir. Thierry Onkelinx Instituut voor natuur- en

Re: [R] Fwd: Dates Conversion/write.foreign

2006-11-24 Thread ONKELINX, Thierry
Correct me if I'm wrong, but a few weeks ago my professor from the statistical computing class told us that SAS sometimes stores dates including the time but only displays the date. So it looks like the time isn't stored. This was the case with data imported from Excel. In our exercise we had to

Re: [R] barplot help needed

2006-11-24 Thread ONKELINX, Thierry
The arrows are messed up because they are partially outside the borders of the barplot. Try adding a good ylim to the barplot. Something like: b - barplot(tab, beside=T, ylim = c(0, 8)) Cheers, Thierry ir. Thierry

Re: [R] t.test()

2006-11-23 Thread ONKELINX, Thierry
There is no such thing as an unpaired t-test. A t-test can be a paired, one sample or two sample t-test. Since you want to compare the sample against a given mean, you need a one sample t-test. You tried to do a two sample test. That didn't work because you need at least two observations in each

Re: [R] dividing vectors into bins with equal widths

2006-11-14 Thread ONKELINX, Thierry
Hi Daniel, Make sure to include working code and list all needed packages. I couldn't run your code on my machine. If you want equal data points in each class, then you could take every n point from the sorted vector. This example generates the breakpoints to divide a vector in 10 parts. x

[R] Simplifying Sweave graphics

2006-11-10 Thread ONKELINX, Thierry
Dear all, I was wondering if it's possible to simplify graphs created with Sweave. I'm using in a document several plots with each about 4000 points (qqnorm(rnorm(4000))). It looks likes the information of each points is maintained in the graph. As a result of that the pdf filesize get's quite

Re: [R] Power of test

2006-10-27 Thread ONKELINX, Thierry
A quick answer to your questions: 1. Since nobody knows the true delta. I prefer to calculate the power for a range of deltas. Most of the time for a range spanning - 2 * expected delta up to 2 * expected delta. This gives an idea on how the power changes if delta changes. 2. ?power.t.test

Re: [R] simplification of code using stamp?

2006-10-25 Thread ONKELINX, Thierry
I think your script is slow because it has to recalculate the same model five times. I've tried to avoid this by rewriting your function(df). function(df){ fit - summary(lm(distance ~ generation, data=df)) result - c(fit$$r.squared, $coefficients[2], $coefficients[4],

Re: [R] simplification of code using stamp?

2006-10-25 Thread ONKELINX, Thierry
, is a delicate dissection of uncertainties, a surgery of suppositions. ~M.J.Moroney -Oorspronkelijk bericht- Van: [EMAIL PROTECTED] [mailto:[EMAIL PROTECTED] Namens ONKELINX, Thierry Verzonden: woensdag 25 oktober 2006 11:36 Aan: [EMAIL PROTECTED]; r-help@stat.math.ethz.ch Onderwerp: Re

Re: [R] RODBC sqlQuery insert slow

2006-10-13 Thread ONKELINX, Thierry
Large for loops are slow. Try to avoid them using apply, sapply, etc. I've made the paste statements a lot shorter by using collapse. See ?paste for more info. Append.SQL - function(x, channel){ sql=INSERT INTO logger (time, v1, v2, v3, v4, v5, v6, v7, v8, v9, v10)

Re: [R] Beginner question: select cases

2006-09-25 Thread ONKELINX, Thierry
Your problem would be a lot easier if you coded the location in one variable instead of three variables. Then you could calculate the means with one line of code: by(results$q1, results$location, mean) With your dataset you could use by(results$London, results$location, mean) by(results$Rome,

Re: [R] RODBC Connections closed automatically in background

2006-09-20 Thread ONKELINX, Thierry
Usually I try to do all data import before I do long calculations. A simple workaround for your problem would be: foo - function(dsn) { db - odbcConnect(dsn) odbcSetAutoCommit(db, FALSE) data - someDatabaseOperation(db) odbcClose(db) data2 - someLongCalculation(data) db -

Re: [R] Simulation help

2006-09-20 Thread ONKELINX, Thierry
This should work. I try to avoid for loops because large (or nested) for loops tend to consume a lot of memory. one.dataset - function(dummy = 0, slope = 0.01){ return(c(yr1= mean(rbinom(50,1,.5)), yr2 =mean(rbinom(50,1,.5 + slope)), yr3 =mean(rbinom(50,1,.5 + 2 * slope)), yr4

Re: [R] Using XY location data to calculate ecological parameters

2006-09-12 Thread ONKELINX, Thierry
Assuming you only use the X direction to split the data into 10 m cells. table(list(Species, round(X, digits = -1))) This will generate a table with the number of seedlings per species in each 10 m cell. Divide this by the area of each cell and you get the densities. Cheers, Thierry

Re: [R] levels of factor when subsetting the factor

2006-09-12 Thread ONKELINX, Thierry
factor(new.fact) will do the trick. But that will recode the levels and that might be something you don't want. fact = as.factor(c(rep(A, 3),rep(B, 3), rep(C, 3))) new.fact = fact[1:6] new.fact [1] A A A B B B Levels: A B C factor(new.fact) [1] A A A B B B Levels: A B Cheers, Thierry