Re: [R] Need help to print matrix with element and position

2021-10-28 Thread Jim Lemon
Hi Anas, How about: cat(row,col,mat_1[row,col],"\n") Jim On Thu, Oct 28, 2021 at 7:19 PM Anas Jamshed wrote: > > I create a matrix of size 3x3 called mat_1 and then I want to iterate over > all the values one by one and print the element as well as the position in > the matrix: > > My code is :

Re: [R] Error with RMySQL

2021-10-28 Thread Jim Lemon
Hi Ashim, I was out for a while. I would first try to restart MySQL, then if that didn't fix it, try logging in as root and accessing the database. While I can't debug this at a distance, I'm pretty sure that the database thinks that you aren't authorized to access it. If the restart works, your pr

Re: [R] Error with RMySQL

2021-10-27 Thread Jim Lemon
HI Ashim, That error means that your user number or group is not allowed to access it. Did you create the new one as a different user, maybe as root? Jim On Thu, Oct 28, 2021 at 4:42 PM Ashim Kapoor wrote: > > Dear R - users, > > I have 2 databases on a MySQL server. I am able to access the old

Re: [R] generate average frame from different data frames

2021-10-23 Thread Jim Lemon
ot;mean" merge of the figures. (Perhaps also > with lines saying: this value comes out 9/10 of times, this 5/10 of > times...). > The problem is that the Z values are factors, not numbers. > > On Sun, Oct 24, 2021 at 12:08 AM Jim Lemon wrote: > > > > Hi Luigi, > > I

Re: [R] generate average frame from different data frames

2021-10-23 Thread Jim Lemon
Hi Luigi, I may be missing the point, but: matrix((z1+z2+z3)/3,ncol=10) gives you the mean rating for each item, and depending upon what distribution you choose, the confidence intervals could be calculated in much the same way. Jim On Sun, Oct 24, 2021 at 7:16 AM Luigi Marongiu wrote: > > Hel

Re: [R] Split plot panel into rows with different columns

2021-10-21 Thread Jim Lemon
Hi Luigi, Bert has identified the problem. If the ordinates in each row are the same, you can save quite a bit of space by setting the left and right margins to zero on all but the left plots in each row. This will jam the plots together at the sides, but that may not matter to you. Remember that y

Re: [R] Rising and falling bar-plots simultaneously

