Re: [R] Alignment of the title in a key for xyplot in lattice.

2019-12-23 Thread Jim Lemon
Hi Rolf, Following the docs back to draw.key, It looks like the ellipsis argument is ignored. I was hoping for a brilliant solution along the lines of: adj=0 that could be passed down the functions like a hot potato, but was disappointed. Jim On Tue, Dec 24, 2019 at 9:26 AM Rolf Turner wrote:

Re: [R] help with if statement with two conditions

2019-12-23 Thread Jim Lemon
Hi Kimberley, Given the number of posts that read "I have a problem, please advise", your concern for our mental welfare is a great Xmas present. Jim On Tue, Dec 24, 2019 at 10:38 AM Steinmann, Kimberly@CDPR wrote: > > I am not sure how to close the thread - I hate to waste anyone's time on a

Re: [R] Converting AIS Message to Number

2019-12-23 Thread Jim Lemon
Hi Paul, For your first question: max(file.info(".")$mtime) [1] "2019-12-21 21:04:19 AEDT" As for the second, I didn't know what an AIS file was, so I googled it. I still don't know, so I don't have a clue how to turn a string like that into a number. Jim On Tue, Dec 24, 2019 at 5:14 AM Paul

Re: [R] help with if statement with two conditions

2019-12-23 Thread Jim Lemon
Hi Kimberley, Since you are using a loop and therefore testing one value of v_trends_lbs at a time, the "&" in the "if" statement should be "&&". Pinching Bert's example but using a for loop instead of ifelse: x <- seq(-2,2,.25) v_lbs<-rep("",length(x)) for(i in 1:length(x)) { if(is.na(x[i]))

Re: [R] all the MAE metric values are missing (Error message)

2019-12-22 Thread Jim Lemon
Hi Neha, Well, that's a clue to why you are getting NAs: log10(0) [1] -Inf Another possibility is that the values used in the initial calculation have been read in as factors. Jim On Mon, Dec 23, 2019 at 10:55 AM Neha gupta wrote: > > Hi Jim > > The objective function is passed to san_res

Re: [R] all the MAE metric values are missing (Error message)

2019-12-22 Thread Jim Lemon
Hi Neha, The error message looks suspicious, as it refers to "all the MAEs" while there is only one NA value in the summary. I would carefully check the object that you are passing to san_res. Jim On Mon, Dec 23, 2019 at 4:17 AM Neha gupta wrote: > > I am using the following code to tune the 4

Re: [R] Readxl Question

