Re: [R] (no subject)

2016-10-06 Thread Jim Lemon
It certainly does. As we are often confronted with requests for solutions of problems so minimally defined as to challenge the most eminent mindreader, this excels. We have a meta-problem as the supplicant him- (or her-, I cannot even ascertain this) does not appear to know what it is. Thus me are

Re: [R] (no subject)

2016-10-06 Thread Jim Lemon
No, I'm quite certain that the answer is: 7*6 = 3*2^4 - 36/6 but I don't know the question Jim On Fri, Oct 7, 2016 at 9:48 AM, Dalthorp, Daniel wrote: > Question and answer: > > 6*9 = (4)*13^1 + (2)*13^0 > > On Thu, Oct 6, 2016 at 3:26 PM, Jim Lemon wrote: >>

Re: [R] date comparison doesn't match value

2016-10-08 Thread Jim Lemon
Hi Heather, I think the problem may be that you are trying to compare a date field and a character string. R helpfully tries to wrangle the two into comparable data types. While I don't know exactly what you have done, as R for: as.numeric(alldata$new.date.local) and look at the value you get. J

Re: [R] Recoding lists of categories of a variable

2016-10-10 Thread Jim Lemon
Hi Margaret, This may be a misunderstanding of your request, but what about: mydata<-data.frame(oldvar=paste("topic",sample(1:9,20,TRUE),sep="")) mydata$newvar<-sapply(mydata$oldvar,gsub,"topic.","parenttopic") Jim On Tue, Oct 11, 2016 at 1:56 AM, MACDOUGALL Margaret wrote: > Hello > > The R c

Re: [R] can we visualize water flows with 3d in R?

2016-10-12 Thread Jim Lemon
Hi Marna, Isn't the conventional way to visualize depth as shades of blue? library(plotrix) depth.col<-color.scale(dat1$depth,extremes=c("lightblue",blue")) Then color the lon/lat rectangles with depth.col Jim On Wed, Oct 12, 2016 at 7:49 PM, Marna Wagley wrote: > Hi R Users, > Is it possibl

Re: [R] barplot beside=TRUE - values differ on scales

