[R] How to plot? stack line plot with different Y axis

2014-03-17 Thread Jinsong Zhao
Hi there, I just find a fancy plot like the following: http://www.nature.com/nature/journal/v505/n7481/images_article/nature12784-f2.jpg I am wondering how to plot something like that in R. Which package will be convenient for doing such things. BTW, the link that points to R graph gallery

Re: [R] Deletion of rows

2014-03-17 Thread PIKAL Petr
Hi Just for completeness, if you want to get rid of all rows regardless in which column they are res3 - res1[complete.cases(res1),] identical(res2, res3) [1] TRUE Petr -Original Message- From: arun [mailto:smartpink...@yahoo.com] Sent: Friday, March 14, 2014 3:19 PM To: dila radi;

Re: [R] Issue with special assignment operator

2014-03-17 Thread AROONALOK PYNE
Thanks a lot Jeff for the reply. I usually do what you said i.e, return a value from the function and save it in the calling environment when I call the function, but I just wanted to experiment with the special assignment operator. Could you clarify a small doubt of mine : I agree that x refers

Re: [R] assigning dataframes in an ifelse statement

2014-03-17 Thread BEUTEL Terry S
Many thanks Jeff. Got it working now. -Original Message- From: Jeff Newmiller [mailto:jdnew...@dcn.davis.ca.us] Sent: Monday, 17 March 2014 3:21 PM To: BEUTEL Terry S; r-help@r-project.org Subject: Re: [R] assigning dataframes in an ifelse statement Solution is to not use ifelse. Use

Re: [R] Deletion of rows

2014-03-17 Thread arun
Hi Dila, Suppose 'dat' is the dataset:  str(dat) #'data.frame':    621 obs. of  5 variables: # $ V1: int  NA 8185 8186 8187 8188 8189 8190 8191 8192 8193 ... # $ V2: Factor w/ 3 levels 1948,1949,..: 3 1 1 1 1 1 1 1 1 1 ... # $ V3: Factor w/ 32 levels 1,10,11,..: 32 1 12 23 26 27 28 29 30 31 ...

Re: [R] assigning dataframes in an ifelse statement

