[R] Creating a specific skewed distribution

2009-06-09 Thread David Arnold
All, Can someone help me create a skewed distribution, mean = 30, with probability of selecting a random number from the distribution greater than or equal 60 equal to 10%? I need the probability density function to equal zero at zero, and have a maximum height at or near 30. Is this possible?

Re: [R] Creating a specific skewed distribution

2009-06-10 Thread David Arnold
n(rweibull(1e5,1.5,33)) [1] 29.77781 pweibull(60,1.5,33) [1] 0.9138475 I'm sure you can play with the parameters to try to get even closer to what you want. On Wed, Jun 10, 2009 at 2:48 AM, David Arnold> wrote: All, Can someone help me create a skewed distribution, mean = 30, with probab

[R] tikzDevice

2013-07-27 Thread David Arnold
All, What is the current method for installing tikzDevice in R version 3.0.1? I'd like to use it with knitr and RStudio. Thanks. D. -- View this message in context: http://r.789695.n4.nabble.com/tikzDevice-tp4672523.html Sent from the R help mailing list archive at Nabble.com. _

Re: [R] tikzDevice

2013-07-27 Thread David Arnold
I am using a MacBook Pro, 10.6.8, R version 3.0.1. and RStudio 0.97.551. I entered your command in the Console Window in RStudio and got the following reply: > install.packages('tikzDevice', repos='http://r-forge.r-project.org', > type='source') Warning in install.packages : package ‘tikzDevice’

Re: [R] tikzDevice

2013-07-27 Thread David Arnold
The following minimal example Sweave file compiled properly in RStudio. \documentclass{article} \begin{document} Example text outside R code here; we know the value of pi is \Sexpr{pi}. <>= set.seed(1213) # for reproducibility x = cumsum(rnorm(100)) mean(x) # mean of x plot(x, type = 'l') # B

[R] ggplot position_dodge requires constant width

2013-07-28 Thread David Arnold
Hi, library(ggplot2,plyr) qplot(carat,depth,data=diamonds, geom="boxplot", group=round_any(carat,0.1,floor), xlim=c(0,3)) Typing: warnings() Gives me: Warning messages: 1: position_dodge requires constant width: output may be incorrect How should the above code be adjusted t

[R] Dot plot similar to StatKey

2013-07-29 Thread David Arnold
Hi, I'd like to use R to produce the following plot: dotplot.jpeg This was constructed using StatKey at: http://www.lock5stat.com/statkey/bootstrap_1_quant/bootstrap_1_quant.html

[R] Masking

2013-09-14 Thread David Arnold
Hi, I'm a bit confused by masking. Thought I understood, but today makes me wonder. x=0:9 y=0:9 sm=data.frame(x=4:8,y=9:13) attach(sm) x detach(sm) The code produces this message: > attach(sm) The following object is masked _by_ .GlobalEnv: x, y > x [1] 0 1 2 3 4 5 6 7 8 9 I guess I tho

[R] Rounding

2013-01-05 Thread David Arnold
Hi, Can someone explain this: > options(digits=20) > 1/3 [1] 0.1483 Why the 1483 at the end? Thanks, David. david-arnolds-macbook-pro-2:~ darnold$ R --version R version 2.15.2 (2012-10-26) -- "Trick or Treat" Copyright (C) 2012 The R Foundation for Statistical Computing ISBN 3

[R] Random Rectangles

2013-01-09 Thread David Arnold
Hi, Just curious. Has anyone out there ever written a script to generate 100 random rectangles such as the ones shown on this page? http://www2.math.umd.edu/~jlh/214/Random%20Rectangles.pdf Thanks. D. -- View this message in context: http://r.789695.n4.nabble.com/Random-Rectangles-tp4655072

[R] SRS, Stratified, and Cluster sampling

2013-01-09 Thread David Arnold
Hi, Has anyone done (or know of) any nice R activities that help introductory students ( and teachers :) ) better understand the concepts of simple vs stratified vs cluster sampling? Any links? David -- View this message in context: http://r.789695.n4.nabble.com/SRS-Stratified-and-Cluster-sa

[R] Aligning labels to bars in barplot

