Re: [R] Polygon shade

2015-10-07 Thread Jim Lemon
Hi bgnum, You can try something like this: testdates<-as.Date(paste(1:30,"Sep",2015),"%d %b %Y") nemails<-sample(10:30,30,TRUE) library(plotrix) stackpoly(testdates,nemails,col="blue") Jim On Wed, Oct 7, 2015 at 12:20 AM, bgnumis bgnum wrote: > Hi All, > > I want to shade the area below "f" v

Re: [R] Smoth matplot

2015-10-09 Thread Jim Lemon
Hi bgnumis, This is definitely a guess at what you want to do: flatbat<-read.table(text="100.0 100.0 100.0 100.0 100. 100.0 100.0 100.0 100.54163 99.23893 100.77238 98.95058 100.2250 99.18830 100.18801 101.10791 99.61230 102.12813 99.34499 97.52805 101.8252

Re: [R] Help with color.scale {plotrix}

2015-10-09 Thread Jim Lemon
Hi Kumar, The color.scale function translates numeric values into one or more intervals of color by a linear transformation into the numeric values that specify colors. One of three color spaces (rgb, hcl and hsv) can be specified, and the endpoints can be specified as "extremes=c(," or as three ve

Re: [R] for loop not working

2015-10-10 Thread Jim Lemon
Hi mnw, It looks to me as though you are testing the entire "holder" list each time you go through the function. First, I'm not sure that a simple "==" is the test you want. "movement" seems to be more than a single value and so you might want to write a function that tests whether all of the compo

Re: [R] 3D matrix columns messed up

2015-10-12 Thread Jim Lemon
Hi Kristi, The first part is relatively easy: # change first line to x$time<-factor(x$time,levels=c("t1","t2","t3","t4","t10","t21")) As you have specified "site" as the second element in "x", not the third, perhaps you just want: x<-structure(list(vs = structure(c(1L, 1L, 2L, 3L, 4L, 2L, 3L, 1L

Re: [R] writing a function that will refer to the elements of a dataframe much as is done by lm

2015-10-12 Thread Jim Lemon
Hi John, Here are a couple of ways to do this. Note that they produce slightly different results. data2<-data.frame(POSTHHMONO=c(1,2,3,4),Mo6MON=c(10,11,12,13)) doit<- function(pre,post,data) { element <- deparse(substitute(pre)) print(element) print(data[element]) frame<-deparse(substitut

Re: [R] 3D matrix columns messed up _ looking for your help

2015-10-13 Thread Jim Lemon
= "factor"), date = structure(c(1L, 3L, 2L), .Label = c("t1", > "t2", "t3"), class = "factor")), .Names = c("Tag", "site", > "DATE", "date"), row.names = c(NA, -3L), class = "data.frame")

Re: [R] 3D matrix columns messed up _ looking for your help

2015-10-14 Thread Jim Lemon
"factor"), > DATE = structure(c(1L, 3L, 2L), .Label = c("t1", "t2", "t3" > ), class = "factor"), date = structure(c(1L, 3L, 2L), .Label = c("t1", > "t2", "t3"), class = "factor")), .Names =

Re: [R] How to plot shades between curves?

