Re: [R] Passing variable name

2020-12-27 Thread Jim Lemon
those names. I don't know why you would change the names to obscure ones like "V1", but I suggest a look at the "names" function. The answer to your question should now be clear to you. Jim On Mon, Dec 28, 2020 at 8:47 AM Jim Lemon wrote: > > Hi Seyet Ali, > If you

Re: [R] Use mapply or lapply to a nested list

2020-12-22 Thread Jim Lemon
Hi Chao, I think what you are looking for is the "rapply" function in the base package. Not sure that it can do exactly what you request but worth a look. Jim On Tue, Dec 22, 2020 at 6:36 AM Chao Liu wrote: > > I want to apply a sample function to a nested list (I will call this list > `bb`)

Re: [R] Problem in cluster sampling: 'mixed with negative subscripts'

2020-12-19 Thread Jim Lemon
It does remind me of counting on one's fingers, though. Jim On Sun, Dec 20, 2020 at 4:38 PM Bert Gunter wrote: > But c(x[-1], x[1]) is, which is not so terrible, after all... __ R-help@r-project.org mailing list -- To UNSUBSCRIBE and more, see

Re: [R] Problem in cluster sampling: 'mixed with negative subscripts'

2020-12-19 Thread Jim Lemon
Hi Chao, You have discovered one of the surprising things about the extraction operator "[". It expects to get an object consisting of integers (like 1,2,3,...) or logical values (TRUE,FALSE or 0,1). As you have passed the _values_ of your cluster, it can't deal with the negative numbers as they

Re: [R] get a month where max value is

2020-12-15 Thread Jim Lemon
Hi Ani, Not sure about this, but is this what you want? ann10<-aggregate(mon10[3:12],list(mon10$Group.1),which.max) Jim On Wed, Dec 16, 2020 at 4:55 PM ani jaya wrote: > > Dear R-Help, > > I have a data frame containing monthly maxima of rainfall in 10 > locations for 30 year and want to look

Re: [R] How to specify year-month-day for a plot

2020-12-15 Thread Jim Lemon
") > Similarly, I would like to draw a dashed vertical background grid. But it is > unclear to me how to direct R to draw a vertical dashed background grid > because I am again baffled how to specify to R a date value such as > 2018-10-20 @18:00. I welcome your guida

Re: [R] making code (loop) more efficient

2020-12-15 Thread Jim Lemon
:A I would take rs4980905 to be in column > "rsid", C in column "ref_allele" and A to be in column "eff_allele", > WGT column would just be filled with a name of the particular RDat > file. > > So the issue is in these lines: > > a <- get(load(files[i]))

Re: [R] making code (loop) more efficient

2020-12-15 Thread Jim Lemon
gt; ... > > Slow code was posted just to show what was running very slow and it > was running. I really need help fixing parallelized version. > > On Tue, Dec 15, 2020 at 7:35 PM Jim Lemon wrote: > > > > Hi Ana, > > My guess is that in your second code fragment you

Re: [R] making code (loop) more efficient

2020-12-15 Thread Jim Lemon
Hi Ana, My guess is that in your second code fragment you are assigning the rownames of "a" and the _values_ contained in a$blup to the data.table "data". As I don't have much experience with data tables I may be wrong, but I suspect that the column name "blup" may not be visible or even present

Re: [R] How to specify year-month-day for a plot

2020-12-13 Thread Jim Lemon
Hi Gregory, On Mon, Dec 14, 2020 at 12:34 PM Gregory Coats wrote: >... > Is there a convenient way to tell R to interpret “2020-12-13” as a date? > Notice the as.Date command in the code I sent to you. this converts a string to a date with a resolution of one day. If you want a higher time

Re: [R] How to specify year-month-day for a plot

2020-12-13 Thread Jim Lemon
Hi Gregory, Here's a start: gcdf<-read.table(text="2020-01-05 15.973 2020-02-15 18.832 2020-03-10 17.392 2020-05-04 14.774 2020-06-21 19.248 2020-08-01 14.913 2020-08-27 15.226 2020-09-28 14.338 2020-11-09 18.777 2020-12-11 19.652", header=TRUE,stringsAsFactors=FALSE,

Re: [R] second legend in biplot

2020-12-09 Thread Jim Lemon
t this second factor in the legend. > > Probably the last resort is to rewrite original code which I would like to > avoid as I am not so experienced in grid graphics. > > Best regards > Petr > > > -Original Message- > > From: Jim Lemon > > Sent: Monday,

Re: [R] second legend in biplot

2020-12-07 Thread Jim Lemon
Hi Petr, Here's an attempt, using the example in biplot.princomp: biplot(princomp(USArrests)) > par("usr") [1] -497.2263 624.8856 -497.2263 624.8856 legend(-180,600,c("State","Crime"),lty=1,col=c("black","red")) Jim On Mon, Dec 7, 2020 at 6:23 PM PIKAL Petr wrote: > > Dear all > > I try to

