Re: [R] Conditional model in R

2012-11-29 Thread Jean V Adams
Kirsten, The overall model is the combination of both models. If you call the parameter estimates from the logistic regression betas and the parameter estimates from the linear regression alpha, you could write the predictive equation something like this (ignoring error terms): cover

Re: [R] How to subtract the counter i in for loop?

2012-11-29 Thread Jean V Adams
Mike, Based on this example, what do you want samples to look like? It's not clear to me what you're trying to do with i-1 Jean C W tmrs...@gmail.com wrote on 11/29/2012 03:55:12 PM: Hi list, I am writing a for loop that looks like this: samples-rep(NA,10) x -

Re: [R] Data Cleaning -New user coming from SAS

2012-11-29 Thread Jean V Adams
Other readers of this list may have better suggestions for how to read in data with interspersed header rows, but here's a work-around to do specifically what you requested ... # find the rows where Loan is in the Date column sel - grep(Loan, dat$Date) # create a new vector with these row

Re: [R] Coerce rownames to factor for ordering

2012-11-29 Thread Jean V Adams
Josh, The code you submitted is not reproducible. I don't have the following objects: barchart, DataToPlot..SeCl, or Colors. However, I think I can answer your questions, with some modified code ... A rowname can't be a factor. But you can still use a factor to sort the rows of your

Re: [R] How to subtract the counter i in for loop?

2012-11-29 Thread Jean V Adams
, 2012 at 5:39 PM, Jean V Adams jvad...@usgs.gov wrote: Mike, Based on this example, what do you want samples to look like? It's not clear to me what you're trying to do with i-1 Jean C W tmrs...@gmail.com wrote on 11/29/2012 03:55:12 PM: Hi list, I am

Re: [R] zeros in double matrix rather than character matrix

2012-11-28 Thread Jean V Adams
Irucka, What is the code that you are using that results in a character matrix? What does the character matrix look like? If your matrix is called m, submit the following code and share the results with us. m[1:6, ] as.numeric(m[1:6, ]) Jean iembry iruc...@mail2world.com wrote on 11/27/2012

Re: [R] Using factor variables with overlapping categories

2012-11-28 Thread Jean V Adams
Andrew, Interesting issue. My tack would be to define an age key that incorporates all of the different cut-points that are used in your data tables. Then, with the use of some simple functions, you can test which factors are nested within other factors, and you can broaden those categories

Re: [R] zeros in double matrix rather than character matrix

2012-11-28 Thread Jean V Adams
introduced by coercion -Original Message- From: Jean V Adams [jvad...@usgs.gov] Sent: 11/28/2012 7:21:16 AM To: iruc...@mail2world.com Cc: r-help@r-project.org Subject: Re: [R] zeros in double matrix rather than character matrix Irucka, What is the code that you are using

Re: [R] Help on function please

2012-11-27 Thread Jean V Adams
Andras, What do you want your code to do? Give us a little explanation with your code. When I try to run your code, I get Error: could not find function genoud. Either supply the code for the functions included in your code, or tell us what packages we need to run it. Jean Andras

Re: [R] glm convergence warning

2012-11-27 Thread Jean V Adams
It could be that for some levels of your independent factor variables (WS, SS), the response is either all zeroes or all ones. Or, for your continuous independent variables (DV, DS), there is a clean break between the zeroes and ones. For example, if all the CIDs are one when DS = 18 but all

Re: [R] Accumulate objects in list after try()

2012-11-27 Thread Jean V Adams
Create an empty list called result before you run the loop. Then store the results of the loop in the list. For example: result - vector(mode=list, length=1000) for(i in 1:1000){ result[[i]] - try(harvest(i)) } Jean mdvaan mathijsdev...@gmail.com wrote on 11/27/2012

Re: [R] Stuck trying to modify a function

2012-11-27 Thread Jean V Adams
Ben, You can use the sample() function to randomly add -1, 0, or 1 to each observation, and control for the probability of mutation at the same time. Then you can use the match() function to make sure that any mutations in X are carried through to Y in the same way. I wrote the function to

Re: [R] heatmap with symbols

2012-11-15 Thread Jean V Adams
Use the col= argument to the heatmap() function to specify the three colors you want. For example: x - matrix(rnorm(50), ncol=5) heatmap(x, col=1:3) Jean furor furor1...@gmail.com wrote on 11/14/2012 03:31:42 AM: Hi all, I've made a heatmap using '-', '=' and '+' as

Re: [R] Adding two different factors to one observation?

2012-11-15 Thread Jean V Adams
Florian, There are a number of different ways to handle data like this. Two that come to my mind are shown below. You could allow each observation to be represented by multiple rows in the data frame: obs dishes 11 saucer 22cup 32 plate 42 saucer 53cup 63