2015-10-18 Thread Jim Lemon
Hi Jackson, >From your description, I think you are trying to illustrate the deviation of Capa.diss, so I will offer an entirely different method. If you do want the primary line on the left of the plot with a big space on the right, presumably to add more stuff there, try this: plot(Capa.diss.mea

Re: [R] warning on generic function when building R package

2015-10-19 Thread Jim Lemon
I think what you may have done is simply changed x.init= to x=x.init. x.init may or may not be there when the function is called, and that is what the warning is saying. While you have satisfied the restriction that the first argument must be "x", but then set the default value to something that R

Re: [R] Scope of Axes

2015-10-20 Thread Jim Lemon
Hi bgnumis, I'm too lazy to try to work out what "Simulation" contains, but try this: Simulation<-sin(seq(0,6*pi,length.out=144))*5000+ 2000*runif(144)+seq(8000,5000,length.out=144) png("bb.png",width=800,height=400) par(mfrow=c(1,2)) plot(Simulation,type="l",ylim=c(0,2)) abline(h = 0, lwd =

Re: [R] Linear regression with a rounded response variable

2015-10-22 Thread Jim Lemon
Hi Ravi, And remember that the vanilla rounding procedure is biased upward. That is, an observation of 5 actually may have ranged from 4.5 to 5.4. Jim On Thu, Oct 22, 2015 at 7:15 AM, peter salzman wrote: > here is one thought: > > if you plug in your numbers into any kind of regression you wil

Re: [R] How to correct documentation?

2015-10-24 Thread Jim Lemon
Hi Ming, In fact, the notation lb/1000 is correct, as the values represent the weight of the cars in pounds (lb) divided by 1000. I am not sure why this particular transformation of the measured values was used, but I'm sure it has caused confusion previously. Jim On Sat, Oct 24, 2015 at 11:59 A

Re: [R] Krippendorff's alpha bootstrapping implementation

2015-10-25 Thread Jim Lemon
Hi Oscar, I would be overjoyed if someone has translated the SPSS or SAS code provided by Andrew Hayes: http://www.afhayes.com/spss-sas-and-mplus-macros-and-code.html scroll down to KALPHA and go for it. If you succeed, let: Matthias Gamer the maintainer of the irr package know, and I am sure

Re: [R] How to plott bar graphics

2015-10-26 Thread Jim Lemon
ually divide negative value of > less than 0 and positve value more than zero, How to do this?? > > Once again Thank you very much for guiding me. > > On Mon, Oct 26, 2015 at 6:02 AM, Jim Lemon wrote: > >> Hi Ujjwal, >> Given that you have asked about a barplot and incl

Re: [R] How to plott bar graphics

2015-10-26 Thread Jim Lemon
Hi Ujjwal, Given that you have asked about a barplot and included standard errors, you probably want something like the following: uk.df<-read.table(text= "habitat,proportion_use,proportion_use_SE,selectivity_index,selectivity_index_SE grassland,0.56,0.22,0.72,0.29 sal_forest,0.11,0.04,-0.43,0

Re: [R] [FORGED] Re: How to correct documentation?

2015-10-26 Thread Jim Lemon
On Mon, Oct 26, 2015 at 10:44 AM, Boris Steipe wrote: > Ming is right. ... Having started all this trouble, I suppose I should offer a modest explanation. The OP was indeed "right" in the sense that the column heading did not indicate the correct _units_ for the values. I suppose that "kilopou

Re: [R] Function help

2015-10-26 Thread Jim Lemon
Hi Alexander, I suspect that when you write "try" you mean that you try to run the function with some value for "pid". The "unexpected symbol" error message usually includes the offending symbol and that will probably identify the problem. Jim On Mon, Oct 26, 2015 at 1:20 PM, wrote: > Hello, >

Re: [R] How to add legend to 2 different data frame overplot?

2015-10-31 Thread Jim Lemon
Hi C W, I would guess you are trying to use the base graphics "legend" function. Have you tried one of the scale_* functions in ggplot? Jim On Sat, Oct 31, 2015 at 3:10 PM, C W wrote: > Hi, > > I am trying to do add a legend to an overplot, something like this: > > ggplot() + > geom_densit

Re: [R] If else

2015-10-31 Thread Jim Lemon
Having had to face this problem myself more than once, I sympathize with Ted's argument. First let me confess that I regard sex as a measure of the reproductive phenotype. Given the ongoing experimentation with both sex and gender, I have had to add "U" (Unstated - includes all those acronyms that

Re: [R] replace NA's with row means for specific columns

2015-11-02 Thread Jim Lemon
Hi Zahra, I can't think of an "apply" function that will do this, but: Zdf<-read.table(text="ID A1 A2 A3 B1 B2 B3 C1 C2 C3 C4 b 4 5 NA2 NA 4 5 13 NA c 4 5 1 NA 34 5 13 2

Re: [R] replace NA's with row means for specific columns

2015-11-02 Thread Jim Lemon
Hi again, Small typo in line 5 - should be replace_NAs<-function(x,group_lab=c("A","B","C")) { for(lab in group_lab) { indices<-grep(lab,names(x),fixed=TRUE) na_indices<-is.na(x[indices]) if(any(na_indices)) x[indices][na_indices]<-rowMeans(x[indices],na.rm=TRUE) } return(x) } Jim

Re: [R] Fwd: Re: Creating "Envelope" around a plot

2015-11-02 Thread Jim Lemon
Hi Nick, I don't think it will do all that you have described, but the "dispersion" function in the plotrix package will draw an "envelope" around a line if you specify type="l" and fill=. If you pass ulim=, the "envelope" will extend that far from the original line. See the second example on the h

Re: [R] CRAN - Package "activity" - how do you convert time (hh:mm) into radians in R 3.1.2 on Windows 7 OS 64bit

2015-11-03 Thread Jim Lemon
Hi Typhenn, Have a look at clock24.plot in the plotrix package. Jim On Wed, Nov 4, 2015 at 9:00 AM, Typhenn Brichieri-Colombi via R-help < r-help@r-project.org> wrote: > Hello, > I am using the "activity" package developed by Marcus Rowcliffe (released > in February, 2015). This package uses ti

Re: [R] problem in R-code

2015-11-03 Thread Jim Lemon
Hi thanoon, The problem may lie in your definition of BZ (which I see Boris has also noticed). Given your code, it will be a vector containing 200 zeros. Your code will generate 200 ones as zero is less than 0.25. Try defining BZ as follows: BZ<-runif(200) You should get something more interestin

Re: [R] problem in R-code

2015-11-04 Thread Jim Lemon
Hi thanoon, Well, you have generated a one column matrix of missing values (NA) and then tried to use those values in a logical test... Jim On Wed, Nov 4, 2015 at 8:02 PM, thanoon younis wrote: > Dear R-Users > > After correct some errors in the code below i have only this error > > "Error in i

Re: [R] CRAN - Package "activity" - how do you convert time (hh:mm) into radians in R 3.1.2 on Windows 7 OS 64bit

2015-11-04 Thread Jim Lemon
Ah, Martin, how is it possible that you have never encountered the 24 hour cuckoo clock? http://www.lutececreations.com/fiche-schneider_black_forest_cuckoo_clock__24_hour_cuckoo_clock_mt_1139_9++de+la+marque-4297.html Jim On Wed, Nov 4, 2015 at 7:02 PM, Martin Maechler wrote: > > Bert Gunt

Re: [R] How to change name of pdf output of function windRose in openair package

2015-11-05 Thread Jim Lemon
Hi Stefano, Just start the PDF device, do the plot, then close the PDF device: library(openair) ... data(mydata) pdf("windRose.pdf") windRose(mydata) dev.off() This is from the first example for the windRose function. It will produce a file named "windRose.pdf" in the working directory of R. Jim

Re: [R] problem in R

2015-11-05 Thread Jim Lemon
Hi thanoon, When I run your code, I get two error messages. Those error messages tell you all you need to know to solve the first part of your problem (i.e. that none of the values in W1 and W2 are changed from NA). The second part of your problem is that even if you attend to those error messages,

Re: [R] Help scatterplot3d

2015-11-08 Thread Jim Lemon
Hi Julian, As I don't have access to "datos", I had to make it up. The following does what I expected. library(scatterplot3d) #datos<-read.csv("C:\\prueba.csv",sep=",",header=TRUE) #str(datos) datos<-data.frame(Bx=runif(40),e=runif(40),t=runif(40)) scatterplot3d(datos) s3d<- scatterplot3d(datos, t

Re: [R] R units of margins, text and points in a figure

2015-11-10 Thread Jim Lemon
Hi Gudrun, Let's see. First, the "cex" argument means character _expansion_, not an absolute size. So as the symbols and letters start out different sizes, that proportional difference remains as they are expanded. The size of text depends a bit upon the font that is being used. Perhaps if you dete

Re: [R] seconds to h:m:s format

2015-11-11 Thread Jim Lemon
Hi Omar, There is some sort of error in your structure definition, but the following works for me: session.duration.fuente <- data.frame(mes=c(rep("oct",5),rep("nov",5)), fuente=c("adwords", "directo", "organico", "redes sociales", "referral", "adwords", "directo", "organico", "redes sociale

Re: [R] Calculating distance between words in string

2015-11-11 Thread Jim Lemon
Perhaps what you are seeking is a sparse distance matrix. "How far is each word from every other matching word" sentence<-"How far is each word from every other matching word" words<-tolower(unlist(strsplit(sentence," "))) nwords<-length(words) wdm<-matrix(NA,nrow=nwords,ncol=nwords) for(word in

Re: [R] seconds to h:m:s format

2015-11-11 Thread Jim Lemon
-01-01". Why this specific date? > > > > > > 2015-11-11 20:22 GMT-05:00 Jim Lemon : > >> Hi Omar, >> There is some sort of error in your structure definition, but the >> following works for me: >> >> session.duration.fuente <- >>

Re: [R] Quotes

2015-11-12 Thread Jim Lemon
Hi Daniel, As David said, these problems are almost always due to fancy quotes. If you want plain old ASCII 34 (double) or 39 (single) quotes, try using Notepad for your editing rather than Word. Jim On Thu, Nov 12, 2015 at 5:02 PM, David Winsemius wrote: > > > On Nov 11, 2015, at 6:54 PM, Dan

Re: [R] mlogit.optim start values problem

2015-11-12 Thread Jim Lemon
Hi Alaa, >From the code you sent, I think that the error may be in one or more lines preceding the call to mlogit.optim. The "+" prompt means that the R interpreter thinks there is more to come, and when you added a right brace ("}"), it probably tried to interpret everything back to the last left

Re: [R] student looking for help with assignment in R

2015-11-13 Thread Jim Lemon
Hi Christopher, If you want to plot the movements of cells, perhaps a look at the help page for color.scale.lines (plotrix) will get you started. Jim On Fri, Nov 13, 2015 at 8:47 PM, PIKAL Petr wrote: > Hi > > What does it mean "to monitor". If you want to compute path length for > each cell i

Re: [R] Strange result when subsetting a data frame based on a character variable

2015-11-17 Thread Jim Lemon
peter dalgaard wrote: > O2 < 2d < O3 had been even stranger, no? Don't give those dudes in Cupertino any more bright ideas, okay? Jim On Wed, Nov 18, 2015 at 12:11 PM, peter dalgaard wrote: > > > On 18 Nov 2015, at 01:59 , Jeff Newmiller > wrote: > > > > Are you sure that wasn't oh-3 rather

Re: [R] Get means of matrix

2015-11-18 Thread Jim Lemon
Hi Jesus, While I do not have your data and cannot test this, the problem may be that you are using two different names for the data frame. Is this more or less what you want? datos<-data.frame(x1=sample(20:40,40,TRUE),x2=sample(20:40,40,TRUE), x3=sample(20:40,40,TRUE),csvdata=rep(1:2,each=20)) s

Re: [R] subset data using a vector

2015-11-24 Thread Jim Lemon
Hi Nilesh, I simplified your code a bit: fun1<-function (dataset, plot.id, ranges2use, control) { m1 <- strsplit(as.character(ranges2use), ",") dat1 <- data.frame() row_check_mean <- NA row_check_adj_yield <- NA x <- length(plot.id) for (i in 1:x) { cat(i,"\n") dat1 <- dataset[dataset$ra

Re: [R] Isotonic Regression

2015-11-28 Thread Jim Lemon
Hi Hamed, I guess the first thing to do is to find out what "test.df" is: is.data.frame(test.df) dim(test.df) If these come up FALSE or NULL respectively, you are not passing the correct data argument to the boot function. Jim On Sun, Nov 29, 2015 at 5:04 AM, Hamed Nofal wrote: > Dear Sir >

Re: [R] Separating lines in ts.plot()?

2015-11-29 Thread Jim Lemon
Hi mviljamaa, Line color, line style, line width... An example or an image of the output would help. Jim On Mon, Nov 30, 2015 at 5:22 AM, mviljamaa wrote: > I'm using ts.plot() to plot a matrix of time series (each column is a ts). > > What I noticed is that ts.plot() creates a lot of overlappi

Re: [R] Converting a matrix to an mcmc object

2015-11-29 Thread Jim Lemon
Hi Margaret, Doesn't the "mcmc" function in the "coda" package create an mcmc object from a matrix? Jim On Mon, Nov 30, 2015 at 9:44 AM, Margaret Donald < merricks.merri...@gmail.com> wrote: > Dear List, > > I am using R2jags and post process some mcmc objects to produce a new > object, which i

Re: [R] filled circle with a black line on the rim in pch function

2015-12-01 Thread Jim Lemon
Hi Christine, When I try to run your script, the plot fails: Error in eval(expr, envir, enclos) : object 'culr' not found > names(Raw) [1] "Date""Year""Station" "Abun""Date1" so I changed the second line to: groups=Year, and it did work. The default (pink, gray) background colors fo

Re: [R] Graphing a subset of data

2015-12-01 Thread Jim Lemon
Hi Alexandra, I think you are going about this in an excessively difficult way. Here is a rough example: graphit<-function(x,var,type,subset=NA,...){ if(!is.na(subset[1])) x<-subset(x,subset) do.call(type,list(x=x[[var]],...)) } # assume that the data are measurements of penetration by crossbow

Re: [R] Strange error

2015-12-03 Thread Jim Lemon
Hi Nick, I think that Jeff may be correct in that the code was cut and pasted from a non-text application. In particular, the error message about "*" is suspicious. What may be happening is that when you select a single line, it only picks up the text, but when you select multiple lines, the garbag

Re: [R] splitting data frame into fixed rows depending on column rep

2015-12-06 Thread Jim Lemon
Hi Ragia, Perhaps the easiest way is to split the data frame into a list by the values of v1: sdf<-split(df,df$v1) Then rename the elements of sdf for convenience: names(sdf)<-paste("v1",1:5,sep="_") Now you can extract whatever you like" sdf$v1_1$v2 [1] 3 4 8 Of course if you only want the v

Re: [R] Error while using e1071 package

2015-12-08 Thread Jim Lemon
Hi Partha, Probably the first thing to be done is to see what: object$tables really is. The error message tells you that either "v" has become larger than the number of elements in the list/data frame "tables" or that "nd" has become larger than the number of columns in the element "v" (or both).

Re: [R] tmap colour scale

2015-12-08 Thread Jim Lemon
Hi Freddy, Have you tried rev() on the palette? Jim On Wed, Dec 9, 2015 at 7:32 AM, Freddy Eggleton wrote: > Hi, > > I am trying to plot Conservative Vote % per borough for London using tmap > however the legend colours boroughs with a high Conservative % as light > blue and boroughs with a lo

Re: [R] [tcltk][tktable] How to make an efficient data transfer from R to Tcl?

2015-12-08 Thread Jim Lemon
Hi Cleber, have you tried: edit(mtcars) Jim On Wed, Dec 9, 2015 at 1:04 PM, Cleber N.Borges wrote: > my objective is to show data in screen inside a tktable... > for that, the data must be in a TCL variable and not only in a R variable > like that: > > library( tcltk ) >> mtcars_in_TCL <- tcl

Re: [R] change the x axis tickmarks when using plot function in drc package

2015-12-08 Thread Jim Lemon
Hi Hannah, Try this: plot(mod, type="all",log="xy") Jim On Wed, Dec 9, 2015 at 1:57 PM, li li wrote: > Hi all, > When plotting the dose response curve using plot function as in the > example codes below, the scale of the axis should really be on the log > scale of the dose given the shape o

Re: [R] Make a box-whiskers plot in R with 5 variables, color coded.

2015-12-15 Thread Jim Lemon
Hi, My understanding is: () - parentheses {} - braces [] - square brackets <> - angle brackets Jim On Wed, Dec 16, 2015 at 6:17 AM, S Ellison wrote: > > It is clear that a ) although is a type of bracket it is called a > parenthesis, just as , > > is called a comma, which is a type of punctua

Re: [R] close specific graphics device

2015-12-15 Thread Jim Lemon
Hi Dan, The range of device numbers seems to be 1-63. There doesn't appear to be a means of explicitly setting the device number when calling dev.new, and devices are numbered sequentially when they are opened. This means that even if you did know that the device number was, say, 4 it would be poss

Re: [R] NIPALS & categorical variables

2015-12-17 Thread Jim Lemon
Hi Hana, If you are using nipals from the plsdepot package, the answer seems to be maybe. If your categorical variables are at least ordinal level, and you can arrange the values so that the factor numbering reflects this, it may be possible to use the numeric values. "...the variables are assumed

Re: [R] Help needed in plotting 2d histogram

2015-12-17 Thread Jim Lemon
Hi Saikat, I don't know whether this can be done with ggplot, but if you don't get another answer, have a look at the second example for the "barp" function in the plotrix package. This shows how to get a specified range on the color legend using the "xrange" argument. Jim On Fri, Dec 18, 2015 a

Re: [R] Would you please help me to create a table in R?

2015-12-17 Thread Jim Lemon
Hi Marna, A bit hard to understand. If raw.data is a record of 11 individuals released at site A at Time 1 and recaptured at either A or B or neither at Time2 or Time3, it doesn't seem to bear any consistent relationship to the numeric coding in table.format or the output at the bottom. Could you e

Re: [R] Cannot subset a specific mean from this function

2015-12-17 Thread Jim Lemon
Hi Bradley, I think I can see one or two reasons why you are getting creamed. First, pollutantmean is a function, and there is no method for taking the mean of a function. Second, nitrate is unlikely to be an extractable element of pollutantmean given the above code (that's the error). I suspect

Re: [R] Changing X axis values

2015-12-18 Thread Jim Lemon
Hi Amelia, The usual way is: plot(...,xaxt="n") axis(1,at=seq(0,18000,by=1000) However, you will get overlapping labels unless you use a small font or a large graphics device. You may want to look at the staxlab function in the plotrix package. Jim On Fri, Dec 18, 2015 at 10:20 PM, Amelia Mars

Re: [R] Would you please help me to create a table in R?

2015-12-18 Thread Jim Lemon
A, NA, NA, 3L, NA, NA, NA, > 4L, NA, NA, NA, 1L, NA), .Label = c("NotSeen", "Re-captured.at.A", > "Re-captured.at.B", "Re-captured.at.C"), class = "factor"), > Time3 = structure(c(2L, 3L, 4L, 1L, 2L, 3L, 4L, 1L, 2L, 3L, >

Re: [R] Help needed in data cleaning

2015-12-21 Thread Jim Lemon
Hi Nash, If I understand your question correctly, you want the "mice" package. Hopefully you have more data than your example. Jim On Sat, Dec 19, 2015 at 6:14 AM, Web Web wrote: > Hello, >I need some help in data cleaning using R. my CSV file looks as > follows. > > > "id","gender

Re: [R] ?currency challenge ?knapsack challenge ?probabilities

2015-12-27 Thread Jim Lemon
Hi Calum, Does this include an error tolerance for the match between the ordered and delivered quantities? That is, is it okay to have a maximum of one unit difference or do deliveries have to exactly match orders? Jim On Sun, Dec 27, 2015 at 10:08 PM, Polwart Calum (COUNTY DURHAM AND DARLINGTON

Re: [R] Mixed Beta Disrubutions

2015-12-28 Thread Jim Lemon
Hi mesude, Achim's example seems particularly clear. Install the "betareg" and "flexmix" packages. I obtain a reasonable looking result for alpha and beta for a simulated dataset very similar to yours. > a Comp.1 Comp.2 10.0674445 0.6452801 > b Comp.1 Comp.2 2.830934 0.769768 Jim O

Re: [R] Rgraphviz overlap of nodes and edges

2015-12-29 Thread Jim Lemon
Hi Liliana, see inline comments On Sat, Jul 18, 2015 at 5:57 AM, Liliana Zazueta wrote: > Excuse me I have this dude, Suppressing my desire to make a bad joke, I think you mean "doubt" > how to make that Rgraphviz graphic without > intersection between nodes and edges? > > I can't test this

Re: [R] Histogram for Left Censored Data

2015-12-31 Thread Jim Lemon
Hi Steve, Maybe something like this: Sconc<-matrix(c(1450,1800,1840,1820,1860,1780,1760,1800,1900, 1770,1790,1780,1850,1760,1450,1710,1575,1475,1780,1790, 1780,1450,1790,1800,1,0,0,0,0,0,0,0,0,0,0,0,0,0,1,0,0,0,0,0,0,1,0,0), 24,2) hist(Sconc[,1],breaks=c(1450,1550,1650,1750,1900)) abline(v=1450

Re: [R] save screen printed data frames and ggplots into a file

2015-12-31 Thread Jim Lemon
Hi Ragia, I may be missing your point, but try the "htmlize" function in the prettyR package. This creates an HTML file containing both the text output and images from an R script. Jim On Fri, Jan 1, 2016 at 11:46 AM, Ragia Ibrahim wrote: > Dear group > I have a script that prints data frames a

Re: [R] [FORGED] Histogram for Left Censored Data

2016-01-01 Thread Jim Lemon
How about this? Sconc<-matrix(c(1450,1800,1840,1820,1860,1780,1760,1800,1900, 1770,1790,1780,1850,1760,1450,1710,1575,1475,1780,1790, 1780,1450,1790,1800,1,0,0,0,0,0,0,0,0,0,0,0,0,0,1,0,0,0,0,0,0,1,0,0), 24,2) Sconc.tab<-table(cut(Sconc[,1],breaks=seq(1450,1900,by=50), include.lowest=TRUE)) Sc

Re: [R] missForest: Looping through files in a folder

2016-01-01 Thread Jim Lemon
Hi Morteza, What you may want is this: my.files<-list.files(pattern=".csv") newfiles<-gsub(".","_F.",my.files,fixed=TRUE) for(i in 1:length(my.files)) { mydat<-read.csv(my.files[i]) mydatimp<-missForest(mydat,verbose=TRUE,maxiter=5) write.csv(mydatimp$ximp,newfiles[i]) } Jim On Sat, Jan 2, 2

Re: [R] Amelia: Inputing Integers

2016-01-06 Thread Jim Lemon
Hi Lorenzo, Perhaps rounding the values in the imputed dataset? Jim On Thu, Jan 7, 2016 at 8:42 AM, Lorenzo Isella wrote: > Dear All, > I can provide a numerical example if needed. > My problem is the following: I am using amelia to input some missing > data in a dataset. > The problem is that

Re: [R] NAs introduced by coercion

2016-01-08 Thread Jim Lemon
Hi Manish, Most likely there are one or more negative numbers in mat1. Jim On Fri, Jan 8, 2016 at 7:35 PM, Manish MAHESHWARI wrote: > Hi, > > In glmnet, while using a matrix as an input, I get an error of NA's > introduced by coercion. However in the input there is no NA value. > > cvfit = cv.

Re: [R] OpenAir package help!!

2016-01-11 Thread Jim Lemon
Hi Diana, As far as I can see, polarPlot (openair) does not specify the colors for the labels. One possibility is to redefine the default foreground color and see what happens: par(fg="red") but this will almost certainly change other elements in the plot. Unfortunately the panel.levelplot funct

Re: [R] for loop

2016-01-12 Thread Jim Lemon
Hi maryam (firoozi), Apart from the fact that you are overworking your sires (or the more realistic scenario of differential mating success) you can achieve the 700:30 ratio in this simple way: sires<-paste("Sire",1:30,sep="") dams<-paste("Dam",1:700,sep="") ped<-data.frame(offspring=1:700,sire=sa

Re: [R] Writing a matrix of lists as a CSV file

2016-01-14 Thread Jim Lemon
Hi Teo, Your "list" looks suspiciously like a vector. It might help if you provided the output of: str(my_matrix) (or whatever your matrix is named) as that would ensure that we were talking about the same objects. Jim On Thu, Jan 14, 2016 at 7:10 PM, TJUN KIAT TEO wrote: > > > I > have a ma

Re: [R] How can we let "multiplot.R" return a plot?

2016-01-14 Thread Jim Lemon
Hi Miao, If I understand your question correctly, you want to get a return value from the "multiplot" function that you have copied into your message. You could simply add: return(plotlist) just before the final right brace in the function and it would return the list of plots that you have creat

Re: [R] write.xlsx- writing in a single sheet

2016-01-15 Thread Jim Lemon
Hi Mohsen, I can guess two things that you might want. One is to join all of the data in the "CSV" files into a single data frame and then write that to a single XLSX sheet. If the names and data structure of these files are similar enough to "rbind" them, just do this in R and then write the resul

Re: [R] Split Strings

2016-01-18 Thread Jim Lemon
Hi Miluji, While the other answers are correct in general, I noticed that your request was for the elements of an incomplete string to be placed in the same positions as in the complete strings. Perhaps this will help: strings<-list("pc_m2_45_ssp3_wheat","pc_m2_45_ssp3_wheat", "ssp3_maize","m2_wh

Re: [R] gap.plot fails to plot tick labels on y-axis

2016-01-19 Thread Jim Lemon
Hi Ludo, The good news is that it was easy. The bad news is that it was my fault. I hadn't tried labeling the axes with something other than numbers. At about line 109 in the source code, this line: show.labels<-c(ytics[littletics],yticlab[bigtics]) should read: show.labels<-c(yticlab[li

Re: [R] (no subject)

2016-01-19 Thread Jim Lemon
Hi Maryam, Sounds like: c(Young.list1[sample(1:20,1),],Young.list2[sample(1:20,1),],Young.list3[sample(1:20,1),]) to me. Jim On Wed, Jan 20, 2016 at 7:35 AM, wrote: > Hello, > > What do you want to sample? Rows? With or without replacement? You > need to give us more information on what you

Re: [R] (no subject)

2016-01-20 Thread Jim Lemon
Hi Maryam, c(Young.list1[sample(1:20,5),], Young.list2[sample(1:20,5),], Young.list3[sample(1:20,5),]) # or for a more general solution nrows<-dim(Young.list1)[1] c(Young.list1[sample(1:nrows,nrows/4),], Young.list2[sample(1:nrows,nrows/4),], Young.list3[sample(1:nrows,nrows/4),]) Jim On We

Re: [R] R plot-par(mfrow=c(x,y)) on multiple pages

2016-01-20 Thread Jim Lemon
Hi Mohsen, I'll have a wild guess at this. I suspect that you have either calculated a value for the ylim= argument or used explicit values for ylim= in the first plot, then propagated the error by copying and pasting. Jim On Thu, Jan 21, 2016 at 8:56 AM, Mohsen Jafarikia wrote: > Thanks very m

Re: [R] Fwd:

2016-01-20 Thread Jim Lemon
Hi maryam, I think you have just restricted yourself to zero and negative numbers for the new cases. Well, I suppose there are imaginary numbers... Jim On Thu, Jan 21, 2016 at 8:26 AM, maryam firoozi via R-help < r-help@r-project.org> wrote: > Hello, > i made a population about 4500 individual.

Re: [R] Histogram with a wide range of numbers.

2016-01-21 Thread Jim Lemon
Hi Sema, I trimmed your file to the first 220 lines. ads<-read.table("all_data_scor.txt",header=TRUE,sep="\t") ads.tab<-table(cut(all_data_scor[,2],breaks=c(0,1e-100,1e-10,1e-1,1,10))) barplot(adt.tab) This gives you a basic idea of what can be done. If this is not clear, ask again. Jim On Thu

Re: [R] Error opening SHP file

2016-01-21 Thread Jim Lemon
Hi Amoy, Another mystery question. I should have pursued parapsychology. That error statement is usually followed by one noting that the file specified cannot be found. Today's guess is that the R working directory: getwd() did not have a "maps" directory below it. Jim On Fri, Jan 22, 2016 at

[R] rstanarm compilation

2016-01-23 Thread Jim Lemon
Hi, Seeing that the "rstanarm" package was available on CRAN in an answer to: Constrained Poisson model / Bayesian Poisson model I tried to install it. Took quite a while, but compilation failed at: ^ {standard input}: Assembler messages: {standard input}:3144199: Warning: end of file in stri

Re: [R] Division of data set with some restriction

2016-01-25 Thread Jim Lemon
Hi Muhammad, There are a large number of approximate answers to your problem. One easy one is to ensure that the standard deviations of the subgroups are maximally different by dividing the observations into "mids" (observations close to the mean) and "tails" (observations far from the mean). The f

Re: [R] Error : there is no .Internal function 'par'

2016-01-27 Thread Jim Lemon
Hi Kim, The only thing that I can think of is that some packages that were previously loaded automatically may now have to be loaded explicitly. Have you tried adding: require(graphics) to your code? Jim On Wed, Jan 27, 2016 at 8:56 PM, Kim Pilegaard wrote: > I have a function that calls par

Re: [R] [FORGED] Re: determine the year of a date

2016-02-03 Thread Jim Lemon
Hi all, If you don't want Excel to surreptitiously "correct" dates that are not in mm/dd/ format, always specify international format -mm-dd in Excel. Jim On Thu, Feb 4, 2016 at 8:26 AM, peter dalgaard wrote: > Fortune candidate... > > -pd > > > On 03 Feb 2016, at 22:13 , Rolf Turner

Re: [R] reading in multiple data sets in 2 loops

2016-02-06 Thread Jim Lemon
Hi Reka, Try this: header<-"C:/Research3/simulation1/second_gen/pheno_ 1000ind_4000m_add_h70_prog" for(index1 in 1:2) { for(index2 in 2:3) read.csv(paste(paste(header,index1,index2,sep="_"),".csv",sep="")) } Jim On Sat, Feb 6, 2016 at 4:53 PM, Reka Howard wrote: > Hello, > I have over 1000

Re: [R] [FORGED] Plot step function

2016-02-07 Thread Jim Lemon
Hail Jupiter, Might a slight alteration of Rolf's suggestion do the trick? plot(c(-4,0,4),c(0,1,1),type="s",xlab="x",ylab="y") Jim On Sun, Feb 7, 2016 at 8:49 AM, jupiter wrote: > Thank you for the all response, how can the point y (0.0) on the same x > axis, and X increases 1 between [-4, 4]

Re: [R] (no subject)

2016-02-07 Thread Jim Lemon
Hi Walter, To make sure that the current R working directory is what you think it is: getwd() If it is not what you want, you can change it with: setwd("C:/Program Files/R/R-3.2.3/Appendix") Notice that I have changed the backslashes (\) to slashes (/). You can also use doubled backslashes if y

Re: [R] readline is not working

2016-02-08 Thread Jim Lemon
Hi Jean, Many laptops perform complicated workarounds to accommodate the virtual keypads on the keyboard. Sometimes a sticky shift key (e.g. NumLock, Caps Lock) will mess up keyboard entry if it is on. Just a wild guess. Jim On Mon, Feb 8, 2016 at 7:16 PM, MAURICE Jean - externe < jean-externe.m

Re: [R] why is 9 after 10?

2016-02-12 Thread Jim Lemon
It depends upon what goes into the "data reshaping pipeline". If there is a single non-numeric value in the data read in, it will alpha sort it upon conversion to a factor: x<-factor(c(sample(6:37,1000,TRUE)," ")) z<-factor(x) levels(z) [1] " " "10" "11" "12" "13" "14" "15" "16" "17" "18" "19" "

Re: [R] Matrix summary

2016-02-12 Thread Jim Lemon
Hi Ashta, Surely you are aware of the "apply" family of functions that return the numbers you want: ashmat<-matrix(c(117,12,13,21,21,32,11,1,65,43,23,7,58,61,78,95 ), nrow=4,byrow=TRUE) apply(ashmat,2,mean) [1] 65.25 37.00 31.25 31.00 apply(ashmat,1,which.max) [1] 1 2 1 4 Jim On Sat, Feb 13, 2

Re: [R] regression coefficients

2016-02-17 Thread Jim Lemon
Hi Cristiano, Might be the data you have for "dv". I don't seem to get the problem. dv<-sample(1:6,15,TRUE) subject<-factor(rep(paste("s",1:5,sep=""),each=3)) myfactor_c<-factor(rep(paste("f",1:3,sep=""),5)) mydata_c<-data.frame(dv,subject,myfactor_c) mod_c<-aov(dv~myfactor_c+Error(subject/myfacto

Re: [R] Reading a datetime vector

2016-02-18 Thread Jim Lemon
Hi Doug, For one thing, you may be using the wrong format. Your example format has no seconds field. The other thing to watch is whether the data are in %m/%d/%Y or %d/%m/%Y date format. If the latter, you would probably get that error on dates like 19/02/2016. Jim On Fri, Feb 19, 2016 at 8:12 A

Re: [R] Question On Regex and DataFrame

2016-02-21 Thread Jim Lemon
Hi kalyan, It is a bit difficult to work out what you want to do. However, there are some things I can suggest. The gsub function is useful for changing strings not assigning new values. If you want to delete a column of a data frame if there are any NA values, you first want to check for NA values

Re: [R] How to merge two tables

2016-02-22 Thread Jim Lemon
Hi Xiyan, It looks like your tables have different numbers of cases. There are: 66 DEAD FEMALES in "cross" 56 DEAD FEMALES in "age" 48 NON-DEAD FEMALES in "cross" 58 NON-DEAD FEMALES in "age" and so on. Perhaps there is some mistake with the counts. If this is the problem you could expand the co

Re: [R] Reading a datetime vector

2016-02-23 Thread Jim Lemon
Hi Doug, It is difficult for us to work out what is happening as we don't have access to a toy data set that we can play with. Excel spreadsheets are one of those things that you can't just attach to your email to the help list. If there is somewhere you can leave a _small_ Excel sample file (take

Re: [R] axis break in R

2016-02-23 Thread Jim Lemon
Hi Eike, I think that plotrix v3.6-1 should run on R v 3.1.2. Jim On Wed, Feb 24, 2016 at 4:11 AM, Federman, Douglas < douglas.feder...@utoledo.edu> wrote: > > The current version of R is 3.2.3 and is available on the website. You > should update. The current version of plotrix is 3.6-1 > > --

Re: [R] Reading a datetime vector

2016-02-23 Thread Jim Lemon
r that I am currently working on. > > Doug > > > On Tuesday, February 23, 2016 4:02 AM, Jim Lemon > wrote: > > > Hi Doug, > It is difficult for us to work out what is happening as we don't have > access to a toy data set that we can play with. Excel spreadsheets a

Re: [R] Reading a datetime vector

2016-02-23 Thread Jim Lemon
Hi again, My apologies - I didn't see the other email. JIm On Wed, Feb 24, 2016 at 10:29 AM, Jim Lemon wrote: > Doug, > We're getting warm. If we ask really nicely, will you tell us the URL of > the "dropbox folder you are working on"? > > Jim > >

<    3   4   5   6   7   8   9   10   11   12   >