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.%m.%Y

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

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){

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",

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

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

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

2016-12-02 Thread Jim Lemon
s - a polygon > inserted 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 <drj

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

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 --

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

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

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

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] 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] 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] 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

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] 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

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

2016-11-13 Thread Jim Lemon
0.847(0.291) = 0.43758 > 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 applic

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.

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.

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]<-

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 <lig...@statistik.tu-dortmund.de> wrote: > > > On 09.11.2016 22:06, Jim Lemon wrote: >> >> Hi Milu

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.

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 <drjimle...@gmail.com> wrote: > Hi Henry, > You are certainly starting from the beginning. first, when you import > the data from a CSV file, remember to ad

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 __

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="")

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

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% {

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).

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

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

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

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] 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 <drjimle...@gmail.com> wrote: > Hi mviljama, > Without knowing what "dta" contains

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

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

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

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

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] (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

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)

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

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

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.

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 <ddalth...@usgs.gov> wrote: > Question and answer: > > 6*9 = (4)*13^1 + (2)*13^0 > > On Thu, Oct 6, 2016 at 3:26 PM, Jim Lemon

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] Trouble with parameter estimation in nonlinear regression model

2016-10-03 Thread Jim Lemon
Hi Syela, Are the values in ASFR monotonically increasing with year? Jim On Tue, Oct 4, 2016 at 4:23 AM, Syela Mohd Noor wrote: > Hi all, I had a problem with the parameter estimation of the Brass Gompertz > model for my dissertation. I run the code for several times

Re: [R] Please help with creating the improved image with pheatmap package

2016-10-03 Thread Jim Lemon
Hi Maryam, Your labels have been "greeked" as the font is too small to be displayed properly. If you must use PNG format, specify your image file at least twice as high. png("pheatmap.png",width=1254,height=5000) PDF would be a better choice as you can just zoom in and scroll down. Jim On

Re: [R] Font problem.

2016-10-02 Thread Jim Lemon
Hi Rolf, I would try using dnf (or whatever the Ubuntu equivalent is) to install the X11 fonts. You may have a GUI method for this in Ubuntu. Jim On Mon, Oct 3, 2016 at 7:55 AM, Rolf Turner wrote: > > Dunno exactly whom I should ask about this problem, but I thought

Re: [R] Histogram using Sturges' Bining Errors

2016-10-02 Thread Jim Lemon
Hi Elysa, This is pretty much a guess. If you understand the first error, i.e. that there are nine rows in your input data frame (?) that contain NA, NaN, or Inf values, have you tried manually removing those rows and feeding the remainder to your code? Jim On Sun, Oct 2, 2016 at 7:19 PM, Elysa

Re: [R] Rearranging sub-folders, how?

2016-10-01 Thread Jim Lemon
Hi Kristi, I assume that B, C and D are not empty, otherwise the answer is trivial. create a directory under B named D move the contents of the old D to the new D delete the directory E beneath the new D create a new directory C under the new D move the contents of the old C to the new C

Re: [R] transform

2016-10-01 Thread Jim Lemon
Hi Val, Perhaps like this? valdat<-read.table(text="obs, Year, bb, kk, y 1, 2001, 25 ,100, 12.6 2, 2001, 15 ,111, 24.7 3, 2001, 53, 110, 13.8 4, 2001, 50, 75, 9.6 5, 2001, 125, 101, 31.5 6, 2001, 205, 407, 65.7 7, 2001, 250, 75, 69.1",sep=",",header=TRUE) selectval<-valdat$bb > 75

Re: [R] Produce multiple line graphs

2016-09-25 Thread Jim Lemon
Hi John, I know this is kind of dumb, but: plot(0,xlim=range(xx$Nit,na.rm=TRUE), ylim=range(xx$CT,na.rm=TRUE),type="n", xlab="Nit",ylab="CT") for(i in unique(xx$PID)) points(xx$Nit[xx$PID==i],xx$CT[xx$PID==i], pch=i,col=i,type="b") Jim On Mon, Sep 26, 2016 at 11:43 AM, John Sorkin

Re: [R] Replacing value with "1"

2016-09-22 Thread Jim Lemon
Hi Saba, Try this: df<-matrix(c(0,NA,0,0,0,1,1,1,0,0,1,0,0,0,NA),nrow=3) dimdf<-dim(df) df1<-df==1 df[cbind(rep(FALSE,dimdf[1]),df1[,-dimdf[2]])]<-1 Jim On Fri, Sep 23, 2016 at 12:27 PM, Saba Sehrish via R-help wrote: > Hi > > I have a matrix that contains 1565 rows and

