Re: [R] how use cat() function?

2009-08-10 Thread Jean V Adams
I'm not exactly sure how you want the file to look, but try this code and see if it works for you. # since I don't have the data file, I'll just set the values here No_GWPMax <- 8 NbpolicyClass1 <- 5 NbpolicyClass2 <- 4 NbpolicyClass3 <- 3 # output1 is the first row of headers Output1 <- paste("

[R] selecting vector elements using matrices and combining the results

2009-07-28 Thread Jean V Adams
two matrices, I want to end up with this list: result <- list(c("A", "b", "D", "f"), c("C", "E"), c("D", "e")) result I'm using R for Windows version 2.9.0. Thanks for your help. Jean `·.,, ><(((º&

[R] selecting vector elements using matrices and combining the results

2009-07-28 Thread Jean V Adams
(I'm resending this, because there seemed to be a problem with my previous attempt.) I've been scratching my head over this one for too long. I'm hoping someone out there can solve this riddle. I have two vectors of characters, v1 and v2, both of length L, and two matrices of logicals, m1 and

Re: [R] How do I plot a line followed by two forecast points?

2009-08-07 Thread Jean V Adams
Just wait until after you have the forecasts before you create the plot. # Sample dates xValues <- seq.Date(as.Date("1990-01-31"), to=as.Date("1992-12-31"), by="month") # Sample y value yValues <- seq(0.1, length=length(xValues)) # Sample forecast one year from xValue's end point fcastDate <- s

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 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: > > X1 <

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 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 only "a" as th

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 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 > desperately for a test which

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 ww

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" 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 at once

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] 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 wrote on 10/01/2012 10:27:23

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 wrote on 10/01/2012 03:42:24 PM: > > Hello, > I have a

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 wrote on 10/04/2012 02:27:38 AM: > > Hi R listers, > > I am tryi

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 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 to the vegetati

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] 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 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 generating the heat

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
7;d spread 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.

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 wrote on 10/23/2012 09:08:39 AM: > > Dear all, > I have a 3x2 plot and in addition to the title of the individual plots I >

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] 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

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(clust

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, m

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

2012-11-06 Thread Jean V Adams
ion(x) plot(x, fit$resid)) fits[[i]] <- fit } Jean Ross Ahmed wrote on 11/06/2012 09:25:13 AM: > > Thanks Jean > > This works for the plots, but it only stores the last lm() computed > > Ross > > From: Jean V Adams > Date: Tuesday, 6 November

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)" wrote on 11/06/2012 03:29:52 PM: > > Hi all, > > I have a list of genes p

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) { j=subjec

Re: [R] sample from list

2012-11-08 Thread Jean V Adams
etc. This 2D layout of rows and columns is then > repeated in the z dimension of the array for each individual. It is > ragged in the sense each individual, each slice through the array in > the z direction, would have different numbers of rows - different > numbers of effectors. I c

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

2012-11-08 Thread Jean V Adams
: > The format would be a 2D layout, Where every line is an effector > gene and every column an aspect of the effector gene(value, > expression state, fitness contribution etc.) This 2D layout of rows > and columns is then repeated in the 3rd dimension (the z of x,y,z) > of the

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 f

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

2012-11-13 Thread Jean V Adams
ay jagged like > this because 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. > > U

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 wrote on 11/14/2012 03:31:42 AM: > > Hi all, > > I've made a heatmap using '-', '=' and '+' as possible values. H

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 want"s 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 yo

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 wrote on 11/27/2012 12:09:38 AM: > > Hi, >

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 do

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 wrote on 11/27/2012 11:35:15 PM: > > Hi,

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 categorie

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

2012-11-28 Thread Jean V Adams
;1.0996;3.0952;0.94324;2.3146;0.9822;1.0752;2. > 6336;4.7202;0.82122;1.2563;0.73988;1.7051;2.3569;1.4296;0.85812;4. > 8422;1.9687;2.511;4.5446;1.9065;2.3899;2.2784;4.174;2.6654;4.8175;3. > 9665;3.902;3.5763;1.337;4.0643;3.6533;0.78097;1.6724;4.957;3.7316;1. > 7372;4.9859;4.2946;4.3697;2

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 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 <- rep(c(111, 225), 5)

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
n, I want to fill up x[2] with value, in our case it's 111. > > Mike > > On Thu, Nov 29, 2012 at 5:39 PM, Jean V Adams wrote: > Mike, > > Based on this example, what do you want > samples > to look like? > > It's not clear to me what you&#

Re: [R] colour of label points on a boxplot

2010-08-05 Thread Jean V Adams
Alison, Check out the options for the function bxp(), they include control over the colors of all parts of the boxplot, e.g., whiskcol for whisker color. Jean `·.,, ><(((º> `·.,, ><(((º> `·.,, ><(((º> Jean V. Adams Statistician U.S. Geological Survey Great La

Re: [R] persp()

2011-08-04 Thread Jean V Adams
at <- c(50.50, 52.35, 54.12, 54.91, 53.17, 52.21, 54.06, 53.61, 50.71, 50.71, 50.50) # use the map() function to set up the long/lat projection without drawing anything map("world", xlim=range(long), ylim=range(lat), type="n") lines(long, lat) Jean `·.,, ><(((º> `·

Re: [R] R loop problem

2011-08-04 Thread Jean V Adams
Try this: q <- z[match(p, y)] Jean `·.,, ><(((º> `·.,, ><(((º> `·.,, ><(((º> Jean V. Adams Statistician U.S. Geological Survey Great Lakes Science Center 223 East Steinfest Road Antigo, WI 54409 USA 715-627-4317, ext. 3125 (Office) 715-216-8014 (

Re: [R] R compare cells in one matrix

2011-08-05 Thread Jean V Adams
j] - mat[i+1, j] c(c1, c2, c3) } compare(a, 1, 1) compare(a, 1, 2) Jean `·.,, ><(((º> `·.,, ><(((º> `·.,, ><(((º> Jean V. Adams Statistician U.S. Geological Survey Great Lakes Science Center 223 East Steinfest Road Antigo, WI 54409 USA From: kokavolchko

Re: [R] problemsn in using nls

2011-08-05 Thread Jean V Adams
2_mrna, data=Data_pp2_mrna, start=list(k1=3.3, v2_Kd=2.4, v2_h=1, v5_Kd=1.2, v5_h=1)) summary(fm_pp2_mrna) Jean `·.,, ><(((º> `·.,, ><(((º> `·.,, ><(((º> Jean V. Adams Statistician U.S. Geological Survey Great Lakes Science Center 223 East Steinfest Road Ant

Re: [R] Displaying a summary in graphics

2011-08-05 Thread Jean V Adams
A search of the R-help archives may provide some help. See, for example, http://r.789695.n4.nabble.com/including-tabular-information-with-a-plot-in-R-Graphics-tt885431.html Jean `·.,, ><(((º> `·.,, ><(((º> `·.,, ><(((º> Jean V. Adams Statistician U.S. Ge

Re: [R] Displaying a summary in graphics

2011-08-05 Thread Jean V Adams
1, outer=TRUE, text=smry2, cex=0.75, line=9, adj=0, family="mono") Jean `·.,, ><(((º> `·.,, ><(((º> `·.,, ><(((º> Jean V. Adams Statistician U.S. Geological Survey Great Lakes Science Center 223 East Steinfest Road Antigo, WI 54409 USA From: Greg S

Re: [R] round() a data frame containing 'character' variables?

2011-08-10 Thread Jean V Adams
1 0.2 setosa 45 32 0.2 setosa 55 41 0.2 setosa 65 42 0.4 setosa Jean `·.,, ><(((º> `·.,, ><(((º> `·.,, ><(((º> Jean V. Adam

Re: [R] Plotting Ellipses and Points of Matching Colors in an Ordination

2011-08-10 Thread Jean V Adams
rdiellipse(mod, Management, kind="se", conf=0.95, label=T, font=2, cex=1.5, col=i, show.groups=groupz[i]) } Jean `·.,, ><(((º> `·.,, ><(((º> `·.,, ><(((º> Jean V. Adams Statistician U.S. Geological Survey Great Lakes Science Center 223 East S

Re: [R] function runif in for loop

2011-08-10 Thread Jean V Adams
from T to X, because T has special meaning in R. Jean `·.,, ><(((º> `·.,, ><(((º> `·.,, ><(((º> Jean V. Adams Statistician U.S. Geological Survey Great Lakes Science Center 223 East Steinfest Road Antigo, WI 54409 USA From: "Johannes Radinger" To: r-hel

Re: [R] column names issue with read.csv

2011-08-10 Thread Jean V Adams
ecessary." There is an argument in read.csv() called check.names. Try setting this to FALSE and see if that works. read.csv(file="Something.csv", check.names=F) Jean `·.,, ><(((º> `·.,, ><(((º> `·.,, ><(((º> Jean V. Adams Statistician U.S. G

Re: [R] function runif in for loop

2011-08-10 Thread Jean V Adams
Following the suggestion by Duncan Murdoch, this should work for you. X <- runif(length(lT), lT, uT) Jean From: "Johannes Radinger" To: Jean V Adams Cc: r-help@r-project.org Date: 08/10/2011 08:40 AM Subject: Re: [R] function runif in for loop Jean, thank you for your answe

Re: [R] round() a data frame containing 'character' variables?

2011-08-10 Thread Jean V Adams
ound(y, 2) else y)) Jean `·.,, ><(((º> `·.,, ><(((º> `·.,, ><(((º> Jean V. Adams Statistician U.S. Geological Survey Great Lakes Science Center 223 East Steinfest Road Antigo, WI 54409 USA Liviu Andronic wrote on 08/10/2011 10:26:43 AM: > [image removed]

Re: [R] Histograms in R

2011-08-10 Thread Jean V Adams
uot;, dimnames(m)[[1]], fill=seq(mut.no), title="Mutation_Status") Jean `·.,, ><(((º> `·.,, ><(((º> `·.,, ><(((º> Jean V. Adams Statistician U.S. Geological Survey Great Lakes Science Center 223 East Steinfest Road Antigo, WI 54409 USA r-help-boun..

Re: [R] convert 'list' to 'vector'?

2011-08-10 Thread Jean V Adams
unlist(x) r-help-boun...@r-project.org wrote on 08/10/2011 01:58:57 PM: > [image removed] > > [R] convert 'list' to 'vector'? > > Liviu Andronic > > to: > > r-help@r-project.org Help > > 08/10/2011 02:02 PM > > Sent by: > > r-help-boun...@r-project.org > > Dear all > How does one conver

Re: [R] Getting bootstrap statistic to work

2011-08-12 Thread Jean V Adams
Shouldn't the "i" in your theta() function refer to the selected rows (a "vector of indices" as referred to in the help file for boot) of the data used by boot()? theta <- function(data, i) { data <- data[i, ] data.cov <- cov(data) data.eigen <- eigen(data.cov) data.eigen$values[1]/sum(d

Re: [R] how to merge distance data based on location

2011-08-19 Thread Jean V Adams
uld you want your merged data frame to look? > > Does anyone have ideas about how to accomplish this? > Thank you, > > Matthew Keller > > -- > Matthew C Keller > Asst. Professor of Psychology > University of Colorado at Boulder > www.matthewckeller.com > Je

Re: [R] display only the top-right half of a correlation matrix?

2011-08-19 Thread Jean V Adams
ince the two sides are identical, there is little value in having > both displayed at the same time. Moreover, it considerably slows down > the inspection of the results. > > Thank you > Liviu > Jean `·.,, ><(((º> `·.,, ><(((º> `·.,, ><(((º

Re: [R] Increase the size of the boxes but not the text in a legend

2011-08-22 Thread Jean V Adams
> [R] Increase the size of the boxes but not the text in a legend > Jürgen Biedermann > to: > r-help > 08/21/2011 06:02 PM > > HI there, > > I want to add a legend to a plot using the density and angle argument, > so patterns with lines in different angles are used in the plot and > should be

Re: [R] Selecting cases from matrices stored in lists

2011-08-22 Thread Jean V Adams
> [R] Selecting cases from matrices stored in lists > mdvaan > to: > r-help > 08/22/2011 07:24 AM > > Hi, > > I have two lists (c and h - see below) containing matrices with similar > cases but different values. I want to split these matrices into multiple > matrices based on the values in h. So

Re: [R] Selecting cases from matrices stored in lists

2011-08-22 Thread Jean V Adams
> Re: [R] Selecting cases from matrices stored in lists > mdvaan > to: > r-help > 08/22/2011 09:46 AM > > Jean V Adams wrote: > > > >> [R] Selecting cases from matrices stored in lists > >> mdvaan > >> to: > >> r-help > >>

Re: [R] Counting Elements Conditionally

2011-08-22 Thread Jean V Adams
> [R] Counting Elements Conditionally > Edward Patzelt > to: > r-help > 08/22/2011 02:33 PM > > R - > > I have 3 variables with data below. Variable "Rev" is a vector that changes > from 1 to 2, 2 to 3, etc Variable "FF" is a binary variable with 1's > and 0's. Variable "bin" is a diffe

Re: [R] Counting Elements Conditionally

2011-08-22 Thread Jean V Adams
> Re: [R] Counting Elements Conditionally > Jean V Adams > to: > Edward Patzelt > 08/22/2011 03:53 PM > > > [R] Counting Elements Conditionally > > Edward Patzelt > > to: > > r-help > > 08/22/2011 02:33 PM > > > > R - > > &

Re: [R] Counting Elements Conditionally

2011-08-22 Thread Jean V Adams
So, using the full data set, what should the result look like? c(NA, NA, NA, 3, NA,NA, NA, 2) ? Jean Edward Patzelt wrote on 08/22/2011 03:58:38 PM: > [image removed] > > Re: [R] Counting Elements Conditionally > > Edward Patzelt > > to: > > Jean

Re: [R] Counting Elements Conditionally

2011-08-23 Thread Jean V Adams
that is exactly correct, assuming we did not start at the beginning, > but started at the first transition (this is the correct way to > think about it) > On Mon, Aug 22, 2011 at 4:08 PM, Jean V Adams wrote: > > So, using the full data set, what should the result lo

Re: [R] NA in last row while reading xlsx file

2011-08-23 Thread Jean V Adams
ashz wrote on 08/23/2011 03:25:57 AM: > > Hi, > > I am using this script to read a xlsx file to a data frame: > library(xlsx) > File <- file.path("d:", "car ", "car95-99.xlsx") > B_car <- read.xlsx(File, "raw_data") > Car2x <- data.frame(month = B_car$Date,Ch = B_car$Ch.des, > lat=B_car$Latitude

Re: [R] Testing Specific Hypothesis

2011-08-23 Thread Jean V Adams
So, you are looking for confidence intervals for each factor level? You can use the predict() function to do that. fit <- aov(values ~ ind, data=otestme) newdat <- data.frame(ind=factor(levels(otestme$ind))) cbind(newdat, predict(fit, newdata=newdat, interval="confidence")) Jean Anna Dunietz wr

Re: [R] Column of probabilities

2011-08-24 Thread Jean V Adams
Try this: prob.xm <- (table(xm)/length(xm))[match(xm, sort(unique(xm)))] Jean Jim Silverton wrote on 08/24/2011 02:31:05 PM: > Hi all, > I have a vector xm say: xm = c(1,2,3,4,5,5,5,6,6) > > I want to return a vector with the corresponding probabilities based on the > amount of times the nu

Re: [R] Append a value to a vector

2011-08-24 Thread Jean V Adams
Claudio Zanettini wrote on 08/24/2011 03:04:39 PM: > This should be easy but it does not work > I have 3 vectors*(activeT,inactT, activeR)*, > the idea is that if the last value in inactT is higher than the last in > activeT > this value has to be append in active T When you say "this value" whi

Re: [R] Append a value to a vector

2011-08-24 Thread Jean V Adams
uot;8630.11" > [25] "8803.11" "9186.11" "9453.11" "10132.11" "10669.21" "10720.61" > [31] "10755.13" "11326.11" "11440.13" "11486.11" "11508.11" "11711.11" > [37] "11

Re: [R] Append a value to a vector

2011-08-24 Thread Jean V Adams
) activeR <- append(activeR, lastR) } Jean > 2011/8/24 Jean V Adams > > I'm still a little confused about lastV and lastI. The code you > provide uses lastV, but your description seems to refer to lastI. > Test out this code and see if it

Re: [R] Split data frame by date (POSIXlt)

2011-08-24 Thread Jean V Adams
You could try using the numeric representation of date, and split the data frame using that variable. For example: src$date.num <- as.numeric(src$date) Jean Franc Lucas wrote on 08/24/2011 02:42:58 PM: > >Hello everyone, >I want to split a data.frame by the column date . The data fram

Re: [R] Creating new variable with maximum visit date by group_id

2011-08-24 Thread Jean V Adams
Try this: require(zoo) lvd <- tapply(df$visit_date, df$unique_id, max) index <- tapply(df$visit_date, df$unique_id) df$last_visit_date <- as.Date(lvd[index]) Jean Kathleen Rollet wrote on 08/24/2011 04:15:45 PM: > > Dear R users, > > I am encoutering the following problem: I have a dataset wit

Re: [R] Application of results from smooth.spline outside R

2011-08-25 Thread Jean V Adams
I'm assuming that you meant to write s <- smooth.spline(x, y) You can look at the code for the predict method for smooth.spline by typing getAnywhere(predict.smooth.spline) If a new value is provided (i.e., the 500 in your example) then the predict method for smooth.spline.fit is applied to t

Re: [R] How to vary the distance between the pairs of a side-by-side barplot?

2011-08-25 Thread Jean V Adams
>From the help for barplot ?barplot The argument "... space may be specified by two numbers, where the first is the space between bars in the same group, and the second the space between the groups. If not given explicitly, it defaults to c(0,1) if height is a matrix and beside is TRUE ..." S

Re: [R] Create two uniformly random variables correlated

2011-08-25 Thread Jean V Adams
Have you tried searching the R-Help archives? I found some answers to a similar question by Googling r multivariate uniform distribution Jean Soberon Velez, Alexandra Pilar wrote on 08/25/2011 04:15:11 AM: > > Hello, > > > > I want to create two random variables (x1,x2) both with unifo

Re: [R] apply function to spatial grid data frame to calculate CTI

2011-08-25 Thread Jean V Adams
It's not clear to me what problem you're having. tan(data$slope) should work. As should log(data$uparea/data$slope) I suggest that you provide a small subset of example data along with an example of any code you've tried, and the output that you'd like. Jean Tom Vanwalleghem wrote on

Re: [R] rpart: plot without scientific notation

2011-08-25 Thread Jean V Adams
I don't see a quick solution to this. You could contact the maintainer of the rpart.plot package, Stephen Milborrow maintainer("rpart.plot") or you could try to modify the rpart.plot() function yourself to meet your needs rpart.plot Jean Jay wrote on 08/25/2011 05:30:25 AM: > >

Re: [R] Choropleth in R

2011-08-25 Thread Jean V Adams
Check out the maps package for a choropleth map. Specifically the map() function (and its argument col=). ?map Check out the image() function for a heat map which can be overlaid. ?image Jean Reza Salimi-Khorshidi wrote on 08/25/2011 09:00:04 AM: > > Hi all, > I would like to use

Re: [R] Construct a File Path: File Path Unknown

2011-08-25 Thread Jean V Adams
Try the dir() function. ?dir # for example dir("c:/", pattern="foo.pdf", full.names=T, ignore.case=T, recursive=T) Jean Tyler Rinker wrote on 08/25/2011 11:54:28 AM: > > I am not a programmer and am self-taught so I may lack the > language to ask this appropriately (perhaps why an rseek searc

Re: [R] Choropleth in R

2011-08-25 Thread Jean V Adams
for the US + a couple of > other country that unfortunately UK is not one of them. What I want > is a solution that takes a list of coordinates/postcodes/cities and > a list of values and gives me a colourful UK map. Any thoughts? > Cheers > On Thu, Aug 25, 2011 at 3:50 PM, Jean

Re: [R] Generating contingency tables from the null

2011-08-29 Thread Jean V Adams
By the "null distribution" do you mean that the assignment of each observation to a column is equal? If so, the function sample() might serve your needs. For example: rows <- 3 cols <- 4 rowtot <- 100 m <- matrix(NA, nrow=rows, ncol=cols) for(i in seq(rows)) { m[i, ] <- tabulate(samp

Re: [R] Treat an Unquoted Character String as a Data Frame

2011-09-01 Thread Jean V Adams
Try this data <- eval(parse(text=paste(study, level, ".", population, sep=""))) Jean - dbateman wrote on 08/31/2011 17:44:44: I have several datasets that come from different studies (fv02 and fv03), they represent different levels (patients and lesions), and they have different patient

Re: [R] If NA Problem!

2011-09-02 Thread Jean V Adams
Anna Dunietz wrote on 09/02/2011 07:16:45 AM: > > Hi All! > > Please find code and the respective lists below. My problem: I specify the > case that lilwin[[p]] is not an NA and want the code found in iwish to be > returned ONLY for that case. Why do I get a list of length 2 (and why is > NU

Re: [R] Hints for Data Clustering

2011-09-02 Thread Jean V Adams
Look at the function daisy in the package cluster. require(cluster) ?daisy Jean Lorenzo Isella wrote on 09/02/2011 11:50:04 AM: > > Dear All, > I will be confronted (relatively soon) with the following problem: > given a set of known statistical indicators {s_i} , i=1,2...N for a N > countries

Re: [R] confusion matrix

2011-09-06 Thread Jean V Adams
Try the table() function. ?table For example, df <- data.frame(real=sample(0:1, 20, replace=T), pred=sample(0:1, 20, replace=T)) table(df) pred real 0 1 0 3 7 1 4 6 Jean Doussa wrote on 09/02/2011 08:46:42 PM: > > hi users > I have a data frame in with there are two colomns real

Re: [R] Generalizing call to function

2011-09-07 Thread Jean V Adams
Try this: funa <- function(n, y, a, rate, samp) { lambda <- a * n dexp(n, rate) * do.call(paste("d", samp, sep=""), y, lambda) } funb <- function(y, a, rate, samp) { integrate(f1, 0, Inf, y, a, rate) } funb(1, 0.1, 0.1, "pois") Jean > > Hello guy

Re: [R] What happens if we give a factor as an index at a list?

2011-09-07 Thread Jean V Adams
Varsha Agrawal wrote on 09/07/2011 05:18:10 AM: > > The code looks like this: > L1=list(a=1,b=2,c=3) > f1=as.factor(c) > L1[[f1]] returns 1 > > What happens if we give a factor as an index at a list? > L1=list(a=1,b=2,c=3) f1=as.factor(L1$c) L1[[f1]] When you use a factor (e.g., f1, corrected

Re: [R] Question about model selection for glm -- how to select features based on BIC?

2011-09-08 Thread Jean V Adams
If you read the help file on the step() function ?step you will see a reference to BIC under the description of the k= argument. This suggests that you could try: BIC.fitted = step(glm.fit, k=log(dim(dat)[1])) Jean Andra Isan wrote on 09/07/2011 06:12:19 PM: > > Hi All, > After fitt

Re: [R] 3D plot RGL

2011-09-08 Thread Jean V Adams
francogrex wrote on 09/08/2011 08:08:19 AM: > > Hi, anyone has experience with 3D plot (ex: in package RGL) I have a > question, I draw a 3D plot of country, year and sales in z axis but when the > type is "h" then it's ok but when I want to link the points and type is 'l' > lines it's a mess Is

Re: [R] pie chart

2011-09-08 Thread Jean V Adams
Mohan L wrote on 09/08/2011 12:35:18 PM: > > Hi All, > > I have txt file like : > > $ cat data.txt > US 10 > UK 12 > Ind 4 > Germany 14 > France 8 > > > rawdata <- read.table(file='data.txt',sep='\t' , header=FALSE) > > > rawdata >V1 V2 > 1 US 10 > 2 UK 12 > 3 I

Re: [R] Subset function

2011-09-09 Thread Jean V Adams
Rainer provided an example of subsetting by the value of a variable in the data frame. Below is an example of subsetting by the value of the row name of the data frame. df <- data.frame(var1=1:10, var2=letters[1:10], var3=sample(10), row.names=month.abb[1:10]) subset(df, subset = row.name

Re: [R] reshape data from long to wide format

2011-09-09 Thread Jean V Adams
maxbre wrote on 09/09/2011 06:28:15 AM: > > This is my reproducible example: > > example<-structure(list(SENSOR = structure(1:6, .Label = c("A", "B", "C", > "D", "E", "F"), class = "factor"), VALUE = c(270, 292.5, 0, 45, > 247.5, 315), DATE = structure(1:6, .Label = c(" 01/01/2010 1", > " 01/

  1   2   3   >