2013-01-16 Thread David Arnold
Hi, Consider: x=c(2,4,5,10,13,73) names(x)=c("American\nIndian", "No\ncategory\nlisted", "Hispanic", "African-\nAmerican", "Asian", "White") barplot(x,main="Undergraduate Enrollment by Race", xlab="Race", ylab="Percent",

Re: [R] Aligning labels to bars in barplot

2013-01-16 Thread David Arnold
Nice, worked very well. But because of the realignment, I now need to lower by xlab a bit. Any suggestions? David. -- View this message in context: http://r.789695.n4.nabble.com/Aligning-labels-to-bars-in-barplot-tp4655701p4655749.html Sent from the R help mailing list archive at Nabble.com.

[R] Adding Latex to text

2013-02-06 Thread David Arnold
Hi, I'd like to add "alpha" in latex code to my image. Any suggestions? library(UsingR) BagA = c(rep(10,6),rep(20,5), rep(30,4),rep(40,3),rep(50,2),60,70) BagA BagB = c(10, 20,rep(30,2),rep(40,3),rep(50,4),rep(60,5),rep(70,6)) BagB par(mfrow = c(2, 1)) DOTplot(BagA) abline(v=60,lwd=2,lty=2,col="

[R] Data sets online for student use

2013-02-12 Thread David Arnold
All, If you have any good links for sites that contain data sets that can easily be accessed and copied (or downloaded) by students in introductory statistics, could you please share them? Thanks. David -- View this message in context: http://r.789695.n4.nabble.com/Data-sets-online-for-stude

Re: [R] Misundertanding of Levels

2013-02-16 Thread David Arnold
I am replying so that this will be accepted by the list. D. -- View this message in context: http://r.789695.n4.nabble.com/Misundertanding-of-Levels-tp4658320p4658781.html Sent from the R help mailing list archive at Nabble.com. __ R-help@r-project.

[R] Seeing Global Workspace and dealing with attach and detach

2013-02-19 Thread David Arnold
Hi, When writing a script, I often start with: library(ISwR) attach(thuesen) Then write some more code, testing it as I write to see if it runs. Then, at the end, a final: detach(thuesen) However, what happens is that I often get errors, which cause an attach, but no subsequent detach. Now, I

[R] Scatterplot, Color by Grade Category

2013-02-20 Thread David Arnold
Hi, I have: hours=c(5,6,6,7,7,8,8,9,7,8,8,8,9,9,10,10,9,10,10,11,11,11,12); level=c(1.0,1.2,0.8,0.8,1.0,1.0,0.6,0.8,1.4,1.2,1.4,1.6, 1.2,1.4,1.0,1.4,1.6,1.6,1.8,1.4,1.6,1.8,1.6); grade=c(rep("First",8),rep("Second",8),rep("Third",7)) length(hours) length(level) length(grade) data=data.fra

[R] prop.test correct true and false gives same answer

2013-03-27 Thread David Arnold
All, How come both of these are the same. Both say "1-sample proportions test without continuity correction." I would suspect one would say "without" and one would say "with." > prop.test(118,236,.5,correct=FALSE,conf.level=0.95) 1-sample proportions test without continuity correction

[R] prop.test vs hand calculated confidence interval

2013-04-03 Thread David Arnold
Hi, This code: n=40 x=17 phat=x/n SE=sqrt(phat*(1-phat)/n) zstar=qnorm(0.995) E=zstar*SE phat+c(-E,E) Gives this result: [1] 0.2236668 0.6263332 The TI Graphing calculator gives the same result. Whereas this test: prop.test(x,n,conf.level=0.99,correct=FALSE) Give this result: 0.2489036 0.6

[R] t-statistic for independent samples

2013-04-17 Thread David Arnold
Hi, Typical things you read when new to stats are cautions about using a t-statistic when comparing independent samples. You are steered toward a pooled test or welch's approximation of the degrees of freedom in order to make the distribution a t-distribution. However, most texts give no informati

Re: [R] t-statistic for independent samples

2013-04-17 Thread David Arnold
OK,although the variance ratio was already 2.25 to 1, tried sigma1=10, sigma2=25, which makes the ratios of the variances 6.25 to 1. Still no change. See: http://msemac.redwoods.edu/~darnold/math15/R/chapter11/DistributionForTwoIndependentSamplesPartII.html D. -- View this message in context

[R] simulating a toss of a coin

2012-10-09 Thread David Arnold
All, I've devised a way to toss a coin three times and record the number of heads, then use the table command to summarize the number of time 0, 1, 2, or 3 heads were obtained. n <- 100 x <- sample(c("H","T"),3*n,replace=TRUE) dim(x) <- c(3,n) num_heads <- apply(x,2,function(x) sum(x=="H")) tab

[R] Margin annotation

2012-10-21 Thread David Arnold
I have this code: x=seq(80-3*15,80+3*15,length=200); y=dnorm(x,80,15) plot(x,y,type="l",lwd=2,col="red") x=seq(80-3*15,70,length=100) y=dnorm(x,80,15) polygon(c(0,x,70),c(0,y,0),col="gray") text(70,0.005,"70") I'd like to draw the number "70" in red underneath a vertical arrow pointing to the pos

[R] Downloading a html table

2012-10-22 Thread David Arnold
All, A friend of mine would like to use this data with his stats class: http://www.worldatlas.com/aatlas/populations/usapoptable.htm I can't figure a way of capturing this data due to the mysql commands in the source code. Any thoughts? David. -- View this message in context: http://r.7896

[R] Compraring two independent samples

2012-11-15 Thread David Arnold
Hi, In my reading of pairing means of two independent samples, I read statements such as the standard error of the meanof X1 minus the mean of X2 is the square root of s1^2/n1+s2^2/n2. Then I read: "We could now derive the two independent samples confidence interval and test statistic. However, a

[R] Analysis of Variance

2012-11-29 Thread David Arnold
Hi, I am encountering a difficulty I don't understand. Be patient, I'm very new to analysis of variance. If I load this data: example12_7=read.table("http://msemac.redwoods.edu/~darnold/math15/data/chapter12/example12_7.dat",header=TRUE) The run the oneway.test: oneway.test(time~drug,data=examp

[R] Unstack a dataframe using RCommander

2014-01-03 Thread David Arnold
Hi, Looking to see how to unstack a dataframe using RCommander. The dataset I'm using is: http://www.sagepub.com/dsur/study/DSUR%20Data%20Files/Chapter%209/SpiderLong.dat I want to use RCommander to change it to this form: http://www.sagepub.com/dsur/study/DSUR%20Data%20Files/Chapter%209/Spider

[R] "With" question

2013-09-17 Thread David Arnold
All, Trying to avoid using attach and detach while teaching class in Intro Stats. data=read.delim("dataset1.dat",header=TRUE) with(data,{ sort(age) length(age) (age[10]+age[11])/2 }) However, this code only produces output for the last line between the curly braces. Granted, as we type the

[R] xlim with barplot

2013-09-22 Thread David Arnold
Hi, I want to compare to barplots with same horizontal axis limits. x=c(55,56,57,58,59,60,60,60,61,62,63,64,65) y=c(35,40,45,50,55,60,60,60,65,70,75,80,85) par(mfrow=c(2,1)) barplot(table(x),xlim=c(35,85)) barplot(table(y),xlim=c(35,85)) par(mfrow=c(1,1)) But the bars disappear.

[R] Installing R, R packages

2013-09-23 Thread David Arnold
All, Consider this attempt: > install.packages("car") trying URL 'http://cran.cnr.Berkeley.edu/bin/macosx/contrib/3.0/car_2.0-19.tgz' Content type 'application/x-gzip' length 1326903 bytes (1.3 Mb) opened URL == downloaded 1.1 Mb car/data/Rdata.rdb: Truncat

[R] Verzani cover figure

2013-10-05 Thread David Arnold
Hi, Has anyone ever coded the figure on the cover of UsingR for Introductory Statistics by John Verzani? D. -- View this message in context: http://r.789695.n4.nabble.com/Verzani-cover-figure-tp4677680.html Sent from the R help mailing list archive at Nabble.com.

[R] Math notation in a title

2013-10-15 Thread David Arnold
Hi, I'd like to put the following in a main title of a plot. Can someone show me how to do this? Thanks. D. -- View this message in context: http://r.789695.n4.nabble.com/Math-notation-in-a-title-tp4678299.html Sent from the R help ma

[R] Setting axis scale for a boxplot

2013-11-18 Thread David Arnold
Hi, I have this code: par(mfrow=c(3,1)) x1=rnorm(10,60,1) x2=rnorm(10,65,1) x3=rnorm(10,70,1) boxplot(x1,x2,x3,horizontal=TRUE,main="Example 1") x1=rnorm(10,60,4) x2=rnorm(10,65,4) x3=rnorm(10,70,4) boxplot(x1,x2,x3,horizontal=TRUE,main="Example 2") x1=rnorm(10,60,9) x2=rnorm(10,65,9) x3=rnorm

Re: [R] Setting axis scale for a boxplot

2013-11-20 Thread David Arnold
Thanks, these replies worked. D. -- View this message in context: http://r.789695.n4.nabble.com/Setting-axis-scale-for-a-boxplot-tp4680704p4680821.html Sent from the R help mailing list archive at Nabble.com. __ R-help@r-project.org mailing list htt

[R] Label point with (x,hat(y))

2013-11-23 Thread David Arnold
Hi, I'd like to do this: text(1,3,"(x,yhat)",pos=3) But using (x,hat(y)). Any suggestions? D. -- View this message in context: http://r.789695.n4.nabble.com/Label-point-with-x-hat-y-tp4681049.html Sent from the R help mailing list archive at Nabble.com.

Re: [R] Label point with (x,hat(y))

2013-11-24 Thread David Arnold
Thanks, that worked well. D. -- View this message in context: http://r.789695.n4.nabble.com/Label-point-with-x-hat-y-tp4681049p4681065.html Sent from the R help mailing list archive at Nabble.com. __ R-help@r-project.org mailing list https://stat.et

[R] Creating a set that has line of best fit y=3+2x so that SST, SSR, SSE are whole numbers

2013-11-24 Thread David Arnold
I wanted to find a set (x,y) of integers so that their line of best fit was y = 3 + 2x. So I thought I'd be losing 2 degrees of freedom and chose 1,2,3,4, and x for my explanatory data and 3, 8, 8, 12, and y for my response data. I then used b = (n sum(xy) - sum(x)sum(y))/(n sum(x^2) - (sum(x)

[R] Sizing axis labels in ggplot2

2013-12-03 Thread David Arnold
All, Say I do: require(ggplot2) names(PlantGrowth) bp <- ggplot(PlantGrowth,aes(x=group,y=weight))+geom_boxplot() But the default axis labels and tick labels are just too small for me to read. What is the easiest was to enlarge the font size of axis labels and tick labels? Thanks. D. -- Vi

[R] Frequency plot --- stacked symbols

2011-02-08 Thread David Arnold
Hi, We were wondering how we could make a stacked frequency diagram such as this one: http://msemac.redwoods.edu/~darnold/math15/liz.pdf We don't necessarily need the shaded "balls", other characters would be fine, such as stacks of x's. David __ R-

Re: [R] Frequency plot --- stacked symbols

2011-02-08 Thread David Arnold
1,at=0,bg="lightblue",col="blue",offset=.5,cex=1.5,xlim=c(0,10)) > > and set 'pch' as you wish, e.g. as in > > example(points) > > hth. > > Am 08.02.2011 08:27, schrieb David Arnold: >> Hi, >> >> We were wondering how we c

[R] Adjusting format of boxplot

2012-07-12 Thread David Arnold
Hi, I managed to use the attached data set and figure out the following: flies <- read.table("example12_1.dat",header=TRUE,sep="\t") boxplot(long ~ group, data = flies, horizontal = TRUE, col = "red") I'm very new to R and would like some help with the following: 1. Chan

[R] Loading Chess Data

2012-09-02 Thread David Arnold
All, What would be the most efficient way to load the data at the following address into a dataframe? http://ratings.fide.com/top.phtml?list=men Thanks, David -- View this message in context: http://r.789695.n4.nabble.com/Loading-Chess-Data-tp4642006.html Sent from the R help mailing list a

[R] Horizontal grid in background of barplot

2012-09-03 Thread David Arnold
All, I have: x <- matrix(c(22,3,6,69,9,4,7,81,23,4,22,50),nrow=3,byrow=TRUE) rownames(x) <- c("Cold or flu","Headache","Backache"); colnames(x) <- c("Went to doctor","No response","Did nothing","Self-medicated") x <- t(x) print(x) barplot(x,beside=TRUE, ylim=c(0,90), xlab="Ailment

[R] Adding summary title to table

2012-09-03 Thread David Arnold
All, I have: x <- matrix(c(22,3,6,69,9,4,7,81,23,4,22,50),nrow=3,byrow=TRUE) rownames(x) <- c("Cold or flu","Headache","Backache"); colnames(x) <- c("Went to doctor","No response","Did nothing","Self-medicated") x <- t(x) print(x) 1. I'd like to add the title "Nutritional Status" above the colum

[R] No room for labels in barplot

2012-09-06 Thread David-Arnold
All, I have: sales <- c(2300,900,155,102,42,10) names(sales) <- c("Christmas","Valentine's Day", "Mother's Day","Father's Day", "Thanksgiving","New Year's Day") barplot(sales,ylim=c(0,2500)) But it doesn't place all of the name labels on the plot. So I tried: sales <- c(23

[R] Importing data with different delimters

2008-06-13 Thread David Arnold
All, I have a data file with 56 entries that looks like this: City State JanTemp Lat Long Mobile, AL 44 31.288.5 Montgomery, AL 38 32.986.8 Phoenix, AZ 35 33.6112.5 Little Rock, AR 31 35.492.8 Los Angeles, CA 47 34.3118.7 San Franci

Re: [R] plotting regression line

2008-06-14 Thread David Arnold
Linda, Been working on that: http://msenux.redwoods.edu/mathdept/R/TransformingData.php Along with some other activities: http://msenux.redwoods.edu/mathdept/R/index.php David Arnold http://online.redwoods.edu/instruct/darnold On Jun 14, 2008, at 2:51 AM, **linda** wrote: > > Hello,

Re: [R] Superimposing Line over Histogram in Density Plot

2008-06-16 Thread David Arnold
Look here: http://msenux.redwoods.edu/mathdept/R/CentralLimit.php D. On Jun 15, 2008, at 11:25 PM, Gundala Viswanath wrote: Hi, Currently I have a density plot generated with this snippet. Is there a way I can add a line curve on top of it? I mean in one figure __BEGIN__ myhist <- hist

[R] Differential Equations

2008-06-17 Thread David Arnold
All, I've found odesolve and lsoda. Any other packages for differential equations? Any good tutorials on using R and solving differential and partial differential equations? D. __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/lis