Re: [R] Download data ph soil

2020-12-03 Thread Jim Lemon
Hi Jose, Searching for "soil pH data" reveals a bucketload of sites with this sort of data in lots of formats. Jim On Thu, Dec 3, 2020 at 10:07 PM José Luis Aguilar wrote: > > Dear list members, > > I am looking for soil pH data for Europe and Africa, but I don't. > I need them to set up a

Re: [R] change frequency of wind data correctly

2020-12-02 Thread Jim Lemon
t;-aggregate(vmax~hour+ampm,ssdf,mean) This does a full day. To do more, add the date_POSIX field to the aggregate command. If you have the date and time in one field you'll have to split that. That will distinguish the AM/PM means in each day as well as hour. Jim On Thu, Dec 3, 2020 at 2:10 PM J

Re: [R] change frequency of wind data correctly

2020-12-02 Thread Jim Lemon
Hi Stefano, I read in your date-time as two separate fields for convenience. You can split your single field at the space to get the same result. ssdf<-read.table(text="date_POSIX time_POSIX vmax 2018-02-01 00:00:00 27 2018-02-01 00:10:00 41 2018-02-01 00:20:00 46 2018-02-01 00:30:00 39

Re: [R] Printing upon calling a function

2020-11-30 Thread Jim Lemon
Hi Steven, You seem to be assigning the result of me.oprobit(obj) to v instead of printing it. By appending ";v" tp that command line, you implicitly call "print". Jim On Mon, Nov 30, 2020 at 7:15 PM Steven Yen wrote: > > I hope I can get away without presenting a replicable set of codes >

Re: [R] the invisible question

2020-11-22 Thread Jim Lemon
Yep, that's it. It's not Kwrite that is doing it, but Gmail. I'll try to find a Gmail help list or help desk that can provide info. thanks. Jim On Mon, Nov 23, 2020 at 12:35 PM David Winsemius wrote: > > > On 11/22/20 5:20 PM, Rolf Turner wrote: > > On Mon, 23 Nov 2020 10:07:4

Re: [R] the invisible question

2020-11-22 Thread Jim Lemon
Hi again, I finally trapped the character (hexadecimal C2 capital A hat) with some low trickery. Jim On Mon, Nov 23, 2020 at 10:07 AM Jim Lemon wrote: > > Hi all, > I have encountered a problem in some emails with invisible characters > in code snippets that throw an error

[R] the invisible question

2020-11-22 Thread Jim Lemon
Hi all, I have encountered a problem in some emails with invisible characters in code snippets that throw an error when pasted into the terminal window: Error: unexpected input in: "star_wars_matrix<-matrix(box_office,nrow=3,byrow=TRUE, �" This morning, after two hours of intense frustration, I

Re: [R] Tutorial/vignette on modified Kneser Ney smoothing

2020-11-18 Thread Jim Lemon
Hi Gayathri, Maybe the cmscu package? https://github.com/jasonkdavis/r-cmscu Jim On Thu, Nov 19, 2020 at 6:30 AM Gayathri Nagarajan < gayathri.nagara...@gmail.com> wrote: > Hi Team > > Iam a new learner trying to build n gram models from text corpus and trying > to understand the modified

Re: [R] counting duplicate items that occur in multiple groups

2020-11-18 Thread Jim Lemon
Oops, I sent this to Tom earlier today and forgot to copy to the list: VendorID=rep(paste0("V",1:10),each=5) AcctID=paste0("A",sample(1:5,50,TRUE)) Data<-data.frame(VendorID,AcctID) table(Data) # get multiple vendors for each account dupAcctID<-colSums(table(Data)>0) Data$dupAcct<-NA # fill in

Re: [R] Inappropriate color name

2020-11-16 Thread Jim Lemon
Hi Elaine, There seems to be a popular contest to discover offence everywhere. I don't think that it does anything against racism, sexism or antidisestablishmentarianism. Words are plucked from our vast lexicon to comfort or insult our fellows depending upon the intent of the user. It is the

Re: [R] please help with "could not find function "ComBat.mc" "

2020-11-11 Thread Jim Lemon
Hi Yuan, The package named "Enmix" is maintained on Bioconductor. It seems to be specific to particular lab equipment and so all I can advise is: 1) Try your question on the Bioconductor help list 2) If no help there contact Zongli Xu (the maintainer) Jim On Thu, Nov 12, 2020 at 11:40 AM Yuan

Re: [R] R ioanalysis pkg

2020-11-10 Thread Jim Lemon
Hi Gaspar, I can see why you are having trouble with this. The "as.inputoutput" function seems to be the core. While the manual claims you can just input the "Z", "RS_label" and and "X" matrices to "as.inputoutput" and get the "InputOutput" object that you need for all the other functions, it

Re: [R] Remove all factor levels from an R dataframe