Re: [R] combine similar variables in chart

2012-11-15 Thread Jean V Adams
You've included three I wants in your message, but no question. Are you looking for functions? Try searching ... in R, on google, on http://rseek.org/, ... Have you tried some code, but can't get it to work? Send your code with error messages, and tell us precisely what you trying to get

Re: [R] Extract cell of many values from dataframe cells and sample from them.

2012-11-13 Thread Jean V Adams
the rows would need to be of equal number for the array function, yet in a list there is not such requirement, and operations on matrices can target elements in specific matrices by [[,]][,] ? Best Wishes, Ben W. UEA (ENV) The Sainsbury Laboratory. From: Jean V Adams [jvad...@usgs.gov

Re: [R] error message no lines available in input

2012-11-08 Thread Jean V Adams
Katrin, I believe that error message is caused by empty lines of data in the file being read by read.table(). What is the last value for j printed when you run the code? What does the file look like at rows j to j+8? Does your code work if you just submit these lines? for (i in 0) {

Re: [R] sample from list

2012-11-08 Thread Jean V Adams
the interactions and immunology and such. Best, Ben W. UEA (ENV) The Sainsbury Laboratory. From: Jean V Adams [jvad...@usgs.gov] Sent: 07 November 2012 21:12 To: Benjamin Ward (ENV) Cc: r-help@r-project.org Subject: Re: [R] sample from list Ben, Can you provide a small example

Re: [R] Extract cell of many values from dataframe cells and sample from them.

2012-11-08 Thread Jean V Adams
arrays, I'm used to data in dataframes (usually from spreadsheets from experiments). From: Jean V Adams [jvad...@usgs.gov] Sent: 08 November 2012 13:35 To: Benjamin Ward (ENV) Cc: r-help@r-project.org Subject: RE: [R] sample from list Ben, You have still not supplied reproducible code

Re: [R] Beginner help about output in R

2012-11-08 Thread Jean V Adams
Nicolas, Maybe something like this would work for you. Put all of your x values in a list (or a vector, if your x values are scalars). Use sapply to loop through all of your x values, applying the value1() and value2() functions, and saving the results in a data frame. Then write the data

Re: [R] sample from list

2012-11-07 Thread Jean V Adams
Ben, Can you provide a small example data set for inds so that we can run the code you have supplied? It's difficult for me to follow what you've got and where you're trying to go. Jean Benjamin Ward (ENV) b.w...@uea.ac.uk wrote on 11/06/2012 03:29:52 PM: Hi all, I have a list

Re: [R] Post hoc tests in gam (mgcv)

2012-11-06 Thread Jean V Adams
David, How would you interpret the results of a post hoc test for sexcolor when you have an interaction term with sexcolor in your model? Perhaps it would be helpful to plot doy vs. predicted tle with confidence intervals for each of the four levels of sexcolor at a fixed tl (e.g., the mean).

Re: [R] Apply same linear model to subset of dataframe

2012-11-06 Thread Jean V Adams
Ross, Here's one way to condense the code ... DV - c(mpg, drat, gear) IV - list(c(cyl, disp, hp), c(wt, qsec), c(carb, hp)) for(i in seq(DV)) { fit - lm(formula=paste(DV[i], paste(IV[[i]], collapse=+), sep=~), data=mtcars) plot(fit$fitted, fit$resid, main=paste(DV, DV[i],

Re: [R] Apply same linear model to subset of dataframe

2012-11-06 Thread Jean V Adams
stores the last lm() computed Ross From: Jean V Adams jvad...@usgs.gov Date: Tuesday, 6 November 2012 14:12 To: Ross Ahmed rossah...@googlemail.com Cc: r-help@r-project.org Subject: Re: [R] Apply same linear model to subset of dataframe Ross, Here's one way to condense the code ... DV

Re: [R] deconstructing curve into rising and falling limbs

2012-10-26 Thread Jean V Adams
Using the data you provided, a combination of slope and height comes close: X - seq(Y) high - Y 0.6 upslope - c(FALSE, diff(Y) 0) section - rep(1, length(Y)) section[upslope==TRUE high==TRUE] - 2 section[upslope==FALSE high==TRUE] - 3 plot(X, Y, col=section) Or you could base the slope on

Re: [R] connect points in charts

2012-10-26 Thread Jean V Adams
Christof, You could use single linkage clustering to separate the dates into different groups if they are more than 14 days apart. Below is a simple example, where x represents day. x - sort(sample(1:500, 100)) y - rnorm(100) cluster - hclust(dist(x), method=single) group - cutree(cluster,

Re: [R] trying ti use a function in aggregate

2012-10-25 Thread Jean V Adams
Sally, It's great that you provided data and code. To make it even more user-friendly for R-help readers, supply your data as Rcode, using (for example) the dput() function. The reason you were getting all 1s with your code, is that you had told it to aggregate by trip, LENGTH, and species.

Re: [R] multi-panel figure: overall title for each row

2012-10-24 Thread Jean V Adams
Hannes, A bit inelegant, but it works. Try this: mtext(Overall Title Row 2, outer=TRUE, line=-17) mtext(Overall Title Row 3, outer=TRUE, line=-34) Jean capy_bara hettl...@few.vu.nl wrote on 10/23/2012 09:08:39 AM: Dear all, I have a 3x2 plot and in addition to the title of the

Re: [R] lm on matrix data

2012-10-11 Thread Jean V Adams
Baoqiang, Here's an approach that should work: (1) Make sure that the column names of trainx and testx are the same. (2) Combine trainy and trainx into a data frame for fitting the model. (2) Use the newdata= argument in the predict() function. (3) Convert testx from matrix to data frame. # some

[R] struggling with R2wd or SWord? Try rtf!

2012-10-11 Thread Jean V Adams
the word (ha!) about rtf. Below is some introductory code based on examples in http://cran.r-project.org/web/packages/rtf/vignettes/rtf.pdf Give it a try. You may like it! Jean `·.,, (((º `·.,, (((º `·.,, (((º Jean V. Adams Statistician U.S. Geological Survey Great Lakes

Re: [R] Reading labels for very large heatmaps

2012-10-09 Thread Jean V Adams
If you provide some example data in reproducible code, I might be able to help. Otherwise, not much I can do. Jean JIMonroe jim...@virginia.edu wrote on 10/08/2012 01:17:55 AM: Jean, It's definitely bigger now, but my axes are cut-off. As in your example, I had them drawn after

Re: [R] (no subject)

2012-10-05 Thread Jean V Adams
DL, Looks like you have a typo in the expression() function. You had only one s. This works for me ... m - 10 beta.q - matrix(rnorm(81), ncol=9) for (i in 1:9){ plot(seq(1/m, 1-1/m, 1/m), beta.q[, i], type=l, col=1, ylim=range(beta.q), xlab=quantile, ylab=expression(beta[i])) }

Re: [R] help with making figures

2012-10-05 Thread Jean V Adams
It's helpful to provide reproducible code in your posting to R help. The dput() function can be used to share some of your data. For example, you might have used dput(mydata[1:10, 1:10]) # here's some data I made up as an example ... df - structure(list(`2000` = c(44L, 31L, 55L, 83L,

Re: [R] Creating vegetation distance groups from one column

2012-10-04 Thread Jean V Adams
Jean, Take a look at the cut() function, ?cut For example ... mydf - data.frame(nest=1:100, d2veg=runif(100, 0, 60)) mydf$dgroup - cut(mydf$d2veg, breaks=seq(0, 70, 5), include.lowest=TRUE) head(mydf) (another) Jean Jhope jeanwaij...@gmail.com wrote on 10/04/2012 02:27:38 AM: Hi R

Re: [R] Creating vegetation distance groups from one column

2012-10-04 Thread Jean V Adams
Try this data.to.analyze$VegIndex - cut(data.to.analyze$Veg, breaks=seq(0, 70, 5), include.lowest=TRUE) plot(data.to.analyze$VegIndex) Jhope jeanwaij...@gmail.com wrote on 10/04/2012 02:25:09 PM: Hi, Allow me to recap my question. In plyr I am trying to group distances of nests

Re: [R] Reading labels for very large heatmaps

2012-10-02 Thread Jean V Adams
Jacob, Try increasing the size of the pdf. For example, I can read all 919 labels in this plot ... pdf(width=200, height=200) plot(1:919, 1:919, axes=FALSE) axis(1) axis(2, at=1:919, las=1, cex=0.01) box() graphics.off() Jean JIMonroe jim...@virginia.edu wrote on 10/01/2012 03:42:24 PM:

Re: [R] Problem with nls regression fit

2012-10-01 Thread Jean V Adams
You have not specified a nonlinear formula. There are no parameters to estimate in the formula you provide, y1~dist. What is the nonlinear relation you are trying to fit? Look at the help file for nls to see some examples worked. ?nls Jean Gyanendra Pokharel gyanendra.pokha...@gmail.com

Re: [R] calculation of diversity confidence interval

2012-09-26 Thread Jean V Adams
Mike, You could use bootstrapping. See for example the function boot() in pacakge boot. library(boot) ?boot Jean Michael Eisenring michael.eisenr...@gmx.ch wrote on 09/25/2012 04:54:29 AM: Dear R-help members. Maybe this is not the right platform to ask this, but I'm looking

Re: [R] Removing duplicates without a for loop

2012-09-26 Thread Jean V Adams
This might be quicker. Para.5C.sorted - Para.5C[order(Para.5C[, 1]), ] Para.5C.final - Para.5C.sorted[!duplicated(Para.5C.sorted$REQ.NR), ] If your data are already sorted by date, then you can skip the first step and just run Para.5C.final - Para.5C[!duplicated(Para.5C$REQ.NR), ] Jean

Re: [R] Reading multiple files

2012-09-26 Thread Jean V Adams
Will your data be read in correctly if you do away with the colClasses argument to read.delim (or read.table)? Jean Silvano Cesar da Costa silv...@uel.br wrote on 09/26/2012 09:11:33 AM: Hi, I have 35 data files for reading. I would like get a program for performing reading of 35 files

Re: [R] Reading multiple files

2012-09-26 Thread Jean V Adams
If your previously posted code worked with files all having the same number of columns, and if your data is read in correctly without the colClasses argument, then I think the following code should work. for(i in names){ filepath = file.path(~/Silvano/Dados, paste(i, .raw, sep=))

Re: [R] Using paste to create and evaluate a variable expression

2012-09-17 Thread Jean V Adams
Bryan, Try this. char - paste(X, 1:2, sep=, collapse=+) eval(parse(text=char)) Jean Bryan Keller bsbkel...@gmail.com wrote on 09/16/2012 11:04:19 PM: Is it possible to use paste to write out an expression and evaluate it? Suppose I want to add two vectors X1 and X2, defined as follows:

Re: [R] I want to send the vector a into the Object A.......

2012-09-17 Thread Jean V Adams
Try this. A - get(x[1]) Jean Sri krishna Devarayalu Balanagu balanagudevaray...@gvkbio.com wrote on 09/17/2012 07:13:51 AM: a=c(1,2,3) b=c(23, 24, 25) x=c(a, b) #if (length(x[1]) == 0) {cat(x[1] is having 3 elements)} Suppose I want to send the vector a into the Object A, um getting

Re: [R] Generalized additive models: Plots for Qualitative Data

2012-09-06 Thread Jean V Adams
Dontrece, Try using the all.terms argument to the plot.gam() function. plot(gam4, shade=TRUE, pages=1, all.terms=TRUE) Does that work? Jean Dontrece Smith smithdon2...@gmail.com wrote on 09/06/2012 06:50:07 AM: Hello, My name is Dontrece Smith. I am creating figures for my GAMs. I change

Re: [R] Change margin size of complex barplot

2012-09-06 Thread Jean V Adams
Michi, Try putting your par() statements BEFORE your barplot() statement. For example, oldpar - par(mar=c(18, 7, 2, 2.1)) oldfont - par(font=3) bp - barplot(data.matrix(geo_barplot_percentage_top10), ... Jean Michael Eisenring eimic...@ethz.ch wrote on 09/06/2012 12:40:27 PM: Dear

Re: [R] Comparing Von Bertalanffy Growth Curves

2012-09-05 Thread Jean V Adams
April Lindeman aprillinde...@yahoo.com wrote on 09/04/2012 01:43:06 PM: I am trying to compare Vbert growth curves from several years of fish data. I am following the code provided by: http:// www.ncfaculty.net/dogle/fishR/gnrlex/VonBertalanffy/VonBertalanffy.pdf . Specifically the section

Re: [R] Scatter plot from tapply output, labels of data

2012-09-04 Thread Jean V Adams
Try this: # I created some example data mydf - data.frame( Species=sample(paste0(Species, 1:3), 50, TRUE), d13C=15+rnorm(50), d15N=15+rnorm(50), Year=sample(2009:2012, 50, TRUE)) attach(mydf) Nmean - tapply(d15N, list(Year,Species), mean) Cmean - tapply(d13C,

Re: [R] Standard deviation from MANOVA??

2012-08-27 Thread Jean V Adams
Not sure why that is. You can always use manova() to get the multivariate summary statistics and then use individual models to get predictions for each response. For example, mydata - data.frame(y1=rnorm(50), y2=rnorm(50), x1=rnorm(50), x2=rnorm(50), x3=rnorm(50)) myfit - manova(cbind(y1,

Re: [R] Assigning colors on low p-values in table

2012-08-27 Thread Jean V Adams
Emil, It's helpful to provide code that generates your (example) data. You can use the function dput() to do that. # I set up your matrix a bit differently than what you presented. output - structure(c(-2.3109, -0.2934, -0.5539, -2.1352, -2.6968, -2.0429, -0.3973, -0.6468, 0.4181, -0.6243,

Re: [R] Euclidean distance function

2012-08-24 Thread Jean V Adams
Kev, The dist() function handles more than 2 dimensions. Using the example you provided ... mydat - structure(list(Species = c(spA, spB, spC, spD), x = c(2.9, 5.5, 1.4, 8.3), y = c(34.2, 46.5, 48.6, 56.1), z = c(0.54, 0.45, 0.84, 0.48), n = c(15.7, 19.4, 24.8,

Re: [R] Accessing the (first or more) principal component with princomp or prcomp

2012-08-23 Thread Jean V Adams
As Bert suggests, the help file explains the differences between princomp and prcomp. Look under the Details section ?princomp ?prcomp # the first PC using princomp a - princomp(USArrests, cor=TRUE) a1 - a$scores[, 1] # the first PC using prcomp # use center=TRUE and scale.=TRUE for the

Re: [R] All possible models with nls()

2012-08-23 Thread Jean V Adams
Try this. # the data y - sample(0:1, 50, replace=T) # response x1 - sample(0:1, 50, replace=T) # explanatory var x2 - sample(0:1, 50, replace=T) # explanatory var # the number of regressors nregressors - 2 # all possible combinations comb - as.matrix(expand.grid(rep(list(0:1),

Re: [R] Simpson diversity in biodiversityR

2012-08-22 Thread Jean V Adams
The functions diversityresult() and diversitycomp() in package BiodiversityR call the function diversity() from package vegan. The calculation of the indices are described in the help file. ?vegan:::diversity Jean Marte Lilleeng mlille...@gmail.com wrote on 08/22/2012 09:28:57 AM: Hello!

Re: [R] radarchart axis scaling

2012-08-21 Thread Jean V Adams
Mitra, Try this ... # provide the data you want to plot, and the desired range mydat - c(3.34, 3.28, 1.37, 1.12, 3.52, 4.07, 3.66) myrange - c(0, 5) # create a data frame with the max and min as the first two rows mydf - data.frame(rbind(max=myrange[2], min=myrange[1], mydat)) # create a radar

Re: [R] Unable to reference variable created in dataframe

2012-08-20 Thread Jean V Adams
Steve, I tried to replicate your error, but couldn't do it. The code below works just fine for me. Does it for you? # create an example data frame Bridges - data.frame(CONDITION=1:5, TRAFFIC=rnorm(5), WEATHER=rnorm(5)) # create new variable LOG_COND Bridges$LOG_COND = log(Bridges$CONDITION,

Re: [R] How to plot data in logarithmic scale

2012-08-16 Thread Jean V Adams
Zuki, You did not provide any information on what table$attrib is. Using a log scale for the y-axis doesn't make much sense to me, since the y-axis is the cumulative proportion of observations, from 0 to 1. Perhaps you are interested in the log scale for the x-axis, instead? In any case,

Re: [R] Color-coded Biplot of Varimax rotated factors from PCA based factor analysis

2012-08-16 Thread Jean V Adams
I suggest that you re-post your question, but this time make it easy for readers to help you by providing a simple reproducible example of your problem. Provide some fake data, or a small subset of your data using, for example, the function dput(). Trim the fat from your code. Get rid of

Re: [R] How to extract from a column in a table?

2012-08-16 Thread Jean V Adams
Sapana Lohani lohani.sap...@ymail.com wrote on 08/16/2012 01:41:23 PM: Hi, I have a table in which one column has the name of the objects as shown below. You don't provide example data, so I'm not sure what you mean by a table. I will assume that you mean a data frame. Name

Re: [R] trouble with looping for effect of sampling interval increase

2012-08-06 Thread Jean V Adams
You would make it much easier for R-help readers to solve your problem if you provided a small example data set with your code, so that we could reproduce your results and troubleshoot the issues. Jean Naidraug white@wright.edu wrote on 08/05/2012 09:08:25 AM: I've looked everywhere

Re: [R] sapply() and by()

2012-08-06 Thread Jean V Adams
Dominic, It's great that you provided some example data, but a much smaller data frame would have sufficed. For example, 10 randomly selected rows from your data ... LF - structure(list(Serra.da.Foladoira = c(27.335652173913, 25.4632608695652, 24.464652173913, 22.550652173913,

Re: [R] How to convert data to 'normal' if they are in the form of standard scientific notations?

2012-08-06 Thread Jean V Adams
HJ, You don't provide any reproducible code, so I had to make up my own. dat - data.frame(a=letters[1:5], x=c(20110911001084, 20110911001084, 20110911001084, 20110911001084, 20110911001084), y=c(2.10004e+12, 2.10004e+12, 2.10004e+12, 2.10004e+12, 2.10004e+12)) In my example,

Re: [R] How to concatenate a several rows according with a column ?

2012-08-03 Thread Jean V Adams
tgodoy tingola...@hotmail.com wrote on 08/03/2012 12:00:24 PM: Hi, I'm a new user or R and I try to concatenate a several rows according with the value in a column. this is my data.frame and I want to concatenate my data.frame according with the column b and make a new data.frame with

Re: [R] rpart package: why does predict.rpart require values for unused predictors?

2012-08-02 Thread Jean V Adams
Jason, In the help file for predict.rpart it says, The predictors referred to in the right side of formula(object) must be present by name in newdata. ?predict.rpart So, that's just the way it is. There are a couple ways to work around this, if you wish. You could create a data frame with

Re: [R] repeating a function across a data frame

2012-08-01 Thread Jean V Adams
As Petr suggests, the dist() function will do much of the work for you. For example ... # example matrix of data nsamples - 40 nreadings - 46 dat - matrix(runif(nsamples*nreadings), nrow=nsamples) # Euclidean distance between the ROWS of dat distance - dist(dat) Jean JenniferH

Re: [R] How to increase lenght of axis according input data?

2012-08-01 Thread Jean V Adams
You could use the xlim argument to barplot. For example, barplot(t(data[,2:3]), beside=TRUE, xlim=c(0, 20), col=c(rgb(.537, .769, .933), rgb(.059, .412, .659)), width=1, horiz=TRUE, cex.names=.9, border =white, las=1, cex.axis=1, cex.lab=1.2) Jean Manish Gupta

Re: [R] help with a regression problem

2012-08-01 Thread Jean V Adams
R Heberto Ghezzo, Dr heberto.ghe...@mcgill.ca wrote on 08/01/2012 08:06:30 AM: Hello, I have a big data frame where consecutive time dates and corresponding observed values for each subject (ID) are on a line. I want to compute the linear slope for each subject. I would like to use apply

Re: [R] Error in for-loop

2012-08-01 Thread Jean V Adams
Domi wrote on 08/01/2012 Jul 29, 2012; 8:59am: Hello erverybody, I have a problem with my second for-loop. 1. First i read the tables. datos.mx1 - read.table('PETmx1.csv',head=TRUE,sep=';') datos.min - read.table('PETmin.csv',head=TRUE,sep=';') You are most likely to get good

Re: [R] cluster of points

2012-07-31 Thread Jean V Adams
Frederico, This is not exactly what you're after, but perhaps it will help. In this example I fit a cluster analysis to the data, then I cut the tree at a height of 3 (you would do this with your data at a height of 40). It's not a perfect solution, but it might be good enough, depending on

Re: [R] help with a regression

2012-07-31 Thread Jean V Adams
Can you provide a small example data set? Does the number after the X and Y indicate the subject? Are you trying to come up with a single line of code to do this ... ? lm(Y1 ~ X1, data=DF) lm(Y2 ~ X2, data=DF) ... lm(Y5 ~ X5, data=DF) Jean R Heberto Ghezzo, Dr

Re: [R] distance matrix and hclustering

2012-07-30 Thread Jean V Adams
Look at the examples for the functions dist() and hclust(), ?dist ?hclust Jean eliza botto eliza_bo...@hotmail.com wrote on 07/30/2012 01:43:55 AM: Dear R Users,i am very new to R. I want your help on an issue regarding distance matrix and cluster analysis i had discharge data of 4

Re: [R] If/then statement, if in a list then

2012-07-30 Thread Jean V Adams
?is.element Jean cm bunnylove...@optonline.net wrote on 07/30/2012 07:55:34 AM: I need to write an if/then statement saying something along the lines of: if (VALUE is in list) {... How do I write that in R's language. Thanks! [[alternative HTML version deleted]]

Re: [R] Understanding the intercept value in a multiple linear regression with categorical values

2012-07-27 Thread Jean V Adams
Joao, There's a very thorough explanation at http://www.ats.ucla.edu/stat/r/library/contrast_coding.htm Jean Joao Azevedo joao.c.azev...@gmail.com wrote on 07/27/2012 06:32:31 AM: Hi! I'm failing to understand the value of the intercept value in a multiple linear regression with

Re: [R] shift pie chart

2012-07-27 Thread Jean V Adams
Michi, The code that you shared was incomplete. Two objects (plant_labels and colors) were not defined. The pie chart would be easier to interpret by direct labeling of slices, rather than trying to decipher a color legend. If you change the initial angle of the first slice, you can rotate

Re: [R] Understanding the intercept value in a multiple linear regression with categorical values

2012-07-27 Thread Jean V Adams
when there are multiple categorical explanatory variables. -- Joao. On Fri, Jul 27, 2012 at 1:04 PM, Jean V Adams jvad...@usgs.gov wrote: Joao, There's a very thorough explanation at http://www.ats.ucla.edu/stat/r/library/contrast_coding.htm Jean Joao Azevedo joao.c.azev

Re: [R] How to run regressions over increasing time series

2012-07-27 Thread Jean V Adams
Philippe, In your example, you have four unique values for Yrs (I had to change your code a little to get it to run, so I have the modified version with my code below), and those values are what you are referring to when you say T1, T2, T3, T4, right? If I follow what you want to do, the code

Re: [R] overlaying a set of 'grouping' lines on a plot from image()

2012-07-27 Thread Jean V Adams
Try this: # define the locations on the x axis for each cell in the image nxcells - dim(m)[2] xlocs - (seq(nxcells)-1)/(nxcells-1) # define the groupings group - rep(1:3, c(10, 20, 25)) # calculate the range of locations on the xaxis for each group group.ranges - sapply(split(xlocs, group),

Re: [R] Adjust the position of main in par(mfrow)

2012-07-26 Thread Jean V Adams
Try changing your plot and outer margins. par(mfrow=c(2,1), mar=c(4, 4, 2, 1), oma=c(0, 0, 2, 0)) Jean phillen phlent...@gmail.com wrote on 07/26/2012 04:28:58 AM: hey guys I want two plots in one window with an overall title and with individual titles for each plots. my code:

Re: [R] Working with Numbers generated from Regression Output

2012-07-26 Thread Jean V Adams
You can learn a lot from the help files. Check out the help files for the lm() and summary.lm() functions ?lm ?summary.lm You can extract the beta values in a few different ways. These two will give you just the estimates in a vector: coef(result) result$coef These two will give you the

Re: [R] image function

2012-07-23 Thread Jean V Adams
Did you try this? image(x, xlim=c(0, 100), ylim=c(0, 100)) Jean li li hannah@gmail.com wrote on 07/22/2012 09:28:33 PM: Dear all, I have a question regarding changing the xlim and ylim in the function image(). For example, in the following code, how can I have a heatmap with

Re: [R] Unique Values per Column

2012-07-23 Thread Jean V Adams
Bert, Is it important that you end up with a data frame? If not, it would be very easy to generate a list with the unique values for each column. For example: df - data.frame(v1 = sample(5, 20, T), v2 = sample(7, 20, T), v3 = sample(9, 20, T), v4 = sample(11, 20, T)) lapply(df,

[R] R2wd package wdGet() error

2012-07-23 Thread Jean V Adams
I am having trouble using the R2wd package. The last time I used it successfully, I was running an earlier version of R and an earlier version of Word with an earlier Windows OS. I'm not sure which if any of these changes might be contributing to the problem. Right now I'm using R

Re: [R] Speeding up a loop

2012-07-20 Thread Jean V Adams
I've had to do something similar, so I wrote a small function to help. This runs in about 1/4 the time of your code on my machine. Others may have a more efficient approach. all.combs - function(num, from=0, to=num) { # create a matrix of all possible combinations of num items #

Re: [R] TukeyHSD not working

2012-07-20 Thread Jean V Adams
Michael, Use dput() to output your data (or perhaps a small subset). Then paste the result of that call and your R code (just those lines of code that are needed to reproduce the problem) right in your message to R-help. That makes it easier for the R-help list readers to help you

Re: [R] Speeding up a loop

2012-07-20 Thread Jean V Adams
Petr, This is great. MUCH faster than the code I provided. And much more elegant code. Thanks for posting! Jean Petr Savicky savi...@cs.cas.cz wrote on 07/20/2012 09:26:34 AM: On Fri, Jul 20, 2012 at 05:45:30AM -0700, wwreith wrote: General problem: I have 20 projects that can be invested

Re: [R] TukeyHSD not working

2012-07-20 Thread Jean V Adams
Michael Eisenring eimic...@ethz.ch wrote on 07/20/2012 09:35:03 AM: Dear Jean, thanks for this email. I'm grateful for this instruction Just to make sure that I understood you properly: something like this?: Michael, Yes, this is perfect. Very helpful. My data:

Re: [R] [External] Re: Speeding up a loop

2012-07-20 Thread Jean V Adams
right now. Optimizing a program is not my thing. Sent from my Verizon Wireless 4GLTE smartphone It's not mine either. Better to ask the group. I'm ccing R-help on this message. Jean - Reply message - From: Jean V Adams jvad...@usgs.gov To: Reith, William [USA] reith_will

Re: [R] Speeding up a loop

2012-07-20 Thread Jean V Adams
right now. Optimizing a program is not my thing. Sent from my Verizon Wireless 4GLTE smartphone It's not mine either. Better to ask the group. I'm ccing R-help on this message. Jean Jean V Adams jvad...@usgs.gov wrote on 07/20/2012 10:05 AM: I've had to do something similar, so I

Re: [R] Contour

2012-07-19 Thread Jean V Adams
As Duncan Murdoch pointed out, the example data frame that you provided doesn't give very interesting results (all the shock values are zero), so I created a different shock variable for illustration. I suggest using the interp() function in the R package akima. df - structure(list(c = 1:6, z

Re: [R] order or sort doesn´t work properly

2012-07-18 Thread Jean V Adams
# MCT ordered by the second column of MCT, from smallest to largest values MCT[order(MCT[, 2]), ] Jean Trying To learn again tryingtolearnag...@gmail.com wrote on 07/17/2012 04:42:24 PM: Hi all, I want to order a series that is included on the second column in MCT.csv. I do but R

Re: [R] fitting several lme sistematically

2012-07-18 Thread Jean V Adams
I'm not sure why, but lme() doesn't seem to like the variables to be referenced as part of a list using [ or $. Here's an easy workaround ... ids - a$id for(i in 2:4){ for(j in 5:7){ y - a[, j] x - a[, i] lme(y ~ x , random= ~1|ids, na.action=na.exclude) }} Jean

Re: [R] loop searching the id corresponding to the given index (timestamp)

2012-07-18 Thread Jean V Adams
What is the function index() that you use in this line of code? thisIndex - as.character(index(diveData_2008[i,])) Is it from some package? Or a function you wrote yourself? I'm trying to run the code you submitted, but I don't have a function called index(). Jean Yolande Tra

Re: [R] fitting several lme sistematically

2012-07-18 Thread Jean V Adams
Med Q3Max -2.0882452 -0.7718563 0.1156507 0.6119178 1.7986478 Number of Observations: 100 Number of Groups: 10 A.K. - Original Message - From: Jean V Adams jvad...@usgs.gov To: Berta Ibáñez bertu...@hotmail.com Cc: Lista de R r-help@r-project.org

Re: [R] Grabbing Indexes of a certain standard deviation

2012-07-16 Thread Jean V Adams
residuals[abs(residuals) (2*sd)] gcm lvog...@grahamcapital.com wrote on 07/16/2012 07:07:31 AM: Jean, how would you modify your function to grab all the selected and not just the first? Thank you so much! From: Jean V Adams [via R] [ mailto:ml-node+s789695n4636370...@n4.nabble.com

Re: [R] Grabbing Indexes of a certain standard deviation

2012-07-16 Thread Jean V Adams
seq(residuals)[abs(residuals) (2*sd)] gcm lvog...@grahamcapital.com wrote on 07/16/2012 07:39:20 AM: But I'll need the indexes and that gives me the values. I need to then be able to make the indexes into a list of numbers. From: Jean V Adams [via R] [ mailto:ml-node+s789695n4636641

Re: [R] Add row into a Matrix witout headers from Function

2012-07-12 Thread Jean V Adams
Try using the rbind() function to combine the two vectors from colSums() into a matrix. Then assign row names and get rid of column names using the dimnames() function. For example: OLDMatrix - matrix(c(22, 25, 10, 24, 27, 13, 23, 27, 15), ncol=3, dimnames = list(NULL, c(X1, X2,

Re: [R] Grabbing Indexes of a certain standard deviation

2012-07-12 Thread Jean V Adams
I wrote a little function called first() to help with situations like this. It returns a 1 every time an element of a vector is different from the previous element, and a 0 otherwise. first - function(x) { L - length(x) c(1, 1-(x[-1]==x[-L])) } sd - 1 residuals - c(1, 2.1, 3, 4,

Re: [R] Plotting rpart trees with long list of class members

2012-07-12 Thread Jean V Adams
The example you gave had only one split. If your real situation has three splits, you'll have to take a look at testtree$csplit matrix and decide how you want to define the new grouping variable. Here's one way to do it ... Jean library(rpart) library(rpart.plot) test_set - data.frame(

Re: [R] Plotting rpart trees with long list of class members

2012-07-10 Thread Jean V Adams
Thanks. Very helpful. You can use the information from the splits in the first tree, to define a new grouping variable, which will simplify the plot: suvar - sort(unique(test_set$list_var)) test_set$var_grp - as.factor(testtree$csplit[match(test_set$list_var, suvar)]) testtree2 - rpart (

Re: [R] Plotting rpart trees with long list of class members

2012-07-09 Thread Jean V Adams
If you provide a simple example, with actual data and code so that we can reproduce your issue, it would make it easier for readers of this list to help. Jean MarkBeauchene markbeauch...@hotmail.com wrote on 07/06/2012 04:38:32 PM: I have a class with 732 members, so using rpart.plot is

Re: [R] Error in hclust?

2012-07-06 Thread Jean V Adams
Mateus, I see what you mean. I can't figure it out. I found a message from a few years ago that mentions the same problem. http://tolstoy.newcastle.edu.au/R/e8/help/09/12/8165.html This may be a bug. Since hclust() is in the stats package, I am ccing the maintainer, r-c...@r-project.org, on

  1   2   3   >