Re: [R] EOF within quoted string

2017-08-10 Thread Adams, Jean
You might want to try some of the suggestions mentioned in this post: https://stackoverflow.com/q/17414776/2140956 Jean On Thu, Aug 10, 2017 at 7:59 AM, wrote: > Hi, > > Reading http://ssc.wisc.edu/~ahanna/20_newsgroups.csv after downloading > it using > >

Re: [R] about reading files in order

2017-06-29 Thread Adams, Jean
Thanks for that answer. I was not aware of gtools::mixedsort function. Jean On Thu, Jun 29, 2017 at 2:47 PM, Henrik Bengtsson < henrik.bengts...@gmail.com> wrote: > You can use: > > > files <- list.files(path =

Re: [R] ggplot2 geom_bar arrangement

2017-06-27 Thread Adams, Jean
You just have to change the levels of the factor ... library(ggplot2) Lab = c(letters[4:6], letters[1:3]) valuex = c(3.1,2.3,0.4,-0.4,-1.2,-4.4) df <- data.frame(Lab,valuex) # set the factor levels to the same order as observed in the data frame df$Lab <- factor(df$Lab, levels=unique(df$Lab))

[R] ASA Conference on Statistical Practice - deadline Thursday

2017-06-16 Thread Adams, Jean
R Users, Abstracts are now being accepted for the ASA Conference on Statistical Practice February 15-17, 2017 Portland, Oregon USA The deadline for submission is Thursday June 22. Presentations will be 35 minutes long and fall into four broad themes: Communication,

Re: [R] point size

2017-06-16 Thread Adams, Jean
You could add size = log10_P to the aes() inside geom_point(). Untested code below. See also http://ggplot2.tidyverse.org/reference/geom_point.html ggplot(mydata, aes(x = X, y = log10_P)) + theme_bw() + theme(panel.border=element_blank(), legend.position="top", axis.text=element_text(size

Re: [R] subletting an array according to dimnames

2017-06-02 Thread Adams, Jean
Have you tried P2["20", "10", "0"] ? Jean On Thu, Jun 1, 2017 at 3:10 PM, li li wrote: > Hi all, > I have a three dimensional array with the corresponding dimension names. > I would like to subset the array according to the dimension names. For > example, > suppose I

Re: [R] Beginner needs help with R

2017-02-06 Thread Adams, Jean
Try this: seq1 <- paste("DQ0", seq(60054, 60060), sep = "") Jean On Sun, Feb 5, 2017 at 7:50 PM, Nabila Arbi wrote: > Dear R-Help Team! > > I have some trouble with R. It's probably nothing big, but I can't find a > solution. > My problem is the following: > I am

Re: [R] Aggregate data to lower resolution

2017-01-19 Thread Adams, Jean
too much. Thanks again. > > Sincerely, > > Milu > > On Fri, Jul 22, 2016 at 3:06 PM, Adams, Jean <jvad...@usgs.gov> wrote: > >> Milu, >> >> Perhaps an approach like this would work. In the example below, I >> calculate the mean GDP for each 1 degr

Re: [R] Is it possible to create such graph - Which packages can come handy?

2016-12-20 Thread Adams, Jean
​You might find the code in this blog post helpful. http://theanalyticalminds.blogspot.com/2015/03/part-3a-plotting-with-ggplot2.html Scroll down to "Analysing the temperature by month - violin geom with jittered points overlaid​". This shows a series of violin plots, which is another way to

Re: [R] how to show a plot without overlaying the text on top of the another text?

2016-12-14 Thread Adams, Jean
The ggrepel package might help. http://blog.revolutionanalytics.com/2016/01/avoid-overlapping-labels-in-ggplot2-charts.html Jean On Tue, Dec 13, 2016 at 5:37 PM, Marna Wagley wrote: > Hi R user, > I have created using metaNMDS (Nonmetirc Multidimensional Scaling, MDS)

Re: [R] R for skip to the next row if condition met and then another condition to check

2016-12-06 Thread Adams, Jean
This might help. # your example data trboot3 <- structure(c(0L, -1L, -1L, -1L, -1L, -1L, -1L, -1L, 0L, 0L, -1L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 1L, 1L, 1L, 0L, 0L, 0L, 0L, 1L, 1L, 1L, 0L, 0L, 0L, 0L, 0L, -1L, -1L, 0L, 1L, 0L, 0L, -1L, -1L, -1L, -1L, -1L, -1L, -1L, -1L, -1L, 0L, 0L, 0L,

Re: [R] barplot beside=TRUE - values differ on scales

2016-10-12 Thread Adams, Jean
on of > chromosome. The number of copies of a gene located in that chromosomal > regions are indicated by GN. > through this barplot, I intend to show that in 7 cases (columns) if a > relationship exist by plotting GN and CN next to each other. If I log > values in GN, I am loosing the

Re: [R] barplot beside=TRUE - values differ on scales

2016-10-12 Thread Adams, Jean
Adrian, What story are you trying to tell? Or what question are you trying to answer by visualizing these data? How is a bar plot of these numbers going to help? I'm just wondering if perhaps a different visualization might make more sense, for example, a scatter plot of GN vs. CN. m <-

Re: [R] Trouble with parameter estimation in nonlinear regression model

2016-10-04 Thread Adams, Jean
Syela, If you want to constrain parameter "a" to be positive, you can rewrite the equation replacing "a" with "exp(theta)". Then when you get the estimate for "theta", simply convert it back to "a". Jean On Mon, Oct 3, 2016 at 12:23 PM, Syela Mohd Noor wrote: > Hi

Re: [R] Run a fixed effect regression and a logit regression on a national survey that need to be "weighted"

2016-09-20 Thread Adams, Jean
If you want your records to be weighted by the survey weights during the analysis, then use the weights= argument of the glm() function. Jean On Tue, Sep 20, 2016 at 5:04 AM, laura roncaglia wrote: > I am a beginner user of R. I am using a national survey to test

Re: [R] Using apply on a three dimensional matrix and passing multiple arguments to user defined function

2016-09-07 Thread Adams, Jean
Justin, I don't think you can get the apply() function to return an array. You could use lapply() instead, and then use simplify2array() to convert the list of matrices to an array. Also, in your mask() function you don't need the which() and you should return the x. See my example with toy

Re: [R] Adding multiple polygons to a Leaflet map

2016-09-01 Thread Adams, Jean
It is hard to troubleshoot without the data. Can you provide the data, for example using the dput() function, or can you replicate the issue with some simplified version of code that we can run? Jean On Tue, Aug 30, 2016 at 11:26 AM, Kevin Haynes wrote: > Hi everyone -

Re: [R] Improving function that estimates regressions for all variables specified

2016-09-01 Thread Adams, Jean
You may be able find someone else's function that already does you want. For example the dredge() function of the MuMIn package. http://rpackages.ianhowson.com/cran/MuMIn/man/MuMIn-package.html Jean On Fri, Aug 26, 2016 at 1:11 PM, Jorge Cimentada wrote: > Hi, I'd like

Re: [R] loop function

2016-08-18 Thread Adams, Jean
You seemed to have re-written over the "b" object in your code. This might work for you. library(MASS) for (i in 58:1){ for(j in 58:i){ str.temp <- paste("y1 ~ x", i, "* x", j, sep = "") univar <- glm.nb(as.formula(str.temp), data=df) b <- summary(univar)$coeffients[4, 4] if(b <

Re: [R] Extracting dates to create a new variable

2016-08-10 Thread Adams, Jean
Try this. dfsub <- df[df$deps %in% c("CC", "DD", "FF"), ] names(dfsub) <- c("Subject", "newdate", "origdep") final <- merge(df, dfsub) Jean On Wed, Aug 10, 2016 at 10:58 AM, Farnoosh Sheikhi via R-help < r-help@r-project.org> wrote: > blockquote, div.yahoo_quoted { margin-left: 0 !important;

Re: [R] Aggregate data to lower resolution

2016-07-22 Thread Adams, Jean
Milu, Perhaps an approach like this would work. In the example below, I calculate the mean GDP for each 1 degree by 1 degree. temp$long1 <- floor(temp$longitude) temp$lat1 <- floor(temp$latitude) temp1 <- aggregate(GDP ~ long1 + lat1, temp, mean) long1 lat1GDP 1 -69 -55 0.90268640

Re: [R] multiple-line plot

2016-07-20 Thread Adams, Jean
Use the dput() function to share a subset of your data with the list (attachments are not supported). For example, submit this command dput(for_jhon[1:20, ]) and post the result to the list along with your question. Jean On Tue, Jul 19, 2016 at 1:24 PM, John Wasige

Re: [R] Forking and adapting an R package

2016-07-13 Thread Adams, Jean
Timo, A couple of thoughts ... First, could you achieve what you want by simply modifying (your own copies of) a function or two from the hexbin package, without having to modify the entire package? This might give you fewer tripping points. Second, right after you forked the package (so that

[R] ASA Conference on Statistical Practice - deadline Thursday

2016-06-20 Thread Adams, Jean
R users, Abstracts are now being accepted for the ASA Conference on Statistical Practice February 23-25, 2017 Jacksonville FL, USA Past conference attendees have shown particular interest in R, reproducibility, and data visualization. The deadline for submission is June 23.

Re: [R] Filtering String Variables

2016-05-23 Thread Adams, Jean
George, You are very close. Try this ... # make Debitor a character variable in the data frame ds_example$Debitor <- as.character(ds_example$Debitor) duplicates <- duplicated(ds_example$Debitor) duplicated_debitors <- unique(ds_example$Debitor[duplicates]) ds_duplicates <-

Re: [R] subset by multiple letters condition

2016-04-23 Thread Adams, Jean
://stackoverflow.com/a/8475315 Jean On Sat, Apr 23, 2016 at 11:09 AM, <chalabi.el...@yahoo.de> wrote: > Thanks Jean, Does anyone know how to set these [hast1] and [hast2] as the > colors of a plot? > > > On Friday, April 22, 2016 7:39 AM, "Adams, Jean" <jvad...@usgs.gov>

Re: [R] subset by multiple letters condition

2016-04-22 Thread Adams, Jean
You can use the grepl() function to give you logicals for each criterion, then combine them as needed. For example: # example version of Command Command <- paste0("_localize_", c("PD","t2","t1_seq", "abc", "xyz", "PD_t1")) hasPD <- grepl("PD", Command, fixed=TRUE) hast1 <- grepl("t1", Command,

Re: [R] New member

2016-04-14 Thread Adams, Jean
This is a good place to start ... https://cran.r-project.org/doc/manuals/R-intro.pdf Jean On Thu, Apr 14, 2016 at 5:39 AM, kipkorirfrankli...@gmail.com < kipkorirfrankli...@gmail.com> wrote: > > Hello. I am Franklin from University of Eldoret. I really want to study > the R package. What should

Re: [R] Storing output of loop into list()

2016-04-07 Thread Adams, Jean
You don't need a for loop for the first part. You can do it like this: Notice that I used unchanging data for the temps vector so that you could tell us what output you expect to see, in case what I provide is not adequate. temps <- c(13.988, 13.932, 14.039, 14.082, 13.998, 13.93, 14.028,

Re: [R] before-after control-impact analysis with R

2016-04-04 Thread Adams, Jean
I searched for analyze BACI data in R and found a couple things that you might find helpful. http://people.stat.sfu.ca/~cschwarz/Stat-650/Notes/MyPrograms/BACI/BACITalk-2012-10-15-UBC/baci.pdf http://people.stat.sfu.ca/~cschwarz/Stat-650/Notes/PDFbigbook-R/R-part013.pdf Jean On Sun, Apr 3,

Re: [R] How to form groups for this specific problem?

2016-03-29 Thread Adams, Jean
re these types of questions appropriate for this group? > > Thanks, > Satish > > > On Mar 28, 2016 9:10 AM, "Adams, Jean" <jvad...@usgs.gov> wrote: > >> Satish, >> >> If you rearrange your data into a network of nodes and edges, you can use >>

Re: [R] How to form groups for this specific problem?

2016-03-28 Thread Adams, Jean
Satish, If you rearrange your data into a network of nodes and edges, you can use the igraph package to identify disconnected (mutually exclusive) groups. # example data df <- data.frame( Component = c("C1", "C2", "C1", "C3", "C4", "C5"), TLA = c("TLA1", "TLA1", "TLA2", "TLA2", "TLA3",

Re: [R] treating integer(0) and NULL in conditions and loops

2016-03-11 Thread Adams, Jean
To reframe the problem ... the issue is not with the function nchar() (or whatever), it's with the input value rz being null. I suggest you build into the loop whatever actions/outputs you want when rz is NULL. for (i in 1:10){ if (is.null(rz)) { # do something here } else { if

Re: [R] bootstrap glm

2016-02-29 Thread Adams, Jean
​It's helpful if you post example data with your question, so R-help readers can easily test your code​. I created a fake data set with two x variables for testing. It's also helpful if you list the necessary packages. I assume that used the boot package. You are dealing with two kinds of

Re: [R] Static to interactive map (leaflet spplot)

2016-02-17 Thread Adams, Jean
Deb, I assume you have already seen the great introduction to leaflet here ... http://rstudio.github.io/leaflet/ You may find these two answers on stackoverflow helpful ... http://stackoverflow.com/a/28240058/2140956 http://stackoverflow.com/a/29118680/2140956 Jean On Tue, Feb 2, 2016 at

Re: [R] log log regression model

2016-01-01 Thread Adams, Jean
This is more of a statistics question than an R programming question. I suggest you look at Cross Validated for an answer. I found this in a quick search, http://stats.stackexchange.com/questions/115571/back-transforming-regression-results-when-modeling-logy Jean On Thu, Dec 31, 2015 at 7:35

Re: [R] (no subject)

2015-12-24 Thread Adams, Jean
Excellent job providing example data and a desired result. This code works on the example you provided. Hope it helps. Jean # reshape the info data frame library(tidyr) info2 <- gather(myinfo, set, val, -game) info2$set <- as.numeric(gsub("[[:alpha:]]", "", info2$set)) # add a new column to

[R] [R-pkgs] LW1949 – new package for evaluating dose-effect experiments

2015-12-07 Thread Adams, Jean
LW1949 1.0.0 is now available on CRAN. LW1949 automates the steps taken in Litchfield and Wilcoxon’s (1949) manual approach to evaluating dose-effect experiments. Letting the computer do the work saves time and yields the best fit possible using the Litchfield Wilcoxon approach (by minimizing

Re: [R] Looping through multiple sub elements of a list to compare to multiple components of a vector

2015-12-02 Thread Adams, Jean
First, a couple posting tips. It's helpful to provide some example data people can work with. Also, please post in plain text (not html). If you have a single standard for comparison, you might find an approach like this helpful. # example data mylist <- c("AAEBCC", "AABDCC", "AABBCD") list.2

Re: [R] Subsetting dataframe by the nearest values of a vector elements

2015-11-09 Thread Adams, Jean
Harun, Can you give a simple example? If your cross_section looked like this c(144, 179, 214, 39, 284, 109, 74, 4, 249) and your other vector looked like this c(0, 50, 100, 150, 200, 250, 300, 350) what would you want your subset to look like? Jean On Mon, Nov 9, 2015 at 7:26 AM, Harun Rashid

Re: [R] mapping between list and vector

2015-10-29 Thread Adams, Jean
Maxim, I'm not sure how much faster this would be ... but you could test it out and see. I defined lngL and result as vectors instead of lists. And I calculated j outside of the "loop". myList <- list(a="key1", b=c("key2","key3"), c="key4") myVec <- c("val1","val2","val3","val4") lngL <-

Re: [R] find max. value for a equation by optimize

2015-10-29 Thread Adams, Jean
If you read the help file for optimize, you will see that you need to set the argument maximum to TRUE. ?optimize optimize(sm, c(0, 50), maximum=TRUE) Jean On Thu, Oct 29, 2015 at 4:19 PM, Jianling Fan wrote: > Hello, everyone, > > I have a specific equation, When I

Re: [R] Distribution hist

2015-10-28 Thread Adams, Jean
Something like this might help you get started. Simulation <- c(10403, NA, NA, NA, NA, 11178, NA, NA, NA, NA, 11521, NA, NA, NA, NA, 11385, NA, NA, NA, NA, 10102, NA, NA, NA, NA, 10544.013, 10339.925, 9912.695, 9928.198, 9932.112, 9008.05, 9437.174, 10406.784, 10832.123, 11095.868,

Re: [R] Formating time in R

2015-10-26 Thread Adams, Jean
Raoni, You could write your own function to do this. For example, using the period class from the R package lubridate, you could do something like this: days2 <- function(x) { h1 <- 24*x h <- floor(h1) m1 <- 60*(h1 - h) m <- floor(m1) s <- round(60*(m1 - m)) new_period(second=s,

Re: [R] Variable names conflict

2015-10-15 Thread Adams, Jean
Axel, The solution you propose looks fine to me, if an error is the outcome that you want in such a situation. Were you hoping for a different outcome? Would you, for example, prefer that the "x" in the data frame be given a different name, rather than the "x" in the function? Jean On Thu, Oct

Re: [R] k-nearest neighbour classification

2015-10-13 Thread Adams, Jean
The argument k should be a scalar, not a vector. So, for example, this works: knn.cv(train=predictors.training, cl=classes.training, k=3, prob=TRUE) Jean On Tue, Oct 13, 2015 at 3:59 AM, Neverstop wrote: > Hi, I'm trying to perform a cross validation to choose the

Re: [R] k-nearest neighbour classification

2015-10-13 Thread Adams, Jean
Ah, I see what you're after. I don't know of a built in function to search for the best number of nearest neighbors. You may have to run the code for each k separately, then compare the resulting errors. Jean On Tue, Oct 13, 2015 at 9:13 AM, Neverstop wrote: > I know

Re: [R] R lappy, sapply or mapply question

2015-10-09 Thread Adams, Jean
You were very close. Try this. df <- data.frame(x5=dailyrecord$a, x6 = dailyrecord$e, x7 = dailyrecord$f) apply(df, 1, function(row) fun3(list1, list2, as.list(row))) Jean On Fri, Oct 9, 2015 at 3:15 PM, liqunhan--- via R-help wrote: > > > Hello, R-experts, > In

Re: [R] vector graphics

2015-10-06 Thread Adams, Jean
Perhaps the discussion at this link will be helpful ... http://stackoverflow.com/questions/9555889/producing-a-vector-graphics-image-i-e-metafile-in-r-suitable-for-printing-in Jean On Tue, Oct 6, 2015 at 9:42 AM, Ivan Calandra wrote: > Dear useRs, > > A colleague

Re: [R] Result error using the function

2015-10-06 Thread Adams, Jean
I have simplified your function. And I have transposed your results such that resulting metrics are in columns rather than rows. So, it's not exactly what you were after, but perhaps you will find it useful. monthly_summary <- function(dt, r, tol=1E-6) { # number of days with above tol by

Re: [R] How to find out if two cells in a dataframe belong to the same pre-specified factor-level

2015-09-28 Thread Adams, Jean
Here's one approach that works. I made some changes to the code you provided. Full working example code given below. library(reshape) library(ggplot2) library(dplyr) dist1 <- matrix(runif(16), 4, 4) dist2 <- matrix(runif(16), 4, 4) rownames(dist1) <- colnames(dist1) <- paste0("A", 1:4)

Re: [R] Line in hist count

2015-09-28 Thread Adams, Jean
I'm not sure what you want when you refer to the "last value of f", but perhaps this will help you out. I simplified your example since the other parts of the code you submitted (par, grid, title, etc.) do not have anything to do with your question. # some fake data for f f <- rnorm(20) # save

Re: [R] Error from lme4: "Error: (p <- ncol(X)) == ncol(Y) is not TRUE"

2015-09-22 Thread Adams, Jean
Rory, When I searched online, I found an issue with lme4 on GitHub that suggests this error is "due to NA values in non-factor variables". https://github.com/lme4/lme4/issues/246 Hope this helps. Jean On Tue, Sep 22, 2015 at 8:18 AM, Rory Wilson wrote: > Hello all, I am

Re: [R] R code help!

2015-09-19 Thread Adams, Jean
Here's one way to save your results, using a list of lists and a for() loop. nsim <- 100 outputs <- vector("list", nsim) for(i in 1:nsim) { outputs[[i]] <- sim.f(p.s=.05, N=1000, sample.size=69, n.sim=500) } Jean On Fri, Sep 18, 2015 at 2:27 PM, SH wrote: > Dear R users,

Re: [R] finding those elements of listA that are found in listB

2015-09-17 Thread Adams, Jean
John, The intersect() function may help you. For example: listA <- sort(sample(10, 5)) listB <- sort(sample(10, 5)) both <- intersect(listA, listB) > listA [1] 2 4 7 8 9 > listB [1] 1 2 3 8 10 > both [1] 2 8 Jean On Wed, Sep 16, 2015 at 9:43 PM, John Sorkin

Re: [R] mtext in the top left of margin

2015-09-16 Thread Adams, Jean
You can use the coordinates of the plot region as fractions of the figure region, par("plt"), to define the adj= argument of mtext(). And you can use the number of lines of the plot margin to define the line= argument of mtext(). For example: plot.figure <- function() { par(mfrow=c(3, 1),

Re: [R] Visualization of people's interactions by participation to parties

2015-09-04 Thread Adams, Jean
Hendrik, It's not clear to me what kind of R help you are looking for. I suggest you provide more information on the data that you have and the questions that you want answered. Is it in an external file? Is it an R object? What code have you written or tried? Including example data, for

Re: [R] accessing confidence interval values from the 'predict' function

2015-08-10 Thread Adams, Jean
Avril, The more direct way to access these columns from the matrix is: ci[, lwr] ci[, upr] Jean On Mon, Aug 10, 2015 at 3:20 AM, alc a...@sanger.ac.uk wrote: Dear all, I'm wondering how can I access the confidence interval values ('upr' and 'lwr' values) produced by the 'predict'

Re: [R] Piecewise (segmented) linear regression with center section slope constraint

2015-08-07 Thread Adams, Jean
This posting on StackOverflow might be useful to you. http://stackoverflow.com/questions/13810607/in-r-package-segmented-how-could-i-set-the-slope-of-one-of-lines-in-the-model Jean On Thu, Aug 6, 2015 at 3:01 PM, Drew Morrison dmorri...@seventhwave.org wrote: Hi, I'm working on a way to

Re: [R] (no subject)

2015-08-06 Thread Adams, Jean
A quick internet search for R version history yielded this page https://cran.r-project.org/bin/windows/base/old/ Jean On Wed, Aug 5, 2015 at 4:55 AM, Djossè Parfait djosseparf...@gmail.com wrote: Good morning, I would like to know how often per year is a new full version release of

Re: [R] A simple question

2015-07-14 Thread Adams, Jean
R-help readers, For your information ... The package stringi is required to run Alex's code. Alex's message was cross posted to StackOverflow, and seems to have been answered there, http://stackoverflow.com/questions/31398466/r-stri-locate-all-creating-a-start-and-end-matrix Jean On Tue, Jul

Re: [R] Function returning multiple objects but printing only one

2015-07-14 Thread Adams, Jean
Daniel, I'm not sure if this is what you're after, but you could include a print() call in your function. For example: myfun - function(x) { m1 - min(x) m2 - mean(x) m3 - max(x) out - list(m1, m2, m3) print(out[[2]]) return(out) } result - myfun(1:10) ​Jean ​ On Mon, Jul 13, 2015

Re: [R] Collecting output of regressions in an intelligent way

2015-06-25 Thread Adams, Jean
Francesca, You don't provide any example data, so the code that I am provided is untested, but here is one way to put your commands into a loop. # define range of p values you want to use ps - 6:10 # create an empty list to collect the results waldchi - vector(list, length(ps)) # loop through

Re: [R] sampling rows with values never sampled before

2015-06-22 Thread Adams, Jean
Mike, There may be a more efficient way to do this, but this works on your example. # mix up the order of the rows mix - dat[order(runif(dim(dat)[1])), ] # get rid of duplicate x1s and x2s sub - mix[!duplicated(mix[, x1]) !duplicated(mix[, x2]), ] sub Jean On Mon, Jun 22, 2015 at 11:42 AM, C

[R] ASA Conference on Statistical Practice - deadline Thursday

2015-06-22 Thread Adams, Jean
R users, Abstracts are now being accepted for the 2016 ASA Conference on Statistical Practice, February 18-20, San Diego, CA, USA. Past conference attendees have shown particular interest in R, reproducibility, and data visualization. The deadline for submission is June 25.

Re: [R] Heatmap.2 error

2015-06-19 Thread Adams, Jean
Pijush, The error is a result of you having repeated color values. The warnings can be addressed by changing the arguments that you use. Attachments are removed from posts to R Help, so I used different data to show you an example. Jean library(gplots) data(mtcars) x -

Re: [R] Change Julian function in SPlus to R date code

2015-06-10 Thread Adams, Jean
Try looking at the julian() function in base ... ?julian Jean On Wed, Jun 10, 2015 at 2:46 AM, roslinazairimah zakaria roslina...@gmail.com wrote: Dear r-users, I have a code in SPlus which use julian function. What is the similar code used in R?

Re: [R] Combining multiple probability weights for the sample() function.

2015-06-02 Thread Adams, Jean
Ben, Perhaps I am missing something, but couldn't you simply reduce your possibilities to: possibilities[c(1, 5, 2, 4), ] Var1 Var2 Var3 [1,] A A C [2,] A A T [3,] C A C [4,] C G C If you sample from these four rows you will have a 50% chance that Var1 and Var2 are equal and a 50%

Re: [R] Scatterplot : smoothing colors according to density of points

2015-06-02 Thread Adams, Jean
Try this. Jean D - structure(list( id = structure(1:6, .Label = c(O13297, O13329, O13525, O13539, O13541, O13547), class = factor), X = c(44.44, 31.272085, 6.865672, 14.176245, 73.275862, 28.991597), Y = c(21.6122, 4.0159, 2.43884, 7.81217, 3.59012, 258.999)), .Names = c(id,

Re: [R] Really stuck with the nls function!! It's Urgent !!

2015-05-28 Thread Adams, Jean
I can't answer your question, but I can help you get help by re-writing your code so it's easy for others to see what you're talking about ... Jean library(expm) apinene_modele_prediction - function(t, theta) { x0 = c(100, 0, 0, 0, 0) A = matrix(c( -(theta[1]+theta[2]), theta[1],

[R] ASA Conference on Statistical Practice

2015-05-20 Thread Adams, Jean
R users, Abstracts are now being accepted for the 2016 ASA Conference on Statistical Practice, February 18-20, San Diego, CA, USA. Past conference attendees have shown particular interest in R, reproducibility, and data visualization. The deadline for submission is June 25.

Re: [R] help with by function

2015-05-12 Thread Adams, Jean
Nilesh, I found a couple errors in your code. First, in your by() statement you have a function to operate on the selected subset of data, which you refer to as x but then, in your aov statement you refer to data_set not x Second, your funC() statement is a function of

Re: [R] How to finding a given length of runs in a series of data?

2015-05-07 Thread Adams, Jean
Two libraries are needed to run the code you submitted ... library(dplyr) library(sqldf) Your IsHigh() function and its use can be replaced by a single line of code isHighFlow - as.numeric(Flow=1600) You are getting the additional hour by using cumsum(). One date element which you seem to

Re: [R] Run Rscript and ignore errors?

2015-04-26 Thread Adams, Jean
Nick, I don't know of a way to do what you want ... tell R to ignore all errors ... but, I do have a suggestion. Since you regard these errors as non-essential, why not edit your code to reflect that? For example, instead of writing plot(df$x1, df$y1) write if (x1 %in% names(df) y1

Re: [R] Script to workflow conversion

2015-04-22 Thread Adams, Jean
Santosh, I know nothing about this personally, but I found this site with an internet search. http://www.ef-prime.com/products/ranalyticflow_en/features.html Jean On Wed, Apr 22, 2015 at 5:20 PM, Santosh santosh2...@gmail.com wrote: Dear Rxperts.. Sorry.. i don't have data for my query..

Re: [R] Sum of some months totals

2015-04-14 Thread Adams, Jean
If you want to calculate the number of days having greater than a certain threshold of rain within a range of months, a function like this might serve your needs. raindays - function(data, monStart=1, monEnd=3, threshold=0.85) { with(data, { selRows - Month = monStart Month = monEnd Rain

Re: [R] help assigning values to matrix

2015-04-14 Thread Adams, Jean
I think it would be easier to keep track of what you're doing, if you save the assignment to the very end of your for() loop. For example ... # create an empty matrix to be used as a template Mtemplate - matrix(data=NA, nrow=13, ncol=3,

Re: [R] BIG difficulties in Using boot.ci (bot package)

2015-04-13 Thread Adams, Jean
S, There is no mention of a type=bca argument on the ?confint help file. You can look here for an example of using the boot.ci() function in the boot package: http://www.statmethods.net/advstats/bootstrapping.html ​Jean​ On Fri, Apr 10, 2015 at 11:01 AM, varin sacha varinsa...@yahoo.fr

Re: [R] mutiple data sets

2015-04-13 Thread Adams, Jean
There are some examples of how to plot correlation matrices at this link. http://stackoverflow.com/questions/5453336/plot-correlation-matrix-into-a-graph/26637268#26637268 Perhaps that will help get you started. Jean On Mon, Apr 13, 2015 at 5:11 AM, ravimantha r...@agrisk.in wrote: Hi just

Re: [R] mutiple data sets

2015-04-13 Thread Adams, Jean
concept. Thank you very much Regards Ravishankar Mantha On 4/13/2015 6:24 PM, Adams, Jean wrote: There are some examples of how to plot correlation matrices at this link. http://stackoverflow.com/questions/5453336/plot-correlation-matrix-into-a-graph/26637268#26637268 Perhaps

Re: [R] How to complete this code

2015-04-13 Thread Adams, Jean
You will likely get more help answering your question if you provide reproducible code of a simple example of your situation. Jean On Fri, Apr 10, 2015 at 3:42 PM, Mahdiyeh Erfaniyan mahdiyeh.erfani...@gmail.com wrote: Hi, Consider the line below: for(r in a)for (s in a)

Re: [R] problem in replication

2015-04-13 Thread Adams, Jean
Why did you submit this post? Are you asking for help with something? Reporting an update on an earlier post? Jean On Mon, Apr 13, 2015 at 5:43 AM, thanoon younis thanoon.youni...@gmail.com wrote: Hi I have a small problem with my code in R. The problem is the replication of simulation

Re: [R] operations on columns when data frames are in a list

2015-04-13 Thread Adams, Jean
If you write a function that takes a data frame as an argument and returns a data frame, you can use lapply to carry out the tasks that you want. For example, if your list of data frames is called mydat ... mon2date - function(df) { if (Month %in% names(df)) { df$Month-

Re: [R] Color US counties on US map using a numeric variable for color intensity

2015-04-03 Thread Adams, Jean
the NAs - despite the ifelse... On Thu, Apr 2, 2015 at 4:26 PM, Adams, Jean jvad...@usgs.gov wrote: Dimitri, You could use colorRamp() and rgb() to get more continuous colors. For example newpal - colorRamp(c(yellow, red)) missing - is.na(mydata.final$Mean.Wait) newcol

Re: [R] Color US counties on US map using a numeric variable for color intensity

2015-04-02 Thread Adams, Jean
Dimitri, You could use colorRamp() and rgb() to get more continuous colors. For example newpal - colorRamp(c(yellow, red)) missing - is.na(mydata.final$Mean.Wait) newcol - ifelse(missing, white, rgb(newpal(mydat$Mean.Wait/max(mydat$Mean.Wait)), maxColorValue=255)) map('county', fill=TRUE,

Re: [R] Calculating different PCAs in R

2015-04-01 Thread Adams, Jean
PCA 1, 2, and 3 refer to the scores not the loadings. Check out the help for princomp. ?princomp pc.cr - princomp(USArrests, cor = TRUE) pc.cr$scores[1:3, ] Jean On Tue, Mar 31, 2015 at 4:26 PM, im db imdb.subscr...@gmail.com wrote: Dear All, I want to use princomp() function in R in order

Re: [R] how to deal with changing weighting functions

2015-03-31 Thread Adams, Jean
Can you give a concrete simple example of inputs with expected results? Is phi a function? Of omega 1 and 2? Is the summation over everything through V_d-k? On Mon, Mar 30, 2015 at 2:58 PM, T.Riedle tr...@kent.ac.uk wrote: Hi everybody, Does anybody have an idea how I can generate tau

Re: [R] automatic coercicion

2015-03-21 Thread Adams, Jean
From one Jean to another ... A[i, , drop=FALSE] On Sat, Mar 21, 2015 at 6:04 AM, jean.cour...@math.u-psud.fr wrote: My question must be a trivial one. There is automatic coercicion to vector when extracting only one line of a matrix. # example A = matrix(1:12,3,4) rownames(A) =

Re: [R] Plotting straight line

2015-03-16 Thread Adams, Jean
Something like this might help you get started. x - seq(-5, 5, 1) m - seq(0.5, 5, 0.5) plot(0, 0, type=n, xlab=, ylab=, xlim=range(x), ylim=range(outer(m, x)+1)) invisible(lapply(m, function(slope) abline(1, slope))) Jean On Sun, Mar 15, 2015 at 11:03 PM, Partha Sinha pnsinh...@gmail.com wrote:

Re: [R] automate press enter

2015-03-12 Thread Adams, Jean
Harold, This did the trick for my application, options(httr_oauth_cache=TRUE) See http://stackoverflow.com/questions/28221405/automated-httr-authentication-with-twitter-provide-response-to-interactive-pro for details. Jean On Thu, Mar 12, 2015 at 10:25 AM, Doran, Harold hdo...@air.org wrote:

Re: [R] Panel Data--filling in missing dates in a span only

2015-03-11 Thread Adams, Jean
Steve, Here is one approach that works. I am calling your first data frame df. # list all years from min to max observed in each ID years - tapply(df$Date, df$ID, function(x) min(x):max(x)) # create a data frame based on the observed range of years fulldf - data.frame(ID=rep(names(years),

Re: [R] t-test: many changing groups.

2015-03-08 Thread Adams, Jean
Hard to disentangle your code in the non-HTML world of r-help. Please use plain text in the future. Below is one approach you could try. Jean # response variables resp_vars - runif(20) names(resp_vars) - paste0(sample_, seq(20)) # independent variables ind_vars - matrix(sample(c(A, B), 2000,

Re: [R] xerror and xstd are missing from cptable of the Rpart package

2015-02-03 Thread Adams, Jean
Kim, The x in xerror and xstd stands for cross validation. But you have specified no cross validations, xval=0. Try: model - rpart(Product ~ ., data=trainData, control=rpart.control(minsplit=50, cp=0.002)) model$cptable Jean On Tue, Feb 3, 2015 at 7:09 AM, Kim C. minorthre...@hotmail.com

Re: [R] naming rows/columns in 'array of matrices'

2015-02-02 Thread Adams, Jean
In your example, P is a three dimensional array. You can assign names to the three dimensions using the dimnames() function. For example, this command assigns names to the first two dimensions, but leaves the third dimension without names. dimnames(P) - list(c(live, dead), c(live, dead), NULL)

Re: [R] Proportion of equal entries in dist()?

2015-01-20 Thread Adams, Jean
Jorge, I have not used it myself, but you might find the dist() function in the proxy package to be useful. http://cran.r-project.org/web/packages/proxy/index.html Jean On Mon, Jan 19, 2015 at 7:38 AM, Jorge I Velez jorgeivanve...@gmail.com wrote: Dear all, Given vectors x and y, I would

Re: [R] Manipulating Plots

2015-01-06 Thread Adams, Jean
It will be easier for folks to help you if you provide example code that produces a plot like the one you are dealing with. Jean On Tue, Jan 6, 2015 at 11:23 AM, Raphael Päbst raphael.pae...@gmail.com wrote: Hello, I have a somewhat complicated question and hope, someone can help me or that

Re: [R] Manipulating Plots

2015-01-06 Thread Adams, Jean
: The relevant bit of code should be this one: #Getting a list of Voronoi-Cells: VoronoiCells - tile.list(DelTriCor) # plotting all of them: figure() plot(VoronoiCells,fillcol=CellColor,close=TRUE,xlim=xlim,ylim=ylim) I hope this helps. All the best! Raphael On 1/6/15, Adams, Jean

Re: [R] Problem with

2014-12-03 Thread Adams, Jean
This question is more about statistics than R. I suggest that you post it to Cross Validated instead, http://stats.stackexchange.com/. Jean On Wed, Dec 3, 2014 at 5:40 AM, Dries David dries-da...@hotmail.com wrote: Hey In my data set i have two variables: month (march or april) and wind

Re: [R] function to avoid -

2014-12-02 Thread Adams, Jean
Glad to see this query and the responses. You all just helped me to eliminate the use of global variables from my R package. I knew they were not recommended, but I didn't know how to get around using them. Thanks! Jean On Tue, Dec 2, 2014 at 10:59 AM, Karim Mezhoud kmezh...@gmail.com wrote:

Re: [R] SVYPLOT

2014-11-20 Thread Adams, Jean
Raphael I just ran an example from the help file, and the xlim argument worked fine. Can you post a small example where the xlim argument doesn't work? Jean library(survey) data(api) dstrat-svydesign(id=~1,strata=~stype, weights=~pw, data=apistrat, fpc=~fpc) svyplot(api00~api99, design=dstrat,

  1   2   3   >