2020-11-10 Thread Jim Lemon
Sure John, df1<-df1[order(as.character(df1$year),decreasing=TRUE),] Jim On Tue, Nov 10, 2020 at 8:05 PM John wrote: > Thanks Jim. Can we do descending order? > > Jim Lemon 於 2020年11月10日 週二 下午4:56寫道: > >> Hi John, >> >> df1<-sapply(df1,as.character) >

Re: [R] Remove all factor levels from an R dataframe

2020-11-10 Thread Jim Lemon
Hi John, df1<-sapply(df1,as.character) Should do what you ask. The error message probably means that you should do this: df1<-df1[order(as.character(df1$year)),] as "year" is the name of the first column in df1, not a separate object. Jim On Tue, Nov 10, 2020 at 6:57 PM John wrote: > Hi, >

Re: [R] fast way to find most common value across columns dataframe

2020-10-31 Thread Jim Lemon
Hi Luigi, If I understand your request: library(prettyR) apply(as.matrix(df),1,Mode) [1] "C" "B" "D" ">1 mode" ">1 mode" ">1 mode" "D" [8] "C" "B" ">1 mode" Jim On Sat, Oct 31, 2020 at 7:56 PM Luigi Marongiu wrote: > Hello, > I have a large dataframe (1 000 000

Re: [R] Error: variable not found

2020-10-30 Thread Jim Lemon
Hi Hannah, Using the same code I sent before, you can append the partner codes to the household code. I apologize, but I don't know how to use the dplyr/tidyr/... stuff so this is written in straight R code using logic statements. ipumsi_8_dta<- read.table( text="country year sample serial

Re: [R] Error: variable not found

2020-10-30 Thread Jim Lemon
Hi Hannah, Have you tried: summary(ipumsi_8_dta$couple_id) Jim On Fri, Oct 30, 2020 at 7:34 PM Hannah Van Impe wrote: > Hello > > I have a question. I made an r-script and did a few commands needed to > make some new variables. They all work out well, and when I run the > commands, the

Re: [R] Good Evening,

2020-10-29 Thread Jim Lemon
Hi Joy, As Rui noted, you can get a plot with: jk.dat<-runif(100,1000,1) plot(jk.dat,type="l") This plots your vector of 100 uniformly distributed numbers against their "index" (the order in which they appear in the vector). I suspect your problem is that you want to define a vector of "x"

Re: [R] Creating unique code

2020-10-28 Thread Jim Lemon
Hi Hannah, Yes, that does give me more insight. The polygyny only doesn't matter, for even if there was polyandry it could be coded in the same way. If I understand this correctly you have one variable (SPRULE) that must contain information about the household of the individual and the identities

Re: [R] Creating unique code

2020-10-27 Thread Jim Lemon
Hi Hannah, Without knowing how the data are organized and what each numeric code means, it is a bit difficult. If it is assumed that each row in the data frame(?) ipumsi_8_dta is a case (individual) and an individual may have zero or more spouses, there would have to be more than one field for

Re: [R] data error problem

2020-10-05 Thread Jim Lemon
Hi Mir, Without knowing what the data looks like, this is only a guess. read.table() expects a white space delimiter and if you have a space in one of your column names it will consider it as two names instead of one. How many columns do you expect? Jim On Mon, Oct 5, 2020 at 6:14 PM Mohammad

Re: [R] help in R code

2020-10-02 Thread Jim Lemon
Hi Faheem, This is a complete guess, but the hours of the day may range from 0 to 23 not 1 to 24. So you may be asking for an out of range hour. Jim On Fri, Oct 2, 2020 at 10:00 PM Faheem Jan via R-help wrote: > > > Hello , i am working in the functional time series using the multivariate >

Re: [R] 2 KM curves on the same plot

2020-09-30 Thread Jim Lemon
omment out the last 2 lines of the above 3 lines, and created a > customized lines2 function. Now it works! > > It's fun to learn clip(). > > Thanks, > > John > > > On Wednesday, September 30, 2020, 01:47:55 AM PDT, Jim Lemon > wrote: > > > Hi John, > Hmmm

Re: [R] 2 KM curves on the same plot

2020-09-30 Thread Jim Lemon
im[4]) > abline(h=0.5,col=2) ### YES, clipping() works! > > lines(fit2, col = 3:4,lty=2) ### clipping does not work! reset to default > plot region > abline(h=0.4,col=2) ### NO, clipping() does not work! > > So disappointed with this, otherwise this would be such a

Re: [R] 2 KM curves on the same plot

2020-09-29 Thread Jim Lemon
lim<-par("usr") > clip(450,xylim[2],xylim[3],xylim[4]) > lines(fit2, col = 3:4,lty=2) > > I can still see that the extra horizontal line on the top. > > Can you or anyone have any suggestion what went wrong? > > Thanks, > > John > > > On Tuesday, Septe

Re: [R] 2 KM curves on the same plot

