Re: [R] fit data to y~A+B*sin(C*x)

2012-02-14 Thread David L Carlson
2 0.922 > nlmod Nonlinear regression model model: Y ~ A + B * sin(C * X) data: mydata A B C 1.999 5.002 1.000 residual sum-of-squares: 0.007378 Number of iterations to convergence: 3 Achieved convergence tolerance: 1.499e-08 ----

Re: [R] cumsum function to determine plankton phenology

2012-02-14 Thread David L Carlson
differences, not just the two smallest absolute values. -- David L Carlson Associate Professor of Anthropology Texas A&M University College Station, TX 77843-4352 -Original Message- From: r-help-boun...@r-project.org [mailto:r-help-boun.

Re: [R] error with persp()- increasing 'x' and 'y' values expected

2012-02-21 Thread David L Carlson
t;- 1:15 > z <- outer(x, y, "*") > persp(x, y, z) You must define a grid and specify a single value at each point on that grid. ---------- David L Carlson Associate Professor of Anthropology Texas A&M University College Station, TX

Re: [R] In R 2.14.1, what does wrong sign in 'by' argument mean?

2012-02-21 Thread David L Carlson
Don't delete the context of the message. If you are sure that windowsize is positive, are you also sure that it is less than length(inputseq)? > seq(1, -10, 1) Error in seq.default(1, -10, 1) : wrong sign in 'by' argument ---------- David L

Re: [R] Frequencies from x/y data into a 2d table (for 3d histogram or heatmap)

2012-02-29 Thread David L Carlson
commands to label it properly. ---------- David L Carlson Associate Professor of Anthropology Texas A&M University College Station, TX 77843-4352 -Original Message- From: r-help-boun...@r-project.org [mailto:r-help-boun...@r-project.org] On Behalf Of

Re: [R] Data frame vs matrix quirk: Hinky error message?

2012-05-01 Thread David L Carlson
[3,]3 NA 11 [4,] NA8 NA > zdf[jx] <- NA > zdf X1 X2 X3 1 1 NA 9 2 NA 6 NA 3 3 NA 11 4 NA 8 NA ---------- David L Carlson Associate Professor of Anthropology Texas A&M University College Station, TX 77843-4352 > -Origi

Re: [R] PLot a matrix

2012-05-06 Thread David L Carlson
select your own colors, line types, and add a legend: ?matplot ?legend If you want separate plots in one plot window: par(mfrow=c(2, 3)) for (i in 1:5) { plot(TSdata[,i], ylab=paste("V", i, sep=""), type="l") } -- David

Re: [R] commenting out a block of R code

2012-05-07 Thread David L Carlson
In RStudio select the lines to be commented (or uncommented) and press Ctrl+/ or select comment/uncomment on the Edit menu tab -- David L Carlson Associate Professor of Anthropology Texas A&M University College Station, TX 77843-4352 > -O

Re: [R] convert 400 numeric variables to categorical together

2012-05-08 Thread David L Carlson
.5), 0) for (i in 11:20) X[,i] <- rnorm(20) str(X) # structure of X # convert numbers to factors for the first 10 columns X2 <- X for (i in 1:10) X2[,i] <- factor(X[,i]) str(X2) ------ David L Carlson Associate Professor of Anthropology Texas

Re: [R] Random resampling of columns in species association matrices

2012-05-09 Thread David L Carlson
interactions with that host. Use sample() to randomly draw a host. You'll probably want to combine the vectors into a list to automate the process over all parasites. -- David L Carlson Associate Professor of Anthropology Texas A&M Universit

Re: [R] Help with writing data to csv