Re: [R] Where is R installed on my Linux?

2016-09-20 Thread Jim Lemon
Hi Mike, Depending upon the flavor of Linux (looks like it's in the RedHat family) it will usually start by running the command "R" in a terminal. What does: which R say? Then look in the startup file (often in /usr/local/bin) for the R_HOME directory. Jim On Tue, Sep 20, 2016 at 9:38 AM,

Re: [R] Overlapping axis numbering and labels when using par(new=TRUE)?

2016-09-19 Thread Jim Lemon
Hi mviljamaa, Have a look a the twoord.plot function in the plotrix package. Jim On Tue, Sep 20, 2016 at 1:50 AM, mviljamaa wrote: > I'm trying to plot two data sets on the same plot by using par(new=TRUE). > > However this results in the axis numbering and labels being

Re: [R] Help modifying "aheatmap" or find a new heatmap package

2016-09-17 Thread Jim Lemon
Hi Michael, Maybe color2D.matplot (plotrix). Have a look at the examples. Jim On Sat, Sep 17, 2016 at 4:10 AM, Michael Young wrote: > I am currently using "aheatmap" which is generating heatmaps based on > Pearson correlation. My data consists of RPKM values for genes

Re: [R] with and evaluation

2016-09-08 Thread Jim Lemon
Hi Carl, order vs sort The order function just returns the indices necessary to put the object into the sorted order, while the sort function returns the sorted object. If you want to use the order function: newdf2<-df2[(order(df2[,1]),] Yes, "with" can be a bit challenging. Think of it as:

Re: [R] hello i have a question on music analysis and mathematical synthesis related to r code

2016-09-08 Thread Jim Lemon
Hi Darth, Have a look at the tuneR package. Jim On Thu, Sep 8, 2016 at 3:57 PM, darth brando wrote: > Apologies for the long title but it is semi specific a topic and yes I am a > noobs user to the system. I have read the guide and will attempt to adhere to > the

Re: [R] Resample with replacement to produce many rarefaction curves with same number of samples

2016-09-07 Thread Jim Lemon
Hi Nick, This is pretty rough, but it may help: pdf("rd.pdf") raredata<-rarecurve(cbind(netdata,netdata,netdata),label=FALSE, col=rgb(0,0,1,0.1),xlim=c(0,100),ylim=c(0,80)) rect(100,0,104,80,col="white",border=NA) dev.off() Jim On Wed, Sep 7, 2016 at 8:05 AM, Nick Pardikes

Re: [R] outliers in Box Plot

2016-09-05 Thread Jim Lemon
Hi Rosa, Your data never seem to get through. Nevertheless, here is a suggestion: rodat<-data.frame(id=1:20,age=sample(c("10-20","21-30","31-40"),20,TRUE), weight=c(sample(40:70,18),110,120)) robp<-boxplot(weight~age,rodat) rodat$id[which(rodat$weight %in% robp$out)] Jim On Mon, Sep 5, 2016

Re: [R] Treating a vector of characters as object names to create list

2016-09-04 Thread Jim Lemon
Hi Ryan, How about: names(merged.parameters)<-merging Jim On Mon, Sep 5, 2016 at 7:57 AM, Ryan Utz wrote: > Hello, > > I have a vector of characters that I know will be object names and I'd like > to treat this vector as a series of names to create a list. But, for the >

Re: [R] Error in reading subset of data from CSV file

2016-09-04 Thread Jim Lemon
Shouldn't get that with write.csv. Jim On Sun, Sep 4, 2016 at 9:29 PM, Christofer Bogaso <bogaso.christo...@gmail.com> wrote: > Didnt work getting unused argument error. > > On Sun, Sep 4, 2016 at 4:47 PM, Jim Lemon <drjimle...@gmail.com> wrote: >> I suppo

Re: [R] Error in reading subset of data from CSV file

2016-09-04 Thread Jim Lemon
I suppose you could try quote=TRUE Jim On Sun, Sep 4, 2016 at 8:13 PM, Christofer Bogaso <bogaso.christo...@gmail.com> wrote: > Thanks Jim. But my data is like that and I have to live with that. Any > idea on workaround. Thanks, > > On Sun, Sep 4, 2016 at 3:40 PM,

Re: [R] Error in reading subset of data from CSV file

2016-09-04 Thread Jim Lemon
Hi Christofer, You have embedded commas in your data structure. This is guaranteed to mess up a CSV read. Jim On Sun, Sep 4, 2016 at 5:54 PM, Christofer Bogaso wrote: > Hi again, > > I was trying to read a subset of Data from a CSV file using below code > as

Re: [R] Creating a loop with code from the mblm package

2016-09-04 Thread Jim Lemon
Hi Bailey, Treat it as a guess, but try this: for (i in c(1:3)){ y<-mydata[,i] x <- mblm(y ~ Year, mydata, repeated = FALSE) print(x) } I'm not sure that you can mix indexed columns with column names. Also, Year is column 4, no? Jim On Sun, Sep 4, 2016 at 11:43 AM, Bailey Hewitt

Re: [R] readBin documentation error

2016-09-02 Thread Jim Lemon
Hi Yucheng, Have a look at "An Introduction to R" (get there with "help.start()"), section : 3.1 Intrinsic attributes: mode and length The distinction between numeric and integer modes in R may not be obvious, but it is important at times. Jim On Fri, Sep 2, 2016 at 5:47 AM, Yucheng Song via

Re: [R] Same code on Mac?

2016-09-01 Thread Jim Lemon
Sometimes the problem stems from chronic exposure to user interfaces. Yesterday I prepared some material for a Mac user's presentation and said, "This text file tells you the names of the files you need for the presentation" the response was, "Can I click on it?" I deleted all the files in the

Re: [R] Looping through different groups of variables in models

2016-08-31 Thread Jim Lemon
Hi Kai, Perhaps something like this: kmdf<-data.frame(group=rep(c("exp","cont"),each=50), time=factor(rep(1:5,20)), condition=rep(rep(c("hot","cold"),each=25),2), value=sample(100:200,100)) for(timeindx in levels(kmdf$time)) { for(condindx in levels(kmdf$condition)) {

Re: [R] Exponential population model

2016-08-29 Thread Jim Lemon
Hi Josephine, Given the parameters you describe, you will probably have to write a function to update the database of animals at regular intervals. You can then run a number of repeats to get a better estimate of the final populations. I tried this and it appears to work. I don't know of any

Re: [R] Storing business hours

2016-08-25 Thread Jim Lemon
Hi Alexander, A time series comes to mind, but perhaps all you need is a matrix with 0s for closed and 1s for open. Each row is a shop. Column names as the times and the resolution is up to you. I think colSums will produce what you want. Jim On Fri, Aug 26, 2016 at 1:10 AM,

Re: [R] function that converts data into a form that can be included in a question to mailing list

2016-08-24 Thread Jim Lemon
Hi John, I think it is "dput". Jim On Thu, Aug 25, 2016 at 8:00 AM, John Sorkin wrote: > > There is a function that can be used to convert data structures such as a > data frame into a different format that allows the data to be sent to the > mailing list. The

Re: [R] aggregate

2016-08-23 Thread Jim Lemon
Hi Gang Chen, If I have the right idea: for(zval in levels(myData$Z)) crossprod(as.matrix(myData[myData$Z==zval,c("X","Y")])) Jim On Wed, Aug 24, 2016 at 8:03 AM, Gang Chen wrote: > This is a simple question: With a dataframe like the following > > myData <-

Re: [R] I had 1 problem with r

2016-08-22 Thread Jim Lemon
Hi SuBin, This seems to work: emp<-read.table(text="empno,ename,job,mgr,hiredate,sal,comm,deptno 7369,SMITH,CLERK,7902,1980-12-17,800,,20 7499,ALLEN,SALESMAN,7698,1981-02-20,1600,300,30 7521,WARD,SALESMAN,7698,1981-02-03,1250,500,30 7566,JONES,MANAGER,7839,1981-03-02,2975,,20

Re: [R] pheatmap breaks

2016-08-20 Thread Jim Lemon
Hi Adrian, I had to add an extra color, but this might do what you want: chxx<-matrix(runif(100,-3.32,4.422),nrow=10) chxx.cut<-as.numeric(cut(chxx,breaks=c(-3.5,-1.96,-1,0,1,1.96,5))) chxx.col<-c("#FF","#FF","#FF","#FF","#FF",NA)[chxx.cut] library(plotrix)

Re: [R] remove rows based on row mean

2016-08-18 Thread Jim Lemon
Hi Adrian, Try this: sm$rowmeans<-rowMeans(sm[,2:length(sm)]) sm<-sm[order(sm$Gene,sm$rowmeans,decreasing=TRUE),] sm[-which(duplicated(sm$Gene)),] Jim On Fri, Aug 19, 2016 at 7:33 AM, Adrian Johnson wrote: > Hi Group, > I have a data matrix sm (dput code given

Re: [R] [R Survey Analysis] Problem counting number of responses

2016-08-16 Thread Jim Lemon
Hi Lauren, As Sarah noted, if your blank responses are coming as NAs, it may be best to leave them alone until you have done the calculations: survey$responses<-!is.na(survey[,c("q1","q2","q3")]) survey$sum_survey<-rowSums(survey[,c("q1","q2","q3")],na.rm=TRUE) # the next line returns a logical

Re: [R] need some help with date

2016-08-14 Thread Jim Lemon
;-paste(x,collapse="/") return(xdate) } newx<-as.Date(sapply(xbits,long_year,new_century),"%m/%d/%Y") return(newx) } Jim On Mon, Aug 15, 2016 at 10:47 AM, Jim Lemon <drjimle...@gmail.com> wrote: > Hi Glenn, > Perhaps this will help: > > dateCentury<

Re: [R] Calendar embedded for event scheduling

2016-08-10 Thread Jim Lemon
Hi Sri Ram, Do you mean that you want to produce a Gantt chart? Have a look at the example for gantt.chart in the plotrix package. Jim On Wed, Aug 10, 2016 at 2:58 PM, Sriram Kumar wrote: > Dear all, > > i am presently doing the r codes for developing the shiny app fro

Re: [R] Visualising multiple temporal periods each with an associated value

2016-08-08 Thread Jim Lemon
as time evolves. That approach would not allow rectangles to expand over time, but that could be accommodated. It's more complicated than either of the two, but I think it can be done. Jim On Tue, Aug 9, 2016 at 8:19 AM, Jim Lemon <drjimle...@gmail.com> wrote: > Hi Loris, > This look

Re: [R] Visualising multiple temporal periods each with an associated value

2016-08-08 Thread Jim Lemon
Hi Loris, This looks a lot like a Gantt chart with variable bar widths. I'll check it when I have a bit of time and repost. JIm On Mon, Aug 8, 2016 at 6:12 PM, Loris Bennett wrote: > Hi, > > I want to visualise temporal events as rectangles, one side of the >

Re: [R] Conditionally remove rows with logic

2016-08-08 Thread Jim Lemon
Hi Jennifer, A very pedestrian method, but I think it does what you want. remove_rows_after_1<-function(x) { nrows<-dim(x)[1] rtr<-NA rtrcount<-1 got1<-FALSE thisID<-x$ID[1] for(i in 1:nrows) { if(x$ID[i] == thisID && got1) { rtr[rtrcount]<-i rtrcount<-rtrcount+1 } if(x$ID[i] !=

Re: [R] R help

2016-08-07 Thread Jim Lemon
d|word > and when I try to > names(unlist(sapply(vdat$tweet,grep,pattern=badwords))) there is a mistake. > I had this question before but do you know by any chance how to separate > just those words in a column badwords and not include NA's or blanks. > > Thank you, &g

Re: [R] R help

2016-08-06 Thread Jim Lemon
Hi Vladimir, Do you want something like this? vdat<-read.table(text="numberoftweet,tweet,locations,badwords 1,My cat is asleep,London,glum 2,My cat is flying,Paris,dashed 3,My cat is dancing,Berlin,mopey 4,My cat is singing,Rome,ill 5,My cat is reading,Budapest,sad 6,My cat is

Re: [R] SAS file

2016-08-06 Thread Jim Lemon
Hi Yuan, Your file didn't make it. The error message you got is generally due to a misspelt filename or to the file not being where you think it is. Jim On Fri, Aug 5, 2016 at 8:10 PM, Yuan Jian via R-help wrote: > Hello,I have a SAS formatted file as attached, when I use

Re: [R] Fwd: only plot borders of a region in a scatter plot

2016-08-04 Thread Jim Lemon
[i+1]) newy<-c(newy,y[i+1]) } lastdx<-dx lastdy<-dy } return(list(x=newx,y=newy)) } x<-c(5,4,4,3,2,2,1,1,2,2,3,4,5,5,6,6,7,8,8,9,8,7,7,6,6,5,5) y<-c(1,2,2,3,4,4,5,6,6,7,8,8,9,8,8,7,7,6,6,5,5,4,3,3,2,2,1) plot(1:9,type="n") lines(x,y) newxy<-pixel8(x,y) lin

Re: [R] Fwd: only plot borders of a region in a scatter plot

2016-08-04 Thread Jim Lemon
Hi Zun Yin, The first problem requires something like this: pixel8<-function(x,y,pixsize=1) { nsteps<-length(x)-1 newx<-x[1] newy<-y[1] for(i in 1:nsteps) { dx<-diff(x[i:(i+1)]) dy<-diff(y[i:(i+1)]) if(dx && dy) { newx<-c(newx,x[i]+dx,x[i]+dx) newy<-c(newy,y[i],y[i]+dy) } else

Re: [R] difftime in years

2016-08-04 Thread Jim Lemon
Hi Thomas, Be aware that if you are attempting to calculate "birthday age", it is probably better to do it like this: bdage<-function(dob,now) { dobbits<-as.numeric(unlist(strsplit(dob,"/"))) nowbits<-as.numeric(unlist(strsplit(now,"/"))) return(nowbits[3]-dobbits[3]- (nowbits[2]

Re: [R] Error code 100 when using the function “fitdist” from the fitdistrplus package

2016-08-04 Thread Jim Lemon
Hi Nelly, The message David suggested was about scaling the values, not adjusting the parameters. It is quite possible that the empirical distribution is nothing like beta or Weibull. Have you tried plotting the values with "density"? Jim On Fri, Aug 5, 2016 at 6:56 AM, Nelly Reduan

Re: [R] Multiple plot in a page

2016-08-03 Thread Jim Lemon
Hi Roslina, You only specify space for two plots in: par(mfrow=c(1,2)) However, you only try to plot two plots, so I will assume that you only want two. You haven't defined "x" in the above code, which will cause an error. The code below gives me two plots as I would expect (I made up the data

Re: [R] Read output:

2016-08-02 Thread Jim Lemon
Hi Roslina, As we do not know whether the file actually exists, all I can do is to suggest that you look in your file manager (Windows Explorer, probably) and see if the file is where you think it is. The problem is most likely a spelling error somewhere in the path or filename. Jim On Tue, Aug

Re: [R] How to Display Value Labels in R Outputs?

2016-07-30 Thread Jim Lemon
Hi Courtney, I haven't seen any answers to your question, and perhaps it is because others, like I, were unable to open the file you attached. The uninformative labels you are getting may be the names of values or the character value of factors. Is there a sample data set from the original file

Re: [R] store result of loop in df

2016-07-29 Thread Jim Lemon
Hi Alain, You are probably storing the result, replicated five times, in df$VAR. Each cycle of the loop replaces the last value with the current value. If you really want the entire output of binom.test in the last column: multi.binom.test<-function(xs,ns) { reslist<-list() for(i in

Re: [R] Extract data

2016-07-29 Thread Jim Lemon
;), row.names = c(NA, > -6L), class = "data.frame") > > Thank you. > > On Fri, Jul 29, 2016 at 2:30 PM, roslinazairimah zakaria > <roslina...@gmail.com> wrote: >> >> I have one more question, how do I get the sum for the years. Thank you. >> >

Re: [R] Extract data

2016-07-28 Thread Jim Lemon
Hi Roslina, Try this: aggbalok_mth[aggbalok_mth$year %in% 2009:2014,] Jim On Fri, Jul 29, 2016 at 1:12 PM, roslinazairimah zakaria wrote: > Dear r-users, > > I would like to extract year from 2009 to 2014 with the corresponding month > and rain amount. > > I tried this:

Re: [R] Subtraction with aggregate

2016-07-28 Thread Jim Lemon
Hi Gang, This is one way: gangdat<-read.table(text="subject QMemotion yi s1 75.1017 neutral -75.928276 s2 -47.3512 neutral -178.295990 s3 -68.9016 neutral -134.753906 s1 17.2099 negative -104.168312 s2 -53.1114 negative -182.373474 s3 -33.0322 negative

Re: [R] change the colour line in gamm4 plotting

2016-07-26 Thread Jim Lemon
Hi Maria, The "plot.gam" function doesn't use the "col" argument for lines, but does change the color of points in the second example on the help page. There doesn't seem to be an easy way to change the function to get what you want. Jim On Tue, Jul 26, 2016 at 11:47 PM, Maria Lathouri via

Re: [R] Ocr

2016-07-26 Thread Jim Lemon
e to be able to write my own script for this as I have many > images/ pdf's in a folder and would like to batch process them using an R > script!! > Thanks > > > On Tuesday, July 26, 2016, Jim Lemon <drjimle...@gmail.com> wrote: >> >> Hi Shane, >&g

Re: [R] Ocr

2016-07-26 Thread Jim Lemon
Hi Shane, FreeOCR is a really good place to start. http://www.paperfile.net/ Jim On Wed, Jul 27, 2016 at 6:11 AM, Shane Carey wrote: > Hi, > > Has anyone ever done any ocr in R?? I have some scanned images that I would > like to convert to text!! > Thanks > > > -- > Le

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