2020-09-29 Thread Jim Lemon
Hi John, Perhaps the most direct way would be: plot(fit1, col=1:2) xylim<-par("usr") clip(4,xylim[2],xylim[3],xylim[4]) lines(fit2,col=1:2) Remember that the new clipping rectangle will persist until you or something else resets it. Jim On Tue, Sep 29, 2020 at 10:34 AM array chip via R-help

Re: [R] package plotrix: how to account for two two z categories

2020-09-25 Thread Jim Lemon
Hmmm, maybe without the caps... Jim On Sat, Sep 26, 2020 at 8:20 AM Jim Lemon wrote: > > Hi Luigi, > Good illustration. Maybe if I can integrate vertical lines to show the > nesting instead of bars it would work better. While it makes the > nesting much clearer, some people may s

Re: [R] package plotrix: how to account for two two z categories

2020-09-25 Thread Jim Lemon
Hi Luigi, Good illustration. Maybe if I can integrate vertical lines to show the nesting instead of bars it would work better. While it makes the nesting much clearer, some people may still accuse you of using a bar plot. # new functions with the modifications source("barNest.R")

Re: [R] package plotrix: how to account for two two z categories

2020-09-25 Thread Jim Lemon
Hi Luigi, Here is a quick example of how points would look in the same configuration. Perhaps with end caps to show the nesting it may be more like what you want. Jim On Thu, Sep 24, 2020 at 6:34 PM Jim Lemon wrote: > > Oh, sorry, forgot about the colors. A list beginning with the

Re: [R] Help with for loops and if statements

2020-09-24 Thread Jim Lemon
Hi Dan, This list has a "no homework" policy, but as you really do seem to be struggling, I'll suggest that you read the help page for "abs" carefully and learn about "<-" (assign a value). Perhaps these will give you a start. Jim On Thu, Sep 24, 2020 at 6:19 PM Dan Bosio wrote: > > Hi there >

Re: [R] package plotrix: how to account for two two z categories

2020-09-24 Thread Jim Lemon
Oh, sorry, forgot about the colors. A list beginning with the color for the overall summary, then colors for the first factor and so on. See the help page for examples. Jim On Thu, Sep 24, 2020 at 6:32 PM Jim Lemon wrote: > > Hi Luigi, > I thought a lot about that when I wa

Re: [R] package plotrix: how to account for two two z categories

2020-09-24 Thread Jim Lemon
On Thu, Sep 24, 2020 at 6:25 PM Luigi Marongiu wrote: > > Thank you Jim, that is really nice! > But is there a way to use dots instead of boxes? and how do I control > the colours? > Best regards > Luigi > > On Thu, Sep 24, 2020 at 9:29 AM Jim Lemon wrote: > > > &g

Re: [R] package plotrix: how to account for two two z categories

2020-09-24 Thread Jim Lemon
Hi Luigi, To display a nested breakdown like this I would suggest barNest. This is one way to display the nesting. Note that if you change the order of the factors in the formula you will get a different plot, so think about how you want the summaries nested. Error bars can only be displayed on

Re: [R] text on curve

2020-09-22 Thread Jim Lemon
Hi Jinsong, This is similar to the "arctext" function in plotrix. I don't want to do all the trig right now, but I would suggest placing the characters on the curve and then offsetting them a constant amount at right angles to the slope of the curve at each letter. I would first try having a

Re: [R] How to model multiple categorical variable in r, using gee model

2020-09-21 Thread Jim Lemon
Hi Augustinius, You are probably familiar with some of these: http://finzi.psych.upenn.edu/R/library/geepack/html/geeglm.html https://faculty.washington.edu/heagerty/Courses/b571/homework/geepack-paper.pdf https://rdrr.io/cran/geex/f/vignettes/articles/mestimation_bib.Rmd Good luck with it. Jim

Re: [R] How to model multiple categorical variable in r, using gee model

2020-09-21 Thread Jim Lemon
Hi Augustinius, You have been set a problem that requires a lot more information than is in your request. Also, you have flagged it as a "homework" problem, so you are unlikely to get much help on this list. Sadly, this sort of problem sometimes arises when being nice to the instructor is more

Re: [R] How to reduce the sparseness in a TDM to make a cluster plot readable?

2020-09-18 Thread Jim Lemon
Hi Andrew, >From your last email the answer to your problem may be the findFreqTerms() function. Just increase the number of times a term has to appear and check the result until you get the matrix size that you want. Jim On Fri, Sep 18, 2020 at 5:32 PM Andrew wrote: > > Hi Abby > > Many thanks

Re: [R] multiple time series plots

2020-09-17 Thread Jim Lemon
Hi Peri, Without the data this is only a guess, but are the values of East and center within the limits of the plot generated by Nation? Jim On Fri, Sep 18, 2020 at 10:12 AM peri He wrote: > > Dear Friends, > > I am trying to add two time series curves into one plot. I don't get any > error

Re: [R] how to overlay two histograms

