[R] Aligning barplot

2012-08-26 Thread darnold
All, Consider: BagA <- c(-1000,10,10,10,10,10,10, 10,20,20,20,20,20,20,30, 30,40,40,50,60) BagB <- c(10,20,30,30,40,40,50,50, 50,50,50,50,60,60,60,60, 60,60,60,1000) layout(c(2,1)) barplot(table(BagB)) barplot(table(BagA)) At this point, I'd like to arr

Re: [R] Aligning barplot

2012-08-26 Thread darnold
s(tblA) tblA <- as.vector(tblA) tblA[8] <- 0 names(tblA) <- c(tblAnames,"1000") tblB <- table(BagB) tblBnames <- names(tblB) tblB <- as.vector(tblB) tblB <- c(0,tblB) names(tblB) <- c("-1000",tblBnames) layout(c(2,1)) barplot(tblB) barplot(tblA) Any better i

Re: [R] Aligning barplot

2012-08-26 Thread darnold
lA <- c(tblA,0) names(tblA) <- c(names(table(BagA)),"1000") tblB <- table(BagB) tblB <- c(0,tblB) names(tblB) <- c("-1000",names(table(BagB))) layout(c(2,1)) barplot(tblB, main="Bag B") barplot(tblA, main="Bag A") D. David Winsemi

Re: [R] Two selections from Bag A

2012-08-26 Thread darnold
Here are the two tables from Aligaga. The first is table 1.1 and the second is table 1.2. http://r.789695.n4.nabble.com/file/n4641344/table1_1.jpg http://r.789695.n4.nabble.com/file/n4641344/table1_2.jpg David Arnold College of the Redwoods -- View this message in context: http://r.789695.

[R] Two selections from Bag A

2012-08-25 Thread darnold
All, I am looking at an example in Aliaga's Interactive Statistics. Bag A has the following vouchers. BagA <- c(-1000,10,10,10,10,10,10, 10,20,20,20,20,20,20,30, 30,40,40,50,60) Bag B has the following vouchers. BagB <- c(10,20,30,30,40,40,50,50, 50,50,50,50,60,60,6

Re: [R] Turning of source echo