2014-03-17 Thread peter dalgaard
On 17 Mar 2014, at 06:20 , Jeff Newmiller jdnew...@dcn.davis.ca.us wrote: Solution is to not use ifelse. Use if...else... Specifically, A - if (x==2) B else C (Newcomers may not immediately catch on to the fact that flow control statements in R are function calls with syntactic sugar, and

Re: [R] Issue with special assignment operator

2014-03-17 Thread Jeff Newmiller
Clearly not. I don't know why you think that should be the expected behaviour. They are different variables. --- Jeff NewmillerThe . . Go Live... DCN:jdnew...@dcn.davis.ca.us

Re: [R] How to plot? stack line plot with different Y axis

2014-03-17 Thread Jim Lemon
On 03/17/2014 05:07 PM, Jinsong Zhao wrote: Hi there, I just find a fancy plot like the following: http://www.nature.com/nature/journal/v505/n7481/images_article/nature12784-f2.jpg I am wondering how to plot something like that in R. Which package will be convenient for doing such things.

Re: [R] Overriding predict based on newdata...

2014-03-17 Thread David Winsemius
S3 classes only dispatch on the basis of the first parameter class. That was one of the reasons for the development of S4-classed objects. You say you have the expectation that the object is of a class that has an ordinary `predict` method presumably S3 in character, so you probably need to

Re: [R] data.table and R package check

2014-03-17 Thread ONKELINX, Thierry
This is workaround by defining the 'global variables' as NULL. Use it with caution. ### Fooling R CMD check transition_group_id - NULL ### Fooling R CMD check setkey(aligtable,transition_group_id,align_origfilename) ir. Thierry Onkelinx Instituut voor natuur- en bosonderzoek / Research

Re: [R] data.table and R package check

2014-03-17 Thread Prof Brian Ripley
On 17/03/2014 09:42, ONKELINX, Thierry wrote: This is workaround by defining the 'global variables' as NULL. Use it with caution. Better, see ?globalVariables (available since R 2.15.1). ### Fooling R CMD check transition_group_id - NULL ### Fooling R CMD check

Re: [R] data frame vs. matrix

2014-03-17 Thread Göran Broström
On 2014-03-16 23:56, Duncan Murdoch wrote: On 14-03-16 2:57 PM, Göran Broström wrote: I have always known that matrices are faster than data frames, for instance this function: dumkoll - function(n = 1000, df = TRUE){ dfr - data.frame(x = rnorm(n), y = rnorm(n)) if (df){

Re: [R] data frame vs. matrix

2014-03-17 Thread Göran Broström
On 2014-03-17 01:31, Jeff Newmiller wrote: Did you really intend to make all of the x values the same? Not at all; the code in the loop was in fact just nonsense. The point was to illustrate the huge difference in execution time. And that the relative difference seems to increase fast with

[R] Extract part of a list based on the value of one of the subsubscript (weird, but with a reproducible example for clarity sake)

2014-03-17 Thread sylvain willart
Dear R (list)-users I'm trying to extract part of a list based on the value of one of the subsubscript element As those things are usually quite complicated to explain, let me provide a simple reproducible example that closely matches my problem (although my actual list has a few thousands

Re: [R] Extract part of a list based on the value of one of the subsubscript (weird, but with a reproducible example for clarity sake)

2014-03-17 Thread Duncan Murdoch
On 14-03-17 7:27 AM, sylvain willart wrote: Dear R (list)-users I'm trying to extract part of a list based on the value of one of the subsubscript element As those things are usually quite complicated to explain, let me provide a simple reproducible example that closely matches my problem

[R] linear programming

2014-03-17 Thread Barbara Rogo
I have this problem with this form: min (A*X) under some constraints. the unknown is X that is a Matrix. I can't use the function linp because in it X is a vector.. How can I do??? Can you help me [[alternative HTML version deleted]] __

Re: [R] survfit question - Q1 and Q3 survival time?

2014-03-17 Thread Therneau, Terry M., Ph.D.
Try help(quantile.survfit) Terry Therneau --- begin included message --- Hello, I am using the function survfit in the 'survival' package. Calling the function produces the median survival time automatically, as below. sleepfit - survfit(Surv(timeb, death)~1) sleepfit Call:

Re: [R] Extract part of a list based on the value of one of the subsubscript (weird, but with a reproducible example for clarity sake)

2014-03-17 Thread sylvain willart
It works like a charm, Plus, this method (logical vector for list extraction) opens a wide range a possibilities for me, thanks a million Duncan 2014-03-17 12:55 GMT+01:00 Duncan Murdoch murdoch.dun...@gmail.com: On 14-03-17 7:27 AM, sylvain willart wrote: Dear R (list)-users I'm trying to

Re: [R] survreg and predict probability of failure

2014-03-17 Thread Therneau, Terry M., Ph.D.
-- begin included message --- Hi, I am fitting a weibull model as follows my models is s - Surv(DFBR$Time,DFBR$Censor) wei - survreg(s~Group+UsefulLife,data = DFBR,dist=weibull) How can i predict the probabilty of failure in next 10 days, for a new data with group =10 and usefuleLife =100

Re: [R] FrailtyHL package does not work

2014-03-17 Thread Therneau, Terry M., Ph.D.
I don't know much about the frailtyHL package, but from the description it appears to be fitting the same model as coxme. The latter is designed to work with large data sets. Terry Therneau __ R-help@r-project.org mailing list

Re: [R] data frame vs. matrix

2014-03-17 Thread Göran Broström
On 2014-03-17 00:36, William Dunlap wrote: Duncan's analysis suggests another way to do this: extract the 'x' vector, operate on that vector in a loop, then insert the result into the data.frame. Thanks Bill, that is a good improvement. Göran I added a df=quicker option to your df argument

Re: [R] smooth spline with R

2014-03-17 Thread Simon Wood
e.g... b - gam(Y~s(X)) ## fit gam.check(b) ## check fitted(b) ## fitted values predict(b,newdata=data.frame(X=c(15,16))) ## predictions at new X see ?predict.gam On 14/03/14 23:24, Parviz Zare wrote: Dear Sir, How I can obtain the predicted values of Y variable with fitting smooth

[R] data.table - How do I transform a set of column?

2014-03-17 Thread Witold E Wolski
I started to use the data.table to subset, reshape large data. But how do I transform a set of columns? # for a data.frame I would do: df = data.frame(a = c(a,b,c,d), b = 1:4,c = 1:4) df[,2:3] = df[,2:3]^2 # but with data.table this somehow similar code produces an error. dt = data.table(a =

Re: [R] mcr mcreg: Why are BCa and quantile se values calculated, stored, then the stored values set to NA?

2014-03-17 Thread Fabian Model
This piece of code is indeed confusing. Generally quantile and BCa bootstrap do not estimate a global SE, so the glob.sigma slot you want to access is not really meaningful for those methods. The result object of a BCa bootstrap as calculated by the mc.bootstrap function will contain a

Re: [R] data.table - How do I transform a set of column?

2014-03-17 Thread arun
Hi, May be this helps: dt1 - copy(dt)  dt[,c(b,c):=lapply(.SD,function(x) x^2),.SDcols=2:3] #or  for(.col in 2:3) set(dt1,j=.col,value=dt1[[.col]]^2) identical(dt,dt1) #[1] TRUE A.K. On Monday, March 17, 2014 10:27 AM, Witold E Wolski wewol...@gmail.com wrote: I started to use the

[R] Plot network communities

2014-03-17 Thread Roney Fraga Souza
Hello everyone, I'm trying to visualize a network with many vertices, where the focus is to detect the evolution of communities over time. My little network has 5000 vertices and 4 edges, and my biggest network has 24 vertices and approximately 2 million edges. I want to replicate

[R] naming files or lists

2014-03-17 Thread Olivier Charansonney
Hello, I would like to name files (.txt, .pdf or lists (or dataframes) with names composed from subjects' IDs, dates, and times e.g. 003DE, 03 17 2014 and 16:02:30 gives a file named 003DE-031714-160230.txt. How can I do that? Thanks for your help. [[alternative HTML version

Re: [R] linear programming

2014-03-17 Thread John P. Burkett
On 03/17/2014 07:57 AM, Barbara Rogo wrote: I have this problem with this form: min (A*X) under some constraints. the unknown is X that is a Matrix. I can't use the function linp because in it X is a vector.. How can I do??? Can you help me If X is a matrix, then A*X could be a matrix or

Re: [R] naming files or lists

2014-03-17 Thread Jeff Newmiller
Generate the desired name(s) as character variables and use those variables as the filename when saving it (them). ?paste ?paste0 ?sprintf ?format.POSIXct If you have not converted your timestamps to a time data type yet then you probably need to do that. You may be able to hack something

Re: [R] Extract part of a list based on the value of one of the subsubscript (weird, but with a reproducible example for clarity sake)

2014-03-17 Thread William Dunlap
ninths - sapply(MyFullList, function(x) x[[9]]) You use sapply so that the result is coerced to a character vector, and x[[9]] rather than x[9] so that each result is a scalar character. Using vapply instead of sapply will make the code a little more robust to errors, since it forces you

[R] open unknown file format in R

2014-03-17 Thread eliza botto
Dear R-Family, I have just downloaded a massive data file from internet (AphroJP_62STN_V1005.1900.gz). Apparently, the file is compressed with .gz. When I uncompressed it, the file was saved in the name (AphroJP_62STN_V1005.1900) of unknown format. How can I open it in R? thankyou very much

Re: [R] open unknown file format in R

2014-03-17 Thread Nordlund, Dan (DSHS/RDA)
-Original Message- From: r-help-boun...@r-project.org [mailto:r-help-bounces@r- project.org] On Behalf Of eliza botto Sent: Monday, March 17, 2014 12:06 PM To: r-help@r-project.org Subject: [R] open unknown file format in R Dear R-Family, I have just downloaded a massive data

Re: [R] open unknown file format in R

2014-03-17 Thread MacQueen, Don
If it's a text file, any of the usual functions, such as read.table(), scan(), etc. If it's a binary file, try readBin() It's up to you to find out what kind of a file it is, and how the data is structured within the file. (hint: on a unix-alike system, the 'file' command will tell you something

Re: [R] strangely long floating point with write.table()

2014-03-17 Thread Mike Miller
On Sun, 16 Mar 2014, Duncan Murdoch wrote: On 14-03-16 2:13 AM, Mike Miller wrote: I always knew there was some numerical reason why I was getting very long stretches of 9s or 0s in the write.table() output, but my concern is really with how to prevent that from happening. So the question

[R] ffload unzip not found

2014-03-17 Thread hannah
Dear all, I do have zipped data and want to use the package ff. Unfortunately I am not able to load the date: When I try to use ffload I always get: Error in system(cmd, intern = TRUE) : 'unzip' not found Conferring to other R-help posts I already downloaded a software for zipping/unzipping and

Re: [R] strangely long floating point with write.table()

2014-03-17 Thread Berend Hasselman
On 17-03-2014, at 21:03, Mike Miller mbmille...@gmail.com wrote: …... data[,c(5:9,11,13,17:21)] - signif(data[,c(5:9,11,13,17:21)], digits=5) Then write.table(data) does what I'd want. It works better than format(). Example: data2 - data data2[,c(5:9,11,13,17:21)] -

[R] Beginner: how to split up character string into different columns

2014-03-17 Thread jmcable
Hello, I'm an R beginner and am not sure how to address this question. I've read through tutorials and am still stuck. I have a column in my data called Sample. The samples are listed as four sites (SFHS, SFLS, NFLS, NFHS) with tree numbers (01 through 23) and replicates per tree (A and B). So, a

[R] error with sendplot

2014-03-17 Thread Straubhaar, Juerg
I am trying to use heatmap.send() in package sendplot with the example data given in 'A tutorial for sendplot R package', Section 4. The code I am using (copied from tutorial) is: data(mtcars) x - as.matrix(mtcars) xy.labels=list(value=x) x.labels=data.frame(label=colnames(x),

Re: [R] How to plot? stack line plot with different Y axis

2014-03-17 Thread Jinsong Zhao
On 2014/3/17 1:12, Jim Lemon wrote: On 03/17/2014 05:07 PM, Jinsong Zhao wrote: Hi there, I just find a fancy plot like the following: http://www.nature.com/nature/journal/v505/n7481/images_article/nature12784-f2.jpg I am wondering how to plot something like that in R. Which package will

[R] is it possible to get the coordinate of mtext()?

2014-03-17 Thread Jinsong Zhao
Hi there, I hope to rotate the Y label of axis(4) with -90 degree. I can typeset the Y label using text() with srt = -90. However, I cannot get the coordinate of the position that mtext() used. In other words, I hope to convert: mtext(Y label, side = 4, at = 0, line = 2) to text(x, 0, Y

Re: [R] strangely long floating point with write.table()

2014-03-17 Thread Mike Miller
On Mon, 17 Mar 2014, Berend Hasselman wrote: On 17-03-2014, at 21:03, Mike Miller mbmille...@gmail.com wrote: …... data[,c(5:9,11,13,17:21)] - signif(data[,c(5:9,11,13,17:21)], digits=5) Then write.table(data) does what I'd want. It works better than format(). Example: data2 - data

Re: [R] Beginner: how to split up character string into different columns

2014-03-17 Thread Peter Alspach
Tena koe Jessie Lots of ways of doing this. Perhaps the easiest, if your data is formatted as you suggest, is to use substring; e.g., substring(yourData$Sample, 1, 4) should give you the sites. Otherwise, you might need to investigate regular expressions. HTH . Peter Alspach

Re: [R] is it possible to get the coordinate of mtext()?

2014-03-17 Thread Jim Lemon
On 03/18/2014 09:18 AM, Jinsong Zhao wrote: Hi there, I hope to rotate the Y label of axis(4) with -90 degree. I can typeset the Y label using text() with srt = -90. However, I cannot get the coordinate of the position that mtext() used. In other words, I hope to convert: mtext(Y label, side =

Re: [R] strangely long floating point with write.table()

2014-03-17 Thread Duncan Murdoch
On 14-03-17 6:22 PM, Mike Miller wrote: On Mon, 17 Mar 2014, Berend Hasselman wrote: On 17-03-2014, at 21:03, Mike Miller mbmille...@gmail.com wrote: …... data[,c(5:9,11,13,17:21)] - signif(data[,c(5:9,11,13,17:21)], digits=5) Then write.table(data) does what I'd want. It works better than

[R] mgcv, should include a intercept for the 'by' varying coefficient model, which is unconstrained

2014-03-17 Thread Xing Zhao
Dear Dr. Wood and other mgcv experts In ?gam.models, it says that the numeric by variable is genrally not subjected to an identifiability constraint, and I used the example in ?gam.models, finding some differences (code below). I think the the problem might become serious when several varying

Re: [R] Beginner: how to split up character string into different columns

2014-03-17 Thread arun
Hi, May be this helps: dat - read.table(text=Sample SFLS01A SFHS05B,sep=,header=TRUE,stringsAsFactors=FALSE) dat1 - setNames(as.data.frame(do.call(rbind,strsplit(gsub(([[:alpha:]]+)(\\d+)([[:alpha:]]+),\\1 \\2 \\3,dat$Sample), )),stringsAsFactors=FALSE),c(site,tree,rep)) #or  dat2 -

Re: [R] open unknown file format in R

2014-03-17 Thread Pascal Oettli
Hello, It is in binary format. I didn't use stations. But to read the gridded format, I used: readBin(fid, numeric(), n=1e8, size=4, signed=TRUE, endian='little') where file is the connection created with file() Hope this helps, Pascal On Tue, Mar 18, 2014 at 4:06 AM, eliza botto

Re: [R] Link prediction in social network with R

2014-03-17 Thread Yogesh Vaghela
hi i am also doing my master degree in link prediction in social network so i need your help.. which tool should i used for that ?? Waiting for your reply __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help

Re: [R] strangely long floating point with write.table()

2014-03-17 Thread Mike Miller
On Mon, 17 Mar 2014, Duncan Murdoch wrote: On 14-03-17 6:22 PM, Mike Miller wrote: Thanks! Another thing I've figured out: Use of drop0trailing=T in format() fixes the .0 stuff that I didn't like: write.table(format(data[1:10,], digits=5, trim=T, drop0trailing=T), row.names=F,

Re: [R] is it possible to get the coordinate of mtext()?

2014-03-17 Thread Jinsong Zhao
On 2014/3/17 15:32, Jim Lemon wrote: On 03/18/2014 09:18 AM, Jinsong Zhao wrote: Hi there, I hope to rotate the Y label of axis(4) with -90 degree. I can typeset the Y label using text() with srt = -90. However, I cannot get the coordinate of the position that mtext() used. In other words, I

[R] locpoly is returning NaN if bandwidth is small

2014-03-17 Thread Xu Wang
The following call to locpoly gives a 'NaN' on one computer and a number on a different computer: library(KernSmooth) x - c(5.84155992364115, 1.55292112974119, 0.0349665318792623, 3.93053647398094, 3.42790577684633, 2.9715553006801, 0.837108410045353, 2.872476865277, 3.89232548092257,

[R] Error Message Help

2014-03-17 Thread Joe Trubisz
Hi... Can someone please explain to me what this error message means? It only appears if I include the correlation= part, but I have no idea why. Thanks, Joe ARModel -lme(Life_Satisfaction ~Time, data = restructuredData, random = ~Time|Person, method = ML, na.action = na.exclude, control =

[R] Beginner: How do I copy the results from a for loop in a csv file?

2014-03-17 Thread koushiki sarkar
Hello I am using 2 for loops to find the difference between all rows of a matrix. I need to store it to a csv file. I have written this: for (i in 0:length(datamat)){ for (j in i+1:length(datamat)){ x-datamat[i,]-datamat[j,]; y-as.data.frama(x); write.csv(y, dif.csv) }} datamat is the original

[R] Reshaping Data in R - Transforming Two Columns Into One

2014-03-17 Thread Abraham Mathew
I have the following data frame. Using the stringr package, I've attempted to map the url's to some specific elements that are in each url. I then used the reshape package to join two different data frames. The next step is to transform the two columns in the mydt data frame (forester and

Re: [R] survfit question - Q1 and Q3 survival time?

2014-03-17 Thread David Winsemius
On Mar 17, 2014, at 5:14 AM, Therneau, Terry M., Ph.D. wrote: Try help(quantile.survfit) Very handy, now that I know to look for it. I wonder if you could add quantile.survfit, lines.survfit, and points.survfit to links on the help page for survfit.object? (I generally look for the list of

Re: [R] Beginner: How do I copy the results from a for loop in a csv file?

2014-03-17 Thread Peter Alspach
Tena koe What are you doing wrong? For one thing not supplying a simple reproducible example :-) Try: set.seed(12) (tempMat - matrix(round(100*runif(12), 0), nrow=3)) [,1] [,2] [,3] [,4] [1,]7 27 181 [2,] 82 17 64 39 [3,] 9432 81 (diffMat - apply(tempMat,

Re: [R] Beginner: How do I copy the results from a for loop in a csv file?

2014-03-17 Thread Bert Gunter
1. I would strongly recommend that you spend some time with one of the many R tutorials (An Introduction to R ships with R, but there are many more on the web) before attempting to write any further code or posting here. 2. Post in plaiin text, not HTML, as code can get scrambled in HTML. Bert