2020-09-17 Thread Jim Lemon
Hi Ana, Sorry it's not in ggplot, but it may help: d<-read.table(text="CHR counts name 1 193554 old 2 220816 old 3 174350 old 4 163112 old 5 168125 old 6 182366 old 7 143023 old 8 147410 old 9 122112 old 10 138394 old 11 130069 old 12 124850 old 13 104119 old

Re: [R] X axis labels are not fully shown when using pareto.chart function

2020-09-15 Thread Jim Lemon
d (to make x-axis labels clearly visible)? I imagine > if work with some other x-axis labels I'd just have to play around with the > width, height, srt and cex parameters? > > Best regards, > > Paul > > > El mar., 15 de septiembre de 2020 7:06 p. m., Jim Lemon > escr

Re: [R] X axis labels are not fully shown when using pareto.chart function

2020-09-15 Thread Jim Lemon
Hi Paul, This looks very familiar to me, but I'll send my previous suggestion. library(qcc) x11(width=13,height=5) pareto.chart(dataset2$Points,xaxt="n") library(plotrix) staxlab(1,at=seq(0.035,0.922,length.out=140), labels=substr(dataset2$School,1,20),srt=90,cex=0.5) Jim On Wed, Sep 16, 2020

Re: [R] monthly mean for each month and each year in the data frame

2020-09-14 Thread Jim Lemon
Hi Stefano, What about this? df$months<-format(df$data_POSIX,"%Y-%m") snow_means<-by(df$value,df$months,mean) Jim On Mon, Sep 14, 2020 at 8:19 PM Stefano Sofia wrote: > > Dear R-list users, > I know that this is a trivial question, but I already wasted quite a large > amount of time on that.

Re: [R] Return filematrix column by column names instead of column index?

2020-09-08 Thread Jim Lemon
Hi Nevil, As I don't have the filematrix package this is really an "any suggestion": FM[,which(colnames(FM) %in% c("one","three"))] Jim On Tue, Sep 8, 2020 at 9:43 PM nevil amos wrote: > > Is there a way to get columns out of a filematrix using the column name > directly in the same way that

Re: [R] find number of consecutive days in NC files by R

2020-09-03 Thread Jim Lemon
_days_1949.tif") > > a<-array(NA,dim=c(dim(r)[1:2],70)) > > i <- 1 > > for (year in 1949:2019) { > > > fi<-paste0("C:/Teaching/MSCprojects/2020/Ahmet/soilm/max_consecutive_days_",year,".tif") > > r<-raster(fi) > > a[,,i]&

Re: [R] statment can tacke value in row1 and rows

2020-09-02 Thread Jim Lemon
Hi Hesham, It think you are looking for something like this: truth<-data.frame(G1=sample(LETTERS[1:4],20,TRUE), G2=sample(LETTERS[1:4],20,TRUE)) truth truth$G3<-as.numeric(truth$G1 == truth$G2) truth Note that like quite a few emails produced with Javascript formatting, there are embedded

Re: [R] plot factors with dots in R

2020-08-27 Thread Jim Lemon
Hi Luigi, Maybe just: plot(as.numeric(factor(x,levels=x)),y,xaxt="n", main="Concentration by effect", xlab="Concentration",ylab="Effect") axis(1,at=1:4,labels=x) Jim On Thu, Aug 27, 2020 at 10:16 PM Luigi Marongiu wrote: > > Hello, > I have a dataframe as follows: > ``` > x = c("0 pmol", "10

Re: [R] draw with plotrix

2020-08-27 Thread Jim Lemon
Hi Luigi, Try this: brkdn.plot(y~x+z,data=Q) Jim On Thu, Aug 27, 2020 at 9:57 PM Luigi Marongiu wrote: > > Hello, > I have a dataframe as follows > ``` > x = c(rep("1000 pmol", 2), rep("100 pmol", 2), rep("10 pmol", 2), > rep("0 pmol", 2)) > y = c(2.7642, 2.8192, 2.1976, 2.2816, 1.8929,

Re: [R] Error computing mlogit model

2020-08-26 Thread Jim Lemon
Hi Eric, There are a few mysteries in your request. As we don't know what "des" is, it is difficult to see why it does not have the correct number of dimensions. It looks like it should be an n x 6 matrix, but is that what it really is and does the mlogit function expect such a matrix? JIm On

Re: [R] Help on plot from transition matrix

2020-08-26 Thread Jim Lemon
Hi Luis, I had a quick look at the "diagram" package, which seems to accept transition matrices. I don't have it installed, but the help pages are fairly easy to follow and may do the job for you. Jim On Wed, Aug 26, 2020 at 5:50 PM Luis Fernando García wrote: > > Dear all, > > I am wanting to

Re: [R] Help on plot from transition matrix

2020-08-24 Thread Jim Lemon
Hi Luis, As so often happens, the image didn't make it. Try PNG or PDF format. Without seeing what you want, it's only guessing. Jim On Mon, Aug 24, 2020 at 6:34 PM Luis Fernando García wrote: > > I am wanting to make a flow diagram like the one attached as an example for > the given dataset. >

Re: [R] plot.window: need finite 'ylim' values

2020-08-23 Thread Jim Lemon
Hi Mike, This looks to me as though the error is not being generated by plot, but by a method specific to the package, maybe something with a name like plot.chart_Series, that is barfing on a vector of NA values. Jim On Mon, Aug 24, 2020 at 1:01 AM Mike wrote: > > Hi Jim, > > on 21.08. you

Re: [R] plot.window: need finite 'ylim' values

2020-08-21 Thread Jim Lemon
Hi Mike, Try this: plot (chart_Series (sample.xts[,1], subset=subset, TA=ta), type="n",ylim=c(minimum,maximum)) where minimum and maximum are the extremes of the plot if there were any valid values. Jim On Fri, Aug 21, 2020 at 6:32 PM Mike wrote: > > Dear R users, > > I have already asked

Re: [R] Trouble getting labels for bars in Pareto Chart

2020-08-19 Thread Jim Lemon
Hi Paul, I ran this: library(qcc) pareto.chart(dataset2$Points) and like you, got the chart. As you have 140 long labels, I thought at first it might be the function trying to abbreviate some of them and actually displaying about 1 in 5. Looking at the code for the function, this is not the

Re: [R] R Script Modification Questions

2020-08-18 Thread Jim Lemon
"Total"), > values = c("red", "blue", "green")) + > ylim(0, 200) + >labs(x = "Date", y = "Number of Tests")+ >ggtitle("COVID-19 Tests in Ohio \n (8/17/20)")+ <- line 33 >