2012-08-25 Thread darnold
Berend, Yes, I did ask this question on RStudio help page. Josh suggested that I try to find some package that pops up a window with the results I want. Anyone know how to do that? Is there a package or a tutorial that will instruct me as to how to do that? Here is my code: BAGA <- c(10,20,20,3

Re: [R] Turning of source echo

2012-08-25 Thread darnold
Noia, Nope. Although sep is helpful for my output, I still get that source echo that I want to suppress. Here is the code with Noia's suggestion. BAGA <- c(10,20,20,30,30,30,30,40, 40,40,40,50,50,50,50,50, 60,60,60,60,60,70,70,70, 70,80,80,80,90,90,100) BAGB <- c(1

[R] Turning of source echo

2012-08-24 Thread darnold
HI, I have this code: BAGA <- c(10,20,20,30,30,30,30,40, 40,40,40,50,50,50,50,50, 60,60,60,60,60,70,70,70, 70,80,80,80,90,90,100) BAGB <- c(10,10,10,10,10,20,20,20, 20,30,30,30,40,40,50,60, 70,70,80,80,80,90,90,90, 90,100,100,100,100

[R] Beside Barplot

2012-08-20 Thread darnold
All, Is there a way to get a barplot with beside for the following without reshaping mydata? opinion <- c("Almost no chance", "Probably Not","50-50 Chance","A good chance","Almost certain") female <- c(96,426,696,663,486) male <- c(98,286,720,758,597) mydata<-data.frame(opinion,female,male) Th

Re: [R] Reading one column .csv file

2012-08-15 Thread darnold
Worked! Thanks. David. -- View this message in context: http://r.789695.n4.nabble.com/Reading-one-column-csv-file-tp4640396p4640462.html Sent from the R help mailing list archive at Nabble.com. __ R-help@r-project.org mailing list https://stat.ethz

Re: [R] Reading one column .csv file

2012-08-15 Thread darnold
Tried that already. My clipboard: x 2 3 4 5 My attempt: > a <- read.delim(pipe("pbpaste")) Warning message: In read.table(file = file, header = header, sep = sep, quote = quote, : incomplete final line found by readTableHeader on 'pbpaste' And again: > a <- read.delim(pipe("pbpaste"),head

Re: [R] Reading one column .csv file

2012-08-15 Thread darnold
Peter, Interesting. Never heard of copying from the clipboard. I am also on a MacBook Pro, but I cannot get it to work. 1. I selected the column of data (including the header) in Excel. 2. Selected Edit->Copy. 3. In R, tried: > a <- read.delim("clipboard") Error in file(file, "rt") : cannot o

[R] Reading one column .csv file

2012-08-15 Thread darnold
My friend sent an Excel file: http://msemac.redwoods.edu/~darnold/temp/cyu01_iqscores.xls http://msemac.redwoods.edu/~darnold/temp/cyu01_iqscores.xls I opened it in Excel, saved is as cyu01_iqscores.csv, then imported it into R with: iqscores=read.csv('cyu01_iqscores.csv',header=

Re: [R] Head or Tails game

2012-08-03 Thread darnold
Wow! Some great responses! I am getting some great responses. I've only read David, Michael, and Dennis thus far, leading me to develop this result before reading further. lead <- function(x) { n <- length(x) count <- 0 if (x[1] >= 0) count <- count + 1 for (i in 2:n) { if (x[i] > 0 |

Re: [R] Head or Tails game

2012-08-03 Thread darnold
David, set.seed(123) # always good to make reproducible winnings <- sum(sample(c(-1,1), 1, replace=TRUE)) Unfortunately, that's not the game. The game requires 40 flips of a coin. Then you have to play the game 10,000 times. D. -- View this message in context: http://r.789695.n4.nabb

[R] Head or Tails game

2012-08-03 Thread darnold
or the help. Great list. David Arnold College of the Redwoods Eureka, CA http://msemac.redwoods.edu/~darnold/index.php -- View this message in context: http://r.789695.n4.nabble.com/Head-or-Tails-game-tp4639142.html Sent from the R help mailing list archive at Nabble.com. __

[R] Printing contents of a variable

2012-08-03 Thread darnold
All, Can someone explain why this does not print the contents of x when I source this file? CoinTosses <- function(n,print=TRUE) { x <- sample(c(0,1), n, replace=TRUE) y <- x y[y==0] <- "T" y[y==1] <- "H" p <- sum(x)/n p } x <- CoinTosses(40) x On the other hand, if I source this fi

[R] Printing a summary

2012-08-03 Thread darnold
All, Is this typical of how people will print a summary of results? CoinTosses <- function(n) { x <- sample(c(0,1), n, replace=TRUE) y <- x y[y==0] <- "T" y[y==1] <- "H" numHeads <- sum(x) numTails <- n-sum(x) p <- numHeads/n cat(cat(y,sep=""),"\n") cat("Number of heads: ", numH

Re: [R] rhsape2 bug?

2012-07-21 Thread darnold
Ista, You are correct. > search() [1] ".GlobalEnv""package:reshape" "package:plyr" [4] "package:reshape2" "tools:rstudio" "package:stats" [7] "package:graphics" "package:grDevices" "package:utils" [10] "package:datasets" "package:methods" "Autoloads" [13

[R] rhsape2 bug?

2012-07-21 Thread darnold
All, I believe I am running the latest version of rshape2 (1.2.1). But this code: library(reshape2) tmp <- melt(smiths, id.vars=1:2, measure.vars=c("age","weight","height"), variable.name="myvars", value.name="myvals" ) names(tmp) Produces this output: > names(tmp) [1] "su

[R] Library control

2012-07-21 Thread darnold
All, 1. Is there a command that tells you what libraries are loaded? 2. How do you remove a library that has been loaded? 3. If you have loaded a library that masks previously loaded objects, how can you tell which object is being run? In Matlab, I would run "which f" to determine the location o

Re: [R] Last answer

2012-07-19 Thread darnold
All, Thanks. That works. D. -- View this message in context: http://r.789695.n4.nabble.com/Last-answer-tp4637151p4637157.html Sent from the R help mailing list archive at Nabble.com. __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman

[R] Last answer

2012-07-19 Thread darnold
Hi, In Matlab, I can access the last computation as follows: >> 2+3 ans = 5 >> ans ans = 5 Anything similar in R? David -- View this message in context: http://r.789695.n4.nabble.com/Last-answer-tp4637151.html Sent from the R help mailing list archive at Nabble.com.

[R] Entering Data Files

2012-07-18 Thread darnold
Hi, Entering data from a given file is the hardest part of learning R for me. For example, I have this datafile from Moore's text: LiveAge Count Parents Age19 324 Another Age19 37 OwnPlaceAge19 116 Group Age19 58 Other Age19 5 Parents Age20 378 Another Age20 47 O

[R] Regression Identity

2012-07-17 Thread darnold
Hi, I see a lot of folks verify the regression identity SST = SSE + SSR numerically, but I cannot seem to find a proof. I wonder if any folks on this list could guide me to a mathematical proof of this fact. Thanks. David. -- View this message in context: http://r.789695.n4.nabble.com/Regressi

[R] Arrange two columns into a five variable dataframe

2012-07-13 Thread darnold
Hi, I hope that folks can give me some simple approaches to taking the data set below, which is accumulated in two columns called "long" and "group", then arrange the data is the "long" column into a data frame containing five variables: "Group 1", "Group 2", "Group 3", "Group 4", and "Group 5".

Re: [R] Side by side strip charts

2012-07-13 Thread darnold
Very nice suggestion. I am getting some very kind help here. x1 <- round(rnorm(10,60,3)) x2 <- round(rnorm(10,65,3)) x3 <- round(rnorm(10,70,3)) stripchart(list(sample1=x1,sample2=x2,sample3=x3), method="stack", pch=4, offset=1/2, col="blue",

Re: [R] Side by side strip charts

2012-07-13 Thread darnold
las=1) Any ideas on how to get an axes drawn under each one as in the image? Thanks. David Arnold College of the Redwoods http://msemac.redwoods.edu/~darnold/index.php -- View this message in context: http://r.789695.n4.nabble.com/Side-by-side-strip-charts-tp4636399p4636464.html Sent

[R] Side by side strip charts

2012-07-12 Thread darnold
Hi, I'm looking for some ideas on how to reproduce the attached image in R. There are three samples, each of size n = 10. The first is drawn from a normal distribution with mean 60 and standard deviation 3. The second is drawn from a normal distribution with mean 65 and standard deviation 3. The t

Re: [R] Adjusting format of boxplot

2012-07-12 Thread darnold
Added your code: flies <- read.table("example12_1.dat",header=TRUE,sep="\t") flies$group <- factor(flies$group,5:1) levels(flies$group) <- paste0("Group ",5:1) boxplot(long ~ group, data = flies, pars = list(las=1, ylim=c(10,110), xaxt="n", bty="n"), horizontal = TRUE,

Re: [R] Adjusting format of boxplot

2012-07-12 Thread darnold
Looks like data was not attached. Here is is. longgroup 40 1 37 1 44 1 47 1 47 1 47 1 68 1 47 1 54 1 61 1 71 1 75 1 89 1 58 1 59 1 62 1 79 1 96 1 58 1 62 1 70 1 72 1 74 1 96

[R] browser() question

2012-07-11 Thread darnold
All, How come i=1 in the first case, but i=2 in the second case. The second case seems to work, but the first case does not. David. > findruns <- function(x,k) { + n <- length(x) + runs <- NULL + for (i in 1:(n-k+1)) { + if (all(x[i:(i+k-1)]==1)) runs <- c(runs,i) + browser(i>1) +