2021-10-17 Thread Jim Lemon
Hi Eliza, Try this: BAS1<- structure(c(3, 4, 2, 3, 3, 4, 3, 3, 3, 3, 2, 3, 3, 4, 3, 2, 2, 3, 2, 3, 3, 3, 4, 5, 3, 4, 3, 4, 4, 3, 4, 4, 3, 3, 3, 4, 3, 3, 3, 4, 3, 3, 4, 5, 4, 4, 4, 3, 4, 3, 3, 3, 3, 4, 4, 5, 4, 3, 4, 4, 2, 3, 3, 3, 2, 4, 4, 3, 3, 4, 3, 3, 3, 3, 4, 4, 3, 3, 2, 3, 3, 3, 3, 2, 5, 2, 4

Re: [R] assumptions about how things are done

2021-10-09 Thread Jim Lemon
Hi Avi, Definitely a learning moment. I may consider writing an ifElse() for my own use and sharing it if anyone wants it. Jim On Sun, Oct 10, 2021 at 6:36 AM Avi Gross via R-help wrote: > > This is supposed to be a forum for help so general and philosophical > discussions belong elsewhere, or n

Re: [R] Rename variables starting with digits

2021-10-05 Thread Jim Lemon
Hi Anne, As mentioned above, you may have to do nothing. Here is an example that might clarify that: azdat<-read.table(text="subject 1 2 3 1 10 20 30 2 11 22 33", header=TRUE,stringsAsFactors=FALSE) azdat subject X1 X2 X3 1 1 10 20 30 2 2 11 22 33 As you can see, R simply prepends an

Re: [R] Improve my plot

2021-09-20 Thread Jim Lemon
Hi varin, Not too difficult: par(mar=c(5,13,4,1)) barplot(height=c(574,557,544,535,534,532,531,527,526,525,524,520,518, 512,507,504,504,489,488,488,487,484,484,474,472,455,444,420), names.arg=c("Fribourg(f)","Valais(d)", "Appenzell Rhodes Intérieures","Fribourg(d)","Jura","Schwyz", "Schaffhouse"

Re: [R] how to remove factors from whole dataframe?

2021-09-19 Thread Jim Lemon
. of 3 variables: > $ region : char "A","B","C","D",..: 1 2 3 4 5 > $ sales : num 13 16 22 27 34 > $ country: char "a","b","c","d",..: 1 2 3 4 5 > ``` > > On Sun, Sep 19, 2021 at 11:37 AM Jim Lemon w

Re: [R] how to remove factors from whole dataframe?

2021-09-19 Thread Jim Lemon
Hi Luigi, It's easy: df1<-df[,!unlist(lapply(df,is.factor))] _except_ when there is only one column left, as in your example. In that case, you will have to coerce the resulting vector back into a one column data frame. Jim On Sun, Sep 19, 2021 at 6:18 PM Luigi Marongiu wrote: > > Hello, > I w

Re: [R] Problem with plotmat package

2021-09-16 Thread Jim Lemon
Okay, that was just my reading of the help page. I hope that I haven't added to the confusion. Jim On Fri, Sep 17, 2021 at 10:50 AM H wrote: > > On 09/15/2021 09:40 PM, Jim Lemon wrote: > > Oops, your plot > > > > On Thu, Sep 16, 2021 at 11:39 AM Jim Lemon wrot

Re: [R] adding results to plot

2021-09-16 Thread Jim Lemon
Hi Petr, The hard part is the names for the data frame that addtable2plot requires: set.seed(753) res <- shapiro.test(rnorm(100)) library(plotrix) plot(0,0,type="n",axes=FALSE) addtable2plot(0,0,data.frame(element=names(res)[1:2], value=round(as.numeric(res[1:2]),3)),xjust=0.5, title=res$metho

Re: [R] order stacked bar plot from total frequency

2021-09-16 Thread Jim Lemon
Hi Kai, I don't know about ggplot, but it may be easier to do it before plotting: set.seed(753) testdat<-matrix(sample(1:10,9),nrow=3) # first plot the raw matrix barplot(testdat) # then plot the matrix ordered by column sums barplot(testdat[,order(colSums(testdat))]) Jim On Fri, Sep 17, 2021 at

Re: [R] Problem with plotmat package

2021-09-15 Thread Jim Lemon
Oops, your plot On Thu, Sep 16, 2021 at 11:39 AM Jim Lemon wrote: > > Hi H, > Looking at your example and the help page, it looks to me as though > the plot is consistent with the "A" matrix: > > Oz > Rain Nice > Rain 0.25 0.75 > Nice 0.60 0.40 >

Re: [R] Problem with plotmat package

2021-09-15 Thread Jim Lemon
Hi H, Looking at your example and the help page, it looks to me as though the plot is consistent with the "A" matrix: Oz Rain Nice Rain 0.25 0.75 Nice 0.60 0.40 # help page A - square coefficient matrix, specifying the links (rows=to, cols=from). In your plot (attached): Rain (col) goes to

Re: [R] field significance test

2021-09-07 Thread Jim Lemon
HIi Ani, I think you are going to a lot of trouble to get a fairly simple result. # matrix of logicals for positive stat values possig<-df3 > 0 & df4 < 0.05 # now negative stat values negsig<-df3 < 0 & df4 < 0.05 # very clunky plots of column counts barplot(colSums(possig), names.arg=paste0("S",

Re: [R] field significance test

2021-09-06 Thread Jim Lemon
HI Ani, I would create these two matrices: # matrix of logicals for positive stat values posvalue<-df3 > 0 # matrix of logicals for significance sigstat<-df4 < 0.05 Then you can identify the positive/negative and significant values: which(posvalue & sigstat) [1] 12 which(!posvalue & sigstat) [1]

Re: [R] Splitting a data column randomly into 3 groups

2021-09-02 Thread Jim Lemon
Hi Abou, One way is to shuffle the original data frame using sample(). and split up the result into three equal parts. I was going to provide example code, but Avi's response popped up and I kind of agree with him. Jim On Fri, Sep 3, 2021 at 11:31 AM AbouEl-Makarim Aboueissa wrote: > > Dear All:

Re: [R] plotting some rows in different color

2021-09-02 Thread Jim Lemon
Hi Eliza This seems to work: plot(BFA3[,1],BFA3[,4], pch=16, xlab = "", ylab = "",col=(BFA3[,2]==BFA3[,3])+2,axes=FALSE) but I have no idea what you are trying to do with the as.numeric(as.Date(...)) business. Jim On Fri, Sep 3, 2021 at 8:44 AM Eliza Botto wrote: > > Dear useRs, > > For the

Re: [R] Selecting elements

2021-08-25 Thread Jim Lemon
nts (variable and value). > Is it possible to add in the output file? > Thank you very much. > > Prof. Dr. Silvano Cesar da Costa > Universidade Estadual de Londrina > Centro de Ciências Exatas > Departamento de Estatística > > Fone: (43) 3371-4346 > > > Em qua., 25

Re: [R] Help needed with getting a decent image of ggplot2 graph

2021-08-24 Thread Jim Lemon
than men and women and isn't not > being incorporated in that width. > > I think I'll have to settle for a smaller title > > Sent from Yahoo Mail on Android > > On Tue, 24 Aug 2021 at 6:54 PM, Jim Lemon > wrote: > Ah, an _upper_ limit. Why not let tiff() work

Re: [R] Selecting elements

2021-08-24 Thread Jim Lemon
Hi Silvano, I was completely stumped by your problem until I looked through Petr's response and guessed that you wanted the largest sum of 'Var.1" constrained by the specified numbers in your three schemes. I think this is what you want, but I haven't checked it exhaustively. set.seed(123) Var.1 <

Re: [R] unable to install source packages with Rtools installed

2021-08-24 Thread Jim Lemon
al\Temp\RtmpoPSf4N\downloaded_packages’ > > Session info: > > sessionInfo() > R version 4.1.1 (2021-08-10) > Platform: x86_64-w64-mingw32/x64 (64-bit) > Running under: Windows 10 x64 (build 18363) > > Matrix products: default > > locale: > [1] LC_COLLATE=Chinese (Simplified)_

Re: [R] Help needed with getting a decent image of ggplot2 graph

2021-08-24 Thread Jim Lemon
it of 440 pixels for the width and an upper limit of > 300 for the dpi. > > On Tuesday, 24 August, 2021, 06:36:16 pm GMT-4, Jim Lemon > wrote: > > > Hi bharat, > I think there is a conflict between your image size and resolution. > You need a lot larger height and width i

Re: [R] Query regarding stats/p.adjust package (base) - specifically 'Hochberg' function

2021-08-24 Thread Jim Lemon
This is beginning to sound like a stats taliban fatwa. I don't care if you're using an abacus, you want to get the correct result. My guess is that the different instantiations of the Hochberg adjustment are using different algorithms to calculate the result. The Hochberg adjustment is known to be

Re: [R] Help needed with getting a decent image of ggplot2 graph

2021-08-24 Thread Jim Lemon
Hi bharat, I think there is a conflict between your image size and resolution. You need a lot larger height and width in pixels to get 300 dpi resolution for the whole plot. tiff("test.tiff", units = "px", width = 2200, height = 1250, res = 300) would probably do it for you. How come you can't c

Re: [R] data manipulation question

2021-08-23 Thread Jim Lemon
Hi Kai, How about setting: germlinepatients$DisclosureStatus <- NA then having your three conditional statements as indices: germlinepatients$DisclosureStatus[germlinepatients$gl_resultsdisclosed == 1] <-"DISCLOSED" germlinepatients$DisclosureStatus[germlinepatients$ gl_resultsdisclosed == 0] <-

Re: [R] Problem in Notrend_test()

2021-08-18 Thread Jim Lemon
Hi bharat, notrend_test (funtimes) wants a vector (univariate time series) as the first argument. My crystal ball suggests that column_Data is too short, but try this: notrend_test(column_Data,test="WAVK") Be aware that this is a guess. Jim On Thu, Aug 19, 2021 at 1:58 PM bharat rawlley via R-h

Re: [R] Including percentage values inside columns of a histogram

2021-08-16 Thread Jim Lemon
Hi Paul, I just worked out your first request: datasetregs<-<-structure(list(Date = structure(c(1L, 1L, 1L, 1L, 1L, 1L, 2L, 2L, 2L, 2L, 2L, 2L, 2L, 2L, 2L, 2L, 2L, 2L, 2L, 2L, 2L, 2L, 2L, 2L, 2L, 2L, 2L, 2L, 2L, 2L, 2L, 2L, 2L, 2L, 2L, 2L, 2L, 2L, 2L, 2L, 2L, 3L, 3L, 3L, 3L, 3L, 3L, 3L, 3L, 3L, 3L

Re: [R] collided row names in heatmap.2

2021-08-11 Thread Jim Lemon
Hi Elham, Your image didn't get through, maybe PNG will work. Label crowding is a common problem, whether horizontal or vertical. One solution is to set a maximum length on label text (see truncString in the prettyR package). Others are to stagger labels (staxlab in plotrix) or shift them apart whe

Re: [R] Calculation of Age heaping

2021-08-09 Thread Jim Lemon
> > Md > > On Mon, Aug 9, 2021 at 1:17 PM Jim Lemon wrote: >> >> And if you really don't like programming: >> >> whipple_index<-function(x,td=c(0,5)) { >> wi<-rep(NA,11) >> names(wi)<-c(paste0("wi",0:9),"O/all&q

Re: [R] Calculation of Age heaping

2021-08-09 Thread Jim Lemon
And if you really don't like programming: whipple_index<-function(x,td=c(0,5)) { wi<-rep(NA,11) names(wi)<-c(paste0("wi",0:9),"O/all") for(i in 0:9) { ttd<-which((x %% 10) %in% i) wi[i+1]<-length(ttd) * 100/length(x) } ttd<-which((x %% 10) %in% td) wi[11]<-length(ttd) * 100/(length(x)/le

Re: [R] Apply gsub to dataframe to modify row values

2021-08-09 Thread Jim Lemon
Value is redrd rdrd > 3 3 empty mpty mpty mpty > ``` > > On Mon, Aug 9, 2021 at 12:40 PM Luigi Marongiu > wrote: > > > > Thank you, that is much appreciated. But on the real data, the > > substitution works only on

Re: [R] Apply gsub to dataframe to modify row values

2021-08-09 Thread Jim Lemon
Hi Luigi, Ah, now I see: df$VAL<-gsub("Value is","",df$VAL,ignore.case=TRUE) df VAR VAL 1 1 blue 2 2 red 3 3 empty Jim On Mon, Aug 9, 2021 at 6:43 PM Luigi Marongiu wrote: > > Hello, > I have a dataframe where I would like to change the string of certain > rows, essentially I am lo

Re: [R] substitute column data frame based on name stored in variable in r

2021-08-09 Thread Jim Lemon
Hi Luigi, It looks to me as though you will have to copy the data frame or store the output in a new data frame. Jim On Mon, Aug 9, 2021 at 6:26 PM Luigi Marongiu wrote: > > Hello, > I would like to recursively select the columns of a dataframe by > strong the names of the dataframe in a vector

Re: [R] No "doc" directory in my installation of R.

2021-08-07 Thread Jim Lemon
Hi Rolf, What about: mkdir /usr/lib/R/doc Jim On Sun, Aug 8, 2021 at 12:45 PM Rolf Turner wrote: > > > Should/shouldn't there be one? > > My R seems to be installed in /usr/lib/R. If do an "ls" of this > directory, I get: > > > bin/ COPYING@etc/ lib/ library/ modules/ > > site-libr

Re: [R] Long Format data

2021-08-05 Thread Jim Lemon
Hi Admire, I think rep_n_stack in the prettyR package may do what you want: # download and install the prettyR package install.packages("prettyR") # load the prettyR package library(prettyR) # read in your data ATCdf<-read.csv("BOP_All_Countries.csv",stringsAsFactors=TRUE) # convert the values you

Re: [R] Long Format data

2021-08-03 Thread Jim Lemon
Hi Admire, Neither the R script nor CSV file was attached to your message. Both should be plain text files and are unlikely to be rejected by the help list mail server. Perhaps check your email client. Jim On Tue, Aug 3, 2021 at 5:09 PM Admire Tarisirayi Chirume wrote: > > Hello, i hope you are

Re: [R] plotrix: Bug in `sizetree()` function

2021-07-30 Thread Jim Lemon
top D5800 > Austin, TX 78712-1289 > > > > > > On Fri, Jul 30, 2021 at 12:39 AM Jim Lemon wrote: > >> Hi Reza, >> I just had a look at that and found the problem. I had not passed the >> "showcount" argument in the recursive calls. The attached co

Re: [R] Cumulates of snowfall within a given interval

2021-07-30 Thread Jim Lemon
Hi Stefano, Try using rollsum from the zoo package: library(zoo) rollsum_index<-function(x,window,val) return(which(rollsum(x,window) >= val)) rollsum_index(mydf$hn,2,80) [1] 6 13 18 19 Jim On Fri, Jul 30, 2021 at 5:24 PM Stefano Sofia wrote: > > Dear R users, > I have a data frame with daily

Re: [R] plotrix: Bug in `sizetree()` function

2021-07-29 Thread Jim Lemon
Speedway, Stop D5800 > Austin, TX 78712-1289 > > > > > > On Thu, Jul 29, 2021 at 4:42 PM Jim Lemon wrote: > >> Hi Reza, >> Thanks for letting me know. I will get to this ASAP. >> >> Jim >> >> On Thu, Jul 29, 2021 at 11:21 PM Reza Norouzian >&

Re: [R] Help with Converting Excel Times to R

2021-07-21 Thread Jim Lemon
Hi Shawn, I don't have any trouble with this: times<-c("7/20/21 13:30","7/20/21 13:40") strptime(times,"%m/%d/%y %H:%M",tz="GMT") [1] "2021-07-20 13:30:00 GMT" "2021-07-20 13:40:00 GMT" I suspect that Excel is causing the problem. Try changing the format of the date column to "Text" and work on t

Re: [R] How to estimate the parameter for many variable?

2021-07-08 Thread Jim Lemon
nthesis are needed to >> keep the dimensions, the matrix form.) >> And, I'm not sure but isn't >> >> head(gev.fit)[1:4] >> >> equivalent to >> >> head(gev.fit, n = 4) >> >> ? >> >> Like Jim says, we need more informat

Re: [R] How to estimate the parameter for many variable?

2021-07-08 Thread Jim Lemon
Hi Siti, I think we need a bit more information to respond helpfully. I have no idea what "Ozone_weekly2" is and Google is also ignorant. "gev.fit" is also unknown. The name suggests that it is the output of some regression or similar. What function produced it, and from what library? "ti" is known

Re: [R] Bibliometix Package Question

2021-07-01 Thread Jim Lemon
Hi Adrianna, I can see why you may be confused about the input file to create the dataframe for bibliometrix. Looking at the 'convert2db' function, it seems to shuffle the various formats to a common order used by other functions. The help page describes that order. I would look at the sample file

Re: [R] Unexpected date format coercion

2021-07-01 Thread Jim Lemon
Hi Jeremie, Try: as.Date("20-12-2020","%y-%m-%d") [1] "2020-12-20" Jim On Thu, Jul 1, 2021 at 6:16 PM Jeremie Juste wrote: > > Hello, > > I have been surprised when converting a character string to a date with the > following > format, > > in R 4.1.0 (linux debian 10) > > as.Date("20-12-2020",

Re: [R] Joining data frames

2021-06-29 Thread Jim Lemon
Hi Esthi, Have you tried something like: df2<-merge(df,df1,by.x="Sample",by.y="Plot",all.y=TRUE) This will get you a right join in "df2", not overwriting "df". Jim On Wed, Jun 30, 2021 at 1:13 AM Esthi Erickson wrote: > > Hi and thank you in advance, > > If I have a dataframe, df: > > Sample >

Re: [R] Help with selection of continuous data

2021-06-21 Thread Jim Lemon
Hi Andre, I've taken a different approach to that employed by Eric: A<-data.frame(c("01/01/2020","01/01/2020","01/01/2020","01/01/2020","01/01/2020", "01/01/2020","01/01/2020","01/01/2020","01/01/2020","01/01/2020","01/01/2020", "01/01/2020","01/02/2020","01/02/2020","01/02/2020","01/02/2020","0

Re: [R] apply a color range (kind of like a heat map) to the values in each cell of a data frame

2021-06-17 Thread Jim Lemon
Hi Ding, There are a number of "value to color" functions in various packages. One is "color.scale" in the plotrix package: library(plotrix) s1 <-c(0.085,0.086,0.139,0.129,0.235,0.177,0.000,0.126,0.271,0.000,0.083,0.163) s2 <-c(0.000,0.093,0.000,0.080,0.072,0.388,0.138,0.107,0.000,0.000,0.474,0.00

Re: [R] Can't add error bars to existing line graph

2021-06-17 Thread Jim Lemon
Hi Bruno, The interaction.plot function plots the _levels_ of the x.factor argument, not the values of the variable that is coerced to a factor. This means that the temperature locations on the x axis are c(1,2), not c(12,17). The code below works for me: readscaphfileNEW<-read.table(text="EXPERIM

Re: [R] most stable way to output text layout

2021-06-12 Thread Jim Lemon
Hi Jeremie, Or assuming that the matrix will always contain strings: tabify<-function(x,col_names=NULL) { # convert NAs to "NA" x[is.na(x)]<-"NA" # if this matrix doesn't have any column names if(is.null(col_names)) col_names<-LETTERS[1:ncol(x)] # get the format argument for sprintf tab_widt

Re: [R] Comments on "Introduction to R"

2021-06-11 Thread Jim Lemon
Hi Abdullah, A good job of proof reading, something too often neglected in documentation. Jim On Fri, Jun 11, 2021 at 4:51 PM Abdullah Khasawneh wrote: > > Dear all, > > I have recently finished reading "Introduction to R" and enjoyed it and > benefited from it immensely. Thank you very much fo

Re: [R] Converting data from weekly interval to daily interval

2021-06-08 Thread Jim Lemon
Hi Bhaskar, Perhaps you are looking for this: approx(c(3,6,7),n=21) $x [1] 1.0 1.1 1.2 1.3 1.4 1.5 1.6 1.7 1.8 1.9 2.0 2.1 2.2 2.3 2.4 2.5 2.6 2.7 2.8 [20] 2.9 3.0 $y [1] 3.0 3.3 3.6 3.9 4.2 4.5 4.8 5.1 5.4 5.7 6.0 6.1 6.2 6.3 6.4 6.5 6.6 6.7 6.8 [20] 6.9 7.0 This assumes that you are taking ea

Re: [R] replace NA into - for specific column

2021-06-02 Thread Jim Lemon
Hi Kai, Maybe this will help: proband_crc2<-data.frame(MMR=rep(c(NA,"+"),3)) proband_crc2 proband_crc2$MMR[is.na(proband_crc2$MMR)]<-"-" proband_crc2 Jim On Wed, Jun 2, 2021 at 9:59 AM Kai Yang via R-help wrote: > > Hi List, > I have a column MMR in a data frame proband_crc2. The column content

Re: [R] if statement and for loop question

2021-05-30 Thread Jim Lemon
Hi Kai, You seem to be asking the same question again and again. This does not give us the warm feeling that you know what you want. testdf<-data.frame(a=c("Negative","Positive","Neutral","Random","VUS"), b=c("No","Yes","No","Maybe","Yes"), c=c("Off","On","Off","Off","On"), d=c("Bad","Good","Ba

Re: [R] R grep question

2021-05-27 Thread Jim Lemon
Hi Kai, You may find %in% easier than grep when multiple matches are needed: match_strings<-c("MLH1","MSH2") CRC<-data.frame(gene.all=c("MLH1","MSL1","MSH2","MCC3")) CRC$MMR.gene<-ifelse(CRC$gene.all %in% match_strings,"Yes","No") Composing your match strings before applying %in% may be more flex

Re: [R] Help in modifying code to extract data from url

2021-05-20 Thread Jim Lemon
Hi Bhaskar, If you are using read.table or similar, see the "fill=" argument. Jim On Thu, May 20, 2021 at 9:54 AM Bhaskar Mitra wrote: > > Hello Everyone, > > I am trying to extract data from a url. The codes work well when the > data structure is as follows: > > X Y > 1 2 > 1 5 > 1 6 > 1 7 > 3

Re: [R] Variable labels

2021-05-14 Thread Jim Lemon
Hi Steven, I just happened to scan Petr's message to you and wondered if you were looking for something related to the "describe" function in the prettyR package (and a few others). For instance, if you do this: library(prettyR) describe(mtcars) you get this: Description of mtcars Numeric

Re: [R] empty plots !

2021-05-12 Thread Jim Lemon
Hi varin, Were you expecting image files? I don't see any plot device e.g. pdf() in your code. Jim On Wed, May 12, 2021 at 6:34 PM varin sacha via R-help wrote: > > Dear Experts, > > My R code was perfectly working since I decide to add a 5th correlation > coefficient : hoeffdings' D. > fter a

Re: [R] calculating area of ellipse

2021-05-07 Thread Jim Lemon
> John > > John Fox, Professor Emeritus > McMaster University > Hamilton, Ontario, Canada > web: https://socialsciences.mcmaster.ca/jfox/ > > On 2021-05-06 10:31 p.m., David Winsemius wrote: > > > > On 5/6/21 6:29 PM, Jim Lemon wrote: > >> Hi James, &

Re: [R] calculating area of ellipse

2021-05-06 Thread Jim Lemon
Hi James, If the result contains the major (a) and minor (b) axes of the ellipse, it's easy: area<-pi*a*b try using str() on the result you get. Jim On Fri, May 7, 2021 at 3:51 AM james meyer wrote: > > In doing meta-analysis of diagnostic accuracy I produce ellipses of confidence > and predic

Re: [R] Question

2021-05-01 Thread Jim Lemon
Hi Myungjin, The funnel plot is no more than the precision of the estimates of related studies plotted against the estimates. That is, if your measure of precision is the sample size (SS) and the estimate is named E, plot(E,SS) Look at the metafor package for good funnel plot functions. Egger's t

Re: [R] Help understanding loop behaviour

2021-04-30 Thread Jim Lemon
Hi email, If you want what you described, try this: xx<-read.table(text="COMPANY_NUMBER NUMBER_OF_YEARS 0070837 3 0070837 3 0070837 3 1000403 4 1000403 4 1000403 4 1000403 4 10029943 3 10029943 3 10029943 3 10037980 4 10037980 4 10037980 4 10037980 4 10057418 3 10057418 3 10057418

Re: [R] [R-pkg-devel] creating a function that creates a figure

2021-04-27 Thread Jim Lemon
Hi Matthew, The conventional way to document a function that doesn't return a value is: \value{nil} in the .Rd file. In the arguments section, if your data frames are named as "d1" and "d2", \item{d1,d2}{Two data frames.} Add any relevant information such as whether they must be conformable. J

Re: [R] Query

2021-04-26 Thread Jim Lemon
Hi SunYong, The docs are not exactly clear on this, but you might try adding axes=FALSE instead of xaxt="n" and then calling both axes separately. Jim On Mon, Apr 26, 2021 at 5:28 PM Sun Yong Kim wrote: > > vars package > > From: John Kane > Sent: Sunday, April

Re: [R] Conditional extraction of values in a data.frame in r

2021-04-22 Thread Jim Lemon
Hi Marna, This may be what you want: get_latest<-function(x,format="%m/%d/%Y") { x<-unlist(x) x[nchar(x)==0]<-NA if(all(is.na(x))) return(NA) else return(format(max(as.Date(x,format),na.rm=TRUE),format)) } daT$output1<-apply(daT[,2:4],1,get_latest) The empty value in daT gave a bit of trouble

Re: [R] The program can't stop when searches over all files under folders and subfolders

2021-04-19 Thread Jim Lemon
Hi John, If the program is still running, I can only guess that the function is not exiting properly. If this happened to me, I would run "top" in a terminal window and see if that process number was actually doing anything or had gone zombie. Jim On Tue, Apr 20, 2021 at 11:28 AM John wrote: > >

Re: [R] LHS random number generator

2021-04-13 Thread Jim Lemon
Hi Shah, I think what you are struggling toward is this: prior_lhs <- list(r_mu=c( 0.00299, 0.0032), r_sd=c( 0.001, 0.002), lmp=c( 0.40, 0.43), gr_mu=c( 0.14, 0.16), gr_s=c( 0.01, 0.020), alpha1=c( 0.0001, 0.

Re: [R] /usr/local/lib/R/site-library is not writable

2021-04-07 Thread Jim Lemon
Hi Gene, This is probably not best practice, but I install packages as root, which allows me to write into the default library. The restriction on non-root users being blocked from making changes to appications is pretty standard. Jim On Thu, Apr 8, 2021 at 8:18 AM Gene Leynes wrote: > > Hello R

Re: [R] How can certain variables be automatically excluded from being saved?

2021-04-01 Thread Jim Lemon
Hi Ralph, I suppose you could write a wrapper for q(): byebye<-function(drop=".Random.seed",save = "default", status = 0, runLast = TRUE) { if(drop %in% ls(all.names=TRUE)) rm(drop,pos=1) q(save=save,status=status,runLast=runLast) ) warning: untested Jim On Thu, Apr 1, 2021 at 7:05 PM Ralf Go

Re: [R] Controling the presentation of violin plot

2021-03-31 Thread Jim Lemon
Hi Mahmood, As I don't know what "mydata" is, I'll have to fake it. Do you want something like this? yourdata<-data.frame(x1=c(1250,600,rep(200,9)), x2=c(7000,2300,800,rep(100,8)), x3=c(8900,950,300,rep(0,8)), x4=c(1400,1000,rep(600,4),rep(200,5))) library(plotrix) violin_plot(yourdata) Jim O

Re: [R] pie3D.labels

2021-03-30 Thread Jim Lemon
Hi Collins, pie3D draws a pseudo-3D pie and then places 2D labels around it. If you put the labels on top of the pie, it is not going to look right. The labels will be displayed with an orthogonal viewing angle, while the pie will be tilted. pie3D is one of those functions that I wrote for those wh

Re: [R] Spie charts

2021-03-30 Thread Jim Lemon
Hi Ferri, Just for fun, I plotted six countries with the current COVID deaths, per million against both population and median income. Even I was surprised. library(plotrix) country<-c("USA","Brazil","India","UK","Czechia","Mexico") COVIDdeath<-c(1694,1471,117,1858,2445,1553) Countrypop<-c(332,214,

Re: [R] "for" loop does not work with my plot_ly command

2021-03-29 Thread Jim Lemon
Hi Rachida, My guess is that you create a vector of filenames: filenames<-list.files(path="FicConfig",pattern="*.txt") then use the filenames in the loop: for(filename in filenames) { nextfile<- read.table(filename, header = TRUE, sep = "\t" , dec = ",", skip = 0) # do whatever you want with

Re: [R] Word cloud based on a specific site

2021-03-29 Thread Jim Lemon
Hi Marcelo, Just google for "word cloud r". Too much information. Jim On Tue, Mar 30, 2021 at 11:18 AM Marcelo Laia wrote: > > Hi, > > I would like to do a word cloud in a specif site related to a specific > word. > > For example, I could be interested in discovery what are the words > linked to

Re: [R] Spie charts

2021-03-29 Thread Jim Lemon
Hi Abby, Have a look at the first example in the radial.pie function (plotrix). Jim On Tue, Mar 30, 2021 at 7:59 AM Abby Spurdle wrote: > > I couldn't find a predefined function for this purpose. > However, it wouldn't be too difficult to write a pair of functions. > > The big question is how fl

Re: [R] Spie charts

2021-03-28 Thread Jim Lemon
Hi Ferri, There are a number of variations on the pie chart. The fan.plot, radial.pie and starPie functions in the plotrix package are but a few. There are two really important considerations in using plots like this: 1) Does the plot illustrate what you want? For example, if you want to show that

Re: [R] Colorizing different individuals with fviz

2021-03-27 Thread Jim Lemon
Hi Mahmood, What you have specified can be done with: col=c(rep("black",10),rep("red",10)) depending upon what print function you are using. I suspect that this may be based on a value in your data. For example, if you want black for values of some variable up to 10 and red for those over: col=

Re: [R] How to average minutes per hour per month in the form of '# hours #minutes'

2021-03-26 Thread Jim Lemon
Hi, As you still seem to be asking for an answer, the following code may help. # begin with a minimal data frame patdb<-data.frame(patno=paste0("p",sample(100:300,200,TRUE)), date=c(paste(2020,11,sort(sample(1:31,66,TRUE)),sep="-"), paste(2020,12,sort(sample(1:31,67,TRUE)),sep="-"), paste(2021,

Re: [R] Thanks for help

2021-03-25 Thread Jim Lemon
;-a[a[,1] != 1,] this will work for first column only. >> >> If I'm trying same by this >> c<-a[a[,1] !=2,] >> c<-a[a[,2] !=2,] >> Two times >> So i was tried for loop but I'm stucked. >> >> On Fri, Mar 26, 2021, 2:37 AM Jim Lemon

Re: [R] Converting POSIXct format date to Character format

2021-03-24 Thread Jim Lemon
Hi ma015k3113, I suspect that you are asking the wrong question. # create an example data frame with an extra field PLC<-read.table(text="YEAR_END_Date EPS junk 2010-09-10.10 A 2009-08-10.20 B", header=TRUE, stringsAsFactors=FALSE) # first, I think that you may already have t

Re: [R] Increasing the resolution of a raster

2021-03-23 Thread Jim Lemon
Hi Javad, You may be trying to reinvent the wheel. Have you looked at Image Magick? Jim On Tue, Mar 23, 2021 at 11:42 PM javad bayat wrote: > > Dear R users; > Is there any way to increase the resolution of a raster so as to be seen > more clear? > I have a raster which is not very clear. I want

Re: [R] for loop implementation in below problem

2021-03-22 Thread Jim Lemon
No, I am confounded, It does return the value of the expressions within the respective braces, just like ifelse. Learn something every day. Jim On Mon, Mar 22, 2021 at 9:35 PM Jim Lemon wrote: > > If he's setting PRE to the return value of "if", that is the logical > va

Re: [R] for loop implementation in below problem

2021-03-22 Thread Jim Lemon
t. PRE<-ifelse(missing(GAY),(GA/GA)*100,(GA/GAY)*100) would return either value depending upon whether GAY was missing. That's what I get from the help pages. Jim On Mon, Mar 22, 2021 at 8:34 PM Duncan Murdoch wrote: > > On 22/03/2021 1:59 a.m., Jim Lemon wrote: > > Hi Goyan

Re: [R] for loop implementation in below problem

2021-03-21 Thread Jim Lemon
Hi Goyani, You are setting "PRE" to the return value of "if" which is one of TRUE (1), FALSE(0) or NULL. Because GAY is always missing in your example, "PRE" is always set to 1. Then you always want to pass 1 in the sample list, and that will not assign anything to PRE. By correcting the "if" claus

Re: [R] for loop implementation in below problem

2021-03-21 Thread Jim Lemon
Hi Goyani, In its present form, the function stalls because you haven't defined pmat before trying to pass it to the function. gmat and wmat suffered the same fate. Even if I define these matrices as I think you have, "solve" fails because at least one is singular. First, put the function in order

Re: [R] How to plot dates

2021-03-16 Thread Jim Lemon
Hi Greg, This example may give you a start: myDat<-read.table(text= "2021-03-11 10:00:00 2021-03-11 14:17:00 2021-03-12 05:16:46 2021-03-12 09:17:02 2021-03-12 13:31:43 2021-03-12 22:00:32 2021-03-13 09:21:43", sep=",", stringsAsFactors=FALSE) myDat$datetime<-strptime(myDat$X,for

Re: [R] How to plot dates

2021-03-15 Thread Jim Lemon
Hi Greg, As the POSIX conversion part is already answered, I'll add: as.Date("16/03/2021",format="%d/%m/%Y") converts to Date object and axis.Date() will display dates on the date axis in base graphics. Jim On Tue, 16 Mar 2021, 08:33 Gregory Coats via R-help I store in a text file the dates

Re: [R] Help please

2021-03-10 Thread Jim Lemon
Hi Areti, Maybe this will help: scrounging<-data.frame( behav=sample(c("inactive","active","foraging","snoozing"),50,TRUE), substr=sample(c("tree","ground","vine","air"),50,TRUE)) scrounge.tab<-table(scrounging) barplot(scrounge.tab) legend(3.8,14,c("inactive","active","foraging","snoozing"), f

Re: [R] Image processing in R for BMI calculation

2021-03-01 Thread Jim Lemon
I must agree with the criticism of BMI as a diagnostic index. It is easy to tell if a person is - ahem - wide and not very high with a single glance. These elementary parameters can easily be deduced from an image of said person. However, it does not convey that essential ratio of muscle to - ahem

Re: [R] Image processing in R for BMI calculation

2021-02-28 Thread Jim Lemon
Hi Paul, The paper doesn't seem to mention R and the journal doesn't inspire confidence, but the formulas provided give you a start: https://www.researchgate.net/publication/280133090_Calculation_of_Body_Mass_Index_using_Image_Processing_Techniques Jim On Mon, Mar 1, 2021 at 3:39 AM Paul Bernal

Re: [R] ddply/tapply and set function

2021-02-17 Thread Jim Lemon
Hi A, I'm unable to work out what you are using as input. Maybe: id<-data.frame(Type=c(1,2,1,1,2),set=c(1,3,5,7,8)) but that doesn't work with your tapply(id,Type,set) command. Perhaps a bit more detail? Jim On Wed, Feb 17, 2021 at 7:48 PM A. Mani wrote: > > I want a data frame (derived f

Re: [R] readline in function call with space in prompt.

2021-02-08 Thread Jim Lemon
Hi Jeremie, Try this: test <- function() { a<-readline("selection: ") return(a) } If it starts working, it could be a difference in the way Windows R handles text input. Both work okay for me on fedora linux. Jim On Tue, Feb 9, 2021 at 12:29 AM Jeremie Juste wrote: > > Hello, > > I have noti

Re: [R] Get 3 values not only 1

2021-01-27 Thread Jim Lemon
Hi varin, How about this: Mbv<-data.frame(MSE=rep(NA,1000), biais=rep(NA,1000),variance=rep(NA,1000)) for(i in 1 :1000) { n<-dim(Dataset)[1] p<-0.667 sam<-sample(1 :n,floor(p*n),replace=FALSE) Training <-Dataset [sam,] Testing <- Dataset [-sam,] fit2<-lm(PIB.hab~ISQ.2018) ypred<-predict(fit

Re: [R] Help with Krippendorff's Alpha

2021-01-22 Thread Jim Lemon
Hi Jean, kripp.alpha expects a classifier by object (in your case, score) matrix as the first argument. If I read your code correctly you are getting the scores zigzagging across six columns when you want a 6 x 180 matrix. My guess is that you want: Trainers<-matrix(c(Trainer_1,Trainer_2, Trainer_

Re: [R] Converting "day of year" to "year", "month" and "day"

2021-01-15 Thread Jim Lemon
Hi Jibrin, solar_wind_sps<-data.frame(sws=306,date="2021-016") solar_wind_spd solar_wind_spd$date<-as.Date(solar_wind_spd$date,"%Y-%j") solar_wind_spd This changes the "date" field to an actual date object. If you just want to change a character string date to another format: solar_wind_spd$date<

Re: [R] text analysis errors

2021-01-06 Thread Jim Lemon
Hi Gordon, Looks to me as though you may have to extract the text from the Word files. Export As Text. Jim On Thu, Jan 7, 2021 at 10:40 AM Gordon Ballingrud wrote: > > Hello all, > > I have asked this question on many forums without response. And although > I've made progress myself, I am stuck

Re: [R] A Labeling the median

2020-12-29 Thread Jim Lemon
Hi Greg, I think what you want is: mtext (side=4, "median", col="firebrick4", at=median(walk_seconds)) "adj" defaults to 0.5 and is usually okay. It looks to me as though mtext has taken your _character_ strings as non-numeric and then tried to work something out with par("las"). Experts more fa

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