Re: [R] Hot Air Balloon Weather Briefings

2020-08-16 Thread Jim Lemon
Hi Philip, My fault for assuming that what worked for the sample data would work for the entire data set. If you run the following code: # read the file into a data frame phdf<-read.csv("phdf.csv",stringsAsFactors=FALSE) print(dim(phdf)) # create a logical variable for the subsetting step

Re: [R] Hot Air Balloon Weather Briefings

2020-08-14 Thread Jim Lemon
Hi Philip, Not very elegant, but: phdf<-read.table(text="Minute Second Speed 29 47 0 29 53 0 29 59 0 30 5 0 30 11 0 30 17 0 30 23 0 30 29 0 30 35 0 30 41 0 30 47 0 30 53 0 30 59 0 31 5 0 31 11 0 31 17 0.402649 31 23 0.671081 31 29 1.588225 31 35 2.438261 31 41 2.706693 31 47

Re: [R] date conversion problem

2020-08-13 Thread Jim Lemon
Hi Abdoulaye, It looks to me as though your offsets are in hours, not days. You can get a rough date like this: time<-c(1569072,1569096,1569120,1569144, 1569168,1569192,1569216,1569240) time_d<-as.Date("1800-01-01")+time/24 time_d [1] "1979-01-01" "1979-01-02" "1979-01-03" "1979-01-04"

Re: [R] find number of consecutive days in NC files by R

2020-08-09 Thread Jim Lemon
m, > > > > Could you help me to remove NA values which are water values ? > > > > > > Kimden: Jim Lemon > Gönderilme: 7 Ağustos 2020 Cuma 22:53 > Kime: ahmet varlı > Konu: Re: [R] find number of consecutive days in NC files by R > > > > There a

Re: [R] Print and plot a cross Data

2020-08-07 Thread Jim Lemon
Hi Pedro, Scratch that last email. I remembered that "tus.datos" was so large that it was hanging my R session last time. However, this seems to work: tus.datos<-read.table("datayield.csv",sep=";", header=TRUE,stringsAsFactors=FALSE) row_subset<-tus.datos$DATA_TYPE_FM %in% data_types &

Re: [R] Print and plot a cross Data

2020-08-07 Thread Jim Lemon
he error is > > for (PERIOD="TRUE") { > Error: inesperado '=' in "for (PERIOD=" > > > > > > plot(x, y) > Error: no se puede ubicar un vector de tamaño 1.3 Gb > > > > } > Error: inesperado '}' in "}" > > > > >

Re: [R] find number of consecutive days in NC files by R

2020-08-06 Thread Jim Lemon
le$lengths[run] } Jim On Fri, Aug 7, 2020 at 3:17 PM Jim Lemon wrote: > > Hi Ahmet, > Here is a way to get the result you ask for for one geographic grid > cell. You may want more detail or something, but this is a > "reproducible example". > > # retrieved from >

Re: [R] find number of consecutive days in NC files by R

2020-08-06 Thread Jim Lemon
0.000 0.000 0.000 0.000 0.000 0.000 0.000 > > [3,] 0.000 0.000 0.000 0.000 0.000 0.000 0.000 > 0.000 0.000 0.000 0.000 0.000 0.000 0.000 > > [4,] 0.358 0.358 0.358 0.358 0.358 0.358 0

Re: [R] find number of consecutive days in NC files by R

