Re: [R] Lattice Histogram with Normal Curve - Y axis as percentages

2014-05-07 Thread jimdare
Thanks for your help Duncan and Peter! I ended up using a combination of your suggestions. I used Duncan's y.limits ration of two plots with differing types (percent and density), to provide me with a scale variable. I then used this in Peter's dnorm_scaled function and called it using

[R] Lattice Histogram with Normal Curve - Y axis as percentages

2014-05-05 Thread jimdare
. Jimdare plot-histogram(~rdf[,j]|Year,nint=20, data=rdf,main = i,strip = my.strip,xlab = j, type = percent,layout=c(2,1), panel=function(x, ...) { panel.histogram(x, ...) panel.mathdensity(dmath=dnorm, col=black, # Add na.rm = TRUE to mean() and sd

[R] Change color of single panel in xyplot

2009-11-19 Thread jimdare
Hi there, I have created a single page, multi-panel, xyplot using lattice. Each panel is a trial (total of 8) from an experiment with 3 variables on the x axis and the observed value on the y axis. I have added the mean of all trials so the entire plot looks like this (where M=mean panel and

[R] Calculate Mean for each Treatment/Trial Interaction in DF

2009-11-05 Thread jimdare
Hi, I am create a new DF that summarizes the mean angle per treatment/trial, of the original DF (see below). I have had some success using: (tapply(df$Angle, INDEX=interaction(df$State, df$Trial), FUN=mean)); however, this gives the answer as a list, which means I would have to split the name

[R] Weird operator behaviour

2009-11-03 Thread jimdare
Hi, I have a dataset called 'fish'. fish$Species returns extract 1. When I use fish$Species != c(CRA,PHC), i.e. I want all species except CRA and PHC, I get extract 2 which is blatantly wrong. Can anyone see what I'm doing wrong? Regards, James EXTRACT 1 fish$Species [1] ALB ALB ALB

Re: [R] Binding objects with a similar name

2009-10-12 Thread jimdare
this: sapply(result, sum) but I would have to see the data to be sure. On Mon, Oct 12, 2009 at 4:26 PM, jimdare jamesdar...@gmail.com wrote: Dear R users, The code below splits a dataset by target_species and then further splits each target species group by year.  Finally the sum

[R] Function Help

2009-10-11 Thread jimdare
Hi there, I have created the function below: pirate-function(x){ a-x-1; b-a/5; c-a-b; d-c-1; e-d/5; f-d-e; g-f-1; h-g/5; i-g-h; j-i-1; k-j/5; l-j-k; m-l-1; n-m/5; o-m-n; final-o/5; final } I want to run this function until the output ('final') is an exact integer (e.g. 893.0 rather than

[R] Loop function/comparison operator problem

2009-10-05 Thread jimdare
Hi There, I have created the following function format- function(){ repeat { form-readline(paste(\nIn what format do you want to save these plots?\nChoose from: wmf, emf, png, jpg, jpeg, bmp, tif, tiff, ps, eps, or pdf.\nNote: eps is the suggested format for publication quality plots.\nPlot

[R] Level name as object name

2009-10-01 Thread jimdare
Hi, If I have a dataset called data with a factor called Species that has three levels Sp1, Sp2, and Sp3. Is there a way to name an object after a specific level? I have tried the code below and get the error error in paste(levels(data$Species)[1]) - 1:10 could not find function paste-

[R] Re gression for levels of a factor/xyplot type=r

2009-09-30 Thread jimdare
Hi, I'm sure these are basic problems so I apologise in advance for my ignorance. I have a dataset with X, Y, and a Factor with 4 levels. I am trying to figure out how to use lm() to find the r2 value, slope and intercept of an X~Y regression, for each level of the Factor. Is there a way to

[R] 3D bar graphs/density plots

2009-09-29 Thread jimdare
Dear R Users, Does anyone know of a package that would enable me to create figures like the ones below? Regards, James http://www.nabble.com/file/p25673513/Picture1.jpg http://www.nabble.com/file/p25673513/Picture2.jpg -- View this message in context:

[R] Defining different objects within a loop

2009-07-30 Thread jimdare
Dear R Users, I have a dataset that I have split by group. For each group I plot a figure using: for (i in splitdf){ plot-xyplot() print(plot) savePlot(filename=paste(i$Group[1]),type=pdf) } This gives me X pdf files where X is the number of groups. Does anyone know a simple

[R] Split rownames into factors

2009-07-27 Thread jimdare
Hi Guys, I was wondering how you would go about solving the following problem: I have a list where the grouping information is in the row names. Rowname [,1] X1Jan08 324 X1Jun08 65 X1Dec08 543 X2Jan08 23 X2Jun08 54 X2Dec08 8765 X3Jan08 213 X3Jun08 43 X3Dec08 65 How can I create the

[R] Sum with Conditions

2009-07-23 Thread jimdare
Dear R-Users, I have a huge data set (172,696 rows) that is set out in the following way: Area | Length | Species | Method | Date | Events I want to sum the number of Events if: Length 28AND Species is NOT X ,Y, or Z AND Method is either 1 ,2, or

Re: [R] Sum with Conditions

2009-07-23 Thread jimdare
] Im Auftrag von jimdare Gesendet: Thursday, July 23, 2009 8:07 PM An: r-help@r-project.org Betreff: [R] Sum with Conditions Dear R-Users, I have a huge data set (172,696 rows) that is set out in the following way: Area | Length | Species | Method | Date | Events I want

[R] Multi-Row Lattice Plot With Y Axis on Same Side

2009-05-18 Thread jimdare
Hi Everyone, I have been creating a lattice plot with the layout = c(1,2). For some reason my boss wants the Y axis of both plots to be on the left hand side of the graph. Is there a way to do this? Regards, James -- View this message in context:

Re: [R] Multi-Row Lattice Plot With Y Axis on Same Side

2009-05-18 Thread jimdare
Thank you. Duncan Mackay-2 wrote: Hi A toy example which you omitted dat - data.frame(x = rep(1:10,2),y = rnorm(20), gp = rep(letters[1:2], each=10) ) xyplot(y~x|gp,dat, scales = list(y = list(alternating = 3))) see ? xyplot and scales a slimmed down sessionInfo() R version

[R] Lattice xyplot: Line and Rectangle in legend.

2009-04-14 Thread jimdare
Hello fellow R users, I have a problem. I have created a barchart overlayed by an xyplot line, both of which read off the same Y axis. The problem comes when I try to generate a key. It seems that I can only create either two lines, or two rectangles. I would much prefer to have the barchat

[R] savePlot error when type = eps or wmf

2009-04-14 Thread jimdare
Hello, When I use savePlot(filename=xy,type=eps) or savePlot(filename=xy,type=wmf) , I get the following error: Error in grid.Call(L_textBounds, as.graphicsAnnot(x$label), x$x, x$y, : Polygon edge not found (zero-width or zero-height?) This doesn't occur when I change the type to jpeg or

[R] Interesting Plot

2009-04-07 Thread jimdare
Hello R Users, I was at a meeting earlier today, where the figure below was presented. Does anyone know what this type of plot is called? Is there an R package designed to generate these? Regards, James http://www.nabble.com/file/p22922671/Plot.gif Plot.gif -- View this message in

[R] Merge two variables together

2009-03-31 Thread jimdare
Hello, If I have two variables: v1-c(2,4,2,3,7,8) v2-c(0,0,0,0,0,0) how can I merge them to form v3-2,0,4,0,2,0,3,0,7,0,8,0 I am trying to use this to get an xyplot to label every second x tick mark (i.e. by replacing v1 with every second year and v2 with ). -- View this message in context:

Re: [R] Merge two variables together

2009-03-31 Thread jimdare
Thanks guys jimdare wrote: Hello, If I have two variables: v1-c(2,4,2,3,7,8) v2-c(0,0,0,0,0,0) how can I merge them to form v3-2,0,4,0,2,0,3,0,7,0,8,0 I am trying to use this to get an xyplot to label every second x tick mark (i.e. by replacing v1 with every second year

[R] Two variables on one lattice barchart

2009-03-29 Thread jimdare
Hi, I created the barchart below using the lattice package, however I can't seem to find a way to add another variable as a line (see the desired square/lines that I drew for the last 10 years of the plot). Can anyone help me with this? Your help is much appreciated! Code:

Re: [R] Two variables on one lattice barchart

2009-03-29 Thread jimdare
$TACC,type='o',lwd=3,col=black) }) jimdare wrote: Hi, I created the barchart below using the lattice package, however I can't seem to find a way to add another variable as a line (see the desired square/lines that I drew for the last 10 years of the plot). Can

[R] Trellis barchart help

2009-03-26 Thread jimdare
Hi, I apologise if this sounds like a really simple problem. I have a time-series data set with two columns of data: Catch and TACC. I want Catch plotted as a barchart and TACC plotted on the same graph as a series of points with an overlaying a line. I have created the code for a barchart

[R] If statement generates two outputs

2009-03-22 Thread jimdare
Hi, How do I tell an if statement to generate two seperate outputs. E.g If X5 I want to create df1 and df2: if (X5) {df1-c(4,5,6,7,8) AND df2-c(9,10,11,12,13)} Thanks, James -- View this message in context: http://www.nabble.com/If-statement-generates-two-outputs-tp22650844p22650844.html

Re: [R] If statement generates two outputs

2009-03-22 Thread jimdare
Thanks very much Wacek Kusnierczyk wrote: jimdare wrote: Hi, How do I tell an if statement to generate two seperate outputs. E.g If X5 I want to create df1 and df2: if (X5) {df1-c(4,5,6,7,8) AND df2-c(9,10,11,12,13)} almost there: if (X5) {df1-c(4,5,6,7,8); df2-c

Re: [R] If statement generates two outputs

2009-03-22 Thread jimdare
, sep=), rowname = NULL, cgroup = c(Fishstock, stocknames,Total), n.cgroup = c(1, rep(2,((nostocks-4)+1)), colheads = c(Year, rep(c(Catch, TACC), nostocks+1)),size=large,center=none) } jimdare wrote: Hi, How do I

[R] 2 Simple Lattice Plot Questions

2009-03-10 Thread jimdare
Hi, I have created the plot below and have a few questions about changes. 1) How do I change the Year title of each plot so it reads from the top 2006,2007,2008,2009. 2) How do I get rid of those vertical grey bars in the title bar of each plot? I apologise for my ignorance... one of those

Re: [R] 2 Simple Lattice Plot Questions

2009-03-10 Thread jimdare
how to change this setting? Cheers, jimdare wrote: Hi, I have created the plot below and have a few questions about changes. 1) How do I change the Year title of each plot so it reads from the top 2006,2007,2008,2009. 2) How do I get rid of those vertical grey bars in the title

Re: [R] 2 Simple Lattice Plot Questions

2009-03-10 Thread jimdare
[mailto:r-help-boun...@r-project.org] On Behalf Of jimdare Sent: Wednesday, 11 March 2009 12:50 PM To: r-help@r-project.org Subject: Re: [R] 2 Simple Lattice Plot Questions Thanks very much.One other thing... see how the Y axis begins before 0. At first glance it appears

Re: [R] 2 Simple Lattice Plot Questions

2009-03-10 Thread jimdare
to display, e.g. ylim=c(0,5,10,15,20,30)?  -Original Message- From:   r-help-boun...@r-project.org [mailto:r-help-boun...@r-project.org]  On Behalf Of jimdare Sent:   Wednesday, 11 March 2009 12:50 PM To:     r-help@r-project.org Subject:        Re: [R] 2 Simple Lattice Plot Questions

[R] Two Column-group names using Latex(Hmisc)

2009-03-02 Thread jimdare
Hi, Using the following code I can generate the attachment Original.pdf: latex(test, file=C:/Documents and Settings/darej/My Documents/James/READY.tex, title = , rowname = NULL, cgroup = c(Fishstock, stocknames), n.cgroup = c(1, rep(2,nostocks)), colheads =

[R] Help with Latex (Hmisc)

2009-02-24 Thread jimdare
Dear R Users, I have three questions. 1) Is there a way to get the output tex file to include \documentclass{report} \begin{document} and \end{document} so I can generate a PDF straight away. (I am trying to generate hundreds of these and don't want to have to manually type this in

[R] Table Formatting

2009-02-11 Thread jimdare
Dear R-Users I have created the following table in R: Year TACC.SNA1 Catch.SNA1 TACC.SNA2 Catch.SNA2 TACC.SNA3 Catch.SNA3 111 1985-86 9396 185951860 530 1486 16727 112 1986-87 3155 121959506

[R] Apology for Multiple Posts

2009-01-22 Thread jimdare
Dear R-Users I sincerely apologise for the multiple posts yesterday afternoon. Apparently there was an error in the server here at work which resulted in the message being sent eight times. I am new to R, as you can probably tell from the majority of my posts, and I really appreciate all the

[R] Defining Solid Line using Line Type Specification

2009-01-21 Thread jimdare
Dear R-Users, I created the xyplot below using 10 groups (9 groups + 'Total' of all groups) with lty=1:10. I need the 'Total' to be a bold solid line (lty=1) where as the 9 groups just need to be distinguishable from each other. As you can probably see, when the group reaches CRA6 the lty

[R] Combining Custom and Preset Linetypes

2009-01-21 Thread jimdare
Dear R-Users, I created the xyplot below using 10 groups (9 groups + 'Total' of all groups) with lty=1:10. I need the 'Total' to be a bold solid line (lty=1) where as the 9 groups just need to be distinguishable from each other. As you can probably see, when the group reaches CRA6 the lty

[R] Combining Custom and Preset Linetypes

2009-01-21 Thread jimdare
Dear R-Users, I created the xyplot below using 10 groups (9 groups + 'Total' of all groups) with lty=1:10. I need the 'Total' to be a bold solid line (lty=1) where as the 9 groups just need to be distinguishable from each other. As you can probably see, when the group reaches CRA6 the lty

[R] Combining Custom and Preset Linetypes

2009-01-21 Thread jimdare
Dear R-Users, I created the xyplot below using 10 groups (9 groups + 'Total' of all groups) with lty=1:10. I need the 'Total' to be a bold solid line (lty=1) where as the 9 groups just need to be distinguishable from each other. As you can probably see, when the group reaches CRA6 the lty

[R] Combining Custom and Preset Linetypes

2009-01-21 Thread jimdare
Dear R-Users, I created the xyplot below using 10 groups (9 groups + 'Total' of all groups) with lty=1:10. I need the 'Total' to be a bold solid line (lty=1) where as the 9 groups just need to be distinguishable from each other. As you can probably see, when the group reaches CRA6 the lty

[R] Combining Custom and Preset Linetypes

2009-01-21 Thread jimdare
Dear R-Users, I created the xyplot below using 10 groups (9 groups + 'Total' of all groups) with lty=1:10. I need the 'Total' to be a bold solid line (lty=1) where as the 9 groups just need to be distinguishable from each other. As you can probably see, when the group reaches CRA6 the lty

[R] Combining Custom and Preset Linetypes

2009-01-21 Thread jimdare
Dear R-Users, I created the xyplot below using 10 groups (9 groups + 'Total' of all groups) with lty=1:10. I need the 'Total' to be a bold solid line (lty=1) where as the 9 groups just need to be distinguishable from each other. As you can probably see, when the group reaches CRA6 the lty

[R] Text Outside Lattice Plot

2009-01-20 Thread jimdare
Dear R users 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 =

Re: [R] XYplot in Lattice Package

2009-01-19 Thread jimdare
Thanks for your help David. I managed to track down this solution in regard to the second question: http://www.nabble.com/lattice-xyplot-with-bty%3D%22l%22-tt12486052.html#a12489170 Regards, James David Winsemius wrote: On Jan 15, 2009, at 9:27 PM, jimdare wrote: Dear R-Users

Re: [R] Odp: Moving a Data Frame Column

2009-01-15 Thread jimdare
Thanks, I knew it was something simple :) Petr Pikal wrote: Hi r-help-boun...@r-project.org napsal dne 15.01.2009 04:47:39: Dear R-Users if I have a data frame (or zoo data) as follows: Run Bike Walk Drive 1 2 7 5 5 2 4 2 8 3 2

[R] XYplot in Lattice Package

2009-01-15 Thread jimdare
Dear R-Users I have 2 questions to do with XYplot. 1) I am trying to use the XYplot function to generate multiple line graphs with the legend outside the plot. I am using the following loop for each graph: library(lattice) for (i in x.sp){ xyplot(Catch~Year, df, groups = Stock,

[R] Zoo Plot Can't Get Rid of Box

2009-01-14 Thread jimdare
Hi, I apologise for the stupid question but how to you get rid of the box around a plot in the package zoo? I can't seem to find an equivalent for bty=l i.e. just x and y axis. Cheers James -- View this message in context:

Re: [R] Zoo Plot Can't Get Rid of Box

2009-01-14 Thread jimdare
) On Wed, Jan 14, 2009 at 7:16 PM, jimdare jamesdar...@gmail.com wrote: Hi, I apologise for the stupid question but how to you get rid of the box around a plot in the package zoo? I can't seem to find an equivalent for bty=l i.e. just x and y axis. Cheers James -- View this message

[R] Moving a Data Frame Column

2009-01-14 Thread jimdare
Dear R-Users if I have a data frame (or zoo data) as follows: Run Bike Walk Drive 1 2 7 5 5 2 4 2 8 3 2 1 How can I re-order it so that it reads: Drive Run Bike Walk 5 1 2 7 2 5 2 4 1 8 3

[R] Help with Plot/Legend

2009-01-13 Thread jimdare
=7. Is there any way I can download new line types to avoid this? Thanks in advance for your help. Jimdare -- View this message in context: http://www.nabble.com/Help-with-Plot-Legend-tp21448206p21448206.html Sent from the R help mailing list archive at Nabble.com

Re: [R] Help with Plot/Legend

2009-01-13 Thread jimdare
' (i.e., does not draw them). _Alternatively, a string of up to 8 characters (from c(1:9, A:F)) may be given, giving the length of line segments which are alternatively drawn and skipped. See section 'Line Type Specification'_ On Tue, Jan 13, 2009 at 8:13 PM, jimdare jamesdar...@gmail.com

Re: [R] How to get legend outside of plot?

2009-01-13 Thread jimdare
I also have this problem! I would be great to hear a solution. Mike Williamson-9 wrote: I am creating a CDF plot function more user-friendly than any default r function. Depending upon the bimodality of the data (it is often bimodal), or any other strange data trends, the points

[R] Spitting a df Column Name

2009-01-11 Thread jimdare
Hi, If I have the following column names: names(data) [1] count.run count.walk count.drive How do I split these so i get names(datanamessplit) [1] run walk drive Thanks for your help, Jim -- View this message in context:

Re: [R] Bar Plot with Connected Points on 1 Y-Axis

2009-01-08 Thread jimdare
, which you can adjust as needed. In this case, increasing the y axis range by 10% to make room. HTH, Marc on 01/07/2009 02:31 PM jimdare wrote: Thanks Marc, that has helped a lot. Say, for example, in a situation where I can't find out the highest value, is there any way to get R

[R] Graph Script/X-axis label Problem

2009-01-08 Thread jimdare
Hi, I created the script below to plot multiple graphs. It seems to work pretty well (see BYX7) except when the max value for catch or TACC is very small. In this case the x-axis labels are removed from the x-axis (see BYX10). I can't figure out why given that y co-ordinate for the text

Re: [R] Bar Plot with Connected Points on 1 Y-Axis

2009-01-07 Thread jimdare
the highest value for each. I could set a standard axis value based on the max values of all stocks, however the detail will be lost for many of the less exploited species. Marc Schwartz wrote: on 01/06/2009 09:07 PM jimdare wrote: Hi Everyone, Have created a bar plot of the data below using

[R] Plotting a graph for every Level of a Factor

2009-01-07 Thread jimdare
Hello, Using the dataset below, is there a way to generate a bar/line plot for the TACC/Catch of every lvl of stock? i.e. OR1,OR3,OR5. The picture at the bottom of this post is an example of the bar/line plot for OR1 which was generated when OR1 was the only stock in the table. This was

Re: [R] Plotting a graph for every Level of a Factor

2009-01-07 Thread jimdare
]), + ylim=c(0,max(i$TACC, i$Catch))) + lines(mp, i$Catch, type='b', pch=19) + } On Wed, Jan 7, 2009 at 6:10 PM, jimdare jamesdar...@gmail.com wrote: Hello, Using the dataset below, is there a way to generate a bar/line plot for the TACC/Catch of every lvl of stock? i.e. OR1,OR3,OR5

[R] Bar Plot with Connected Points on 1 Y-Axis

2009-01-06 Thread jimdare
Hi Everyone, Have created a bar plot of the data below using the following code: barplot(TACC,space=0,names.arg=Year). I now want to add a series of connected points to represent the catch. I tried to do this using line(Catch) or points(Catch), however both of these commands result in each

[R] Population Decay in R

2008-12-15 Thread jimdare
Hi, I am new to R. I am trying to plot the decay of a population over time (0-50yrs). I have the initial population value (5000) and the mortality rate (0.26/yr) and I can't figure out how to apply this so I get a remaining population value each year. In excel (ignoring headings) I would put