2019-12-20 Thread Jim Lemon
Hi Thomas, Perhaps this is what you are seeking: my_read_excel<-function(filename) { serials<-read_excel(filename,sheet="Flow Data",range=("c6")) flow.data<-read_excel(filename,sheet="Flow Data",range=("c22:c70")) dates<-read_excel(filename,sheet="Flow Data",range=("h14"))

Re: [R] How to create a new data.frame based on calculation of subsets of an existing data.frame

2019-12-20 Thread Jim Lemon
I'm probably misunderstanding what you want. I get this from the code I sent: VC [[1]] Prob.of.exceedance_1 Prob.of.exceedance_2 Prob.of.exceedance_3 100 0.005343027 Prob.of.exceedance_4 1 0.01947477 [[2]] Prob.of.exceedance_1

Re: [R] How to create a new data.frame based on calculation of subsets of an existing data.frame

2019-12-20 Thread Jim Lemon
Hi Ioanna, We're getting somewhere, but there are four unique combinations of Taxonomy and IM.type: ER+ETR_H1,PGA ER+ETR_H2,PGA ER+ETR_H1,Sa ER+ETR_H2,Sa Perhaps you mean that ER+ETR_H1 only occurs with PGA and ER+ETR_H2 only occurs with Sa. I handled that by checking that there were any rows

Re: [R] How to create a new data.frame based on calculation of subsets of an existing data.frame

2019-12-20 Thread Jim Lemon
Hi Ioanna, For simplicity assume that the new data frame will be named E: E<-D[,c("Taxonomy","IM.type",paste("VC,1:4,sep="_"))] While I haven't tested this, I'm pretty sure I have it correct. Just extract the columns you want from D and assign that to E. Jim On Fri, Dec 20, 2019 at 9:02 PM

Re: [R] How to create a new data.frame based on calculation of subsets of an existing data.frame

2019-12-18 Thread Jim Lemon
Hi Ioanna, I looked at the problem this morning and tried to work out what you wanted. With a problem like this, it is often easy when you have someone point to the data and say "I want this added to that and this multiplied by that". I have probably made the wrong guesses, but I hope that you can

Re: [R] choose randomly

2019-12-18 Thread Jim Lemon
Hi Medic, mydata$Temperature[sample(1:N,N) should do the trick. You will just get a pseudo-randomly shuffled set of the same values. Jim On Thu, Dec 19, 2019 at 7:34 AM Medic wrote: > > Variable temperature: > mydata$temperature > has N values. > With what code to сhoice (without return) n

Re: [R] How to create a new data.frame based on calculation of subsets of an existing data.frame

2019-12-17 Thread Jim Lemon
0435,0.000405) > ) > > Basically I am using the total probability theorem to calculate a best > estimate. I am stuck how to do it for many cases. Many thanks for your > patience. > > -Original Message- > From: Jim Lemon [mailto:drjimle...@gmail

Re: [R] how to create a txt file with parsed columns

2019-12-08 Thread Jim Lemon
Hi Ana, Is this what you want? a<-read.table(text="GENErs BETA 1 ENSG0154803 rs2605134 0.0360182 2 ENSG0154803 rs7405677 0.0525463 3 ENSG0154803 rs7211573 0.0525531 4 ENSG0154803 rs2746026 0.0466392 5 ENSG0141030 rs2605134 0.0806140 6 ENSG0141030

Re: [R] Plotting confidence intervals

2019-12-08 Thread Jim Lemon
Hi Philip, This may be a starter: attach(airquality) heights <- tapply(Temp,Month,mean) temp_sd<-tapply(Temp,Month,sd) lower <- tapply(Temp,Month,function(v) t.test(v)$conf.int[1]) upper <- tapply(Temp,Month,function(v) t.test(v)$conf.int[2]) library(plotrix)

Re: [R] Two geom_bar with counts to put in the same plot

2019-12-05 Thread Jim Lemon
Hi Francesca, Do you want something like this? Jim On Thu, Dec 5, 2019 at 6:58 PM Francesca wrote: > > Hi, sorry for bothering again. > I was wondering how I can reshape the data, if in your code, > I would like to have only two panels, where in the panel with Participation > =0, I represent

Re: [R] 回复:How to find the best fit of inner cut ellipse to points in polar plot?

2019-12-03 Thread Jim Lemon
Hi vod, Now that I have your data I can do a bit better: # save data as "vv.csv" vv<-read.csv("vv.csv") # order the points in order of theta vv<-vv[order(vv$theta),] oldpar<-polar.plot(vv$r,vv$theta,main="Polar plat of vv.csv",lwd=3,line.col=4,

Re: [R] Conditions

2019-11-26 Thread Jim Lemon
Hi val, You had a "conditional leak" in your ifelse statements: dat2 <-read.table(text="ID d1 d2 d3 A 0 25 35 B 12 22 0 C 0 0 31 E 10 20 30 F 0 0 0", header=TRUE,stringsAsFactors=FALSE) dat2$d4<- ifelse(dat2$d1,dat2$d1,ifelse(dat2$d2,dat2$d2,ifelse(dat2$d3,dat2$d3,0))) Even though it works, it

Re: [R] Separating Output of Modularity Analyses

2019-11-19 Thread Jim Lemon
Hi Chelsea, A brute force method, but I think it does what you want: # create a sequence of integers to make checking easy null.cz<-1:68 separate_interdigitated_vectors<-function(x,nv=2,vlen=17) { xlen<-length(x) starts<-seq(1,xlen-vlen*nv+1,by=vlen*nv) cat(xlen,starts,"\n") for(start in

Re: [R] Labeling Stacked Bar Plots Representing Percentages with Count Data

2019-11-16 Thread Jim Lemon
Hi Josh, I couldn't work out how to do this in ggplot, but here is a possible solution: tagSummary<-read.csv(text="speciesSci,recvDeployName,nDet Arenaria interpres,Bucktoe Preserve,96 Arenaria interpres,CHDE,132 Arenaria interpres,Fortescue,22133 Arenaria interpres,Mispillion,2031 Arenaria

Re: [R] Remove highly correlated variables from a data frame or matrix

2019-11-15 Thread Jim Lemon
While the remedy for your dissatisfaction with my previous solution should be obvious, I will make it explicit. # that is rows containing at most one value > 0.8 # ignoring the diagonal keeprows<-apply(ro246,1,function(x) return(sum(x>0.8)<2)) ro246.lt.8<-ro246[keeprows,keeprows] Jim

Re: [R] Remove highly correlated variables from a data frame or matrix

2019-11-14 Thread Jim Lemon
I thought you were going to trick us. What I think you are asking now is how to get the variable names in the columns that have at most one _absolute_ value greater than 0.8. OK: # I'm not going to try to recreate your correlation matrix calc.jim<-matrix(runif(100,min=-1,max=1),nrow=10) for(i in

Re: [R] Remove highly correlated variables from a data frame or matrix

2019-11-14 Thread Jim Lemon
Hi Ana, Rather than addressing the question of why you want to do this, Let's get make the question easier to answer: calc.rho<-matrix(c(0.903,0.268,0.327,0.327,0.327,0.582, 0.928,0.276,0.336,0.336,0.336,0.598, 0.975,0.309,0.371,0.371,0.371,0.638, 0.975,0.309,0.371,0.371,0.371,0.638,

Re: [R] QQ plot

2019-11-12 Thread Jim Lemon
so far that this kind of QQ plot is an indication that > data has non zero mean: > https://stats.stackexchange.com/questions/280634/how-to-interpret-qq-plot-not-on-the-line > > but is that an indication that something is wrong with the analysis? > > Thanks > Ana > >

Re: [R] QQ plot

2019-11-12 Thread Jim Lemon
I thought about this and did a little study of GWAS and the use of p-values to assess significant associations. As Ana's plot begins at values of about 0.001, this seems to imply that almost everything in the genome is associated to some degree. One expects that most SNPs will not be associated

Re: [R] [help]Format excel spreadsheet using R?

2019-11-07 Thread Jim Lemon
Hi Baojun, You probably need the right condition: x<-c(1,2,3.1415926535,4) > nonint<-floor(x)!=x > nonint [1] FALSE FALSE TRUE FALSE > x[nonint]<-round(x[nonint],3) > x [1] 1.000 2.000 3.142 4.000 Jim On Fri, Nov 8, 2019 at 12:54 AM Baojun Sun wrote: > > I have a Excel spreadsheet with two

Re: [R] unordered y axis

2019-11-06 Thread Jim Lemon
ually everything is good, but I want to 'kill' my curiosity. > > year<-c(1981:2015) > month<-c(3, 1, 12, 11, 2, 1, 12, 1, 2, 1, 12, 3, 2, 12, 2, 7, 2, 6, 2, 1, 1, > 12, 3, 12, 3, 12, 2, 2, 9, 2, 1, 4, 12, 3, 4) > plot(month~year,xaxt="n", type="b", yla

Re: [R] unordered y axis

2019-11-06 Thread Jim Lemon
Hi Ani, There are a number of ways to modify this sort of plot. Here is one: x11(width=7,height=5) par(cex.axis=.8) plot(month~year,xaxt="n", type="l", ylab="Month", xlab="Year", main="Month of occurrence in year") axis(1,at=seq(1981,2014,3)) library(plotrix)

Re: [R] problem in WRS2

2019-11-06 Thread Jim Lemon
Hi Greg, I tried this: cp<-read.table(text="Birey Grup Time y 11 Cp1 0.7916386 11 Cp3 1.7463777 11 Cp7 1.2008390 11 Cp14 0.6311380 11 Cp21 2.1563557 11 Cp28 1.2008390", header=TRUE) library(prettyR) xtab(Grup~Time,cp) Crosstabulation of Grup by Time Time

Re: [R] Help needed for one question (Urgent)

2019-11-05 Thread Jim Lemon
Homework Chandeep, homework. Jim On Tue, Nov 5, 2019 at 9:40 PM Chandeep Kaur wrote: > > Dear Team, > > Could you please help me with the below question? How can I get the desired > output? > > Produce the following sequence using only rep(), seq() and potentially > other functions/operators.

Re: [R] save() unable to find object

2019-10-31 Thread Jim Lemon
Hi Christofer, This is a guess, but have you tried: save(AAA31,file="Save.RData") Jim On Thu, Oct 31, 2019 at 8:10 PM Christofer Bogaso wrote: > > Hi, > > I wanted to save a few R objects in RData file for some future use. > The names of such R objects are actually dynamic so I used below code

Re: [R] Help for pdf conversion

2019-10-31 Thread Jim Lemon
Hi Thomas, Perhaps you should be doing something like writeLines(txt[1],...) or just: sink("10619.txt") cat(txt[1]) sink() Jim On Thu, Oct 31, 2019 at 4:48 PM Thomas Subia wrote: > > Colleagues, > > I'm trying to convert a pdf to a text file with the following code. > > # pdf to excel >

Re: [R] Error when using qvalue function

2019-10-28 Thread Jim Lemon
Hi Ana, Seems to work without error for me: # installed qvalue_1.26.0 from CRAN archive library(qvalue) pvals<-c(6.919239e-02,1.073784e-01,1.218613e-01,1.586202e-01, 1.370340e-01,3.452574e-02,2.545619e-01,1.676715e-02,8.571197e-01, 8.649025e-01,1.777414e-02,6.801867e-01,6.873085e-01,

Re: [R] negative vector length when merging data frames

2019-10-23 Thread Jim Lemon
in via SQL or whatever language is available. Jim On Thu, Oct 24, 2019 at 10:17 AM Ana Marija wrote: > > no can you please send me an example how the command would look like in my > case? > > On Wed, Oct 23, 2019 at 6:16 PM Jim Lemon wrote: > > > > Yes. Have you tri

Re: [R] negative vector length when merging data frames

2019-10-23 Thread Jim Lemon
t; so my example would not reproduce the error > > On Wed, Oct 23, 2019 at 6:05 PM Jim Lemon wrote: > > > > Hi Ana, > > When I run this example taken from your email: > > > > l4<-read.table(text="X1 X2 X3 X4 X5 variant_id pval_nominal gene_id.LCL > > ch

Re: [R] negative vector length when merging data frames

2019-10-23 Thread Jim Lemon
Ah, it looks like a memory allocation problem. Jim On Thu, Oct 24, 2019 at 10:05 AM Ana Marija wrote: > > I also tried left_join but I got: Error: std::bad_alloc > > > df3 <- left_join(l4, asign, by = c("chr","pos")) > Error: std::bad_alloc > > dim(l4) > [1] 166941635 8 > > dim(asign) >

Re: [R] negative vector length when merging data frames

2019-10-23 Thread Jim Lemon
Hi Ana, When I run this example taken from your email: l4<-read.table(text="X1 X2 X3 X4 X5 variant_id pval_nominal gene_id.LCL chr1 13550 G A b38 1:13550:G:A 0.375614 ENSG0227232 chr1 14671 G C b38 1:14671:G:C 0.474708 ENSG0227232 chr1 14677 G A b38 1:14677:G:A 0.699887

Re: [R] If Loop I Think

2019-10-22 Thread Jim Lemon
w more once I'm done. > > Can you suggest any other sources? > > Thanks. > > -Original Message- > From: Jim Lemon > Sent: Tuesday, October 22, 2019 3:26 PM > To: Phillip Heinrich > Cc: r-help > Subject: Re: [R] If Loop I Think > > Hi Philip, > Try this: >

Re: [R] If Loop I Think

2019-10-22 Thread Jim Lemon
Hi Philip, Try this: phdf<-read.table( text="Row Outs RunnerFirst RunnerSecond RunnerThird R1 R2 R3 1 0 2 1 3 1 4 1 arenn001 5 2 arenn001 6 0 7 0 perad001 8 0 polla001 perad001 9 0 goldp001 polla001 perad001 10 0 lambj001 goldp001 11 1 lambj001 goldp001 12 2 lambj001 13 0 14 1 ",

Re: [R] Conditions in R (Help Post)

2019-10-22 Thread Jim Lemon
Hi Yeasmin, I suspect that you didn't intend to have conditions like: a<0 && b>0 && b 0 && abs(b) < abs(a) If this is the case, the following function seems to return the values of phase that you want: assign_phase<-function(x,y) { phase<-c(1,2,7,8,3,4,6,5) phase_index<-4 * (x > 0) + 2 * (y >

Re: [R] Query about calculating the monthly average of daily data columns

2019-10-20 Thread Jim Lemon
Hi Subhamitra, This is not the only way to do this, but if you only want the monthly averages, it is simple: # I had to change the "soft" tabs in your email to commas # in order to read the data in spdf<-read.table(text="PERMNO,DATE,Spread 111,19940103,0.025464308 111,19940104,0.064424296

Re: [R] "chi-square" | "chi-squared" | "chi squared" | "chi square" ?

2019-10-18 Thread Jim Lemon
I have thought about this one myself, and just reading the posts and links has afforded me a more informed viewpoint. My guess is that it boils down to a contest between mathematics and prosody. To speakers of English, "square" in the mathematical sense implies the active form such as "I square

Re: [R] List of data frame

2019-10-17 Thread Jim Lemon
Hi ani, Sorry, a typo in the function - should be: makeNA(x)<-function(x,varname,value) { x[,varname][x[,varname]==value]<-NA return(x) } Jim On Fri, Oct 18, 2019 at 2:01 PM Jim Lemon wrote: > > Hi ani, > You say you want to replace with NA, so: > > # it will be ea

Re: [R] List of data frame

2019-10-17 Thread Jim Lemon
Hi ani, You say you want to replace with NA, so: # it will be easier if you don't use numbers for the names of the data frames names(test) <- paste0("Y",1986:2015) makeNA(x)<-function(x,varname,value) { x[,varname][x[,varname]<-value]<-NA return(x) } lapply(test,makeNA,list("RR",))

Re: [R] Bar Charts

2019-10-16 Thread Jim Lemon
gt; It`s like this? > > barplot(CONTBR_RESULT[order(CONTBR_RESULT)][16:30]) > > Regards > Jorge > > On Wed, 16 Oct 2019 at 02:51, Jim Lemon wrote: >> >> Hi Jeff, >> Let's say you have the following data: >> >> set.seed(12345) >> CONTBR_RESULT<-s

Re: [R] Bar Charts

2019-10-15 Thread Jim Lemon
Hi Jeff, Let's say you have the following data: set.seed(12345) CONTBR_RESULT<-sample(20:200,30) If you don't mind ordering the results, you can do this: barplot(rev(sort(CONTBR_RESULT))[1:15],...) If you want the values in the original order: barplot(CONTBR_RESULT[order(CONTBR_RESULT) >

Re: [R] Testing for normality in categorical data

2019-10-05 Thread Jim Lemon
Hi Nancy, The chickwts dataset contains one sort-of continuous variable (weight) and a categorical variable (feed). Two things that will help you to understand what you are trying to do is to "eyeball" the "weight" data: # this shows you the rough distribution of chick weights

Re: [R] my question is how to read pvcm file

2019-10-04 Thread Jim Lemon
Hi Jui-Kun, Are you using the plm package and talking about a pvcm object that is returned by the function of the same name? If so, it is not a "file" but a list of values returned by the function. Maybe this will move your question in the direction of intelligibility. Jim On Sat, Oct 5, 2019 at

Re: [R] Can you turn an input into a variable name?

2019-10-04 Thread Jim Lemon via R-help
Hi April, Try this: # this could be done from a file textlines<-read.table(text="color=green shape=circle age=17 name=Jim", stringsAsFactors=FALSE) for(i in 1:length(textlines)) { nextline<-unlist(strsplit(textlines[i,1],"=")) assign(nextline[1],nextline[2]) } color [1] "green" shape [1]

Re: [R] mapple

2019-10-02 Thread Jim Lemon
uot;1","2","4": 1 4 2 1 1 2 2 2 3 1 > $ v3 : Factor w/ 4 levels "0","1","2","3": 1 1 1 2 2 1 3 3 4 1 > $ v4 : Factor w/ 4 levels "0","2","3","4": 1 1 1 1 1 1 1 3 4 2 > $ v5 : Factor w/

Re: [R] mapple

2019-10-01 Thread Jim Lemon
Hi Phillip, The following seems to do what you want: phdf<-read.table(text="v1 v2 v3 v4 v5 code 0 0 0 0 01 1 4 0 0 01 1 1 0 0 01 1 0 1 0 01 2 0 1 0 01 0 1 0 0 01 0 1 2 0 01 0 1 2 3 01 0 2 3 4 41 0 0 0 2 31",

Re: [R] how to add p values to bar plot?

2019-09-28 Thread Jim Lemon
Hi Ana, You seem to have a p-value at the top of the second plot. Do you just want that p-value in a different place? My first guess would be the "annotate" argument. Say you wanted your p-value in the middle of the plot. # your ggplot line p+annotate("text",x=1.5,y=0.05,label="p = 1.6x10-16") p

Re: [R] I am a user of the package plotrix, and want to ask a question that I can't possibly find the answer anywhere

2019-09-28 Thread Jim Lemon
Hi Leo, The easiest way to do this is: par(las=1) # twoord.plot command par(las=0) Jim On Sat, Sep 28, 2019 at 8:56 PM leo wu wrote: > > Dear Jim Lemon: > I am currently using the twoord.plot() function in plotrix package. I > want to inquire, how am I supposed to rotate my

Re: [R] The "--slave" option ==> will become "--no-echo"

2019-09-27 Thread Jim Lemon
On Sat, Sep 28, 2019 at 2:04 AM Martin Maechler wrote: > > For back compatibility reasons, the old command line option will > continue to work so the many shell and other scripts that use > it, will not stop working. > That's a relief. I was getting worried that we would become: The knights who

Re: [R] Creating a Date Field

2019-09-24 Thread Jim Lemon
Hi Phillip, Try this: as.Date(c("20180329","20180330","20180331"),"%Y%m%d") [1] "2018-03-29" "2018-03-30" "2018-03-31" Note that the format argument has to match the date format exactly. Jim On Wed, Sep 25, 2019 at 9:54 AM Phillip Heinrich wrote: > > The date is imbedded in the GameID

Re: [R] how to calculate True Positive Rate in R?

2019-09-24 Thread Jim Lemon
Hi Ana, Your minimum value in pvalR is very small and may be causing trouble. As the qvalue package seems to be in Bioconductor, perhaps posting to that help list would get an answer. Jim On Wed, Sep 25, 2019 at 1:48 AM Ana Marija wrote: > > Hello, > > I tried using qvalue function: > >

Re: [R] Loop With Dates

2019-09-21 Thread Jim Lemon
Hi Phillip, While I really like Ana's solution, this might also help: phdf<-read.table(text="Date count 2018-03-29 1 2018-03-29 1 2018-03-29 1 2018-03-30 1 2018-03-30 1 2018-03-30 1 2018-03-31 1 2018-03-31 1 2018-03-31 1",

Re: [R] The way giving the suitable data structure to the obtained data for the use of "prospectr"

2019-09-19 Thread Jim Lemon
Hi rhotuser, Your question is really not about R, but about understanding IR spectroscopy methods for soil composition. That's not my field, and you will be lucky to find someone on this help list who is: 1) an expert in the field 2) willing to explain the methods used in the prospectr package

Re: [R] problem with pyramid.plot

2019-09-19 Thread Jim Lemon
Hi Christophe, Your call to pyramid.plot is okay. I would make a couple of suggestions: par(mar=pyramid.plot(males.overweight,females.overweight, top.labels=c("Males","Labels","Females"),laxlab=seq(0,60,by=10), raxlab=seq(0,30,by=10),labels=agelabels,lxcol="#74c476",rxcol="#9e9ac8",

Re: [R] Data conversion

2019-09-18 Thread Jim Lemon
Hi Edward, Say your "data frame" is named "epdat". This may do it: epmat<-matrix(epdat[10:289],nrow=28) colnames(epmat)<-sub("1","",names(epdat[10:289])[seq(1,270,by=28)]) This one looks like the Sorceror's Apprentice tangled with one of those experimental schedule scripting programs. Jim On

Re: [R] How to use breaks argument in hist() function correctly?

2019-09-18 Thread Jim Lemon
Hi Cristofer, If you just ask for a number of breaks, you will get what "hist" thinks you should. Try this or something similar: hist(x,breaks=seq(min(x),max(x),length.out=21)) Jim On Wed, Sep 18, 2019 at 8:55 PM Christofer Bogaso wrote: > > Hi, > > I have a numerical vector as below > > x =

Re: [R] bi-directional bar chart with a central axis

2019-09-17 Thread Jim Lemon
Hi Jennifer, This is one way: library(plotrix) pyramid.plot(my.dta[,1],my.dta[,2], labels=c("Statement 1","Statement 2","Statement 3", "Statement 4","Statement 5","Statement 6", "Statement 7","Statement 8","Statement 9", "Statement 10","Statement 11","Statement 12","Statement 13"),

Re: [R] Query about calculating the monthly average of daily data columns

2019-09-13 Thread Jim Lemon
Sorry, forgot to include the list. On Sat, Sep 14, 2019 at 10:27 AM Jim Lemon wrote: > > See inline > > On Fri, Sep 13, 2019 at 11:20 PM Subhamitra Patra > wrote: >> >> Dear Sir, >> >> Yes, I understood the logic. But, still, I have a few queries

Re: [R] Query about calculating the monthly average of daily data columns

2019-09-13 Thread Jim Lemon
Hi Subhamitra, I'll try to write my answers adjacent to your questions below. On Fri, Sep 13, 2019 at 6:08 PM Subhamitra Patra wrote: > Dear Sir, > > Thank you very much for your suggestion. > > Yes, your suggested code worked. But, actually, I have data from 3rd > January 1994 to 3rd August

Re: [R] Query about calculating the monthly average of daily data columns

2019-09-12 Thread Jim Lemon
Hi Subhamitra, Your data didn't make it through, so I guess the first thing is to guess what it looks like. Here's a try at just January and February of 1994 so that we can see the result on the screen. The logic will work just as well for the whole seven years. # create fake data for the first

Re: [R] Inter-rater reliability for 3 unique raters with binary outcome

2019-09-12 Thread Jim Lemon
Hi Lubo, Have a look at the "irr" package. I transferred any unique functions from concord to it to reduce duplication of functions in different packages. Jim On Thu, Sep 12, 2019 at 7:03 PM Lubo Larsson wrote: > > Hello, > > I would like to know if there is an R utility for computing some >

Re: [R] Strange behaviour of sapply function.

2019-09-12 Thread Jim Lemon
Hi bickis, Putting on my dark glasses and flailing about with a big white stick*, I would suggest that you look at what "atv" actually produces from those three objects. I wouldn't be surprised to find quite different things. Jim * blind guess On Thu, Sep 12, 2019 at 7:04 PM wrote: > > Here is

Re: [R] Moving 2nd column into 1st column using R

2019-09-09 Thread Jim Lemon
Hi Zuhri, Try: mydf<-mydf[,c(2,1)] You might be surprised. Jim On Tue, Sep 10, 2019 at 12:20 PM smart hendsome via R-help wrote: > > Hi R-user, > I have a problem regarding R. How can I move my 2nd column into 1st column. > For example I have data as below: > mydf <-

Re: [R] Structuring Inventory in R

2019-08-27 Thread Jim Lemon
Hi Alex, At a guess you may want something like this: data.frame(item="SKU",price=10,qty=2,ID="1") This produces a data frame with one row. You will probably want many more rows. Jim On Wed, Aug 28, 2019 at 2:21 PM Alex Naverniak wrote: > > Hi, > I am trying to create Inventory structure

Re: [R] Data frame organization

2019-08-26 Thread Jim Lemon
Hi Arnaud, The reason I wrote the following function is that it always takes me half a dozen tries with "reshape" before I get the syntax right: amdf<-read.table(text="A 10 B 5 C 9 A 5 B 15 C 20") library(prettyR) stretch_df(amdf,"V1","V2") V1 V2_1 V2_2 1 A 105 2 B5 15

Re: [R] Labeling Dates of different length on two in axis plot

2019-08-25 Thread Jim Lemon
Hi Ogbos, Hope things are going well for you. Perhaps this is what you want: date_x1<-seq(as.Date("1953-01-02"),as.Date("2006-11-15"),length.out=8) value_x1<-sample(1000:5000,8) date_x2<-seq(as.Date("1957-07-26"),as.Date("1994-07-17"),length.out=6) value_x2<-sample(0:1000,6)

Re: [R] Creating data using multiple for loops

2019-08-19 Thread Jim Lemon
Hi Greg, I replied because I thought the name of the "expand.grid" function can be puzzling. While "expand.grid" is a very elegant and useful function, it is much easier to see what is happening with explicit loops rather than loops buried deep inside "expand.grid". Also note Bill's comment about

Re: [R] Creating data using multiple for loops

2019-08-18 Thread Jim Lemon
Hi Greg, One problem is that you have misplaced the closing brace in the third loop. It should follow the assignment statement. Because you used loops rather than Bert's suggestion, perhaps you are trying to order the values assigned. In your example, the ordering will be ssn, then month of birth,

Re: [R] QQ plot

2019-08-14 Thread Jim Lemon
Hi Ana Marija, It would help if we had the data, but I suspect that the data that we don't have is not uniformly distributed: library(plotrix) ams_norm<-rnorm(100) png("ams_norm.png") qqunif(rescale(ams_norm,c(0,1))) dev.off() ams_unif<-runif(100) png("ams_unif.png") qqunif(ams_unif) dev.off()

Re: [R] Help with if else statement

2019-08-07 Thread Jim Lemon
Hi Ana, Or just for a bit of fun: pt<-read.table(text="eidQ phenoQ phenoH 117 -9 -9 125 -9 -9 138 -9 1 142 -9 -9 156 -9 -9 174 -9 -9 138 -9 1 1000127 2 1 1000690 2 -9 1000711 2

Re: [R] Loop Repetition

2019-08-06 Thread Jim Lemon
Hi Tolulope, The "in" operator steps through each element of the vector on the right. You only have one element. Therefore you probably want: for(x in 1:5) ... Jim Jim On Tue, Aug 6, 2019 at 6:54 PM Tolulope Adeagbo wrote: > > Hey guys, > > I'm trying to write a loop that will repeat an

Re: [R] Monte carlo Simulation

2019-07-29 Thread Jim Lemon
Hi Tolulope, Get the Monte Carlo package: https://cran.r-project.org/web/packages/MonteCarlo/vignettes/MonteCarlo-Vignette.html and look at an online tutorial: https://www.youtube.com/watch?v=T_igE6bb6hU Jim On Mon, Jul 29, 2019 at 5:29 PM Tolulope Adeagbo wrote: > > Hello Everyone, > >

Re: [R] Creating a conditional lag variable in R

2019-07-26 Thread Jim Lemon
Hi Faradj, There is a problem with your structure statement in that the hyphen (-) following the left angle bracket (<) has been transformed into a fancy hyphen somewhere in the process. I replaced it with an ordinary hyphen and it worked okay. Also, your coding for "B" seems to include the first

Re: [R] Capturing positive and negative changes using R

2019-07-20 Thread Jim Lemon
Hi Faradj, Rui's advice is correct, here's a way to do it. Note that I have replaced the comma decimal points with full stops for my convenience: fkdf<-read.csv(text="Year,Country,X1,X2 1990,United States,0,0.22 1991,United States,0,0.22 1992,United States,0,0.22 1993,United States,0,0.22

Re: [R] How to create a data set from object/data frame?

2019-07-20 Thread Jim Lemon
Hi Spencer, While Sarah has already given you very good advice, there is a rough method of checking whether one data set can be substituted for another: str(anno) str(Dilution) If you're lucky and the objects are not too complicated, this will give you a start on whether one can be substituted

Re: [R] Plotting in R

2019-07-18 Thread Jim Lemon
> > library(plotly) > plot_ly(sydf, > x = ~year, > y = ~rate, > type = 'scatter', mode = 'lines') %>% > layout( > xaxis = list( > ticktext = sydf$monthday[seq(1, length(sydf$monthday), 3)], > tickvals = sydf$year, > tickmode = &quo

Re: [R] Plotting in R

2019-07-12 Thread Jim Lemon
ot;2002-07-13" So making the labels these mid-year dates as character strings might do what you want: yrlabels<-as.character(yrticks) Jim On Sat, Jul 13, 2019 at 8:33 AM Jim Lemon wrote: > > Hi Steven, > year1 is a number (e.g. 1993), monthday (e.g. 05-01) is not. > >

Re: [R] Plotting in R

2019-07-12 Thread Jim Lemon
nthday, > tickvals = sydf$yrticks, > tickmode = "array", > tickangle = 270 > )) > > But the chart didn't show any tick labels. > I guess I need to sample sydf$monthday, right? Because that's what I want to > show as tick labels. But the probl

Re: [R] Plotting in R

2019-07-11 Thread Jim Lemon
axis lables, and > use that for the "ticktext" parameter. > I thought it must be some variation of the seq(from, to, by= ). Can I use > that with a list of strings? > > Thanks, > Steven > > -Original Message- > From: Jim Lemon > Sent: Thursday,

Re: [R] Plotting in R

2019-07-11 Thread Jim Lemon
axis, but still > have the plot showing the chart as rate based on year? > I tried this: > plot(sydf$year,sydf$rate,type="b", > xlab="month-day",ylab="Rate") > > but this only changes the title of the x axis to "month-day". I want

Re: [R] Error in readChar(con, 5L, useBytes = TRUE) : cannot open the connection

2019-07-09 Thread Jim Lemon
Hi Ana, The first error message may be the critical one. "weight//NA" is almost certainly not the name of the file you want, and two consecutive slashes in a path is also incorrect. You may not have placed the data files in the correct file structure, often a problem with programs that are written

Re: [R] Plotting in R

2019-07-07 Thread Jim Lemon
Hi Steven, A basic plot can be displayed like this: sydf<-read.table(text="year rate 1993 0.608 1994 0.622 1996 0.623 1998 0.647 2000 0.646 2002 0.625 2004 0.628 2006 0.685 2008 0.679 2010 0.595 2012 0.567 2014 0.599 2016 0.642 2018 0.685", header=TRUE)

Re: [R] How to set scale of color scatterplot points relative to a third variable?

2019-07-06 Thread Jim Lemon
Hi Sarah, The size_n_color function in the plotrix package does something like this. To get the colors that you want using "color.scale" in the same package, look at the help page for that function. The values in A1.matrix[,3] probably don't range from 0 to 2, so getting exactly what you want can

Re: [R] Read Unicode text (*.txt)

2019-07-01 Thread Jim Lemon
Yep, you're right. Jim On Tue, Jul 2, 2019 at 7:52 AM William Dunlap wrote: > > Should that encoding="UTF-8" be encoding="UTF-16"? > > Bill Dunlap > TIBCO Software > wdunlap tibco.com > > > On Mon, Jul 1, 2019 at 2:45 PM Jim Lemon wrote

Re: [R] sd in aggregate and help.search/?? seem not to work as usual in latest version

2019-07-01 Thread Jim Lemon
Hi Marvin, One way to get around the problem with "sd" is to only process those columns of a data frame for which the variance is defined. It is an opportunity to show students how to write wrapper functions as well: sd_num<-function(x) return(ifelse(is.numeric(x),sd(x),NA))

Re: [R] Read Unicode text (*.txt)

2019-07-01 Thread Jim Lemon
Hi Javad, Unicode characters do have embedded nulls. Try this: d4<-read.table("./4.csv",sep=";",header=TRUE,encoding="UTF-8") Jim On Tue, Jul 2, 2019 at 3:47 AM javad bayat wrote: > > Dear R users; > I am trying to read an excel CSV file (1.csv). When I read it as csv file > in R, the R shows

Re: [R] Assumptions ANOVA

2019-06-29 Thread Jim Lemon
Hi Eleftheria, If a non-parametric test doesn't sink your preferred hypothesis, it can offer some peace of mind with regard to scrupulous reviewers. If it does, it is wise to ponder the reliability of your results. Jim On Fri, Jun 28, 2019 at 10:34 PM Eleftheria Dalmaris wrote: > > Dear all, >

Re: [R] splitting a column of data into multiple columns

2019-06-28 Thread Jim Lemon
Hi Janet, This might help: jcdf<-read.table(text="scen trans evap flow 1 1.10.10.09 1 1.20.20.10 1 1.30.30.20 2 2.10.10.09 2 2.20.20.10 2 2.30.30.20 3 3.10.10.09 3 3.20.20.10 3

Re: [R] Separating Date and Time

2019-06-19 Thread Jim Lemon
Hi Jeff, Well, the output of "format" is character strings, so that is what you are missing. I assume that you want to get two numeric values for each date. date1<-"06/20/2019 09:07" > as.POSIXct(date1,format="%m/%d/%Y %H:%M") [1] "2019-06-20 09:07:00 AEST"

Re: [R] Help with numeric and character separation

2019-06-16 Thread Jim Lemon
Hi Sam, If I have the structure of your data right, this might help: scdf<-read.csv(text="DD Pack0.00 FTA English News0.00 FTA Complimentary0.00 WB1.18 WION1.18 Al Jazeera0.00 Animal Planet2.36 Asianet Movies17.70 Calcutta News0.00 Comedy Central5.90", header=FALSE, stringsAsFactors=FALSE)

Re: [R] reg expr that retains only bracketed text from strings

2019-06-12 Thread Jim Lemon
Hi Nevil, In case you are still having trouble with this, I wrote something in R that should do what you want: mystrings<-c("ABC","A(B)C","AB[C]","BC","{AB}C") get_enclosed<-function(x,left=c("(","[","<","{"),right=c(")","]",">","}")) { newx<-rep("",length(x)) for(li in 1:length(left)) {

Re: [R] Changing the label name in the plot

2019-06-12 Thread Jim Lemon
ess >> distance between each data point, but the points corresponding to the >> labels can be clearly accessible in the zoom mode. >> >> Thank you very much Sir. >> >> >> >> >> >> [image: Mailtrack] >> <https://mail

Re: [R] Changing the label name in the plot

2019-06-12 Thread Jim Lemon
label > (mentioned in column 1, and 3) for the different data points of column 2, > and 4. > > Hope I successfully answered your question. > > Thank you. > > > > [image: Mailtrack] > <https://mailtrack.io?utm_source=gmail_medium=signature_campaign=signatureviralit

Re: [R] Changing the label name in the plot

2019-06-11 Thread Jim Lemon
Hi Subhamitra, It is time to admit that I had the wrong idea about what you wanted to do, due to the combination of trying to solve two problems at once while I was very tired. I appreciate your patience. >From your last email, you have a data frame with four columns. The first and third are

Re: [R] Changing the label name in the plot

2019-06-11 Thread Jim Lemon
Hi Subhamitra, I don't have the factoextra package, but this may give you what you want: ts<-read.table(text="Name DMs Name EMs A 2.071 a 2.038 B 2.0548 b 2.017 C 2.0544 c 2.007 D 2.047 d 1.963 E 2.033 f 1.947 F 2.0327 g 1.942 G 2.0321 h 1.932 H 2.031 i 1.924 I 2.0293 j 1.913 J 2.0291 k 1.906 K

<    1   2   3   4   5   6   7   8   9   10   >