2020-08-06 Thread Jim Lemon
Hi Ahmet, I think what you are looking for can be done using run length encoding (rle). # make up some data soil_moisture<-sin(seq(0,4*pi,length.out=730))+1.1 dates<-as.Date(as.Date("2018-01-01"):as.Date("2019-12-31"), origin=as.Date("1970-01-01")) # get a logical vector for your condition

Re: [R] Print and plot a cross Data

2020-08-05 Thread Jim Lemon
Hi Pedro, I'm not exactly sure of what you want, but try this: # I downloaded the CSV file as datayield.csv tus.datos<-read.table("datayield.csv",sep=";",header=TRUE) library(scatterplot3d) data_types<-c("PY_1Y","PY_2Y","PY_3Y","PY_4Y","PY_5Y","PY_6Y","PY_7Y") row_subset<-tus.datos$DATA_TYPE %in%

Re: [R] Arrange data

2020-08-05 Thread Jim Lemon
ut got the error > > for(i in 1975:2017){ > for(j in 1:44){ > mddat2[j]<-mddat[mddat$Year == i & mddat$Month >= 7 | > mddat$Year == (i+1) & mddat$Month <= 6,] > } > m[j]=mean(mddat2$Value) > > } > m > > Please help me in th

Re: [R] Arrange data

2020-08-04 Thread Jim Lemon
in advance. > > Md > > > On Mon, Aug 3, 2020 at 12:33 PM Rasmus Liland wrote: >> >> On 2020-08-03 21:11 +1000, Jim Lemon wrote: >> > On Mon, Aug 3, 2020 at 8:52 PM Md. Moyazzem Hossain >> > wrote: >> > > >> > > Hi, >> >

Re: [R] Arrange data

2020-08-03 Thread Jim Lemon
Hi Md, One way is to form a subset of your data, then calculate the means by year: # assume your data is named mddat mddat2<-mddat[mddat$month < 7,] jan2jun<-by(mddat2$value,mddat2$year,mean) Jim On Mon, Aug 3, 2020 at 8:52 PM Md. Moyazzem Hossain wrote: > > Hi, > > I have a dataset having

Re: [R] adding new level with new values and transpose the dataframe

2020-07-30 Thread Jim Lemon
Hi Engin, If you know what all the levels are, you can specify these in the format command: Classification_Description<-factor(Classification_Description, levels=c("Total Surplus (+) or Deficit (-)","Borrowing from the Public", "By other means")) This ensures that all the levels are encoded

Re: [R] How to create a readable plot in R with 10000+ values in a dataframe

2020-07-30 Thread Jim Lemon
Hi Ritwik, Carlos made an excellent suggestion and there are at least two ways to plot "machine" and "region" as the cells in a 2D matrix and then add two more variables (say count and price) as the attributes of each cell. Is the data you are using publicly available? If so a demonstration of

Re: [R] How to create a readable plot in R with 10000+ values in a dataframe

2020-07-29 Thread Jim Lemon
Hi Ritwik, I haven't seen any further answers to your request, so I'll make a suggestion. I don't think there is any sensible way to illustrate that many data points on a single plot. I would try to segment the data by machine type or similar and plot a number of plots. Jim On Fri, Jul 24, 2020

Re: [R] Playing a music file in R

2020-07-23 Thread Jim Lemon
r code is related to call a music player? > > 2. Which part is related to call a music file? > > I want to do this on my laptop, so I need to understand your code (the answer > to the above questions). > > Regards, > Vahid > > > On Wed, Jul 22, 2020 at 1:45 AM J

Re: [R] How to generate this type of scatter plots in R

2020-07-22 Thread Jim Lemon
Hi John, Perhaps "dendroPlot" in the plotrix package? JIm On Thu, Jul 23, 2020 at 11:00 AM array chip via R-help wrote: > > > Hello everyone, > > I saw this scatterplots from a paper and thought it looked very nice: > >

Re: [R] viewing, editing and saving an RDATA file

2020-07-22 Thread Jim Lemon
Hi Jason, I assume that you actually have "WVS.RData" in your working directory when you try to load it. Otherwise you will get an error message. If you don't get an error message when you do this: load("WVS.RData") there will be a new object in your workspace. So if you want to see what the

Re: [R] Looping through a dataframe

2020-07-21 Thread Jim Lemon
Hi Ahson, Guessing what your data frame might look like, here are two easy ways: All_companies<-data.frame(year=c(1970:2015,2000:2015,2010:2015), COMPANY_NUMBER=c(rep(1,46),rep(2,16),rep(3,6)), COMPANY_NAME=c(rep("IBM",46),rep("AMAZON",16),rep("SPACE-X",6))) # easy ways

Re: [R] Playing a music file in R

2020-07-21 Thread Jim Lemon
Hi Vahid, The following command: system("mplayer /home/jim/songs/bimbo_soul.mp3", wait=FALSE,ignore.stdout=TRUE) works fine for me. Of course you'll have to specify a music player and music file that you have... Jim On Wed, Jul 22, 2020 at 4:02 AM Vahid Borji wrote: > > Hello my R friends, >