2016-10-12 Thread Jim Lemon
Hi Adrian, Perhaps what you want is this: ajdat<-structure(c(112L, 0L, 579L, 1L, 131L, 1L, 2234L, 2L, 2892L, 1L, 528L, 0L, 582L, 2L), .Dim = c(2L, 7L), .Dimnames = list(c("GN", "CN"), c("DC5", "DC8", "DC14", "DC18", "DC19", "DC20", "DC23" ))) library(plotrix) twoord.plot(0.8:6.8,ajdat[2,],1.2:7.2,

Re: [R] (no subject)

2016-10-13 Thread Jim Lemon
The crucial thing is probably: "... they are translated to UTF-8 before comparison." Although the first 127 characters seem to be identical to ASCII, in which punctuation marks sorted before digits or letters, the encoding to UTF-8 may make that impractical. Jim On Thu, Oct 13, 2016 at 8:55 PM

Re: [R] Function Distributions does not exist in package stats

2016-10-13 Thread Jim Lemon
Hi Hugo, If you look at the help page for "distributions", you will see that it describes a number of functions that return density functions, etc. for specific distributions. If you are looking for something that informs you which distribution might approximate an existing set of values, try the "

Re: [R] ifelse for creating discriminating variable based on two conditions

2016-10-14 Thread Jim Lemon
Hi Andreas, Try this: fruit_2sds<-by(data2$molecule,data2$fruit,sd)*2 data2$newcol<-ifelse(data2$molecule>fruit_2sds[data2$fruit],1,0) or even just: data$newcol<-as.numeric(data2$molecule>fruit_2sds[data2$fruit]) Jim On Fri, Oct 14, 2016 at 5:17 PM, Andreas Nord wrote: > > Dear list, > > Apo

Re: [R] Return.clean () - PerformanceAnalytics package

2016-10-15 Thread Jim Lemon
Hi T, Have you tried converting "clearntest" or "data" into a time series? Jim On Sat, Oct 15, 2016 at 4:47 AM, T.Riedle wrote: > Dear all, > > I am trying to clean return data using the Return.clean() function in the > PerformanceAnalytics package. Hence, my code looks as follows but I get an

Re: [R] Difficulties with setting working directory

2016-10-15 Thread Jim Lemon
Hi Anze, I'm not sure that this will work on Windows, but you can create a function named ".First" (note the leading period) with something like this: .First<-function() setwd("C:/Users/anze") To do this, start a session, enter the above line and then quit the session, saving the current workspac

Re: [R] How is label parameter used in text() when passing it a vector?

2016-10-20 Thread Jim Lemon
Hi mviljama, Without knowing what "dta" contains, it's a bit difficult. Here is an example: set.seed(2345) dta<-data.frame(age=sample(20:80,50),skin=sample(0:1,50,TRUE), gender=sample(0:1,50,TRUE),trt=sample(0:1,50,TRUE), exposure=sample(1:21,50,TRUE),fit5=runif(50)) # define your subset here fo

Re: [R] How is label parameter used in text() when passing it a vector?

2016-10-20 Thread Jim Lemon
Hi again, Sorry, the text command should read: text(x=dta$age[samp010],y=dta$fit5[samp010],labels=dta$exposure[samp010], col=expcol[samp010]) Jim On Fri, Oct 21, 2016 at 8:50 AM, Jim Lemon wrote: > Hi mviljama, > Without knowing what "dta" contains, it's a bit difficul

Re: [R] Error in a regression

2016-10-24 Thread Jim Lemon
Hi Andrea, Assuming that your model is something like: lm(y~x,data=mydata) See what: cor(mydata$y,mydata$x) returns. If it is very very close to 1 or -1, there lies your problem. If one or more of your predictor variables is an almost perfect predictor of the response, you don't have much room

Re: [R] PROBLEM: correspondence analysis with vegan

2016-10-26 Thread Jim Lemon
Hi Julia, The error you got is usually due to data that should be numeric (1, 2, 3, ...) actually being a factor data type. This often happens when R reads in a CSV file with the default option of converting character variables (A, B, C,...) to factors. So your first column after input may be a fac

Re: [R] interpretation of plot.svm graph

2016-10-26 Thread Jim Lemon
Hi Alily, Your image file didn't get through to the list. Try sending a PDF image or perhaps providing a URL for an image stored on the internet. Jim On Wed, Oct 26, 2016 at 8:46 PM, Indhira, Anusha wrote: > Hi, > > I am trying to understand graph generated by plot.svm command. when I use > mod

Re: [R] Convert matrix

2016-10-30 Thread Jim Lemon
Hi Elham, As you have asked this question a large number of times in quite a few places, and have received reasonable answers, I assume that you already know that the gene names and associated values are in another format. What you probably want to do is to convert the first column of the data that

Re: [R] How to pre-process fwf or csv files to remove unexpected characters in R?

2016-11-06 Thread Jim Lemon
Hi Lucas, This is a rough outline of something I programmed years ago for data cleaning (that was programmed in C). The basic idea is to read the file line by line and check for a problem (in the initial application this was a discrepancy between two lines that were supposed to be identical). Here,

Re: [R] Is this foreach behaviour correct?

2016-11-06 Thread Jim Lemon
hi James, I think you have to have a starting date ("origin") for as.Date to convert numbers to dates. Jim On Sun, Nov 6, 2016 at 12:10 PM, James Hirschorn wrote: > This seemed odd so I wanted to check: > > > x <- foreach(i=1:10100, .combine='c') %do% { as.Date(i) } > > yields a numeric vec

Re: [R] Pesky file encoding problem

2016-11-06 Thread Jim Lemon
Hi Joshua, Use Notepad++. It will also convert the linefeed EOLs to CR/LF. Jim On Mon, Nov 7, 2016 at 4:25 AM, Joshua Banta wrote: > Dear everyone, > > Please consider the following code, which I am using to make a custom text > file. (I need to build the text file line-by-line like this for so

Re: [R] Read in files in r

2016-11-08 Thread Jim Lemon
Hi lily, My first guess is that the errors are due to trying to open a file like: "fold1/file1.txt" as: "file1.txt" That is, your code will generate filenames in the directories fold1,..., without prepending the folder names. Maybe: result_list<-list() read_dirs<-paste("fold",1:3,sep="") rn<-1

Re: [R] Spatial & Temporal Analysis of Daily Rainfall, Temperature Data

2016-11-09 Thread Jim Lemon
Hi Henry, You are certainly starting from the beginning. first, when you import the data from a CSV file, remember to add: read.csv(...,stringsAsFactors=TRUE) There will doubtless be other problems, but you have to start somewhere. Jim __ R-help@r-pro

Re: [R] Spatial & Temporal Analysis of Daily Rainfall, Temperature Data

2016-11-09 Thread Jim Lemon
Geez, I must be too excited. I meant: stringsAsFactors=FALSE Jim On Wed, Nov 9, 2016 at 7:44 PM, Jim Lemon wrote: > Hi Henry, > You are certainly starting from the beginning. first, when you import > the data from a CSV file, remember to add: > > read.csv(...,stringsAsFactors=

Re: [R] Average every 4 columns

2016-11-09 Thread Jim Lemon
Hi Milu, Perhaps this will help: apply(as.matrix(x[-1,seq(1:dim(x)[1],by=4)]),1,mean) Jim On Thu, Nov 10, 2016 at 4:00 AM, Miluji Sb wrote: > Thanks a lot for your quick reply. I made a mistake in the question, I > meant to ask every 4 (or 12) rows not columns. Apologies. Thanks again! > > Sin

Re: [R] Average every 4 columns

2016-11-09 Thread Jim Lemon
Thanks - it made me realize that I had reversed the column and row selection rowMeans(x[seq(1:dim(x)[1],by=4),-1]) Jim On Thu, Nov 10, 2016 at 8:30 AM, Uwe Ligges wrote: > > > On 09.11.2016 22:06, Jim Lemon wrote: >> >> Hi Milu, >> Perhaps this will help: >>

Re: [R] Average every 4 columns

2016-11-12 Thread Jim Lemon
Hi Miluj, Perhaps you didn't get my previous email. Let your data frame be named "msdf": block_col_summ<-function(x,step,block_size,FUN="mean") { dimx<-dim(x) return_value<-NA start<-1 end<-start+block_size-1 block_count<-1 while(end <= dimx[2]) { return_value[block_count]<- do.call(FUN

Re: [R] value matching %in% for a number pair

2016-11-12 Thread Jim Lemon
Hi john, I don't know whether this breaks any rules, but: target_pair<-c(3,4) pair_list<-list(c(1,2),c(3,4),c(5,6)) sapply(pair_list,identical,target_pair) [1] FALSE TRUE FALSE Jim On Sun, Nov 13, 2016 at 1:32 PM, Jeff Newmiller wrote: > Sorry, that was a fail. Better to think about: > > any(

Re: [R] Principle Component Analysis: Ranking Animal Size Based On Combined Metrics

2016-11-13 Thread Jim Lemon
Hi Salvatore, If by "size" you mean volume, why not directly measure the volume of your animals? They appear to be fairly small. Sometimes working out what the critical value actually means can inform the way to measure it. Jim On Sun, Nov 13, 2016 at 4:46 PM, Sidoti, Salvatore A. wrote: > Let'

Re: [R] Principle Component Analysis: Ranking Animal Size Based On Combined Metrics

2016-11-13 Thread Jim Lemon
; Then divide by the sum of the weights: > 0.43758 / 1.697 = 0.257855 = "animal size" > > This value can then be used to rank the animal according to its size for > further analysis... > > Does this sound like a reasonable application of my PCA data? > > Salvatore A

Re: [R] Function argument and scope

2016-11-13 Thread Jim Lemon
Hi Bernardo, I don't think that your function is doing anything like you expect it to do: test <- data.frame(var1=c("a","b","c"),var2=c("d","e","f")) test var1 var2 1ad 2be 3cf You have a data frame with two columns, the first thing you do is extract the first value in th

Re: [R] question on mean, sum

2016-11-14 Thread Jim Lemon
Hi mokuram, As others have noted, you will profit from a bit more knowledge about "extraction": sum(mtcars) [1] 13942.2 This works because you have "extracted" the first column of the "mtcars" data frame _as a data frame_ mtcars[1] mpg Mazda RX4 21.0 Mazda RX4 Wag

Re: [R] Text categories based on the sentences

2016-11-14 Thread Jim Lemon
Hi Venky, Unfortunately the MindReader package produces the following: 1. I want ice cream Desire 2. I like banana very much Pleasure 3. Tomorrow i will eat chicken Expectation 4. Yesterday i went to bi

Re: [R] unique dates per ID

2016-11-14 Thread Jim Lemon
Hi Farnoosh, Try this: for(id in unique(df$Subject)) { whichsub<-df$Subject==id if(exists("newdf")) newdf<-rbind(newdf,df[whichsub,][which(!duplicated(df$dates[whichsub])),]) else newdf<-df[whichsub,][which(!duplicated(df$dates[whichsub])),] } Jim On Tue, Nov 15, 2016 at 9:38 AM, Farnoosh

Re: [R] explicit coercion warnings as.numeric Versus as.logical

2016-11-21 Thread Jim Lemon
Hi Ramnik, Bert's answer is correct, and an easy way to see why is to look at: c(1,F,"b") [1] "1" "FALSE" "b" The reason that "F" is translated to "FALSE" is that is its default value when R is started. If you change that value: F<-"foo" c(1,F,"b") [1] "1" "foo" "b" as.logical(c(1,F,"b"))

Re: [R] Combining columns

2016-11-21 Thread Jim Lemon
Hi Olu, If you always have only one non-NA value in the first three columns: veg_df<-data.frame(col1=c(NA,"cassava","yam",NA,NA,NA,"maize"), col2=c("pumpkin",NA,NA,"cherry",NA,NA,NA), col3=c(NA,NA,NA,NA,"pepper","mango",NA)) veg_df$col4<-apply(as.matrix(veg_df),1,function(x) x[!is.na(x)]) Jim

Re: [R] Error occurring

2016-11-24 Thread Jim Lemon
`Hi Stuti, Your problem is that if you want to have more than one command on a single line, you must separate them with a semicolon. j <- function() { if(!exists ("a")){ a <- 1 } else{ a <- a+1 }; print(a)} The above will work, but is usually considered bad form. What follows is usually easie

Re: [R] abline with zoo series

2016-11-24 Thread Jim Lemon
Hi Erin, I would look at: par("usr") to see what the range of the abscissa might be. Jim On Fri, Nov 25, 2016 at 2:03 PM, Erin Hodgess wrote: > Hello! Happy Thanksgiving to those who are celebrating. > > I have a zoo series that I am plotting, and I would like to have some > vertical lines a

Re: [R] about data manipulation

2016-11-30 Thread Jim Lemon
Hi lily, If you want to use aggregate, supply the name of the function: aggregate(flow~year, data=df, "sum") You can also use "by" like this by(df$flow,df$year,FUN=sum) I assume that you don't have to worry about missing months in a year. Jim : On Thu, Dec 1, 2016 at 3:06 PM, lily li wrote:

Re: [R] Identifying Gender

2016-12-01 Thread Jim Lemon
On Fri, Dec 2, 2016 at 7:58 AM, Ismail SEZEN wrote: > > So, it’s more reasonable to identify the gender manually. > Both Paul ("Crocodile Dundee") Hogan and Donald Trump agree on that. Jim __ R-help@r-project.org mailing list -- To UNSUBSCRIBE and more

Re: [R] Plotting Confidence Intervals into a density plot

2016-12-02 Thread Jim Lemon
Hi Elysa, I think you are going a bit off course in your example. Try this and see if it is close to what you want: data<-rnorm(100)+runif(100,0,15) smu_data<-supsmu(1:100,data) rollfun<-function(x,window=10,FUN=sd) { xlen<-length(x) xout<-NA forward<-window%/%2 backward<-window-forward for(i

Re: [R] Plotting Confidence Intervals into a density plot

2016-12-02 Thread Jim Lemon
into my density plot (and not a confidence line along a scatter > plot like your suggested solution) > > My x-axis is an index (a data frame), my y-axis is the automatically > constructed density > > On Fri, Dec 2, 2016 at 10:01 AM, Jim Lemon wrote: >> >> Hi Elysa, >>

Re: [R] Plotting Confidence Intervals into a density plot

2016-12-02 Thread Jim Lemon
Hang on, maybe you mean something like this: erupt_dens<-density(faithful$eruptions) plot(erupt_dens,ylim=c(0,0.65)) dispersion(erupt_dens$x,erupt_dens$y,ulim=erupt_dens$y/5, type="l",fill="lightgray",interval=TRUE) lines(erupt_dens) Jim On Fri, Dec 2, 2016 at 9:36 PM,

Re: [R] scatter plot of numerical variables against different sample ids

2016-12-05 Thread Jim Lemon
Hi Maria, Perhaps something like this: mldf<-read.table(text="Sample Cu Zn Mn M1 1 5 10 M2 2.5 11 8 M3 1.15 11 12 M4 2 4 30 M5 8 15 35", header=TRUE) matplot(mldf,type="b",pch=c("C","Z","M")) Jim On Mon, Dec 5, 2016 at 11:25 PM, Maria Lathouri via R-help wrote: > Dear al

Re: [R] drawing a ... barplot (?) along time

2016-12-06 Thread Jim Lemon
Hi Dagmar, I think you want something like a gantt.chart. I know this is wrong in some ways, but it is late and I must retire: datframe <- data.frame(Name=c("Kati","Kati","Kati","Leon","Leon","Leon"), changepoint=as.Date(c("03.01.2011","05.01.2011", "27.01.2011", "26.01.2011","28.01.2011", "28.

Re: [R] create list of vectors in for loop

2016-12-06 Thread Jim Lemon
Hi Paul, The easy to understand way is: n <- c(1:10) # Create empty list to store vectors list_of_vecs <- list() # Create n vectors of random numbers - length 10. This works ok. for (i in n){ list_of_vecs[[i]]<-rnorm(10,0,1) } If you really want to use "assign": for (i in n){ vecname<-paste('v

Re: [R] CONFUSSING WITH select[!miss] <- 1:sum(!miss)

2016-12-06 Thread Jim Lemon
Hi Greg, What is happening is easy to see: ph<-matrix(sample(1:100,40),ncol=4) colnames(ph)<-c("M1","X1","X2","X3") ph[sample(1:10,3),1]<-NA ph M1 X1 X2 X3 [1,] 34 98 3 35 [2,] 13 66 74 68 [3,] NA 22 99 79 [4,] 94 6 80 36 [5,] 18 9 16 65 [6,] NA 29 56 90 [7,] 41 23 7 5

Re: [R] drawing a ... barplot (?) along time

2016-12-06 Thread Jim Lemon
;01.01.2011","%d.%m.%Y")), datframe$changepoint[1:2], as.POSIXct(strptime("24.01.2011","%d.%m.%Y")), datframe$changepoint[4:5]), ends=datframe$changepoint) gantt.chart(tm.info, xlim=as.POSIXct(strptime(c("1.1.2011","10.3.2011"),"%d.%

Re: [R] how to randomly select the samples with different probabilities for different classes?

2016-12-07 Thread Jim Lemon
Hi Marna, If we assume a sample size of 1, something like this: dat[sample(which(dat$group!="C"),ceiling(14*0.4),TRUE),] dat[sample(which(dat$group=="C"),floor(14*0.6),TRUE),] Then just step through the two subsets to access your samples. One problem is that you will not get exactly 40 or 60 %,

Re: [R] R problem

2016-12-08 Thread Jim Lemon
Hi Grace, It is almost certainly a directory problem. The new R installation may be in a different directory from the old one. Does R run from the Start menu or a desktop icon? If so, look at "Properties" to discover where it is located and use the explicit path (e.g. C:\Users\Grace\R -save < IPFPU

Re: [R] issue overlaying a contour plot on map

2016-12-09 Thread Jim Lemon
Hi Jatin, It looks as though the third plot has the contour plot beneath the map, which is opaque.If you just want to show the three "hotspots" on the map, perhaps you could adjust the colors so that they are displayed on a transparent field instead of blue and then overlay that on the map. Jim

Re: [R] sample train and test data using dplyr

2016-12-09 Thread Jim Lemon
Sample without replacement and then split that sample into train and test components. Jim On Fri, Dec 9, 2016 at 4:55 PM, Partha Sinha wrote: > How to get two sets of non overlapping data? > Regards > Parth __ R-help@r-project.org mailing list -- To U

Re: [R] Organize regression output

2016-12-11 Thread Jim Lemon
Hi Francesca, I'm not sure what you are doing here, but try this: regnames<-paste("r",letters[1:8],sep="") for(i in 1:8) { response<-rnorm(20) coef1<-rnorm(20) coef2<-rnorm(20) age<-sample(20:50,20) gender<-sample(c("M","F"),20,TRUE) assign(regnames[i],lm(response~coef1+coef2+age+gender)) }

Re: [R] Overlapping of arrow in PCA

2016-12-11 Thread Jim Lemon
Hi Tan Dai, It looks like you have little or no variance in your measurements, and so the result is degenerate. The functions you are using are probably working properly, but there is nothing to display. Jim On Sat, Dec 10, 2016 at 6:04 PM, Tan Dai Chuan via R-help wrote: > Hi, i face the probl

Re: [R] Reshape to wide format

2016-12-13 Thread Jim Lemon
Hi Milu, I may have the wrong idea, but is this what you want? temp$ID<-paste(temp$iso3,temp$lon,temp$lat,sep="") library(prettyR) newtemp<-stretch_df(temp,"month","precip")[,c(5,7,8)] names(newtemp)<-c("month",unique(temp$ID)) Jim On Tue, Dec 13, 2016 at 4:10 AM, Miluji Sb wrote: > Dear all,

Re: [R] Unable arrange the functions according to the requirement in the help page of my package.

2016-12-14 Thread Jim Lemon
Hi Pijush, Don't worry about the "arrangement" of the functions in the help file. They are ordered alphabetically and this has nothing to do with the order in which they are actually used. The more serious problem is probably your help files. There should be a "man" (help) file for each function, u

Re: [R] how to show a plot without overlaying the text on top of the another text?

2016-12-14 Thread Jim Lemon
Hi Marna, Your request made me think that a simple manual label placing function might be useful to some people. placeLabels<-function(pointer=TRUE,cex=1,labelcol=par("fg"), bg="white",border=par("fg"),pointercol=par("fg")) { cat("Enter a blank label to finish\n") nextlabel<-"XXX" while(nchar

Re: [R] Merging two columns of unequal length

2016-12-15 Thread Jim Lemon
Hi Bailey, I may be misunderstanding what you are doing as I can't work out how you get unequal column lengths, but this may help: myval<-matrix(sample(1:365,740,TRUE),ncol=74) mydata<-as.data.frame(cbind(1950:1959,myval)) lakenames<-paste(rep(LETTERS[1:26],length.out=74), rev(rep(letters[1:25],l

Re: [R] how to show a plot without overlaying the text on top of the another text?

2016-12-15 Thread Jim Lemon
Hi Marna, After a bit of experimenting I came up with the following function that "flags" each point to be labeled an allows the operator to manually place the label for that point: placeLabels<-function(x,y,labels,pointer=TRUE,cex=1,labelcol=par("fg"), labelbg="white",border=par("fg"),pointercol

Re: [R] Export R output in Excel

2016-12-28 Thread Jim Lemon
Hi Bryan, When I have to do something like this, I usually go through HTML output and import it into MS Word. I am not suggesting that this is the best thing to do, but it might get you out of trouble. I'm not sure whether importing HTML into Excel will work as well. I assume that you are running a

Re: [R] Export R output in Excel

2016-12-29 Thread Jim Lemon
; > I found this code, but it doesn’t cover the whole output of the console. > > write.csv(coef(summary(test)), file=“test.csv”) > > My whole output consists of descriptives and regressions. > > Best, > > Bryan Mac > bryanmac...@gmail.com > > > >> O

Re: [R] stacked and dodged bar graph ggplot

2016-12-30 Thread Jim Lemon
Hi Robert, I realize that this isn't in ggplot, but are you looking for something like this? Demog <- data.frame(source=c(rep("Davis",4),rep("Dixon",4),rep("Winters",4)), group =c("Asian / Pacific Islander","Caucasian","Latinx", "Not Latinx","African American", "Native American", "Latinx", "Not

Re: [R] Generating a Special Histogram

2017-01-05 Thread Jim Lemon
Hi Dan, This may help if your data is in the format below: waffle.mat<-matrix(c(rep(NA,14),137,135,rep(NA,6),144,149, rep(NA,3),150,152,159,157,154, NA,163,164,164,161,162,165,164,rep(NA,5),179,173,173, rep(NA,4),182,180,185,180, rep(NA,6),197,190,rep(NA,8)),ncol=9) waffle.col<-matrix("lightbl

Re: [R] [FORGED] Re: Generating a Special Histogram

2017-01-05 Thread Jim Lemon
egdat[as.numeric(egcut)==egindex]) egdf<-as.data.frame(lapply(eglist,function(x) x[1:8])) names(egdf)<-paste("V",1:9,sep="") waffle.mat<-as.matrix(sapply(egdf,rev)) Jim On Fri, Jan 6, 2017 at 9:21 AM, Rolf Turner wrote: > On 06/01/17 10:31, Jim Lemon wrote: >&g

Re: [R] About concatenating strings

2017-01-05 Thread Jim Lemon
Hi lily, maybe this is what you want: strings1<-c(1.2,1.31,1.4,1.51) strings2<-c(2.1,2.22,2.3,2.44) paste(formatC(strings1,digits=2,format="f"), formatC(strings2,digits=2,format="f"),sep="-") Jim On Fri, Jan 6, 2017 at 4:56 PM, lily li wrote: > Sorry for the emails. I just checked and the pro

Re: [R] Assignment 1 (function error)

2017-01-05 Thread Jim Lemon
Hi Malvika, What David means is that we don't do people's homework for them. Have a look at "An Introduction to R" that comes with the R distribution, particularly about sequences and vectorization. Jim On Fri, Jan 6, 2017 at 7:40 AM, Malvika Marathe wrote: > Can you please help me with this as

Re: [R] if i paste this into my windows 3.3.2 R console, it crashes

2017-01-07 Thread Jim Lemon
Hi Anthony, I think you have included most of the forbidden characters in Windows folder names and while I am too lazy to count the characters, you may have exceeded the 259 character limit as well. Are there really embedded EOLs as well? This is truly a masterpiece of computer disobedience. Jim

Re: [R] Getting Started

2017-01-10 Thread Jim Lemon
Hi Lakshya, One good way to contribute is to try to do something in R, and if you see a way to do it better or more easily, you may have an improvement that will find its way into R. This usually involves a lot of discovering that someone else has already done it, but as your knowledge of R expands

Re: [R] Qvalue package: I am getting back 1, 000 q values when I only want 1 q value.

2017-01-12 Thread Jim Lemon
Hi Tom, >From a quick scan of the docs, I think you are looking for qobj$pi0. The vector qobj$qvalue seems to be the local false discovery rate for each of your randomizations. Note that the manual implies that the p values are those of multiple comparisons within a data set, not randomizations of

Re: [R] Receiving NaN message

2017-01-16 Thread Jim Lemon
Hi Robert, There is a policy of not doing people's homework for them on the list. Nevertheless, I would advise you to read up on how to use the comparison operator (==). Good luck. Jim On Tue, Jan 17, 2017 at 7:10 AM, Robert Piliero wrote: > Hello, > > I am working on a Coursera assignment and

[R] turning the output of cut into a waffle plot

2017-01-17 Thread Jim Lemon
Hi all, A few days ago I offered a suggestion on how to display the initial values that were cut into a factor as a waffle plot. As Rolf Turner noted, a major problem for users would be constructing the matrix that was fed to the color2D.matplot function. Here is a fairly general purpose function f

Re: [R] Adding regression line to each individual plot in a window with multiple plots

2017-01-17 Thread Jim Lemon
Hi Jake, As I don't have your data set, try this: attach(mtcars) plot(mpg~disp,xaxs="i",yaxs="i") abline(lm(mpg~disp)) Jim On Wed, Jan 18, 2017 at 12:04 PM, Jake William Andrae wrote: > Hi Everyone, > > > > I've constructed a script that adds multiple plots to the plot window, but > I'm having

Re: [R] Adding regression line to each individual plot in a window with multiple plots

2017-01-17 Thread Jim Lemon
regression line you display. Jim On Wed, Jan 18, 2017 at 1:41 PM, Jake William Andrae wrote: > Hi Jim, that works but this is what it then looks like. > > -Original Message- > From: Jim Lemon [mailto:drjimle...@gmail.com] > Sent: Wednesday, 18 January 2017 1:06 PM > To: J

Re: [R] Adding regression line to each individual plot in a window with multiple plots

2017-01-17 Thread Jim Lemon
s = "i", xlim = > c(0, 700), ylim = c(0,30), xlab = "Total precipitation (mm)", ylab = "CPI", > pch=21, bg='black', > rect(par("usr")[1],par("usr")[3],par("usr")[2],par("usr")[4],col = "white")) >

Re: [R] [FORGED] turning the output of cut into a waffle plot

2017-01-18 Thread Jim Lemon
things out, as there is a lot left to discover, I would like to be sure that more than one person sees a use for it. Jim On Wed, Jan 18, 2017 at 5:37 PM, Rolf Turner wrote: > On 18/01/17 12:21, Jim Lemon wrote: >> >> Hi all, >> A few days ago I offered a suggestion on how t

Re: [R] T tests on multiple groups

2017-01-19 Thread Jim Lemon
Hi Ed, It's little hard to work out exactly what you want, but here's a guess: esdf<-data.frame(GENO=rep(c("control","A","B","AB"),each=20), age=rep(c(10,20),40),OBS=runif(80,1,21)) for(age in c(10,20)) { for(geno in c("A","B","AB")) print(t.test(OBS~GENO,esdf[esdf$age==age & esdf$GENO %in%

Re: [R] Zip Files

2017-01-21 Thread Jim Lemon
Hi Glenn, I would try the "rename" option which should allow you to give the output another name. Jim On Sat, Jan 21, 2017 at 2:09 AM, Glenn Schultz wrote: > All, > I have a zip that was downloaded with HTTR. I had to use HTTR because I > need to login and post to the website. The files down

Re: [R] Subset()

2017-01-21 Thread Jim Lemon
Hi Elise,. I would ask: class(data$DateTime) and see if it returns: "POSIXct" "POSIXt" Jim On Sat, Jan 21, 2017 at 3:02 AM, Elise LIKILIKI wrote: > Hello, > > I have a dataset containing Date Time, Air Temperature, PPFD, Sol > Temperature... > The first data are false so I would like to extr

Re: [R] Subset()

2017-01-21 Thread Jim Lemon
the data before 2017-01-10 11:00:00 nor columns : Records and > Ptemp. > I've tried with subset() and with [ ] but I still have some rows containing > data before 2017-01-10 11:00:00. > > I'm french so I am really sorry about my english > > 2017-01-21 11:41 GMT+01:00 Jim

Re: [R] Subset()

2017-01-21 Thread Jim Lemon
much, it works with your method !! I'm going to be able to >> process my data, thanks again ! >> >> Regards, >> >> Elise >> >> 2017-01-21 23:32 GMT+01:00 Jim Lemon : >>> >>> Hi Elise, >>> If I create a CSV file like your example

Re: [R] Extracting first number after * in a character vector

2017-01-23 Thread Jim Lemon
Hi Abhinaba, I'm sure that someone will post a terrifyingly elegant regular expression that does this, but: ardat<- c([1] " 1 X[0,SMITH] * 0 0 1 ", ... numpoststar<-function(x) { xsplit<-unlist(strsplit(x,"")) starpos<-which(xsplit=="*") # watch out

Re: [R] graphical behavior of a table of numbers

2017-01-28 Thread Jim Lemon
Hi Richard, I think there may be something amiss in the plot.table function. As you note, changing the class of fr to array produces a more sensible plot, as does Bert's "as.vector". Yet inside plot.table we find: plot(x0, unclass(x), ... and that should produce an array: class(unclass(fr)) [1]

Re: [R] caculate correlation

2017-01-30 Thread Jim Lemon
Hi Elham, Without knowing much about what coding.rpkm and ncoding.rkpm look like, it is difficult to say. Have you tried to subset these matrices as you do in the "cor" function and see what is returned? Jim On Tue, Jan 31, 2017 at 6:40 AM, Elham - via R-help wrote: > for calculating correlation

Re: [R] Challenge extracting months

2017-01-30 Thread Jim Lemon
Hi Kwesi, Even without the data, it seems clear that you want something like a rolling mean. Here is a simple function that will apply a function like "mean" to successive bits of a vector of numbers: collapse_values<-function(x,span,FUN="mean",na.rm=FALSE) { jump<-span-1 newx<-rep(NA,length(x)-

Re: [R] caculate correlation

2017-01-30 Thread Jim Lemon
first > I transposed data ,(rows become columns)so row is control&treatment and > columns are gene names.(so I have 2 matrix with same row and different > column).This information is enough? > > > > > On Tuesday, January 31, 2017 1:06 AM, Jim Lemon > wrote: > > >

Re: [R] Challenge extracting months

2017-01-30 Thread Jim Lemon
-function(x,span,FUN="mean",na.rm=FALSE) { > jump<-span-1 > newx<-rep(NA,length(x)-jump) > for(i in 1:length(newx)) > newx[i]<-do.call(FUN,list(x[i:(i+jump)],na.rm=na.rm)) > return(newx) > } > > #test<-1:12 > names(era.sta)<-month.ab

Re: [R] caculate correlation

2017-01-30 Thread Jim Lemon
ext: > "grep(".C",lnc$name)" > > I`m so sorry,maybe I do not understand you again. > > > On Tuesday, January 31, 2017 1:27 AM, Jim Lemon > wrote: > > > Hi Elham, > This is about the same as your first message. What I meant was, what > do the

Re: [R] HELP GLM

2017-01-30 Thread Jim Lemon
After scrupulous textual analysis, I conclude that you have at least one NA/NaN/Inf in b$induction. There is also a hint that you should acquaint yourself with family="binomial". Sherlock On Tue, Jan 31, 2017 at 11:18 AM, CHIRIBOGA Xavier wrote: > Dear colleagues, > > > I am trying to perform GL

Re: [R] Challenge extracting months

2017-01-30 Thread Jim Lemon
Hi Kwesi, A mistake in the last email. Don't try to replace the column in era.sta as the result will be a different length. Try this: newera.sta2<-collapse.values(era.sta[,2],3) Jim On Tue, Jan 31, 2017 at 10:32 AM, Jim Lemon wrote: > Hi Kwesi, > The function collapse_values wil

Re: [R] caculate correlation

2017-01-31 Thread Jim Lemon
Hi Elham, On Tue, Jan 31, 2017 at 7:28 PM, Elham - wrote: > Hi Dear Jim, > > I did it, both return a vector of name of the genes with different length,as > I said before I have list of coding and noncoding so the length are not > same. > > where is number?! > Not in the values you are extracting

Re: [R] Challenge extracting months

2017-01-31 Thread Jim Lemon
(era.nodes.days,start=as.Date("1980-01-01"),end=as.Date("2016-12-31")) > > mon.t1<-as.numeric(format(index(era.nodes.days.t1),"%m")) > seas.t1 <-as.numeric(format(index(era.nodes.days.t1),"%Y")) > era.nodes.days.t1<-cbind(era.nodes.days.t1,mon.t1,

Re: [R] caculate correlation

2017-01-31 Thread Jim Lemon
> there is gene name instead of number > > > On Tuesday, January 31, 2017 12:20 PM, Jim Lemon > wrote: > > > Hi Elham, > > On Tue, Jan 31, 2017 at 7:28 PM, Elham - wrote: >> Hi Dear Jim, >> >> I did it, both return a vector of name of the genes with di

Re: [R] sub-setting rows based on dates in R

2017-01-31 Thread Jim Lemon
Hi Md, This kind of clunky, but it might do what you want. df1<-read.table(text="DateRainfall_Duration 6/14/2016 10 6/15/2016 20 6/17/2016 10 8/16/2016 30 8/19/2016 40", header=TRUE,stringsAsFactors=FALSE) df1$Date<-as.Date(df1$Date,"%m/%d/%Y") df2<-read.t

Re: [R] Challenge extracting months

2017-02-01 Thread Jim Lemon
rateful for any help. > > Kwesi > > On Wed, Feb 1, 2017 at 1:12 AM, Jim Lemon wrote: >> >> Hi Kwesi, >> I worked through your code below, and I think that when you have the >> two variables "mon.t1" and "seas.t1" you can select a "

Re: [R] Challenge extracting months

2017-02-01 Thread Jim Lemon
have been able to manipulate the > barplot with "margin" to get the plot in a better shape but now the y-axis > is out of the plot zone. I have attached my script. Kindly have a look. Its > with the data I earlier sent. > > > > On Thu, Feb 2, 2017 at 1:08 AM, Jim Le

Re: [R] sub-setting rows based on dates in R

2017-02-02 Thread Jim Lemon
/2016 17.2* > > > Expected output: > > > df3 <- > > Rate.Removal.Date Date Rainfall_Duration > 6/17/2016 6/14/2016 10 > 6/17/2016 6/15/2016 20 > 6/17/2016 6/17/2016 10 > 6/30/2016 6/14/2016 10 > 6/30/2016 6/15/2016 20 > 6/30/2016 6/17/2016

Re: [R] sub-setting rows based on dates in R

2017-02-02 Thread Jim Lemon
getting this error: > Error in `*tmp*`[[j]] : subscript out of bounds > Do you have any solution for that? You have already done a lot. So, I > really appreciate your effort. Thanks > > -- > *From:* Jim Lemon > *Sent:* Thursday, February 2, 2017 2:07 PM > > *To:* Md Sami

Re: [R] need help to generate an intersection matrix

2017-02-02 Thread Jim Lemon
Hi Ana, Here is one way: pathway1<-LETTERS[1:5] pathway2<-c("A","C","F") pathway3<-c("B","D","E") intersect.mat<-matrix(0,nrow=3,ncol=3) rownames(intersect.mat)<-paste("pathway",1:3,sep="") colnames(intersect.mat)<-paste("pathway",1:3,sep="") for(row in 1:3) { for(col in 1:3) intersect.mat[row,

Re: [R] how to interpret t.test output

2017-02-06 Thread Jim Lemon
Hi Somayya, When you perform a t-test on two sets of numeric values, the answer you get tells you how likely it is that those two sets of numbers came from the same distribution. What most people are interested in is whether the means of those two distributions are different. Let's see, you seem to

Re: [R] How to include custom na.action in function

2017-02-09 Thread Jim Lemon
Hi Alejandro, How about: -sign(x) * sign(x) * x Jim On Fri, Feb 10, 2017 at 6:30 AM, Alejandro wrote: > Hello, > > I’ve tried googling for an answer to this but I simply can’t find something > that fixes my problem. I have a long numerical vector with positive, negative > and null values. I

Re: [R] Independent samples bootstrapped T-test : question

2017-02-11 Thread Jim Lemon
Hi Tahereh, In the code you provided, there seems to be a mistake in the calls to "sample" in that you haven't specified the "size" argument. You should have gotten an error there. Also, you have assigned both samples to the same variable name, so there will be no "boot.p" when the call to t-test i

<    5   6   7   8   9   10   11   12   13   14   >