Re: [R] Error: if statement: missing value where TRUE/FALSE needed

2022-01-06 Thread Chuck Coleman via R-help
. Thanks for helping, Chuck On Thursday, January 6, 2022, 12:14:15 PM EST, Duncan Murdoch wrote: I've downloaded your code, and I'm seeing some strange results.  When I source MetroTest.R, it creates a log file ending Error in if (xseg[w1] > ub & m == 1) olrmark[w

Re: [R] Error: if statement: missing value where TRUE/FALSE needed

2022-01-06 Thread Chuck Coleman via R-help
ple OSs.  Since I'm not a programmer by profession, I've had little need to use these constructs. Chuck Coleman On Wednesday, January 5, 2022, 02:51:07 PM EST, Duncan Murdoch wrote: On 05/01/2022 2:09 p.m., Ivan Krylov wrote: > On Wed, 5 Jan 2022 21:22:37 +0300 > Ivan Kry

[R] Error: if statement: missing value where TRUE/FALSE needed

2022-01-05 Thread Chuck Coleman via R-help
arlier versions of R.  (I don't want to tamper with my installations.)  Afterwards, I have no idea.  Hence, my post. Thank you for your help, Chuck __ R-help@r-project.org mailing list -- To UNSUBSCRIBE and more, see https://stat.ethz.ch/mail

[R] using extremes - extreme value analysis for low (minimum) temperature

2017-02-04 Thread Chuck Snell
Hello, I am trying to answer the question: "What is the probability of a certain day's low forecast (of 21) being the month's overall low?" I decided to attempt it in R Searching pointed me to extreme value analysis. I created a csv file of the last 8 years lows for the month: year month

[R] machine learning goal (new to R )

2017-01-03 Thread Chuck Snell
Hello, I am new to R, a computer programmer friend of mine recommended R for a project I have on my plate. (He is not a R guy but knows I need to consider it for the problem I described to him) Frist, I have plenty of data I have been doing this task with regression models but was asked to try

[R] SimpleR

2013-08-26 Thread Chuck
ackage for SimpleR that is compatible with R 3.x.x? 2) Is there still a binary version of R 1.5.x (or above) that works for Windows? I could use this for the manual, and then switch to 3.x.x for further work. Thanks, Chuck Nelson [[alternative HTML versi

Re: [R] How to count the number of different elements in a column

2012-11-26 Thread chuck.01
My apologies. I still do not understand the difference; good luck. Hard Core wrote > this is wrong because with the command "unique" it counts the only values > that are unique .. > > in my column, for instance, 1 and 4 are not unique so the formula doesn't > work in my case -- View this m

Re: [R] How to count the number of different elements in a column

2012-11-26 Thread chuck.01
length(unique(a)) Hard Core wrote > Hello, > Suppose that i have a dataframe > a <- read.dta("banca_impresa.dta") > > i have a column with 17900 obs like > > 1 > 2 > 3 > 1 > 6 > 7 > 8 > 3 > 4 > 4 > > and i want to know the number of the different values so in this case it > would be 7 > Ho

Re: [R] IMPORTANT!!!! PLEASE HELP ME

2012-11-24 Thread chuck.01
1st. Calm down, this doesn't seem that important. Then you will need to know some base functions. see ?rnorm Doing this 10,000 times and making them of size 50 is no problem. FYI: I don't understand what "with replacement case" means; could you clarify? Jasmin wrote > Hi, > I want to gener

Re: [R] Biologist R learner

2012-11-19 Thread chuck.01
Please take the advice of Berend if you ever want to get help here. Also, you will need to do some basic and initial work yourself; read what he suggested, use Google to search keywords, and see great help like this: http://cran.r-project.org/doc/contrib/Short-refcard.pdf also, use the built in

Re: [R] Jackknife in Logistic Regression

2012-11-14 Thread chuck.01
untested, but something like this should get you what you want: no.it <- 5 out <- vector("list", length=no.it) for(i in 1:no.it){ mydata2 <- mydata[ sample(1:nrow(mydata), 76000/no.it) ,] out[[i]] <- coef( glm(f_ocur~altitud+UTM_X+UTM_Y+j_sin+j_cos+temp_res+pp+offset(log(1/off)), data

Re: [R] Random sampling many times and run through glm model

2012-11-13 Thread chuck.01
see: ?boot SASandRlearn wrote > I have a large dataset from which i need to take a random sample many > times ( say N=50) and run it through the same glm() - logistic regression > model everytime ( 50 times ) and capture the chi-square p-values ( Pr > > ChiSq ) of the variables for each run an

Re: [R] Is there a way to export regression output to an excel spreadsheet?

2012-11-09 Thread chuck.01
Yes. see: ?lm ?coef ?write.csv also, if fit <- lm(Y~X) then: slope_p-value <- summary(fit)[[4]][2,4] Double check that last one for yourself. Good luck. hoguejm wrote > I want to export the coefficient values and p-values from my regression > output into a spreadsheet. Is there a way to

[R] extracting information from txt file

2012-10-31 Thread chuck.01
Hello, Here is a link to some data: http://www.epa.gov/emap/html/data/surfwatr/data/mastreams/9396/wchem/chmval.txt I am trying to read this in, and want to use: chmval <- read.table("http://www.epa.gov/emap/html/data/surfwatr/data/mastreams/9396/wchem/chmval.txt";, sep=",", skip= 84, header=T)

Re: [R] grep txt file names from html

2012-10-31 Thread chuck.01
epends on what you plan to do with them, > and what sort of output you expect. > > It isn't even clear whether you plan to do this in R. > > Sarah > > > On Wed, Oct 31, 2012 at 12:56 PM, chuck.01 < > CharlieTheBrown77@ > >wrote: > >> Sorry, I

[R] grep txt file names from html

2012-10-31 Thread chuck.01
Sorry, I know I should read a little 1st about this, but I am actually just helping somebody really quick and need help too. I want to grep all of the names of the .txt files mentioned on this html web page: http://www.epa.gov/emap/remap/html/three/data/index.html Thanks ahead of time. -- Vi

Re: [R] POSIXct date missing "time component"

2012-10-31 Thread chuck.01
onds. > > So, may be it is better to add a sec and later subtract it. > >  dates.mine2<-dates.mine+1 > dates.mine2[3] > #[1] "2009-05-22 00:00:01 GMT" >  dates.mine3<-dates.mine2-1 >  dates.mine3[3] > #[1] "2009-05-22 GMT" > A.K. > > &g

Re: [R] POSIXct date missing "time component"

2012-10-30 Thread chuck.01
0:00 GMT" "2009-05-21 23:45:00 GMT" [3] "2009-05-22 00:00:00 GMT" "2009-05-22 00:15:00 GMT" dates.mine[3] [1] "2009-05-22 GMT" chuck.01 wrote > Hi, > > I have some dates that are giving me a problem, in general the dates look > like this

Re: [R] POSIXct date missing "time component"

2012-10-30 Thread chuck.01
Um, OK. My dates have times, they are 00:00:00 (i.e. midnight) I'll just add a fraction of a second my dates and go with it. Thanks for the reply. arun kirshna wrote > HI, > Please check this link > (http://rss.acs.unt.edu/Rdoc/library/base/html/as.POSIXlt.html). > "Dates without times are

[R] POSIXct date missing "time component"

2012-10-30 Thread chuck.01
Hi, I have some dates that are giving me a problem, in general the dates look like this: free.dates[60:61] [1] "2009-05-21 23:45:00 GMT" "2009-05-22 00:00:00 GMT" but for some reason, when taken "alone", they look like this: free.dates[60] [1] "2009-05-21 23:45:00 GMT" free.dates[61] [1] "2009

[R] changing date by +/- days

2012-10-29 Thread chuck.01
Hi, Let say I have a date variable like this: structure(1243792800, class = c("POSIXct", "POSIXt"), tzone = "GMT") [1] "2009-05-31 18:00:00 GMT" How can I make it 10 days prior, so: [1] "2009-05-21 18:00:00 GMT" I'm randomly selecting dates from a list and want a second value a set # of days

Re: [R] changing date by +/- days

2012-10-29 Thread chuck.01
got it, sorry! structure(1243792800, class = c("POSIXct", "POSIXt"), tzone = "GMT")-(60*60*24*10) chuck.01 wrote > Hi, > Let say I have a date variable like this: > > structure(1243792800, class = c("POSIXct", "POSIXt"), tzone =

Re: [R] Which test should I use for comparing the change of two samples

2012-10-29 Thread chuck.01
1) get differences 2) run t-test on #1 * Be warned: I am not a statistician. Tammy Ma wrote > Dear All, > > I have two samples as the following: > conjps<-c(9.41,10.45,10.78,10.73,11.11,11.12,11.59,11.04,11.63) > > ms<-c(4.11,5.10,5.70,6.46,6.04,6.16, 6.24,6.32,7.33) > > I want to test

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

2012-10-26 Thread chuck.01
Thanks Jean, Your 1st solution was one I've tried, w/o great success. The 2nd works a lot better (on real, and more messy, data), especially when I set span to a much smaller number than 1/10. Thank you greatly. -Chuck Jean V Adams wrote > Using the data you provided, a combin

[R] deconstructing curve into rising and falling limbs

2012-10-26 Thread chuck.01
hello, I have some data that looks similar to this (only not as nice as this): Y <- c(abs(rnorm(100, 0.10, .1)), seq(.10, 1.0, .3)+rnorm(1, 0, .5) , seq(0.8, 4.0, .31)+rnorm(1, 0, .5) , seq(3.9, .20, -.2)+rnorm(1, 0, .5) , abs(rnorm(100, 0.13, .1)) , seq(.10, 1.2, .35)+rnorm(1, 0, .5) , seq(0.7,

Re: [R] Help with correlation matrices, thresholding

2012-07-16 Thread chuck.01
Try this as a starting point; dat is your whole data set, and r = correlation coefficient threshold: spec.cor <- function (dat, r, ...) { x <- cor(dat, ...) x[upper.tri(x, TRUE)] <- NA i <- which(abs(x) >= r, arr.ind = TRUE) data.frame(matrix(colnames(x)[as.vector(i)], ncol = 2)

Re: [R] residuals from lm

2012-07-02 Thread chuck.01
nevermind... I forgot the column of 1's for the intercept term chuck.01 wrote > > Hi, > I was playing around with something else and I noticed this matrix code > for residuals in a linear model doesn't say what lm() says. Please tell > me if I am completely misguide

[R] residuals from lm

2012-07-02 Thread chuck.01
Hi, I was playing around with something else and I noticed this matrix code for residuals in a linear model doesn't say what lm() says. Please tell me if I am completely misguided here. data(mtcars) Y <- as.matrix(mtcars[,1]) X <- as.matrix(mtcars[,c(2:11)]) # shouldnt this: H <- X %*% solve(

Re: [R] residuals from lm

2012-07-02 Thread chuck.01
FYI: As you are likely thinking: this doesn't belong here (It just occurred to me), I am questioning what I did, not the output of lm() But if someone knows why I am wrong please let me know. chuck.01 wrote > > Hi, > I was playing around with something else and I noticed th

Re: [R] problem with get() inside of lme()

2012-05-12 Thread chuck.01
~EP, random= ~1|No, data=petrol) I'd really like to use the variable... again, this is inside a function. Any idea how to solve this. Thanks for your time and expertise, Chuck chuck.01 wrote > > please note that I edited the original message to say: > >> length(with(new

[R] round up/down to nearest hundredth

2012-05-12 Thread chuck.01
Hi, How can I round up and down to the nearest hundredth example: x <- 0.18 how do I round down to 0.15? how do I round down to 0.20? -- View this message in context: http://r.789695.n4.nabble.com/round-up-down-to-nearest-hundredth-tp4629451.html Sent from the R help mailing list archive at

Re: [R] problem with get() inside of lme()

2012-05-12 Thread chuck.01
please note that I edited the original message to say: > length(with(new3, perm.score))==length(with(new3, get(TRAIT1))) [1] TRUE chuck.01 wrote > > Hi, > The following lines of code are inside of a function, where "TRAIT1" is > a function variable calling a

[R] problem with get() inside of lme()

2012-05-12 Thread chuck.01
Hi, In the following lines of code are inside of a function, where "TRAIT1" is a function variable calling a column-name inside of the data.frame "new3". This works just fine: m2 <- lmer(get(TRAIT1) ~ perm.score + (1|site), data=new3) but this will not work, m3 <- lme(get(TRAIT1) ~ perm.sc

Re: [R] Merge function - Return NON matches

2012-04-26 Thread chuck.01
# dput() example # lets say you have data called y, like this: > y sp1 sp2 sp3 sp4 d 0 0 0 0 e 0 0 0 0 f 0 0 0 0 # ok, so do this: > dput(y) structure(list(sp1 = c(0, 0, 0), sp2 = c(0, 0, 0), sp3 = c(0, 0, 0), sp4 = c(0, 0, 0)), .Names = c("sp1", "sp2", "sp3", "sp4" )

Re: [R] fill a dataframe with zeros where the rows are a smaller subset of a larger dataframe (species by site)

2012-04-25 Thread chuck.01
-- View this message in context: http://r.789695.n4.nabble.com/fill-a-dataframe-with-zeros-where-the-rows-are-a-smaller-subset-of-a-larger-dataframe-species-by-sit-tp4586534p4586711.html Sent from the R help mailing list archive at Nabble.com. __ R-he

Re: [R] call object from character?

2012-04-18 Thread chuck.01
I figured as much. Thank you greatly. plangfelder wrote > > On Wed, Apr 18, 2012 at 7:25 PM, chuck.01 <CharlieTheBrown77@> > wrote: >> Let say I have an object (I hope my terminology is correct) a >> a <- 12 >>> a >> [1] 12 >> >> An

[R] call object from character?

2012-04-18 Thread chuck.01
Let say I have an object (I hope my terminology is correct) a a <- 12 > a [1] 12 And "a" has been assigned the number 12, or whatever And lets say I have a character "call_A" call_A <- "a" >call_A [1] "a" What is the function "F" that allows this to happen: > F( call_A ) [1] 12 -- View this mes

Re: [R] Function - simple question

2012-04-05 Thread chuck.01
This is one way: f <- function(x, y){ Z <- ifelse(x==y, 3, 4) return(Z) } DS[3] <- with(DS, f(X,Y)) colnames(DS)[3] <- "Z" But you don't really need a function to do that. DS[3] <- with(DS, ifelse(X==Y, 3, 4)) # this works just fine I'm glad you've decided to use R; eventually you will ne

Re: [R] map and shapefile help

2012-04-01 Thread chuck.01
Sun, Apr 1, 2012 at 4:55 PM, Michael Sumner <mdsumner@> wrote: >>> Try the R-Sig-Geo mailing list for a better target community, but if >>> these >>> are shapefiles there is read support in rgdal (or maptools for a simpler >>> alternative) and if these a

[R] map and shapefile help

2012-03-31 Thread chuck.01
Hi, I want to use map("state") and have the ecoregion shape (please see link) file projected onto this. ftp://ftp.epa.gov/wed/ecoregions/cec_na/NA_CEC_Eco_Level3.zip ftp://ftp.epa.gov/wed/ecoregions/cec_na/NA_CEC_Eco_Level3.zip Could someone please show me how; I have never messed with this so

Re: [R] What error distribution should I use?

2012-03-27 Thread chuck.01
Could you please post a small example of your data and code which gives you this error. Your assumed error distribution sounds reasonable. I am interested as to why you have zeros... you have sites with species richness ==0 ?? Lívia Dorneles Audino wrote > > I'm trying to make a glmm to i

Re: [R] reading header in txt file and making histogram

2012-03-26 Thread chuck.01
You really need to read one of many beginners guides to R; but I will say this much: YOUR_DATA <- read.table("nigeria slr misc/Nigeria India /DBHHISTOGRAM.txt", header=TRUE) then you should be able to plot it like I said previously. If that still doesn't work, you need to read the posting guide

Re: [R] reading header in txt file and making histogram

2012-03-25 Thread chuck.01
dbh is the column name. What is the name of your data? Lets assume your data is called "YOUR_DATA" then try: with(YOUR_DATA, hist(dbh)) OR hist(YOUR_DATA$dbh) OR hist(YOUR_DATA[, "dbh"]) etc... bamboohydraulics wrote > > Dear all > > I am a BEGINNER and have R on my Mac. I saved my

Re: [R] show and produce PDF file with pdf() and dev.off( ) in function

2012-03-23 Thread chuck.01
1) thats not a function (i'm sure just a mistake) 2) Just add another plot line myplot <- function(x){ plot(x) pdf("xplot.pdf") plot(x) dev.off() } myplot(1:20) casperyc wrote > > Hi all, > > I know how to use pdf() and dev.off() to produce and save a graph. > > However, wh

Re: [R] How to convert factors to numbers

2012-03-23 Thread chuck.01
Using your posed data, the variable price was numeric: data.precios <- read.table("http://r.789695.n4.nabble.com/file/n4498828/p_diarios.txt";, header=T) str(data.precios) 'data.frame': 1996 obs. of 2 variables: $ time : int 37988 37991 37993 37994 37995 37998 37999 38000 38001 38002 ... $

Re: [R] PCA in predefined Groups??

2012-03-10 Thread chuck.01
Without taking away all the fun of trial and error, and exploration in R... I will direct you to this website which I found invaluable when I first began to use R. one way would be to use: plot(Yourdata, type="n") and then 3 text() or points() statements to plot the groups represented by differen

Re: [R] For loop and using its index

2012-03-09 Thread chuck.01
] = 200 - x[i] } # finally, this will reassemble the output of the for loop z <- do.call(cbind, z) colnames(z) <- c("z1", "z2", "z3") # Finally, do read what the others sent you as they provide more efficient solutions HTH Chuck Hassan Eini Zinab wrote >

Re: [R] Correlation between 2 matrices but with subset of variables

2012-03-08 Thread chuck.01
Example data would be helpful A Ezhil wrote > > Dear All, > I have two matrices A (40 x 732) and B (40 x 1230) and would like to > calculate correlation between them.  I can use: cor(A,B, method="pearson") > to calculate correlation between all possible pairs. But the issue is that > there is

Re: [R] pasting several things

2012-03-03 Thread chuck.01
ot;) > > paste(x[1, 1], do.call(paste, c(x[1, x != ""][, -1], list(sep="_"))), > sep=" -") > > # Output looks like this >> paste(x[1, 1], do.call(paste, c(x[1, x != ""][, -1], list(sep="_"))), >> sep=" -")

[R] pasting several things

2012-03-02 Thread chuck.01
I have this type of format: structure(list(day = 19, C1 = structure(1L, .Label = c("", "C1" ), class = "factor"), C2 = structure(2L, .Label = c("", "C2"), class = "factor"), C3 = structure(1L, .Label = c("", "C3"), class = "factor"), Q1 = structure(2L, .Label = c("", "Q1"), class = "fact

Re: [R] loop for a large database

2012-02-26 Thread chuck.01
Untested die to no data, but this should work with a loop out=vector("list", length= length(MyVector)) for(i in 1 : length (MyVector)) { x <- data.frame (sum (MyTable ==MyVector[i])) out[[i]] <- x } sum(do.call(rbind, out)) -- View this message in context: http://r.789

Re: [R] How to resample matrices to test for the robustness of their correlation

2012-02-18 Thread chuck.01
see: ?sample library(vegan) ?rrarefy not knowing your data structure, its hard to say. camilleislande wrote > > Hello > I have several populations where I have morphology and diet for each > individual. I am interested in the correlation between diet and > morphological distances. However the

[R] incomplete final line found by readTableHeader on 'test.csv'

2012-02-16 Thread chuck.01
Hello, I have recently had issues with read.csv where i get the following warning, and this happens on both my OSX and Linux machines. Here is the warning and an example CSV file is attached: Warning message: In read.table(file = file, header = header, sep = sep, quote = quote, : incomplete

Re: [R] matching a sequence in a vector?

2012-02-15 Thread chuck.01
this is ugly, but... l <-length(patrn) l2 <-length(exmpl) out <- vector("list") for(i in 1:(l2-l+1)) { exmpl[i:(i+l-1)] patrn==exmpl[i:(i+l-1)] if(all(patrn==exmpl[i:(i+l-1)])) { out[[i]] <- i } else { out[[i]] <- "NA"} } out <- do.call(c, out) as.numeric(out[which(out!="NA")]) ##

Re: [R] comparing vectors with condition

2012-02-13 Thread chuck.01
sum(ifelse(x*total!=0, as.numeric(x> total), 0)) arunkumar wrote > > Hi > > I have two vector > > x=c(10,30,40,50) > total=c(20,20,0,10) > > Var_exceeding_total=sum(as.numeric(x> total)) > > This will compare the vectors x and total a gives the result. > > if i want to compare only if t

Re: [R] Reading in csv with footer

2012-02-13 Thread chuck.01
I believe this should work d <- read.table("foo.csv", header=T, sep=",", comment="T") although its spitting back a warning... this used to work for me. Noah Silverman wrote > > Hi, > > I have a CSV file that is formatted well, except that the last line is a > "summary" not is CSV format.

[R] 3d average values

2012-02-06 Thread chuck.01
Hello, given the set of grey points (corners of squares, see visual)... something like this: http://r.789695.n4.nabble.com/file/n4363505/Slide2.png how do I calculate the average value of the variable z, that was measured at the corners of the rectangles (represented by the black points in th

Re: [R] How to Compare the median to the mean?

2012-02-04 Thread chuck.01
I found something a little different: > median(nb10[,1]) [1] 404 > mean(nb10[,1]) [1] 404.59 compare them They are different. Your sample is not perfectly symmetrical (50% above, 50% below) about the mean (ie. the third standardized moment (skewness) is not zero). This is really not a ques

Re: [R] Binding matrices of different sizes

2012-02-03 Thread chuck.01
http://r.789695.n4.nabble.com/template/NamlServlet.jtp?macro=search_page&node=789695&query=cbind+with+different+rows Rambler1 wrote > > I am trying to bind two matrices of different length. They both are one > column and many rows but the rows differ by a few. How am I able to cbind > them toge

Re: [R] Contour plot with messy field data.

2012-02-02 Thread chuck.01
I wanted) Per_neg_0.5 <- (length(which(z.2<=-.5))*diff_y*diff_x)/total_area If you see a problem, please let me know. chuck.01 wrote > > Ok, > I've since found this: > > # called previously posted dataset "dat" > > attach(dat) > library(akima)

Re: [R] Contour plot with messy field data.

2012-02-02 Thread chuck.01
Ok, I've since found this: # called previously posted dataset "dat" attach(dat) library(akima) data.interp <- interp(x,y,z) contour(data.interp) any idea how to calculate area within specified contour lines? Thanks chuck.01 wrote > > Hello, > I have some da

[R] Contour plot with messy field data.

2012-02-02 Thread chuck.01
Hello, I have some data that will be in the form: structure(list(station = structure(c(20L, 2L, 4L, 19L, 3L, 11L, 1L, 5L, 10L, 12L, 17L, 18L, 6L, 9L, 13L, 16L, 7L, 8L, 15L, 14L ), .Label = c("1", "10", "11", "12", "13", "14", "15", "16", "17", "18", "19", "2", "3", "4", "5", "6", "7", "8", "9",

Re: [R] Graph Titles

2012-01-28 Thread chuck.01
Hard to help without a short example dataset (please read posting guide!) posted with dput(). You likely want to "paste" together a title for your graph. see ?paste Rambler1 wrote > > Another simple question that is driving me crazy: > I have a for loop that loops through a matrix and pulls d

Re: [R] Grabbing Column and Row titles

2012-01-27 Thread chuck.01
the code without the "function(dat,...){}" and have it run in a > larger function? > Also what is the context of the command "dat" R is very new and confusing > to me and sometimes ?# doesn't fully explain it for me. Thank you! > > > > chuck.01 wr

Re: [R] Grabbing Column and Row titles

2012-01-27 Thread chuck.01
This is true with regard to all things you don't understand in R... use question mark (?) # this will show you the manual, or help page ?dput also, make sure you hit the "quote" button when you reply on this forum so that people know what you are replying to. I used dput() to create the follo

Re: [R] Grabbing Column and Row titles

2012-01-27 Thread chuck.01
Please use dput() to post your example matrix. Rambler1 wrote > > I have run into a problem in my code. What I want to accomplish is this: > I have a user input stock symbols into a list and from there I run the > quantmod package to get historical data. I compute the correlation matrix > and

Re: [R] nls help

2011-11-30 Thread chuck.01
initial guess is just so far gone that the nls() > optimizer can't handle it. > > If you try a more reasonable initial guess it works fine: > > fit <- nls(Y ~ a*exp(-k * X), datum, start=c(a=3400, k=1.867)) > > Michael > > On Wed, Nov 30, 2011 at 12:14 PM, chuck.01 <C

[R] nls help

2011-11-30 Thread chuck.01
estimates I have never attempted to fit a non-linear model before, and thus the model may be inappropriately specified, or it is also possible that I have no idea what I am doing. Would someone please offer some advice. Thanks. Chuck -- View this message in context: http://r.789695.n4.nabble

Re: [R] Change the colour of lines in the xyplot?

2010-07-12 Thread Chuck Cleland
_ > R-help@r-project.org mailing list > https://stat.ethz.ch/mailman/listinfo/r-help > PLEASE do read the posting guide http://www.R-project.org/posting-guide.html > and provide commented, minimal, self-contained, reproducible code. -- Chuck Cleland, Ph.D. NDRI, Inc. (www.ndri.org) 71 We

Re: [R] Logistic regression with multiple imputation

2010-06-30 Thread Chuck Cleland
v) summary(MIcombine(betas,vars)) > Thank you! > > Daniel > > [[alternative HTML version deleted]] > > __ > R-help@r-project.org mailing list > https://stat.ethz.ch/mailman/listinfo/r-help > PLEASE do read the posting

Re: [R] "If-error-resume-next"

2010-06-24 Thread Chuck Cleland
ed, minimal, self-contained, reproducible code. -- Chuck Cleland, Ph.D. NDRI, Inc. (www.ndri.org) 71 West 23rd Street, 8th floor New York, NY 10010 tel: (212) 845-4495 (Tu, Th) tel: (732) 512-0171 (M, W, F) fax: (917) 438-0894 __ R-help@r-project.org mailing lis

Re: [R] Power calculation

2010-06-10 Thread Chuck Cleland
> R-help@r-project.org mailing list > https://stat.ethz.ch/mailman/listinfo/r-help > PLEASE do read the posting guide http://www.R-project.org/posting-guide.html > and provide commented, minimal, self-contained, reproducible code. -- Chuck Cleland, Ph.D. NDRI, Inc. (www.n

Re: [R] switching elements of a vector

2010-05-24 Thread Chuck Cleland
d after that I've selected elements different from zero > ...it is quite long... > can you find an easier solution? > > Thank you for you help -- Chuck Cleland, Ph.D. NDRI, Inc. (www.ndri.org) 71 West 23rd Street, 8th floor New York, NY 10010 tel: (212) 845-4495 (Tu, Th) tel: (

Re: [R] Getting dates in an SPSS file in right format.

2010-05-18 Thread Chuck Cleland
t.org mailing list > https://stat.ethz.ch/mailman/listinfo/r-help > PLEASE do read the posting guide http://www.R-project.org/posting-guide.html > and provide commented, minimal, self-contained, reproducible code. -- Chuck Cleland, Ph.D. NDRI, Inc. (www.ndri.org) 71 West 23rd Street, 8th flo

Re: [R] How ls() only functions or anything else but functions?

2010-05-13 Thread Chuck Cleland
On 5/13/2010 11:04 AM, Chuck Cleland wrote: > On 5/13/2010 10:02 AM, John Edwards wrote: >> Hello, >> >> How ls() only functions or only data objects (basically anything other than >> functions) such as data.frame, numeric ...? > > c(ls.str(mode = "function&

Re: [R] How ls() only functions or anything else but functions?

2010-05-13 Thread Chuck Cleland
nd provide commented, minimal, self-contained, reproducible code. -- Chuck Cleland, Ph.D. NDRI, Inc. (www.ndri.org) 71 West 23rd Street, 8th floor New York, NY 10010 tel: (212) 845-4495 (Tu, Th) tel: (732) 512-0171 (M, W, F) fax: (917) 438-0894 __ R-h

Re: [R] vectorize a power analysis?

2010-05-12 Thread Chuck Cleland
how the timing compares, but I like the simplicity and readability of replicate(). hope this helps, Chuck > Someone told me that the apply functions are barely any faster than for > loops, so what is the best way, in general, to approach this type of problem > in R-style? > Could s

Re: [R] Determining Index of Last Element in Vector

2010-04-25 Thread Chuck Cleland
c(1, rep(2, length(v) - 2), 1)) [1] 1 2 2 3 3 4 > So the question is, is there a better way specify the last element of a > vector? If not, is there a better way to duplicate all elements of a vector > except for the first and last? (I know you can achieve this using two > lines, but

Re: [R] substract start from the end of the vector

2010-04-23 Thread Chuck Cleland
** > > > > > [[alternative HTML version deleted]] > > __ > R-help@r-project.org mailing list > https://stat.ethz.ch/mailman/listinfo/r-help > PLEASE do read the posting guide http://www.R-

Re: [R] How to make a boxplot with exclusion of certain groups

2010-04-19 Thread Chuck Cleland
st > https://stat.ethz.ch/mailman/listinfo/r-help > PLEASE do read the posting guide http://www.R-project.org/posting-guide.html > and provide commented, minimal, self-contained, reproducible code. -- Chuck Cleland, Ph.D. NDRI, Inc. (www.ndri.org) 71

Re: [R] sum specific rows in a data frame

2010-04-14 Thread Chuck
Depending on the size of the dataframe and the operations you are trying to perform, aggregate or ddply may be better. In the function below, df has the same structure as your dataframe. Check out this code which runs aggregate and ddply for different dataframe sizes.

[R] search and replace

2010-04-14 Thread Chuck
I have a dataframe with almost a million rows which has one column with strings. That column has several entries with the words "South", "North", "East" and "West" which I would like to replace with S, N, E, and W, respectively. Obviously, I can use gsub multiple times df $col2 <- gsub("West", "W

Re: [R] how to delete columns with NA values?

2010-04-14 Thread Chuck Cleland
na(tm1)) == 0] > I search a lot, all I found is how to delete column with all NA values.. > > Thanks a lot > > muting -- Chuck Cleland, Ph.D. NDRI, Inc. (www.ndri.org) 71 West 23rd Street, 8th floor New York, NY 10010 tel: (212) 845-4495 (Tu, Th) tel: (732) 512-0171 (M, W, F) fax

Re: [R] Finding common an unique elements in character vectors

2010-03-29 Thread Chuck Cleland
__ > R-help@r-project.org mailing list > https://stat.ethz.ch/mailman/listinfo/r-help > PLEASE do read the posting guide http://www.R-project.org/posting-guide.html > and provide commented, minimal, self-contained, reproducible code. --

Re: [R] Stacking matrices

2010-03-15 Thread Chuck Cleland
tp://www.R-project.org/posting-guide.html > and provide commented, minimal, self-contained, reproducible code. -- Chuck Cleland, Ph.D. NDRI, Inc. (www.ndri.org) 71 West 23rd Street, 8th floor New York, NY 10010 tel: (212) 845-4495 (Tu, Th) tel: (732) 512-0

Re: [R] Randomly sampling subsets of dataframe variable

2010-03-12 Thread Chuck Cleland
ect.org mailing list > https://stat.ethz.ch/mailman/listinfo/r-help > PLEASE do read the posting guide http://www.R-project.org/posting-guide.html > and provide commented, minimal, self-contained, reproducible code. -- Chuck Cleland, Ph.D. NDRI, Inc. (www.ndri.org) 71 West 23rd Street, 8t

Re: [R] TukeyHSD model thing

2010-03-06 Thread Chuck Cleland
29.62672 > full documents are in the attachment, > can someone suggest to me the relevent R codes > that does the same sort of thing? > (tukeyHSD,fisherLSD,and anova table ) > > Thanks! > > casper http://n4.nabble.com/file/n1583109/SAS.pdf SAS.pdf > http://n

Re: [R] sem package and growth curves

2010-03-03 Thread Chuck Cleland
Dear John, Thanks very much for your message. I should have looked at the help page for sem() more closely. Thanks again for your excellent work on the package. Regards, Chuck On 3/3/2010 10:18 AM, John Fox wrote: > Dear Chuck and Daniel, > > First, thanks Chuck for fielding the

Re: [R] sem package and growth curves

2010-03-03 Thread Chuck Cleland
could be. If anyone has approaches to specifying the models that are less sensitive to starting values, or ways for less sophisticated users to generate good starting values, please share. Chuck # Begin Code for Models A-D, Chapter 8, Singer & Willett (2003) alc2 <- read.table("h

Re: [R] setting the steps for x axis labels on plot

2010-03-01 Thread Chuck Cleland
ng list > https://stat.ethz.ch/mailman/listinfo/r-help > PLEASE do read the posting guide > http://www.R-project.org/posting-guide.html > and provide commented, minimal, self-contained, reproducible code. -- Chuck Cleland, Ph.D. NDRI, Inc. (www.ndri.org) 71 West 23rd Street,

[R] aggregate function / custom column names?

2010-02-11 Thread Chuck White
This question is about column names returned by the aggregate function. Consider the following example df <- data.frame( id = c(rep('11',30),rep('22',30),rep('33',30)), value = c(rnorm(30,2,0.5), rnorm(30,3,0.5), rnorm(30,6,0.5)) ) aggregate(df[,c("value"),drop=FALSE], by=list(id=df$id), m

Re: [R] ggplot2 / time series with different scales

2010-02-05 Thread Chuck White
Thank you both for your response. As the names suggest, I am plotting the sales & price data for items over time to understand the how certain items may be more responsive than others to price changes. Another way of displaying this information on the same chart as the one showing sales, would

[R] ggplot2 / time series with different scales

2010-02-04 Thread Chuck White
I am trying to plot this dataset using ggplot2: df <- data.frame( sid = c(rep('11',30),rep('22',30)), time = rep(ISOdate(year = 2010, month = 1, day = 1:30),2), sales = c(rnorm(30, 1000, 20),rnorm(30, 900, 10)), price = c(rnorm(30, 2, 0.5),rnorm(30, 3,0.5)) ) Plotting just the sales

Re: [R] merging columns

2010-02-02 Thread Chuck White
ing seems to work: data.frame(sapply(col2.uniq, function(col) { wcol <- which(col==col2) as.numeric(rowSums(data.frame(data.df[,wcol]))>0) })) I had to wrap data.df[,wcol] in another data.frame to handle situations where wcol had one element. Is there a better approach? ---- Chuck Whi

[R] merging columns

2010-02-02 Thread Chuck White
Hello -- I am trying to merge columns in a dataframe based on substring matches in colnames. I would appreciate if somebody can suggest a faster/cleaner approach (eg. I would have really liked to avoid the if-else piece but rowSums does not like that). Thanks. data.df <- data.frame(aa=c(1,1,0),

Re: [R] Subset and plot

2010-02-02 Thread Chuck Cleland
ial==2 & Tanks=="a4"|Trial==2 & > Tanks=="c4"|Trial==2 & Tanks=="h4") > daily.sub1<-as.data.frame(daily.sub) > attach(daily.sub1) > daily.sub1 > x11() > plot(Day, Wgt) > #plot(Day, Wgt, pch=c(2,19,21)[Tanks]) > detach(daily

Re: [R] ggplot/time series with indicators question

2010-02-01 Thread Chuck White
; > > Since this question properly belongs on the ggplot2 list, it is being cc'ed > there as well. > > HTH, > Dennis > > On Mon, Feb 1, 2010 at 6:06 PM, Chuck White wrote: > > > Hello, I am trying to plot time-series data with certain weeks highlighted > &g

[R] ggplot/time series with indicators question

2010-02-01 Thread Chuck White
Hello, I am trying to plot time-series data with certain weeks highlighted using symbols. require(ggplot2) #plotting time series data timescale <- seq(as.Date("01/01/09","%m/%d/%y"), length.out=12, by=7) data.all <- data.frame( id = c(rep('111',12),rep('222',12),rep('333',12)), week=c(ti

Re: [R] Using auto.key with two variable plots

2010-01-30 Thread Chuck Cleland
? Something like this: print(xyplot(temp_species_EAM_Pred_Pop$x + temp_species_NULL_Pred_Pop$x ~ temp_species_EAM_Pred_Pop$Action, main=current_species, xlab="Action",ylab="Predicted Pop", xlim=c(xmin,xmax),ylim=c(ymin,ymax),

[R] SemiPar/spm question

2010-01-29 Thread Chuck White
Hello -- I posted this question yesterday and for some reason the post seems to be attached to the wrong thread. Also, I extended my test a little and it seems to indicate the problem is with spm. I would appreciate any help. Thanks. == lib

  1   2   3   4   >