[R] Links to vignettes in the base packages

2015-01-14 Thread Richard Cotton
Contributed packages have copies of their vignettes on CRAN (in their package page at cranmirror/web/packages/packagename). Since base packages no longer have a page here, I can't find a web link to them. I'm aware that I can find the vignette via browseVignettes() or vignette(vignettename,

Re: [R] R Style Guide -- Was Post-hoc tests in MASS using glm.nb

2011-05-23 Thread Richard . Cotton
LIST OF CONVENTIONS/STYLES FOR R: [1] R coding standards in the R Internals manual http://www.cran.r-project.org/doc/manuals/R-ints.html#R-coding-standards [2] Bioconductor coding standards http://wiki.fhcrc.org/bioc/Coding_Standards [3] Google R style

Re: [R] How is the relation between Frequency and Counts in hist/density defined?

2011-05-23 Thread Richard . Cotton
In order to do this I can use the relation between count and density, but I would like to know if there is a way for me to predict it upfront. In the code for hist.default, you'll see the line dens - counts/(n * diff(breaks)) Here is an example: set.seed(242) z =

Re: [R] qbeta

2011-02-22 Thread Richard . Cotton
Does any body know how I can see the code behind qbeta function? As the code seems to be internal, you'll need to download the r-source code and find it in there. In my copy of R it is here: R-2.11.1/src/nmath/qbeta.c An alternative is to view the source code online. The code for qbeta is

Re: [R] Implementing R's recycling rule

2010-10-19 Thread Richard . Cotton
x - c(1, 2, 3) n - 10 ## so using the recycling rules, I would like to get from FUN(x, n)==1 ## I am doing: xRecycled - rep(x, length.out=n)[n] This works, but it seems to me that I am missing something really basic here - is there more straightforward way of doing this? x[n %%

Re: [R] table, sum, cat function

2009-08-25 Thread Richard . Cotton
the second step in my exercice is to calculate the sum of the amout for each class et not the frequency i have this vector x y 1 100 2 1500 3 3250 4 6250 5 2000 6 450 i want to use the function table

Re: [R] mixed normal distriburtion

2009-08-25 Thread Richard . Cotton
I'm trying to draw the density function of a mixed normal distribution in the form of: .6*N(.4,.1)+ .4*N(.8,.1) At first I generate a random sample with size 200 by the below code: means = c(.4,.8) sds = sqrt(c(.1,.1)) ind = sample(1:2, n, replace=TRUE, prob=c(.6,.4))

Re: [R] formats

2009-08-25 Thread Richard . Cotton
what do you mean by %d-%b-%y. is it reading format or writing format. %d-%b-%y is a date format - see the help page for strptime. Example usage: strptime(01-Jan-84, %d-%b-%y) strftime(Sys.time(), %d-%b-%y) Regards, Richie. Mathematical Sciences Unit HSL

Re: [R] HELP: BRUGS/WinBUGS/RBUGS Response is a combination of random variables

2009-07-20 Thread Richard . Cotton
Is there anyone know if BUGS language allows the combination of variables as response It seems doesn't work in my model. The problem is between two ##. modelCompile(numChains=1) multiple definitions of node bm[1] ### bm[iter] -

Re: [R] Regression for loop test HELP! URGENT!

2009-07-20 Thread Richard . Cotton
I'm new to R, and I've sent this message as a non-member, but since it's pretty urgent, I'm sending it again now I'm on the mailing list (Thanks Daniel for your suggestion nevertheless). I have calculated a regression in the form of M ~ D + O + S, and I would like to take this regression

Re: [R] Histograms on a log scale

2009-07-20 Thread Richard . Cotton
I would like to be able to plot histograms/densities on a semi-log or log-log scale. # Get a random log-normal distribution r - rlnorm(1000) # Get the distribution without plotting it using tighter breaks h - hist(r, plot=F, breaks=c(seq(0,max(r)+1, .1))) # Plot the distribution using

Re: [R] rle

2009-07-07 Thread Richard . Cotton
I have an other problem, I have this vector signData with an alternation of 1 and -1 that corrispond to the duration of two different percepts. I extracted the durations like this: signData- scan(dataTR10.txt) dur-rle(signData)$length I think that last line should be

Re: [R] how to apply a self-written function to a data frame

2009-07-06 Thread Richard . Cotton
I have written a function in order to analyse gaze paths. It works with the test data but when I try to apply the function to a data frame that stores the real data in columns I receive the error message that the In if (pp 1) { : condition has length 1 only the first element will

Re: [R] variable driven csv file names?

2009-06-01 Thread Richard . Cotton
Is it possible to have variable driven csv file names? Such as: ds.name-bob.csv write.table( distribution.data, file = ~//Documents/Research/Distribution Analysis/ds.name, sep = ,, col.names = FALSE, qmethod = double) Yes. You just need to construct

Re: [R] R help

2009-05-28 Thread Richard . Cotton
I am interested in modeling hydrological extreme events. I found MSClaio2008 very interesting function. In this function four criterions for choosing distributions. Can we call these criterions as model selection techniques or goodness of fit techniques or both? Because goodness of fit

Re: [R] sample unique pairs from a matrix

2009-05-28 Thread Richard . Cotton
I have a matrix of both negative and positive values that I would like to randomly sample with the following 2 conditions: 1. only sample positive values 2. once a cell in the matrix has been sampled the row and column of that cell cannot be sampled from again. #some dummy data

Re: [R] Plot error

2009-05-28 Thread Richard . Cotton
I want to plot data such that the 3 time points(a,b,c) lie on the X-axis and the values of these times points are on Y-axis for n samples (e.g.100). So, I have an object x, dim 100 4, it is a dataframe (when checked the class) x = name a b c 10.11 1.11 0.86 2

Re: [R] r-plot

2009-05-27 Thread Richard . Cotton
I want to make a simple plot, here is my code: http://gist.github.com/118550 Unfortunately, the annotation of both the x- and y-axis are not correct, as you can see in the following picture: http://www.nabble.com/file/p23739356/plot.png I am not an expert of R, so maybe someone can point

Re: [R] XML parse error

2009-05-21 Thread Richard . Cotton
I am trying to parse XML file ( binary hex) but get an error. Code I am using is: xsd = xmlTreeParse(system.file(exampleData, norel.xsd, package = XML), isSchema =TRUE) doc = xmlInternalTreeParse(system. file(exampleData, LogCallSummary.bin, package = XML)) Start tag expected, '' not

Re: [R] [newbie] how to do a 3d plot of bivariate density?

2009-05-21 Thread Richard . Cotton
I am new to R. Yesterday I passed the afternoon reading the introduction and language reference, but I could'nt find a way to do a 3d plot of the density of a data table of size 2. I am trying with: plot(density(t(t2))) but it mixes the two columns and calculate the density like it is a

Re: [R] Need help on ploting Histograms

2009-05-21 Thread Richard . Cotton
this is the command i made for a normal distribution, but when i try to plot the histograms, i dont know why the bars don't stick on the line... nsamples-1000 sampsize-15 Samples-matrix(rnorm(nsamples*sampsize,0,1),nrow=nsamples) a-apply(Samples,1,var) NC14-a*14 x-0:40

Re: [R] arrangement of crowded labels

2009-05-20 Thread Richard . Cotton
I'm looking for algorithms that assist in spreading out crowded labels, e.g. labels of points in a scatter plot, in order to obtain a nicer visual appearance and better legibility. I'm probably just stuck because I didn't find the right key words for a successful search on the R

Re: [R] Where to find a changelog for the survival package

2009-05-20 Thread Richard . Cotton
since some days I try to use the versions 2.35-4 of the survival package instead of versions 2.31, I had installed until now. Several changes in print.survfit, plot.survfit and seemingly in the structure of ratetabels effect some of my syntax files. Is there somewhere a documentation of

Re: [R] How to google for R stuff?

2009-05-20 Thread Richard . Cotton
One thing I find most frustrating about R is how difficult it is to use Google (or any other search tool) to look for answers to my R-related questions. With languages with even slightly more distinctive names like Perl, Java, Python, Matlab, OCaml, etc., usually including the name of the

Re: [R] help on Nan error

2009-05-15 Thread Richard . Cotton
When i want to do ANOSIM i get an NaN error message. What is wrong? (lots of other code) iwithin=rep(0,(N*(N-1)/2) ) r.w=sum(r*iwithin)/sum(iwithin) iwithin is a vector of zeroes and so is its sum. r*iwithin is also a vector of zeroes, and so is its sum. Thus

Re: [R] Finding root using Newton's method

2009-05-14 Thread Richard . Cotton
I want generate R code to determine the real root of the polynomial x^3-2*x^2+3*x-5. Using an initial guess of 1 with Newton's method. Homework? - see your instructor! Otherwise, provide minimal self-contained code and show us where you are stuck. It gets a little suspicious when there are

Re: [R] decimal troubles ?

2009-05-12 Thread Richard . Cotton
I have some trouble with the number of decimals in R (currently R 2.9.0). For instance: options()$digits [1] 3 let me hope that I will get three digits where useful when a number is printed. BUT: 44.25+31.1+50 [1] 125 No way to get the right result 125.35 Can anybody tell

Re: [R] (no subject)

2009-05-12 Thread Richard . Cotton
if i have the following function, f - function(x) x^3-2*x^2+3*x-5 i need a simple function for the derivative of this with respect to 'x', so that i can then sub in values to the the derivative function, and use Newtons method of finding a root for this. You could take a look at

Re: [R] lattice histogram for multiple variables : adjusting x axis

2009-05-12 Thread Richard . Cotton
I have a large data frame and I want to look at the distribution of each variable very quickly by plotting an individual histogram for each variable. I'd like to do so using lattice. Here is a small example using the iris data set:

Re: [R] how the break is calculated by R?

2009-05-12 Thread Richard . Cotton
As to hist,the help file says: R's default with equi-spaced breaks (also the default) is to plot the counts in the cells defined by breaks. I wanna know how the break is calculated by R? In other words: break = (max - min)/(number of group) but how the number of group is calculated by

Re: [R] xyplot: no ticks for a factor scale?

2009-05-12 Thread Richard . Cotton
I would like to have no ticks on a scale that represents a factor. The tick.number argument from scales does not work in such a situation, as the help page as well as this simple (fairly stupid) code show: require(lattice) fact-gl(4,1,labels=LETTERS[1:4]) y-c(1,4,3,2)

Re: [R] working with groups of labels?

2009-05-11 Thread Richard . Cotton
I have a graph with groups of variables. I have include the group names as variables so that I can have them positioned correctly. Unfortunately this means that the group names have to follow all of the same rules as the variables within the groups. I would rather have those group names

Re: [R] What does it mean by skip=2 and skip=7?

2009-05-11 Thread Richard . Cotton
Can anyone tell me what is skip=2, skip =7 From ?read.csv: skip: integer: the number of lines of the data file to skip before beginning to read data. and %in% mean here? %in% matches values; see ?'%in%', and example('%in%') Regards, Richie. Mathematical Sciences Unit HSL

Re: [R] working with groups of labels?

2009-05-11 Thread Richard . Cotton
It seems that the structure of your data is that you have two groups (Real Bad Stuff and Other Crazy Things) which are then subdivided into further categories. I'd be tempted to set your data up like this: dfr - data.frame( score=c(23, 14, 17, 8, 43, 13), group=rep(c(Real Bad Stuff,

Re: [R] Plotting questions

2009-05-08 Thread Richard . Cotton
1. How to plot several lines in a figure? Suppose I have several sets of points (xi,yi), where xi and yi are equal-length vector. plot(x1,y1) will give a line connecting these points. Another plot(x2,y2) will erase what plot before and plot the new line. Can I have these lines all drawn in

Re: [R] I'm offering $300 for someone who know R-programming to do the assignments for me.

2009-05-08 Thread Richard . Cotton
There are six assignments in total. It won't take you long if you were familiar with R. For those who are interested, please send me an email with your profile (your experience with R, how long and how often have you been using it.) I will be paying through paypal. Thanks! Now see, you made

Re: [R] howto find x value where x=max(x)

2009-05-08 Thread Richard . Cotton
fp is a data frame like this ,[ fp ] |Frequenz AmpNorm | 1 3322 0.0379490639 | 2 3061 0.0476033058 | 3 2833 0.0592954124 | 4 2242 0.1275510204 ` i want to find the Frequenz where AmpNorm is max. Use which.max. fp -

Re: [R] Create Pie chart from .csv file

2009-05-07 Thread Richard . Cotton
Ive found out a way around my problem. I was trying to plaot a histogram of strings, but I had to change it into integers. I ran an sql query on the original DB that I got the CSV file from and used COUNT to get the number of each unique item in a given column. I then used these numbers to

Re: [R] Show name of dataset in graph

2009-05-07 Thread Richard . Cotton
I?ve written a script to run several multivariate statistical analysis automatically. As one result a biplot and screeplot is produced. Now I?d like to display the name of the inputdatset as part of the title of these graphics and I do not want to enter it each time I run the script. How

Re: [R] Create Pie chart from .csv file

2009-05-05 Thread Richard . Cotton
I am looking to create a pie chart from a given column in a .csv file. My class variables are as follows: entry_type, uniquekey, types, title,url, abstract, journal, author, month, year, howpublished So say I want to export a pie chart that groups together all entries under

Re: [R] displaying percentage in bar plot

2009-04-24 Thread Richard . Cotton
I have a following data AIS LEvel 1 23 body regionA 10 15 20 B 15 25 15 Now I want to plot a barplot and in each bar (corresponding a body region),

Re: [R] Plots - several pages per pdf - quality/size issue

2009-04-23 Thread Richard . Cotton
I hope that question will not be too redundant (sorry if it is) but i don't seem able to find the answer i need in the archives... I try to create a file which would have 1.several pages and 2. several plots by page. I know how to make a pdf file this way, but my problem is that the pdf

Re: [R] Problem with a defined function which cannot access a function defined outside of the function

2009-04-16 Thread Richard . Cotton
i have a problem with a function that i defined: the function needs to use a function which is defined outside the function but i realised that this is not working. a friend told me that this must be a problem with hidden parameters. a workaround works when i just define all

Re: [R] geometric mean to handle large number and negative values

2009-04-15 Thread Richard . Cotton
I have created two functions to compute geometric means. Method 1 can handle even number of negative values but not large number, vice versa for method 2. How can I merge both functions so that both large number and negative values can be handled ? geometric.mean1 - function(x)

Re: [R] geometric mean to handle large number and negative values

2009-04-15 Thread Richard . Cotton
geometric.mean1 - function(x) prod(x)^(1/length(x)) geometric.mean2 - function(x) exp(mean(log(x))) geometric.mean1(c(-5,-4,4,5)) [1] 4.472136 geometric.mean2(c(-5,-4,4,5)) [1] NaN Warning message: In log(x) : NaNs produced comp.x - as.complex(c(-5,-4,4,5))

Re: [R] Extending a vector to length n

2009-04-15 Thread Richard . Cotton
In general, how can I increase a vector of length m ( n) to length n by padding it with m - n missing values, without losing attributes? The two approaches I've tried, using length- and adding missings with c, do not work in general: a - as.Date(2008-01-01) c(a, NA) [1] 2008-01-01 NA

Re: [R] Lattice xyplot with two y axis

2009-04-14 Thread Richard . Cotton
I have some data which needs to be plotted with lattice. library(lattice) cars - c(0.1, 0.3, 0.6, 0.4, 0.9) trucks - c(0.2, 0.5, 0.4, 0.5, 0.1) drivers-c(121,145,167,200, 210) year-c(2005,2006,2007,2008,2009) type-c(local,local,foreign,foreign,foreign) xyplot(cars+trucks~year|type,

Re: [R] default print format for large numbers

2009-04-08 Thread Richard . Cotton
Numbers like ``1239178547.653775 is inserted into a vector. I print the vector: route_9_80_end [1] 1239178522 1239178526 1239178524 1239178524 1239178524 1239178523 1239178524 1239178522 1239178521 1239178565 1239178566 1239178566 [13] 1239178565 1239178566 1239178566 1239178565

Re: [R] R and .net/C#

2009-04-07 Thread Richard . Cotton
There seems to be a way for calling R from .net. However, is there anyway for calling .net/C# code from R? Something similar to the RJava package for .net? To the best of my knowledge, there isn't at the moment. The latest release of MATLAB does though, so in the spirit of

Re: [R] Difference in client vs. server graphics defaults

2009-03-20 Thread Richard Cotton
lawnboy34 wrote: I am having trouble with the difference between default graphic settings on my client machine and the instance of R on our company's server. I created a script locally that output graphs, but when I run it on the server the output graphs have titles running past the

Re: [R] who can give me some hint?

2009-03-12 Thread Richard . Cotton
Hi All, act_2 DateDtime Hour Min Second Rep 51 2006-02-22 14:52:18 14 52 18 useractivity_act 52 2006-02-22 14:52:18 14 52 18 4 55 2006-02-22 14:52:49 14 52 49 4 57 2006-02-22 14:52:51 14 52 51

Re: [R] help with loop

2009-03-12 Thread Richard . Cotton
I'm trying to write a loop to sum my data in the following way: (the second - the first) + (the third - the second) + (the fourth - the third) + ... for each column. This is just sum(diff(x)), or even x[length(x)] - x[1]. Regards, Richie. Mathematical Sciences Unit HSL

Re: [R] Help

2009-03-09 Thread Richard . Cotton
I am trying to excess the inbuit .Fortran and .C codes of R. Can any one help me in that. For example in kmeans clustering the algorithms are written in .Fortran I want to access them and see the .Fortran syntax of the codes. Can any one help me how can I do that? Download the R source

Re: [R] Normal Probability Plot - Time series

2009-03-09 Thread Richard . Cotton
I have some time-series data and wish to plot a normal probability plot in R. How do I go about this? In R, they are known as quantile-quantile plots. Check out ?qqplot and ?qqnorm. Regards, Richie. Mathematical Sciences Unit HSL

Re: [R] Adding text to both grid and base graphs

2009-03-09 Thread Richard . Cotton
I generate graphs using both the grid system (with lattice) and the base system. I'd like to be able to identify these graphs later on with a bit of identifying text (e.g. a date and some comments). Adding text to these graphs cannot be done using a common system if you want to save them as

Re: [R] dummy variable encoding

2009-03-06 Thread Richard . Cotton
The best encoding depends upon which language you would like to manipulate the variable in. In R, genders are most naturally represented as factors. That means that in an external data source (like a spreadsheet of data), you should ideally have the gender recorded as

Re: [R] About warnings for non-matched items

2009-03-06 Thread Richard . Cotton
I have many files in my directory. I want to transfer each data into one which is readable. They have so many possibilities, i have collected(manually and visually) all possibilities and represent them as different numbers. Rep[grep('context_log',log1$Remain[1:length(log1$Date)]),]-2

Re: [R] dummy variable encoding

2009-03-05 Thread Richard . Cotton
can anyone tell me why an encoding of 1/2 for a dummy variable for two groups (e.g. gender) seems to be preferred over 0/1? It's been bugging me for a while, 0/1 seems more natural, but I have been told (without explanation) that 1/2 is better. Why? The best encoding depends upon

Re: [R] The Origins of R AND CALCULUS

2009-02-05 Thread Richard . Cotton
Does any student, or teacher for that matter care whether Newton or Leibntiz invented calculas. Students or teachers may not care, but Newton and Leibniz themselves were pretty bitter about who should get credit for what. http://en.wikipedia.org/wiki/Newton_v._Leibniz_calculus_controversy I

Re: [R] Equivalent of Hold On MatLab Command

2009-01-30 Thread Richard . Cotton
Does R have a graphic command equivalent of MatLab Hold On ? I am trying to sabve on a pdf file a composite drawing. I first declare the canvas size, then I define the layout, finally I generate the 4 plots according to layout order. Eventually I close the pdf file (dev.off()). The

Re: [R] Text Outside Lattice Plot

2009-01-21 Thread Richard . Cotton
I created the graph at the bottom using xyplot in the lattice package. I added a title using the main=Title command in xyplot, however it is plotted too close to the legend for my liking. To remedy this I increased the upper margin of the plot using plot(data, position = c(0,0,1,.9)) and

Re: [R] filling blanks with NA

2009-01-21 Thread Richard . Cotton
I do have a data set with some missing values that appear as blanks. I want to fill these blanks with an NA. How can this be done? Thanks for your help Please help us to help you. What form are the data in? Are they in a text file, or are they in R already? What do you mean by 'blanks'?

Re: [R] WinBUGS with R

2009-01-20 Thread Richard . Cotton
I am having some problems using R with WinBUGS using the R2WinBUGS package. Specifically, when I try to run bugs() I get the following message. Error in FUN(X[[1L]], ...) : .C(..): 'type' must be real for this format To give a little more context, my bugs() command (for a

Re: [R] Deleting columns where the frequency of values are too disparate

2009-01-19 Thread Richard . Cotton
Please consider the following toy data matrix example, called x for simplicity. There are 20 different individuals (ID), with information about the alleles (A,T, G, C) at six different loci (Locus1 - Locus6) for each of these 20 individuals. At any single locus (e.g., Locus1 or Locus2,

Re: [R] LCA (e1071 package): error

2009-01-15 Thread Richard . Cotton
I will use the lca method in the e1071 package. But I get the following error: Error in pas[j, ] - drop(exp(rep(1, nvar) %*% log(mp))) : number of items to replace is not a multiple of replacement length Does anybody know this error and knows what this means? The error means that you are

[R] R2WinBUGS stopping execution

2009-01-12 Thread Richard . Cotton
Apologies if this isn't acceptable for the general help list. I'm running OpenBUGS model via the R2WinBUGS package interface, under Windows. Is it possible to terminate running models, short of using the Windows Task Manager to forcibly exit the program? Regards, Richie. Mathematical

[R] Saving plots as byte streams

2009-01-09 Thread Richard . Cotton
Is it possible to save plots as byte streams? For example, if I want the bytes for a PNG plot, I could use #Write the plot to a PNG file png(test.png) plot(1:10) dev.off() #Read the bytes back in from the file plotbytes - readBin(test.png, raw, n=2000) Ideally, I'd like to avoid having to

Re: [R] for loop and if problem

2009-01-06 Thread Richard . Cotton
I'm heaving difficulties with a dataset containing gene names and positions of those genes. Not such a big problem, but each gene has multiple exons so it's hard to say where de gene starts and where it ends. I want the starting and ending position of each gene in my dataset. Attached is

[R] Borders for rectangles in lattice plot key

2008-12-23 Thread Richard . Cotton
Hopefully an easy question. When drawing a rectangles in a lattice plot key, how do you omit the black borders? Here is an example adapted from one on the xyplot help page: bar.cols - c(red, blue) key.list - list( space=top, rectangles=list(col=bar.cols), text=list(c(foo, bar)) )

Re: [R] problem with Surv

2008-12-15 Thread Richard . Cotton
I'm trying to estimate a tobit model with survrec function. I use the following code : reg-survreg(Surv(crs_prod,crs_prod=1)~SOLVA+log(AF088) +HHI+ACTIONNA,data=dat,dist=gaussian) I get this error message with R 2.7.2 Error in survreg(Surv(crs_prod, crs_prod = 1) ~ SOLVA + log(AF088) +

Re: [R] Legend and Main Title positioning

2008-12-05 Thread Richard . Cotton
layout(matrix(c(1,2,3,4), nrow = 2, byrow = TRUE)) plot(rnorm(100)) plot(rnorm(200)) plot(rnorm(300)) plot(rnorm(400)) Now, I'd like to create a legend below each plot and generate a common title. How can I do that? If you are laying plots out in grids like this then lattice graphics

Re: [R] levels update

2008-12-05 Thread Richard . Cotton
I hope this question is not too stupid. I would like to know how to update levels after subsetting data from a data.frame. df - data.frame(factor(c(a,a,c,b,b)), c(4,5,6,7,8), c(9,1,2,3,4)) names(df) - c(X1,X2,X3) my.sub - subset(df, X1 == a | X1 == b) levels(my.sub$X1) # still

Re: [R] Sink does not send graphs to sink file

2008-12-05 Thread Richard . Cotton
I am using sink() to send the results of my analyses to a text file. Unfortunately my graphs do not become part of the file. Is there anyway that I can have both the text and graphic output of my analyses appear in a file? You can create a latex document with text, graphs and R-code using

Re: [R] Problems with lattice-histograms or png within loops

2008-12-05 Thread Richard . Cotton
I have a question concerning the use of lattice plots within for-loops. I want to create a png file containing a lattice histogram which works out fine (part 1). When I loop the whole code, the graphic file does not contain anything (part 2). I can fix it by wrapping the histogram

Re: [R] question involving loops from intro level R programming class

2008-11-28 Thread Richard . Cotton
a. Write a R function zerdiag.v1(m) using loop to output a square matrix whose diagonal elements are zero and the other elements are filled in by consecutive integers from 1 to m row-wise. For example, zerdiag.v1(6) = [0, 1, 2] [3, 0, 4]

Re: [R] construct a vector

2008-11-26 Thread Richard . Cotton
I have an unkown number of vectors (=2) all of the same length. Out of these, I want to construct a new one as follows: having vectors u,v and w, the resulting vector z should have entries: z[1] = u[1], z[2] = v[1], z[3] = w[1] z[4] = u[2], z[5] = v[2], z[6] = w[2] ... i.e. go through the

Re: [R] basic information defining functions

2008-11-25 Thread Richard . Cotton
i am looking from some insights to define own R functions. so far i found most basics in documentations that are around on the web. except for one thing: I´d like to define some function, say: #assume my data matrix contains vectors like data$myColumn1,data $myColumn2 etc. Do you

Re: [R] lattice contourplot background covers inward-facing ticks

2008-11-25 Thread Richard . Cotton
I wish to have inward-pointing ticks on my contourplot graph, but the colored background produced by the region=TRUE statement covers the ticks up, is there any way around this? Sample code below. --Seth library(lattice) model - function(a,b,c,d,e, f, X1,X2) # provide model

Re: [R] Calculating sum of letter values

2008-11-24 Thread Richard . Cotton
Thanks, that's almost exactly what I need...theres just a slight difference with my requirement, in that I am looking for the actual index value in the alphabetical sequence, so that instead of: as.numeric(factor(unlist(strsplit(XYZ, [1] 1 2 3 I would expect to see [1] 24 25 26

Re: [R] R course in Scotland

2008-11-21 Thread Richard Cotton
pzs wrote: Several people have suggested that I just pick up R and give it a try. My reluctance to do this is that I am already very familiar with my current working method (Python + Numpy) and I worry that without a course I will work in a Python-centric way, which won't be optimal.

Re: [R] Dequantizing

2008-11-20 Thread Richard . Cotton
I have some data measured with a coarsely-quantized clock. Let's say the real data are q- sort(rexp(100,.5)) The quantized form is floor(q), so a simple quantile plot of one against the other can be calculated using: plot(q,type=l); points(floor(q),col=red) which of

Re: [R] sequencially merge multiple files in a folder

2008-11-18 Thread Richard . Cotton
Here I have a folder with more than 50 tab-delimited files. Each file has a few hundreds of thousands rows/subjects, and the number of columns/variables of each file varies.The 1st row consists of all the variable names. Now I would like to merge all the files into one tab-delimited file

Re: [R] Accessing Results from cenmle function in NADA package

2008-11-12 Thread Richard . Cotton
I figured it out. In case anyone else ever has this question -- given the following output from cenmle: fit.cen - cenmle(obs, censored, groups) fit.cen Value Std. Errorz p (Intercept) 1.19473 0.0772 15.4695 5.58e-54 groups1 0.00208 0.0789

Re: [R] Barplot Labels Problem

2008-11-05 Thread Richard . Cotton
I’m using barplot function. I pretend to create a horizontal barplot with two different information (side by side) for a species list. Well I can generate the graph easily, but the problem is that the labels with the species names are cut by device window!! I’ve tried lots of par functions

Re: [R] counting run lengths

2008-10-27 Thread Richard . Cotton
It works, but the for (i in ...) loop slows down the simulation a lot. Any suggestion on how to avoid this loop? (or in general, to speed up this part of the simulation) Actually, I have not specified the following: i want to consider only the most recent sequence of zeros, that is

Re: [R] Arrays of Trellis plots

2008-10-27 Thread Richard . Cotton
the example below does not work. (i know it's not supposed, but it makes it clear what i'm trying to achieve) par(mfrow=c(2,1)) xyplot(y~x2|x1,data=dataframe1,pch=20) xyplot(y~x2|x1,data=dataframe2,pch=20) i know i could probably merge the two datasets and do something like

Re: [R] convert matrix to dataframe with repeating row names

2008-10-20 Thread Richard . Cotton
The row names on a data frame should be unique. You can try as.data.frame(xx, row.names=FALSE) to convert zz to be a data frame. If you need the row name information, add it as a column in the data frame, e.g. mydataframe$rnames - rownames(zz). (Note to R-Core: the documentation for

Re: [R] convert matrix to dataframe with repeating row names

2008-10-20 Thread Richard . Cotton
I have a matrix x with repeating row names. zz-matrix(0,4,4) rownames(zz)=c(a,a,b,b) data.frame(zz) (?) The row names on a data frame should be unique. You can try as.data.frame(xx, row.names=FALSE) to convert zz to be a data frame. If you need the row name information, add it as a

[R] Using key.opts in Ecdf/labcurve (Hmisc package)

2008-10-17 Thread Richard . Cotton
I'm presumably missing something very obvious, but how does one use the key.opts argument in labcurve (via Ecdf)? In this example, I want the key to be big and have a blue background, but it isn't and doesn't. ch - rnorm(1000, 200, 40) sex - factor(sample(c('female','male'), 1000, TRUE))

Re: [R] how to store lme/lmer fit result

2008-10-10 Thread Richard . Cotton
I am building a hierarchical model on a large data set. It can take quite some time to finish one fit, I was just wondering whether it is possible to store the fit object (the result) to a file for later (offline) analysis. See ?save. Regards, Richie. Mathematical Sciences Unit HSL

Re: [R] Space between bars in barplot

2008-10-10 Thread Richard . Cotton
I played around with your suggestions to change the appearance of my graph, but there is still a problem I could not fix. The vector, which I want to plot, contains 60 entries. After 3 bars I want to have a large gap between the next 3 bars. But what always happens is, that R took at the

Re: [R] Space between bars in barplot

2008-10-09 Thread Richard . Cotton
with the space parameter it is possible to change the gap / distance between the bars, but is it also possible to change the space after each 6th bar? So for example you have bars from 1 to 6 then a large gap and then the next six bars from 7 to 12 Try, for example y - runif(13) y[7] - NA

Re: [R] histogram loses top row with alpha transparency under Windows

2008-10-09 Thread Richard Cotton
k.ponting wrote: Hello all. Trying to use transparency for overlaid histogram plots I have come across an interesting inconsistency, possibly a bug when running under Windows. Originally noticed in R 2.7.1, it is still there in 2.8.0 beta. library(lattice) zz - function(n,alpha) {

Re: [R] Exporting symnum() result from cor()

2008-10-09 Thread Richard Cotton
Michael Just wrote: Hello, I am trying to export the results from symnum() while maintain their readability. I tried using sink to text file and also copying and pasting but the results end up looking like this: symnum(c5.s) bC bED bEN bLP bLS bPA bPD bPR p bbContag 1

Re: [R] vectorization instead of using loop

2008-10-09 Thread Richard . Cotton
I've sent this question 2 days ago and got response from Sarah. Thanks for that. But unfortunately, it did not really solve our problem. The main issue is that we want to use our own (manipulated) covariance matrix in the calculation of the mahalanobis distance. Does anyone know how to

Re: [R] vectorization instead of using loop

2008-10-09 Thread Richard . Cotton
Frank said: This piece of code works, but it is very slow. We were wondering if it's at all possible to somehow vectorize this function. Any help would be greatly appreciated. Richie said: You can save a substantial time by calling as.matrix before the loop Patrick said: One thing

Re: [R] question from Braun/Murdoch book

2008-10-08 Thread Richard . Cotton
I am looking at the Braun/Murdoch book, A First Course in Statistical Programming in R, and I have a question about a function there. It's on page 52, Example 4.5; the sieve of Erastosthenes. There is a line: primes - c() Is there a difference between using that and primes - NULL

Re: [R] Fitting weibull, exponential and lognormal distributions to left-truncated data.

2008-10-07 Thread Richard . Cotton
I have several datasets, all left-truncated at x=1, that I am attempting to fit distributions to (lognormal, weibull and exponential). I had been using fitdistr in the MASS package as follows: A possible solution is to use the survreg() in the survival package without specifying the

Re: [R] horizontal boxplot + xlim

2008-10-06 Thread Richard . Cotton
I get a strange behaviour of a boxplot with the following code. There seems to be a problem with the xlim-parameter. Did I do anything wrong? What else can I do to force the boxplot to have a defined x-range? x - rnorm(100) boxplot(x, notch=TRUE, xlab=parameter, xlim - c(-4,4),

Re: [R] horizontal boxplot + xlim

2008-10-06 Thread Richard . Cotton
True, I made a mistake here. Still, I have problems to visualize my data (not the example code I used). I just see a flat line instead a proper plot... Another example code with creating a strange plot: x - rnorm(100) + 100 maxval - max(x) boxplot(x, notch=TRUE, xlim = c(0,maxval),

  1   2   3   >