Re: [R] pheatmap query

2018-09-03 Thread Jim Lemon
Hi Tanya, Have you looked at the return value of pheatmap? ret<-pheatmap(counts_filtered_df,scale="row",cluster_col=FALSE, cluster_row=TRUE,border_color=NA,show_rownames = TRUE) str(ret) names(ret$tree_row) names(ret$tree_col) Look at what is in "ret" to see if your numeric matrix is hidden

Re: [R] Account for a factor variability in a logistic GLMM in lme4

2018-09-03 Thread Jim Lemon
Hi Pedro, I have encountered similar situations in a number of areas. Great care is taken to record significant events of low probability, but not the non-occurrence of those events. Sometimes this is due to a problem with the definition of non-occurrence. To use your example, how close does an

Re: [R] graphing repeated curves

2018-08-22 Thread Jim Lemon
Hi Richard, This may be what you want: data(mtcars) m<-list() for(i in 1:6) { rhterms<-paste(paste0("I(hp^",1:i,")"),sep="+") lmexp<-paste0("lm(mpg~",rhterms,",mtcars)") cat(lmexp,"\n") m[[i]]<-eval(parse(text=lmexp)) } plot(mpg~hp,mtcars,type="n") for(i in 1:6) abline(m[[i]],col=i) Jim On

Re: [R] Transforming data for nice output table

2018-08-20 Thread Jim Lemon
Hi David, As you want the _values_ of Year from the initial data frame appended to the _names_ of GW_Elevation, you can't do it the easy way: dddf<-read.table(text="LocationDateYear GW_Elevation 127(I)5/14/2006 2006 752.46 119(I)5/14/2006 2006

Re: [R] as.Date() function

2018-08-19 Thread Jim Lemon
Hi Phillip, Jose has the correct answer. You probably missed this sentence in the "Note" section of the help page: "If the date string does not specify the date completely, the returned answer may be system-specific." In your case, the function throws up its hands and returns NA as you haven't

Re: [R] [FORGED] Re: bar plot add space to group data

2018-08-18 Thread Jim Lemon
quot;)) and I thank you for alerting me to the fact that the legend arguments in barp don't position the legend properly. I'll fix it. Jim On Sun, Aug 19, 2018 at 9:52 AM, Rolf Turner wrote: > > Jim: > > (a) There's no legend. > > (b) I am still curious as to why the OP's code d

Re: [R] bar plot add space to group data