2012-05-14 Thread David L Carlson
at packages xlsx, xlsReadWrite, and R2wd. ---------- David L Carlson Associate Professor of Anthropology Texas A&M University College Station, TX 77843-4352 > -Original Message- > From: r-help-boun...@r-project.org [mailto:r-help-bounces@r- > project.

Re: [R] how to write data using xlsReadWrite

2012-05-14 Thread David L Carlson
You didn't tell us what your problem is, but it probably relates to the fact that mydata is never defined. -- David L Carlson Associate Professor of Anthropology Texas A&M University College Station, TX 77843-4352 > -Original Message---

Re: [R] How do I do group wise clustering in R?

2012-05-14 Thread David L Carlson
Look at the aggregate function to create a new data.frame in which you have M rows that have the means of the K variables for each group. Then use cluster analysis to cluster the M groups. -- David L Carlson Associate Professor of Anthropology Texas A&a

Re: [R] New to R

2012-05-14 Thread David L Carlson
Views from the list on the left. -- David L Carlson Associate Professor of Anthropology Texas A&M University College Station, TX 77843-4352 > -Original Message- > From: r-help-boun...@r-project.org [mailto:r-help-bounces@r- > pr

Re: [R] select data

2012-05-14 Thread David L Carlson
This overwrites the data so you might want to create a copy first. example <- data.frame(V1=c(3, -1), V2=c(-2, 4), V3=c(4, 1)) tf <- ifelse(example<0, TRUE, FALSE) example[tf] <- NA apply(example, 1, mean, na.rm=TRUE) ---------- David L Carls

Re: [R] How to Un-group a grouped data set?

2012-05-15 Thread David L Carlson
ant to clean up the rownumbers with rownames(newdats) <- 1:nrow(newdats) ------ David L Carlson Associate Professor of Anthropology Texas A&M University College Station, TX 77843-4352 > -Original Message- > From: r-help-boun...@r-project

Re: [R] Probabilistic aggregation

2012-05-15 Thread David L Carlson
To generate multivariate normal distributions, you will want mvrnorm in package MASS. > -Original Message- > From: r-help-boun...@r-project.org [mailto:r-help-bounces@r- > project.org] On Behalf Of Petr Savicky > Sent: Tuesday, May 15, 2012 7:14 AM > To: r-help@r-project.org > Subject: Re:

Re: [R] save to Rdata file and to txt

2012-05-15 Thread David L Carlson
capture.output(moransI, file="moransI.txt") ------ David L Carlson Associate Professor of Anthropology Texas A&M University College Station, TX 77843-4352 > -Original Message- > From: r-help-boun...@r-project.org [mai

Re: [R] Lattice: Add abline to Single Value qqmath() Plot

2012-05-15 Thread David L Carlson
Deepayan Sarkar's webpage. This is a simple example modified from the example in the lattice package manual: qqmath(~ rnorm(100), panel = function(x, ...) { panel.qqmathline(x, ...) panel.qqmath(x, ...) }) -- David L Carlson Associate Prof

Re: [R] Help needed for efficient way to loop through rows and columns

2012-05-16 Thread David L Carlson
loop). -- David L Carlson Associate Professor of Anthropology Texas A&M University College Station, TX 77843-4352 > -Original Message- > From: r-help-boun...@r-project.org [mailto:r-help-bounces@r- > project.org] On Behalf Of Priya Bhatt > Sent: Wednesday,

Re: [R] Reading Excel Formulas as values

2012-05-16 Thread David L Carlson
t the formulas as factors. I don't get any NA's. I can also place a formula on the second sheet that accesses data from the first sheet without any problems. I haven't tried, Excel 2010. Could your formulas be accessing data from another spreadsheet? ------

Re: [R] Help needed for efficient way to loop through rows and columns

2012-05-17 Thread David L Carlson
mod[,2:4] <- NA # Recoded values into samplemod for (i in 1:nrow(sample)) { for (j in 2:4) { if (!is.na(sample[i,j])){ if (sample[i, 5] == "A") { samplemod[i,j] <- switch(sample[i,j], AA = 2, AB = 1, BA = 1, BB = 0) } else { if (sam

Re: [R] Finding the principal components

2012-05-18 Thread David L Carlson
d with one another or you have more variables than cases. The function prcomp also computes PCs but it uses singular value decomposition rather than matrix inversion. ------ David L Carlson Associate Professor of Anthropology Texas A&M University Colle

Re: [R] Loop Help

2012-05-21 Thread David L Carlson
Here is a slightly different approach that takes advantage of recycling: # Make 7 data frames for (i in 1:7) { assign(paste("TOWER", i, sep=""), data.frame(A=letters[1:4], X=rnorm(4))) } # Add Tower column taking advantage of recyling tnames <- paste("TOWER", 1:7, sep="") for (i in 1:7) {

Re: [R] Loop Help

2012-05-21 Thread David L Carlson
I should have added TOWER$Tower <- factor(TOWER$Tower) To the end to convert Tower from an integer to a factor. -- David L Carlson Associate Professor of Anthropology Texas A&M University College Station, TX 77843-4352 > -Origin

Re: [R] write.xls

2012-05-23 Thread David L Carlson
ccomplishes what you want read<-read.xlsx("D:\\FYP\\image\\Cropped Images\\user227\\user227forger.xlsx", sheetName="Sheet1") ---------- David L Carlson Associate Professor of Anthropology Texas A&M University College Station, TX 7784

Re: [R] Exclude when sd=0

2012-05-24 Thread David L Carlson
2, sd) > 1e-10)] ---------- David L Carlson Associate Professor of Anthropology Texas A&M University College Station, TX 77843-4352 > -Original Message- > From: r-help-boun...@r-project.org [mailto:r-help-bounces@r- > project.org] On Behalf Of Chris Burns > Sent: Wednesday,

Re: [R] applying cbind (or any function) across all components in a list

2012-05-24 Thread David L Carlson
ern[,2]])/2) } } Combine(l1, l2) This simply prints the results, but you didn't indicate how you wanted the output organized. ---------- David L Carlson Associate Professor of Anthropology Texas A&M University College Station, TX 77843-4352 >

Re: [R] applying cbind (or any function) across all components in a list

2012-05-25 Thread David L Carlson
2)) lnew <- lapply(1:length(l1), function(i) (l1[[i]][,pattern[,1]]+l2[[i]][,pattern[,2]])/2) lnew If all the information from your several posts had been included in the original request, we could have responded more quickly. ---------- David L Carlso

Re: [R] Filling NA with cumprod?

2012-05-25 Thread David L Carlson
1 <- a alag <- c(NA, a1[1:length(a1)-1]) # change NA to the value to use if the first value in a is NA while (sum(is.na(a1)) > 0) { a1 <- ifelse(is.na(a1), f*alag, a1) alag <- c(NA, a1[1:length(a1)-1]) } ---------- David L Carlson Associate

Re: [R] import contingency table

2012-05-28 Thread David L Carlson
How about this? exdf <- read.table("clipboard", sep=",", header=T, row.names=1) extbl <- as.table(as.matrix(exdf)) ---------- David L Carlson Associate Professor of Anthropology Texas A&M University College Station, TX 77843-

<    5   6   7   8   9   10