Re: [R] rgl terminology: the definitions of "thickness" and "width" in rgl

2020-07-21 Thread Jim Lemon
Hi Byron, As in the help page, three types of arrows can be specified. In the "rotation" type, "width" is the parameter that determines the diameter of the cylindrical shaft as a fraction of the "barb", the cone at the end. In the default "extrusion" arrow, "thickness" is the fraction of the

Re: [R] Plot base 100

2020-07-19 Thread Jim Lemon
Hi Pedro, Assuming that you get a vector of daily percentage changes: dpc<-c(+3.1, -2.8, +1.7, +2.1) get the cumulative change and add 100: cumsum(dpc)+100 [1] 103.1 100.3 102.0 104.1 You can then plot that. As Rui noted, your mail client is inserting invisible characters that prevent cutting

Re: [R] Year and month from a sequence

2020-07-14 Thread Jim Lemon
Hi Milu, This is similar to the "birthday age" problem as it is much easier to deal with the constant "12 months in a year" rather than the highly variable number of days between two dates: monthno2my<-function(x,startyear=1861,startmonth=2400) { year<-startyear+(x-startmonth)%/%12

Re: [R] How to differ stats_cor labels by group on a ggplot

2020-07-12 Thread Jim Lemon
;),pch=19, col=c("lightgray","green","orange")) dev.off() } I've been meaning to finish off the "supsubtext" function for a while. Jim On Sun, Jul 12, 2020 at 11:20 AM Paulina Skolasinska wrote: > > Sorry for misspelling your name, Jim. Well, i

Re: [R] Character (1a, 1b) to numeric

2020-07-11 Thread Jim Lemon
I'll admit that I cut my teeth on ASCII, but I worried about your reliance on that ancient typographic ordering. I wrote a little function: al2num_sub<-function(x) { xspl<-unlist(strsplit(x,"")) if(length(xspl) > 1) xspl<-paste(xspl[1],which(letters==xspl[2]),sep=".") return(xspl) }

Re: [R] How to differ stats_cor labels by group on a ggplot

2020-07-11 Thread Jim Lemon
, > group=1, color="black"), method = "pearson",label.y=0.5, > label.x.npc = c("center"), > position = position_nudge(y = 0.015 * 0.5)) > > ggsave(p1, file=paste0("TestAge_", names(df)[i], ".png")

Re: [R] How to differ stats_cor labels by group on a ggplot

2020-07-10 Thread Jim Lemon
Hi Paulina, Without data it's hard to work out what you are doing. Even a small simulated data set would help to get answers. Jim On Fri, Jul 10, 2020 at 11:49 PM Paulina Skolasinska wrote: > > 'm using ggplot2 to plot two variables at a time. I'm plotting two age groups > and overall data on

Re: [R] plot shows exponential values incompatible with data

2020-07-09 Thread Jim Lemon
Hi Luigi, This is a result of the "pretty" function that calculates hopefully good looking axis ticks automatically. You can always specify ylim=c(1.0E09,max(Y)) if you want. Jim On Thu, Jul 9, 2020 at 10:59 PM Luigi Marongiu wrote: > > Hello, > I have these vectors: > ``` > X <- 1:7 > Y <-

Re: [R] output from R to simple html

2020-07-09 Thread Jim Lemon
Hi Marc, The "htmlize" function in the prettyR package might be what you are looking for. Jim On Thu, Jul 9, 2020 at 5:02 AM Marc Roos wrote: > > > > I would like to parse some input to an R script and use its result > output (maybe in json) on a web page. I think this shiny framework is a >

Re: [R] Help with looping a function over a list of dataframes:

2020-07-04 Thread Jim Lemon
Hi Kathan, This is a very lazy answer as I haven't tested it. I think you will need to wrap your loop in a function and return the modified list_df to assign it like this: add_IDs<-function(xdf) { for(i in seq_along(xdf)) { xdf$position_tab_[[i]]$ID <-

Re: [R] piping in only specific parts of a certain column

2020-07-02 Thread Jim Lemon
Hi Drake, This is a guess on my part, but what about: \ q3only<-unclean_data[unclean_data$question == 3,] then perform your operations on q3only Jim On Thu, Jul 2, 2020 at 8:35 PM Drake Gossi wrote: > > Hello! > > Question. I'm dealing with a large excel sheet that I'm trying to tidy > and

Re: [R] species accumulation curve with percentages

2020-06-16 Thread Jim Lemon
Hi Eddie, Upon reading your initial request more carefully, the last command should be: plot(nspec/nspec[50]*100,type="l",xlab="Sites", ylab="Species accumulation (%)",ylim=c(1,100)) Jim On Wed, Jun 17, 2020 at 8:23 AM Jim Lemon wrote: > > Hi Edd

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