2018-08-18 Thread Jim Lemon
Hi citc, Try this: geac<-matrix(c(9,9,8,8,8,23,23,23,23,22,27,27,27,25,24, 19,19,19,20,20,17,17,17,18,19,8,8,8,9,9,2,2,3,3,3),ncol=5,byrow=TRUE) library(plotrix) barp(geac,names.arg=2014:2018,main="A level grades chemistry", xlab="Year",ylab="Percentage of each grade",ylim=c(0,30),

Re: [R] cumulate of snow cumulates from daily values of different automatic stations for some time intervals

2018-08-12 Thread Jim Lemon
Hi Stefano, This was such a stinker of a problem that I just had to crack it: # create some data the lazy man's way year_dates<-c(paste(2000,rep("01",31),formatC(1:31,width=2,flag=0),sep="-"), paste(2000,rep("02",29),formatC(1:29,width=2,flag=0),sep="-"),

Re: [R] source script file that contains Unicode non-English characters

2018-08-11 Thread Jim Lemon
Hi Farid, Whatever you attached has not gotten through. Jim On Sat, Aug 11, 2018 at 6:47 PM, Farid Ch wrote: > Hi all, > > Please check the attached file. > > Thanks > Farid > > > __ > R-help@r-project.org mailing list -- To UNSUBSCRIBE and more, see

Re: [R] Help reinstalling rgdal (Ubuntu 16.04)

2018-08-09 Thread Jim Lemon
Hi Alex, I don't use Ubuntu, but if I saw that error message I would upgrade my C++ compiler and try again. With luck, this is what caused the cascade of errors beneath it. Jim On Fri, Aug 10, 2018 at 1:36 AM, Alexandra Thorn wrote: > Hi all, > > Following some updates to R that I received via

Re: [R] (no subject)

2018-08-07 Thread Jim Lemon
Hi malika, You don't seem to have defined your functions correctly. For example: H<-function(u,x1) would define an empty function H if that command worked, but it doesn't Jim On Tue, Aug 7, 2018 at 3:51 PM, malika yassa via R-help wrote: > hellothis is my programmeyou can help me, i cann't

Re: [R] linear regression

2018-08-07 Thread Jim Lemon
Hi Kenneth, My guess is that you have tried to send screenshots of your output and these were blocked. Try to cut and paste the output into your message. Jim On Tue, Aug 7, 2018 at 6:38 PM, John wrote: > On Mon, 6 Aug 2018 20:18:38 +0200 > kenneth Barnhoorn wrote: > > Your examples did not

Re: [R] how to allign data

2018-08-02 Thread Jim Lemon
Hi Petr, I recently had to align the minima of deceleration events to form an aggregate "braking profile" for different locations. It seems as though you are looking for something like: find_increase<-function(x,surround=10) { inc_index<-which.max(diff(x))

Re: [R] Combinations of true/false values where one pair is mutually exclusive

2018-08-01 Thread Jim Lemon
Hi Rod, How about this? scenarios <- expand.grid(A = c("pass", "fail"), B = c("pass", "fail"), C = c("pass", "fail"), D = c("pass", "fail"), E = c("pass", "fail")) scenarios$F<-ifelse(scenarios$E=="pass","fail","pass") Jim On Thu, Aug 2, 2018 at 11:20 AM, R Stafford wrote: > I have 6

Re: [R] read txt file - date - no space

2018-07-31 Thread Jim Lemon
ot. >> >> Unfortunately, I get the following error: >> >> >> st1_daily<-by(MyData$st1,MyData$date,mean) >> Error in tapply(seq_len(0L), list(`MyData$date` = c(913L, 914L, 925L, : >> arguments must have same length >> >> >> This is particul

Re: [R] read txt file - date - no space

2018-07-31 Thread Jim Lemon
native, >>>dadf$datetime <- as.POSIXct(paste(dadf$V1,dadf$V2)) >>> since the dates appear to be in the default format. >>> (I generally prefer to work with datetimes in POSIXct class rather than >>> POSIXlt class) >>> >>> -Don >>> >&

Re: [R] Plot Rclimdex or Climpact map with R

2018-07-30 Thread Jim Lemon
Hi Agathe, You can start with the "maps" package: # in an R session install.packages("maps") # assume you want a simple map containing France map("world",xlim=c(-6.0,9.6),ylim=c(42,51.5)) then plot your data by the coordinates of the stations. You will probably want to plot graphical elements to

Re: [R] read txt file - date - no space

2018-07-30 Thread Jim Lemon
Hi Diego, You may have to do some conversion as you have three fields in the first line using the default space separator and five fields in subsequent lines. If the first line doesn't contain any important data you can just delete it or replace it with a meaningful header line with five fields

Re: [R] Automate running files in R

2018-07-22 Thread Jim Lemon
Hi Serena, I think the directory structure you have described is something like this: mov_study___ | | mov1 ...mov9 / \

Re: [R] GGPlot plot

2018-07-18 Thread Jim Lemon
Hi again, Sorry, forgot this line: fpdf$PASPpos<-fpdf$PASP > 0 just after reading in the data frame. Jim On Thu, Jul 19, 2018 at 9:04 AM, Jim Lemon wrote: > Hi Francesca, > This looks like a fairly simple task. Try this: > > fpdf<-read.table(text="PASP

Re: [R] GGPlot plot

2018-07-18 Thread Jim Lemon
Hi Francesca, This looks like a fairly simple task. Try this: fpdf<-read.table(text="PASP SUBJC 0 0 4 1 0 0 8 0 4 0 0 1 0 1", header=TRUE) # get the number of positive PASP results by group

Re: [R] Help in debugging a script

2018-07-16 Thread Jim Lemon
Hi Frederic, You are asking for the sum of cases in the months September to December for the years 2012 to 2017. I get a plot that shows that from: plot(busoro[,"X"],busoro[,"Sep"] + busoro[,"Oct"] + busoro [,"Nov"] + busoro[,"Dec"],type="b",ylab="Malaria Cases",xlab="Year") What sort of plot

Re: [R] even display of unevenly spaced numbers on x/y coordinates

2018-07-15 Thread Jim Lemon
Hi Bogdan, There seem to be three problems. One is that if you want a logarithmic x axis you shouldn't have a zero (or a negative number) in your data. The second is that you have to ask for a logarithmic axis. The third is that you have limited your x axis to less than the range of the data in

Re: [R] Generate N random numbers with a given probability and condition

2018-07-11 Thread Jim Lemon
;- crank::permute(r[[sample(1:length(r), 1)]]) > rp[sample(1:dim(rp)[1],1),] > > In this case, Is it correct to permute the elements of a vector rather than > to permute a vector ? > > > Many thanks for your time. > > Have a nice day > > Nell > > > ___

Re: [R] Generate N random numbers with a given probability and condition

2018-07-10 Thread Jim Lemon
Hi Nell, I may not have the right idea about this, but I think you need to do this in two steps if it can be done. Let's say you want a sequence of 20 (N) numbers between 0 and 10 that sums to 10 (M). You can enumerate the monotonically increasing sequences like this:

Re: [R] (no subject)

2018-07-09 Thread Jim Lemon
Hi Laura, Here's a basic method: lsdf<-read.table(text="Bird Date Latitude Longitude eb80976 16/07/2012 50.99 -5.85 eb80976 17/07/2012 52.09 -4.58 eb80976 18/07/2012 49.72 -5.56 eb80976 19/07/2012 51.59 -3.17 eb80976 20/07/2012 52.45 -2.03 eb80976 21/07/2012

Re: [R] command to change some vars to missing into my dataset

2018-07-05 Thread Jim Lemon
Hi Adam, Looks like you have a matrix or data frame and want to change one or more observations to NA. I think this will do the trick: # assume the matrix or data frame is named "ajdat" randomNA<-function(x,nNA=1) { dimx<-dim(x) x[sample(1:dimx[1],nNA),sample(1:dimx[2],nNA)]<-NA return(x) }

Re: [R] trouble with exiting loop if condition is met

2018-06-28 Thread Jim Lemon
Hi Kelly, You seem to be testing the two "years" independently, so here is a possible solution: npg<-16 futility1<-futility2<-psignif1<-psignif2<-nrep<-0 while(!futility1 && !futility2 && !psignif1 && !psignif2 && nrep < 1) { control_respond1<-sum(runif(npg,0,1) < 0.05)

Re: [R] How long can a csv file label be?

2018-06-27 Thread Jim Lemon
Hi Nick, You are probably using Windows, for which the maximum path length is claimed to be 260 characters. The most common alternative, Linux, has a maximum filename length of 255 and a maximum path length of 4096. If you are simply writing a file to the current path, it won't make much

Re: [R] Adding Axis value to R Plot

2018-06-25 Thread Jim Lemon
Hi Abou, You can't display an axis if it is not in the range of the plot. I think you want: plot(0,type="n",yaxs="i",xaxs="i",xaxt="n",yaxt="n",xlim=c(15,85), ylim=c(300,600),xlab="Age",ylab="Distance (ft)",cex.lab=1.5) grid(nx = 10, ny = 10, col = "lightgray", lty = "dotted", lwd = 2) xticks <-

Re: [R] Outputting variable names and their value bindings

2018-06-24 Thread Jim Lemon
Hi Simon, Easy to do if you call "print" directly: print<-function(x) cat(deparse(substitute(x)),"=\n",x,"\n") y<-3 print(y) y = 3 Obviously you will want to get rid of your print function when it is not being used with "rm" or by starting a new session. Getting it to bypass the default print

Re: [R] tapply and error bars

2018-06-24 Thread Jim Lemon
Hi Ogbos, The problem is almost certainly with the data. I get the plot I expect with the sample data that you first posted, so I know that the code works. If you try thIs what do you get? oodf<-read.table(text="S/N AB 1-5 64833 2-4 95864 3-3 82322 4-2 95591 5

Re: [R] tapply and error bars

2018-06-24 Thread Jim Lemon
he error says: > Error in FUN(X[[1L]], ...) : could not find function "FUN" > > Please note that I use: > std.error = sd(B)/sqrt(sum(!is.na(B))) > to calculate the standard error as it requested for it. > > Thanks > Ogbos > > On Sat, Jun 23, 2018 at 10:09 AM,

Re: [R] tapply and error bars

2018-06-23 Thread Jim Lemon
Hi Ogbos, This may help: # assume your data frame is named "oodf" oomean<-as.vector(by(oodf$B,oodf$A,mean)) oose<-as.vector(by(oodf$B,oodf$A,std.error)) plot(-5:10,oomean,type="b",ylim=c(5,11), xlab="days (epoch is the day of Fd)",ylab="strikes/km2/day") dispersion(-5:10,oomean,oose)

Re: [R] Data frame with Factor column missing data change to NA

2018-06-13 Thread Jim Lemon
Hi Bill, It may be that the NonAcceptanceOther, being a character value, has "" (0 length string) rather than NA. You can convert that to NA like this: df2$NonAcceptanceOther[nchar(df2$NonAcceptanceOther) == 0]<-NA Jim On Thu, Jun 14, 2018 at 12:47 AM, Bill Poling wrote: > Good morning. > >

Re: [R] Changing selected columns to factor

2018-06-11 Thread Jim Lemon
Hi Jeff, jrdf<-data.frame(A=rnorm(10),B=rnorm(10),C=rnorm(10), D=rnorm(10),E=rnorm(10),F=rnorm(10),G=rnorm(10), H=rnorm(10),I=rnorm(10),J=rnorm(10)) for(i in c(2,7,8,9)) jrdf[,i]<-factor(jrdf[,i]) sapply(jrdf,"class") Jim On Tue, Jun 12, 2018 at 9:57 AM, Jeff Reichman wrote: > R-Help Forum >

Re: [R] Plot in real unit (1:1)

2018-06-06 Thread Jim Lemon
5,95),c(95,145,95,45), c(95,145,95,45),c(145,95,45,95)) box() dev.off() Jim On Thu, Jun 7, 2018 at 8:16 AM, Jim Lemon wrote: > Hi Christian, > When I have to do something like this, I usually write it in > Postscript using this: > > /def mm 2.8346 mul > > that converts

Re: [R] Plot in real unit (1:1)

2018-06-06 Thread Jim Lemon
Hi Christian, When I have to do something like this, I usually write it in Postscript using this: /def mm 2.8346 mul that converts a dimension in mm to points (1/72 inch). However, this won't work in R. It may be possible to set up the device like this: postscript("myfile.ps",paper="a4")

Re: [R] mysterious rounding digits output

2018-05-30 Thread Jim Lemon
Hi Joshua, Because there are no values in column ddd less than 1. itemInfo[3,"ddd"]<-0.3645372 itemInfo aaa bbb ccc dddeee skill 1.396 6.225 0.517 5.775 2.497 predict 1.326 5.230 0.462 5.116 -2.673 waiting 1.117 4.948NA 0.365 NA complex 1.237 4.170 0.220

Re: [R] How to generate a conditional dummy in R?

2018-05-29 Thread Jim Lemon
ce in the data (e.g. > USSR Yugoslavia etc). > > Best, > Faradj > > > 29 maj 2018 kl. 02:15 skrev Jim Lemon : > > Hi Faradj, > What a problem! I think I have worked it out, but only because the > result is the one you said you wanted. > > # the sample data frame i

Re: [R] How to generate a conditional dummy in R?

2018-05-28 Thread Jim Lemon
Hi Faradj, What a problem! I think I have worked it out, but only because the result is the one you said you wanted. # the sample data frame is named fkdf Y2Xby3<-function(x) { nrows<-dim(x)[1] X<-rep(0,nrows) for(i in 1:(nrows-2)) { if(!is.na(x$Y[i])) { if(x$Y[i] == 1 &&

Re: [R] How to average values from grid cells with coordinates

2018-05-23 Thread Jim Lemon
Hi lili, You can extend it like this. I checked this with two values each for pop and mood, and it looked okay. Obviously I didn't check the result with 365 values for each, but it ran okay. # these values are the centers of the black cells lat<-rep(28:38,11) lon<-rep(98:108,each=11)

Re: [R] Plot qualitative y axis

2018-05-23 Thread Jim Lemon
>> Many thanks, >> >> My goal is to make a plott like attached but the Y axis starts in XIV and >> end at top in I. Generally for instance in excel X axis is categories but Y >> axis is numbers I want the contrary plotted in lines, your last help is near >>

Re: [R] Loop Function to Create Multiple Scatterplots

2018-05-21 Thread Jim Lemon
Hi Steven, Sad to say that your CSV file didn't make it to the list and I can't access the data via your Dropbox account. Therefore we don't know the structure of "mydata". If you are able to plot the data as in your example, this might help: genexp<-matrix(runif(360,1,2),ncol=18)

Re: [R] How to average values from grid cells with coordinates

2018-05-20 Thread Jim Lemon
Hi lily, It's not too hard to do it using dataframes. Getting the indexing right is usually that hardest part: # these values are the centers of the black cells lat<-rep(28:38,11) lon<-rep(98:108,each=11) pop<-sample(80:200,121) # just use the data.frame function

Re: [R] How to average values from grid cells with coordinates

2018-05-19 Thread Jim Lemon
mp; > abs(blackcells[[i]]$lon-redcell$lon) < 1) { > close4[closen]<-i > closen<-closen+1 > } > } > > On Wed, May 16, 2018 at 2:45 AM, Jim Lemon <drjimle...@gmail.com> wrote: >> >> Hi lily, >> There are one or two assumptions to be made here. Firs

Re: [R] Convert a list of $NULL into multiple dataframes

2018-05-18 Thread Jim Lemon
Hi Ilio, As far as I can see, this is what you have done: A<-data.frame(V1="Year",V2=1992,V3=1993) B<-data.frame(V1=c("Year","18-19"),V2=c("Average (cm)",178.3), V3=c("N",6309),V4=c("SD",6.39)) A V1 V2 V3 1 Year 1992 1993 B V1 V2 V3 V4 1 Year Average (cm)N SD 2

Re: [R] exclude

2018-05-17 Thread Jim Lemon
Hi Val, This may help: tdat$allpresent<-FALSE for(state in allstates) tdat$allpresent[tdat$stat == state]<- all(allyears %in% tdat$year[tdat$stat==state]) tdat2<-tdat[tdat$allpresent,] xtabs(Y~stat+year,tdat2) table(tdat2$stat,tdat2$year) Jim On Fri, May 18, 2018 at 10:48 AM, Val

Re: [R] How to average values from grid cells with coordinates

2018-05-16 Thread Jim Lemon
Hi lily, There are one or two assumptions to be made here. First is that the latitude and longitude values of the "black" cells are equally spaced as in your illustration. Second, that all latitude and longitude values for the "red" cells fall at the corners of four "black" cells. You can get the

Re: [R] Adding Year-Month-Day to X axis

2018-05-11 Thread Jim Lemon
Hi Jayaganesh, I'm not sure this will help, but here is a simple example using box.heresy: y_duration <- c (16.438, 15.321, 12.700, 12.397, 10.795, 9.928, 10.386) library(plotrix) box.heresy(1,mean(y_duration),uinner=std.error(y_duration) ,ulim=sd(y_duration),intervals=TRUE) #add the median as a

Re: [R] Seasonal weekly average

2018-05-09 Thread Jim Lemon
Hi Shakeel, Assuming that you are starting with a bunch of dates: # make a vector of character strings that can be converted to dates rep_dates<-paste(sample(1:30,500,TRUE),sample(1:12,500,TRUE), sample(2013:2017,500,TRUE),sep="/") # if this isn't your format, change it date_format<-"%d/%m/%Y" #

Re: [R] Pruning a dendrogram based on frequencies

2018-05-08 Thread Jim Lemon
Hi Franklin, plot.dendrite was not designed to be pruned. I have had a look at the problem, and I may be able to suggest a way to drop values in the "dendrite" object that is the input to plot.dendrite. I'll let you know. Jim On Tue, May 8, 2018 at 11:46 PM, Franklin Mairura via R-help

Re: [R] Adding Year-Month-Day to X axis

2018-05-08 Thread Jim Lemon
Hi Greg, This is because both plots have equally spaced x values. To see the difference, try this: plot (x_mmdd, y_duration, type="l", xaxt="n", yaxt="n", ylim=range(240,480), xlab="", ylab="", col="blue") axis(1) plot (y_duration, type="l", xaxt="n", yaxt="n",

Re: [R] Adding Year-Month-Day to X axis

2018-05-06 Thread Jim Lemon
ymmdd,labels=format(x_mmdd,"%Y-%m-%d")) > > How do I get the text for -MM-DD to be drawn vertically, instead of > horizontally? > Greg > > On May 6, 2018, at 11:54 PM, Jim Lemon <drjimle...@gmail.com> wrote: > > axi

Re: [R] Adding Year-Month-Day to X axis

2018-05-06 Thread Jim Lemon
(x_mmdd, y_duration, type="l", xaxt="n", yaxt="n", > ylim=range(240,480)) > abline (h=c(240,270,300,330,360,390,420,450,480,510,540), lty=2, lwd=1.0, > col="grey40") > axis (side=2, at=240, cex.axis=1.0, label="4:00") > axi

Re: [R] Adding Year-Month-Day to X axis

2018-05-06 Thread Jim Lemon
Hi Greg, By default, the "axis" function puts the labels on one line and drops labels that would overlap. When you have labels that are all the same length, this usually results in every second, or third, or fourth label being displayed. So you can probably get what you want by not using staxlab.

Re: [R] Adding Year-Month-Day to X axis

2018-05-05 Thread Jim Lemon
nding! > I am using the official R 3.5.0 for Mac OS X. > This apparently does not include library (plotrix) > > library(plotrix) > Error in library(plotrix) : there is no package called ‘plotrix’ > > Greg > > On May 5, 2018, at 6:50 PM, Jim Lemon <drjimle...@gmai

Re: [R] Adding Year-Month-Day to X axis

2018-05-05 Thread Jim Lemon
Hi Greg, What you are getting there is a factor, interpreted as a 1:n sequence based on the sort order of your "dates". Here's a way to get dates on your x-axis in the format you want: x_mmdd<-as.Date(c("2018-04-25","2018-04-26","2018-04-27",

Re: [R] how can I convert a long to wide matrix?

2018-05-01 Thread Jim Lemon
following > > FinalData1 > > B1B2 > id_X "A" "B" > id_Y "A" "B" > > thanks, > > > > On Tue, May 1, 2018 at 4:05 PM, Jim Lemon <drjimle...@gmail.com> wrote: >> >> Hi Marna, >&

Re: [R] how can I convert a long to wide matrix?

2018-05-01 Thread Jim Lemon
.stretch=c("EventDate","SITE")) > > > ID timeGroup EventDate_1 EventDate_2 EventDate_3 SITE_1 SITE_2 SITE_3 > 1 id_XB1 9/8/16 9/9/16 9/15/17 A A B > 2 id_YB1 9/7/16 9/15/16 A B >> >

Re: [R] how can I convert a long to wide matrix?

2018-05-01 Thread Jim Lemon
Hi Marna, Try this: library(prettyR) stretch_df(dat,idvar="ID",to.stretch=c("EventDate","SITE")) Jim On Wed, May 2, 2018 at 8:24 AM, Marna Wagley wrote: > Hi R user, > I was trying to convert a long matrix to wide? I have an example and would > like to get a table

Re: [R] Overlay line on a bar plot - multiple axis

2018-04-29 Thread Jim Lemon
Hi Miluji, You have a problem as the x-axis is different for the two plots. However, the y-axis can be the same, so you really don't need different axes. I think you want to display city within week. The example below shows how to display both the counts for the cities by week, the mean z by week

Re: [R] Gantt Chart Using Plotrix

2018-04-22 Thread Jim Lemon
Hi bbb_aaa, The format for the input to the function (gantt.info) is a list. As Sarah mentions, a data frame is a list, so as long as your columns have the right names and are in the correct order, it should work. As you probably know, you can import a CSV file into R as a data frame using

Re: [R] Check if row of dataframe is superset of any row in another dataframe.

2018-04-21 Thread Jim Lemon
Hi Neha, How about this? find_subset<-function(x,y) { yrows<-dim(y)[1] match<-0 for(row in 1:yrows) match<-sum(x[row]) >= sum(y[row]) return(match) } apply(B,1,find_subset,A) This is somewhat obscure, as the dataframe B is coerced to a matrix by the apply function. Jim On Sat, Apr 21, 2018

Re: [R] Identifying columns with specific character

2018-04-18 Thread Jim Lemon
Hi Farnoosh, Perhaps this will help: drop_dollar<-function(x) return(as.numeric(as.character(gsub("\\$","",x sapply(My.Data,drop_dollar) Jim On Thu, Apr 19, 2018 at 7:23 AM, Farnoosh Sheikhi via R-help wrote: > Hello, > I have a data frame with 400 columns and wanted

Re: [R] Hacked

2018-04-17 Thread Jim Lemon
It's happened 3 or 4 times for me, only on the R list. It only happens when answering certain questions and I think all responders to that question may get it. Seems to have nothing to do with the OP. I just block the email address. Jim On Wed, Apr 18, 2018 at 1:33 PM, Mark Leeds

Re: [R] Fwd: Help with R-Calling forth csv.

2018-04-16 Thread Jim Lemon
Hi Mohammad, The plot you attached suggests that the underlying distribution may be a mixture. Is there anything in your data that would explain this, such as laden/unladen, uphill/downhill, different road surface? Jim On Mon, Apr 16, 2018 at 11:31 PM, Mohammad Areida wrote:

Re: [R] repeating functions for different folders?

2018-04-12 Thread Jim Lemon
Hi Marna, Assuming that you are descending into different subdirectories from the same directory: directories<-c("dir1","dir2","dir3") for(directory in directories) { setwd(directory) # do whatever you want to do # then return to the directory above setwd("..") } This will allow you to start

Re: [R] Elements of Sets as dataframe column names

2018-03-20 Thread Jim Lemon
Hi Neha, >From your message I think that you might get what you want with: names(df)<-unlist(B) However, the "sets" package might handle lists differently. Jim On Tue, Mar 20, 2018 at 2:24 PM, Neha Aggarwal wrote: > Hello all, > > I have a set B and a dataframe df.

Re: [R] Struggling to compute marginal effects !

2018-03-19 Thread Jim Lemon
l effect.Less_reliable effect.Somehow_reliable > effect.Very reliable > Adopt -0.073 -0.057 > -0.0640.193 > Training-0.283 -0.135 > -0.0510.469 > > > On Mon, Mar 19, 2018 at 6:46 PM, J

Re: [R] Struggling to compute marginal effects !

2018-03-19 Thread Jim Lemon
Hi Willy, The error message may be due to passing an inappropriate environment. I don't have the "erer" package, but if that function has a default for the environment argument, perhaps passing just the "predvars" and "data" arguments will work. Jim On Tue, Mar 20, 2018 at 8:24 AM, Willy

Re: [R] subsetting comparison problem

2018-03-11 Thread Jim Lemon
Hi Neha, This might help: R<-read.table(text="C1 C2 C3 C4 R1 0 1 0 1 R2 1 0 1 1 R3 1 0 0 0", header=TRUE) U<-read.table(text="C1 C2 C3 C4 U1 1 1 0 1 U2 1 1 1 1", header=TRUE) # these are matrices - I think this will work for dataframes as well for(ui in 1:dim(U)[1]) { for(ri in 1:dim(R)[1]) {

Re: [R] Empirical density estimation

2018-03-11 Thread Jim Lemon
Hi Christofer, You may be looking for ecdf (stats) for a start, then working out a way to translate the cumulative density values into probability values. Jim On Mon, Mar 12, 2018 at 5:45 AM, Christofer Bogaso wrote: > Hi, > > Let say I have below vector of

Re: [R] couple of how-to-do it in R questions regarding corelations and mean and SD of likert items

2018-03-06 Thread Jim Lemon
Hi Faiz, Just to add to the confusion: library(prettyR) describe(iris) You can specify which summary measures you want in the "num.desc" argument. Jim On Tue, Mar 6, 2018 at 11:03 PM, faiz rasool wrote: > Dear list, I have the following how-to-do it in R, questions. > >

Re: [R] raster time series statistics

2018-03-05 Thread Jim Lemon
I can't test that at the moment as I don't have the libraries. Perhaps later. Jim On Tue, Mar 6, 2018 at 11:36 AM, wrote: > Last line in the following (updated) code produces the error > require(raster) > require(rts) > require(stringr) > r <- raster(ncol=100,

Re: [R] raster time series statistics

2018-03-05 Thread Jim Lemon
Hi Herry, This is probably due to a call to strptime (or similar). No, it doesn't accept %Y-%m as a valid format. Maybe add a constant day to all the dates as that will work: dt<-list(ID=seq(1:24),month=rep(formatC(1:12,flag=0,width=2),2), year=sort(rep(2016:2017,12)))

Re: [R] reshaping column items into rows per unique ID

2018-02-25 Thread Jim Lemon
Hi Allaisone, If you want a data frame as the output you will have to put up with a few NA values unless each Customer has the same number of diet types: a1df<-read.table(text="CustomerIDDietType 1 a 1c 1b 2

Re: [R] include

2018-02-24 Thread Jim Lemon
the data as you suggested but I could not find K1 in col1. > > rbind(preval,mydat) > Col1 Col2 col3 > 1 > 2 X1 > 3 Y1 > 4 K2 > 5 W1 > 6 Z1 K1 K2 > 7 Z2 > 8 Z3 X1 > 9 Z4 Y1 W1 > > > > On Sat, Feb 24, 2018

Re: [R] include

2018-02-24 Thread Jim Lemon
so >>>> x2 <- x[!is.na(x1)] <- 0 >>>> is equivalent to >>>> x[!is.na(x1)] <- 0 >>>> x2 <- 0 >>>> >>> >>> That's not right in general, is it? I'd think that should be >>> >>>

Re: [R] include

2018-02-23 Thread Jim Lemon
Hi Val, Try this: preval<-data.frame(Col1=unique(unlist(mydat[,c("Col2","col3")]))[-1], Col2=NA,col3=NA) rbind(preval,mydat) Jim On Sat, Feb 24, 2018 at 3:34 PM, Val wrote: > Hi All, > > I am reading a file as follow, > > mydat <- read.table(textConnection("Col1 Col2 col3

Re: [R] Help with regular expressions

2018-02-12 Thread Jim Lemon
Hi Dennis, How about: # define the two values to search for x<-2 y<-3 # create your search string and replacement string repstring<-paste(x,y,sep=",") newstring<-paste(x,y,sep=".") # this is the string that you want to change thetastring<-"SIGMA(2,3)" sub(repstring,newstring,thetastring) [1]

Re: [R] help with the plot overlay

2018-02-04 Thread Jim Lemon
Hi Ace, You can do it with plotrix: library(plotrix) barpos<-barp(c(1,5,38),width=0.5,col=c("white","lightgray","darkgray"),ylim=c(0,70)) ehplot(c(1,0.8,0.9,0.8,1.1,1,4,3,5,14,3,2,32,27,33,30,50,61), c(1,1,1,1,1,1,2,2,2,2,2,2,3,3,3,3,3,3),median=FALSE,add=TRUE,cex=2, pch=21,bg="white")

Re: [R] Manipulating two large dataset differing by date and time

2018-01-21 Thread Jim Lemon
Hi Ogbos, You can just use ISOdate. If you pass more values, it will process them: ISOdate(2018,01,22) [1] "2018-01-22 12:00:00 GMT" > ISOdate(2018,01,22,18,17) [1] "2018-01-22 18:17:00 GMT" Add something like: if(is.null(data$hour),data$hour<-12 then pass data$hour as it will default to the

Re: [R] Leaflet maps. Nudging co-incident markers

2018-01-20 Thread Jim Lemon
Hi Gavin, Here's a sort of brute force way to nudge points. Might be helpful. nudge<-function(x,y,away=0.1,tol=0.01) { dimx<-dim(x) if(missing(y) && !is.null(dimx)) { y<-x[,2] x<-x[,1] } xlen<-length(x) if(xlen != length(y)) stop("x and y must be the same length.") for(i in 1:xlen) {

Re: [R] barplot that displays sums of values of 2 y colums grouped by different variables

2018-01-15 Thread Jim Lemon
Hi Kenneth, I don't know about ggplot, but perhaps this will help: kddf<-read.table(text="city n y mon 100 200 tor 209 300 edm 98 87 mon 20 76 tor 50 96 edm 62 27", header=TRUE,stringsAsFactors=FALSE) library(plotrix) barpos<-barp(t(kddf[,2:3]),names.arg=kddf[,1],xlab="City",ylab="Sum",

Re: [R] barplot_add=TRUE

2018-01-09 Thread Jim Lemon
Hi Sibylle, I might have the wrong idea, but does this: hecke<-matrix(sample(1:40,104,TRUE),nrow=2) library(plotrix) barp(hecke,col=c("lightblue","pink")) legend(43,40,c("M","F"),fill=c("lightblue","pink")) do what you want? It is also possible to display this as a nested bar plot showing males

Re: [R] Draw Overlapping Circles with shaded tracks

2017-12-31 Thread Jim Lemon
; *Professor of Statistics* > > *Department of Mathematics and Statistics* > *University of Southern Maine* > > > On Sun, Dec 31, 2017 at 8:40 AM, Marc Girondot via R-help < > r-help@r-project.org> wrote: > >> Another solution: >> >> library("

Re: [R] Draw Overlapping Circles with shaded tracks

2017-12-29 Thread Jim Lemon
Hi Abou, Without an illustration it's hard to work out what you want. here is a simple example of two circles using semi-transparency. Is this any help? pdf("circles.pdf") plot(0:10,type="n",axes=FALSE,xlab="",ylab="") draw.circle(4,5,radius=3,border="#ffaa",lwd=10)

Re: [R] Coeficients estimation in a repeated measures linear model

2017-12-06 Thread Jim Lemon
Hi Sergio, You seem to be aiming for a univariate repeated measures analysis. Maybe this will help: subno<-rep(1:6,2) dat <- data.frame(subno=rep(1:6,2),,vals = c(ctrl, ttd), cond = c(rep("ctrl", 6), rep("ttd", 6)), ind = factor(rep(1:6, 2))) fit<-aov(vals~ind+cond+Error(subno),data=dat) fit

Re: [R] Fwd: Wanted to learn R Language

2017-11-30 Thread Jim Lemon
Hi SAS_learner, Have a look at the read.xport function in the foreign package. Jim On Fri, Dec 1, 2017 at 7:50 AM, SAS_learner wrote: > Hello all , > > I am a SAS user for a while and wanted to learn to program in R . My > biggest hurdle to start, is to get the data (I

Re: [R] Data cleaning & Data preparation, what do R users want?

2017-11-29 Thread Jim Lemon
Hi again, Typo in the last email. Should read "about 40 standard deviations". Jim On Thu, Nov 30, 2017 at 10:54 AM, Jim Lemon <drjimle...@gmail.com> wrote: > Hi Robert, > People want different levels of automation in the software they use. > What concerns

Re: [R] Data cleaning & Data preparation, what do R users want?

2017-11-29 Thread Jim Lemon
Hi Robert, People want different levels of automation in the software they use. What concerns many of us is the desire for the function "figure-out-what-this-data-is-import-it-and-get-rid-of-bad-values". Such users typically want something that justifies its use by being written by someone who

Re: [R] Scatterplot of many variables against a single variable

2017-11-27 Thread Jim Lemon
Hi Engin, Sadly, your illustration was ambushed on the way to the list. Perhaps you want something like this: # proportion of useful answers to your request pua<-sort(runif(20)) #legibility of your request lor<-sort(runif(20))+runif(20,-0.5,0.5) # is a data set provided?

Re: [R] Fw: modified mankendal

2017-11-24 Thread Jim Lemon
but nothing > find. how can I search for missing value? > Sincerely yours > Elham > > Elham Fakharizadeshirazi. > > Doctoral guest researcher in Institute of Meteorology, > > Department of Earth Sciences, > > Free university of Berlin, > > Berlin, Germany. &g

Re: [R] Fw: modified mankendal

2017-11-23 Thread Jim Lemon
Hi Elham, The error message is pretty explicit. Check your dataset for missing values. Jim On Thu, Nov 23, 2017 at 6:14 AM, Elham Fakharizade via R-help wrote: > > Hello DearI used modifiedmk package for trend analyses.this is my script >

Re: [R] Converting a string to variable names

2017-11-15 Thread Jim Lemon
would not work probably because x is simply a name instead of a > data.frame variable(Error: "attempt to set 'rownames' on an object with no > dimensions"). But I could not find the right way out… How should I solve it? > > Thanks! > > Ruiyang > > >> On Nov

Re: [R] Converting a string to variable names

2017-11-14 Thread Jim Lemon
Hi Ruiyang, I think you want "get": For (index in seq(1,16)){ plot(x=(a given set of value),y=get(paste(“PC”,as.character(index),sep=“”))) } On Wed, Nov 15, 2017 at 7:43 AM, 刘瑞阳 wrote: > Hi, > Suppose that I want to do a series of plots with the y value for each plot as

Re: [R] how to label station names on point

2017-11-13 Thread Jim Lemon
Hi Javad, You can place text using the "text" function or for a slightly fancier label, try boxed.labels in the plotrix package. Jim On Mon, Nov 13, 2017 at 5:04 PM, Javad Bayat via R-help wrote: > I have a shapefile point and I plot it over my polygon. Is it possible to

Re: [R] Help Converting Calendars

2017-11-08 Thread Jim Lemon
Or if you want a slightly prettier output: formatDate<-function(x) { return(paste(x$year,formatC(x$month,width=2,flag=0), formatC(x$day,width=2,flag=0),sep="-")) } formatDate(p.dates) Jim On Thu, Nov 9, 2017 at 10:32 AM, David L Carlson wrote: > How about > >> p_dates <-

Re: [R] Scatterplot3d :: Rotating x tick labels by x degrees

2017-10-31 Thread Jim Lemon
Well, scatterplot3d might not allow it, but have a look at the second example for staxlab in the plotrix package. Jim On Wed, Nov 1, 2017 at 7:30 AM, Uwe Ligges wrote: > > > On 31.10.2017 00:56, Alex Restrepo wrote: > ... > 45 degree rotation is not supported in

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