[R] Use "append" in the function write.xlsx2 or write.xlsx (openxlsx package)

2016-05-02 Thread jpm miao
Hi, I am trying to print several dataset in several different sheets of the same xlsx file. I sometimes run the codes more than once, and I need to erase all things in the target file, and I do not use "append" in the first function call. However I want to write it in a loop. Is there a way to

Re: [R] Extracting rows of a data.frame by "identical"

2016-05-02 Thread Ulrik Stervbo
Can you use subset? subset(d, b == 4 & c == 10) Best Ulrik On Tue, 3 May 2016 04:58 jpm miao, wrote: > Is it possible? I am expecting the result to be the second row of the data > frame ... > > > d<-data.frame(a=1:3, b=3:5,c=9:11) > > d > a b c > 1 1 3 9 > 2 2 4 10 > 3

[R] Extracting rows of a data.frame by "identical"

2016-05-02 Thread jpm miao
Is it possible? I am expecting the result to be the second row of the data frame ... d<-data.frame(a=1:3, b=3:5,c=9:11) > d a b c 1 1 3 9 2 2 4 10 3 3 5 11 > d[identical(d[c("b","c")],c(4,10)),] [1] a b c <0 rows> (or 0-length row.names) [[alternative HTML version deleted]]

Re: [R] Network Layouting in R

2016-05-02 Thread Sarah Goslee
Hi, On Mon, May 2, 2016 at 8:36 AM, Kushank Chhabra wrote: > Hi, > > > > I am trying to plot a network diagram of around 1500 component (as nodes) > and many connections (as edges) within them. > I tried igraph package, however unable to create a layout where

Re: [R] how to use AND in grepl

2016-05-02 Thread Tom Wright
Sorry for the missed braces earlier. I was typing on a phone, not the best place to conjugate regular expressions. Using the example you provided: > df=data.frame(Command=c("_localize_PD", "_localize_tre_t2", "_abdomen_t1_seq", "knee_pd_t1_localize", "pd_local_abdomen_t2")) >

[R] Network Layouting in R

2016-05-02 Thread Kushank Chhabra
Hi, I am trying to plot a network diagram of around 1500 component (as nodes) and many connections (as edges) within them. I tried igraph package, however unable to create a layout where there is no overlap of nodes or edges. More or less tried all the things mentioned in this link -

Re: [R] Help regarding Community Detection Algorithm in R (like Propagation, Walktrap)

2016-05-02 Thread Giorgio Garziano
You may look at: http://rseek.org/?q=community%20detection -- Best, GG [[alternative HTML version deleted]] __ R-help@r-project.org mailing list -- To UNSUBSCRIBE and more, see https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read

Re: [R] How to print the frequency table (produced by the command "table" to Excel

2016-05-02 Thread Bert Gunter
Don't know if this would help, but you could always set an attribute of alphatab to be the dimnames. See ?attrib . Of course you would then have to write a custom print() function, possibly along the lines you indicated. You could also do this via S3 (or whatever) classes, of course. But again,

Re: [R] Issue installing packages - Linux

2016-05-02 Thread Shouro Dasgupta
Hello Lara, I recently installed a number of packages through compiling. After downloading the package using 'wget', running R CMD INSTALL package.tar.gz should work. Sincerely, Shouro On Mon, May 2, 2016 at 5:17 PM, Lars Bishop wrote: > Thanks Jim. I don't think that is

[R] Help regarding Community Detection Algorithm in R (like Propagation, Walktrap)

2016-05-02 Thread Swagatam Basu
Hi I am very new to R studio and R language. I have installed the R studio in my machine. I need to do a community detection of a set of message. I have a Matrix for that. Is there any sample code /Package/ website is present which will help me to understand/do this community Detection (like

Re: [R] how to use AND in grepl

2016-05-02 Thread ch.elahe via R-help
Thanks Peter, you were right, the exact grepl is grepl("(.*t2.*pd.*)|(.*pd.*t2.*)",df$Command), but it does not change anything in Command, when I check the size of it by sum(grepl("(.*t2.*pd.*)|(.*pd.*t2.*)",df$Command)) the result is 0, but I am sure that the size is not 0. It seems that

Re: [R] Issue installing packages - Linux

2016-05-02 Thread Lars Bishop
Thanks Jim. I don't think that is the issue...if anyone else can shed some light here, that would be much appreciated. Regards Lars. On Saturday, 30 April 2016, Jim Lemon wrote: > Hi Lars, > A mystery, but for the bodgy characters in your error message. Perhaps > there is

Re: [R] how to use AND in grepl

2016-05-02 Thread Tom Wright
The first thing I notice here is that your first two subset statements are searching in an object named Command, not the column df$Command. I'm not at all sure what you are trying to achieve with the str_extract process but it is looking for the exact string 'PDT2' the vectors / dataframe formed

Re: [R] how to use AND in grepl

2016-05-02 Thread ch.elahe via R-help
Yes it works, but let me explain what I am going to do. I extract all the names I want and then create a new column out of them for my plot. This is he whole thing I do: PD=subset(df,grepl("pd",Command)) //extract names in Command with only "pd" t2=subset(df,grepl("t2",Command)) //extract

Re: [R] tcltk: click and return table cell index

2016-05-02 Thread Dalthorp, Daniel
Thanks, John. The trouble with that solution is that it gives the index for where the cursor was before clicking rather than the cell that was clicked. The solution is that the binding gives the x, y pixel coordinates of the click to the callback, and the pixel coordinates can be translated to

[R] Generating 3Dplot in lattice package

2016-05-02 Thread T.Riedle
Dear R users, I am trying to generate a 3D plot using the wireframe() function in the lattice package. The corresponding formula in Excel looks as follows and is applied to the wireframe() function: MIN(psi/K14,EXP(((ABS(H14)/peak)^omega)*LN(psi/K14))) I tried to "translate" this formula in

[R] Can't rename a data frame column

2016-05-02 Thread jpm miao
Hi, Could someone suggest a way to rename a data frame column? For example, I want to rename the column beta, but I can't do it this way > d <- data.frame(alpha=1:3, beta=4:6, gamma=7:9) > mm<-"beta" > rename(d, c(mm="two", "gamma"="three")) The following `from` values were not present in

[R] greek characters in Figures

2016-05-02 Thread Alaios via R-help
Dear all,I am trying to write in my Figure labels short equations that contain greek characters For example:  C(h) = sigma^2 * rho(h).    I am googling it and there are many packages available but unfortunately they do not look available for my 3.2.4 latex version

Re: [R] greek characters in Figures

2016-05-02 Thread Martin Maechler
> Alaios via R-help > on Mon, 2 May 2016 17:32:34 + writes: > Dear all,I am trying to write in my Figure labels short equations that contain greek characters > For example:  C(h) = sigma^2 * rho(h).    > I am googling it and there are many

Re: [R] Can't rename a data frame column

2016-05-02 Thread Boris Steipe
You need to learn about proper subsetting, and the names() function. Consider the following: R > d <- data.frame(alpha=1:3, beta=4:6, gamma=7:9) R > d alpha beta gamma 1 14 7 2 25 8 3 36 9 R > names(d) [1] "alpha" "beta" "gamma" R > names(d) == "beta" [1]

Re: [R] how to use AND in grepl

2016-05-02 Thread ch.elahe via R-help
I just changed all the names in Command to lowercase, then this str_extract works fine for "pd" and "t2", but not for "PDT2". Do you have any idea how I can bring PDT2 also in str_extract? On Monday, May 2, 2016 9:16 AM, Tom Wright wrote: The first thing I notice here

Re: [R] Removing NAs from dataframe (for use in Vioplot)

2016-05-02 Thread Martin Maechler
> Bert Gunter > on Mon, 2 May 2016 06:20:52 -0700 writes: > Martin et. al.: > na.omit(frame) will remove all rows/cases in which an NA occurs. I'm > not sure that this is what the OP wanted, which seemed to be to > separately remove NA's from

[R] Backtesting VaR using rugarch package

2016-05-02 Thread T.Riedle
Dear R users, I am trying to backtest VaR using the rugarch package. My code looks as follows VaRTest(alpha=0.025,Backtesting_BuVaR$Log.return,Backtesting_BuVaR$VaR,conf.level = 0.975) R returns following output. I don't understand why I get NAs except for the critical values. Does anyone have

Re: [R] Can't rename a data frame column

2016-05-02 Thread Thierry Onkelinx
Or you dplyr library(dplyr) d <- data.frame(alpha=1:3, beta=4:6, gamma=7:9) mm <- "beta" rename_(d, "two" = mm, "three" = "gamma") ir. Thierry Onkelinx Instituut voor natuur- en bosonderzoek / Research Institute for Nature and Forest team Biometrie & Kwaliteitszorg / team Biometrics & Quality

Re: [R] how to use AND in grepl

2016-05-02 Thread John McKown
On Mon, May 2, 2016 at 1:01 PM, ch.elahe via R-help wrote: > I just changed all the names in Command to lowercase, then this > str_extract works fine for "pd" and "t2", but not for "PDT2". Do you have > any idea how I can bring PDT2 also in str_extract? > Looking at

Re: [R] greek characters in Figures

2016-05-02 Thread David Winsemius
> On May 2, 2016, at 10:32 AM, Alaios via R-help wrote: > > Dear all,I am trying to write in my Figure labels short equations that > contain greek characters > > For example: C(h) = sigma^2 * rho(h). > > I am googling it and there are many packages available but

Re: [R] how to use AND in grepl

2016-05-02 Thread Tom Wright
Please try to read my earlier comments. In the absence of a proper example with expected output I think what you are trying to achieve is: # create a sample dataframe df <- data.frame(Command=c("_localize_PD", "_localize_tre_t2", "_abdomen_t1_seq", "knee_pd_t1_localize", "pd_local_abdomen_t2"))

Re: [R] Generating 3Dplot in lattice package

2016-05-02 Thread William Dunlap via R-help
For starters, use 'pmin' (parallel min) instead of 'min'. substitute(MIN(psi/K14,EXP(((ABS(H14)/peak)^omega)*LN(psi/K14))), list(MIN=quote(pmin), K14=quote(VaR), ABS=quote(abs), EXP=quote(exp), LN=quote(log), H14=quote(Bmax), omega=quote(w2))) # pmin(psi/VaR,

Re: [R] inserting row(column) in array or dataframe at specified row(column)

2016-05-02 Thread PIKAL Petr
Hi You can use rbind, cbind but you need to be aware of what objects you are binding together. mm<-matrix(rnorm(12), 3,4) > rbind(mm[1:2,], 1:4, mm[3,]) [,1] [,2] [,3] [,4] [1,] -0.2029407 -1.5910628 -0.2582281 -0.1649921 [2,] -0.6913951 0.3591561 0.8236836

Re: [R] Removing NAs from dataframe (for use in Vioplot)

2016-05-02 Thread Martin Maechler
> Mike Smith > on Sun, 1 May 2016 08:15:44 +0100 writes: On Apr 30, 2016, at 12:58 PM, Mike Smith wrote: Hi First post and a relative R newbie I am using the vioplot library to produce some violin

[R] Retrieving response variable in the probit

2016-05-02 Thread Steven Yen
Can anyone tell me how to retrieve the response (dependent) variable from a probit regression object (as much as model.matrix(obj) retrieves the data matrix). Below is a self-runnable set of codes. Thank you! library(sampleSelection)

[R] Order of bars w geom_errorbarh ??

2016-05-02 Thread Judson Blake
Using geom_errorbarh with ggplot, my plot has several error bars. For my presentation, the order of these bars from top to bottom is important. But errorbarh seems to put these in a random order I can't change. ( It does not follow the order in the data.frame. )How can I specify the order

[R] Accessing terminal datasets in Ctree()

2016-05-02 Thread Preetam Pal
Hi guys, If I am applying ctree() on a data (specifying some control parameters like maxdepth), is there a way I can programmatically access the (smaller) datasets corresponding to the terminal nodes in the tree? Say, if there are 7 terminal nodes, I need those 7 datasets (of course, I can look

Re: [R] Accessing terminal datasets in Ctree()

2016-05-02 Thread Achim Zeileis
On Mon, 2 May 2016, Preetam Pal wrote: Hi guys, If I am applying ctree() on a data (specifying some control parameters like maxdepth), is there a way I can programmatically access the (smaller) datasets corresponding to the terminal nodes in the tree? Say, if there are 7 terminal nodes, I need

Re: [R] Accessing terminal datasets in Ctree()

2016-05-02 Thread Preetam Pal
Again, really appreciate your help on this. Thanks, Achim. -Preetam On Tue, May 3, 2016 at 3:22 AM, Achim Zeileis wrote: > On Mon, 2 May 2016, Preetam Pal wrote: > > Great, thank you so much Achim.But one issue, in case I do not know how >> many >> terminal nodes would

Re: [R] Create a new variable and concatenation inside a "for" loop

2016-05-02 Thread Raubertas, Richard
What nonsense. There is a group of finger-waggers on this list who jump on every poster who uses the name of an R function as a variable name. R is perfectly capable of distinguishing the two, so if 'c' (or 'data' or 'df', etc.) is the natural name for a variable then go ahead and use it.

Re: [R] Accessing terminal datasets in Ctree()

2016-05-02 Thread Preetam Pal
Great, thank you so much Achim. But one issue, in case I do not know how many terminal nodes would be there, what do I do? Note that I do not need the datasets corresponding to the intermediate nodes only need the terminal datasets. Regards, Preetam On Tue, May 3, 2016 at 3:08 AM, Achim Zeileis

Re: [R] Accessing terminal datasets in Ctree()

2016-05-02 Thread Achim Zeileis
On Mon, 2 May 2016, Preetam Pal wrote: Great, thank you so much Achim.But one issue, in case I do not know how many terminal nodes would be there, what do I do? Note that I do not need the datasets corresponding to the intermediate nodes only need the terminal datasets. With predict(ct, type

Re: [R] how to use AND in grepl

2016-05-02 Thread peter dalgaard
On 02 May 2016, at 12:43 , ch.elahe via R-help wrote: > Thanks for your reply tom. After using > Subset(df,grepl("(.*t2.*pd.*)|(.*pd.*t2.*)"),df$Command) I get this error: > Argument "x" is missing, with no default. Actually I don't know how to fix > this. Do you have

Re: [R] Removing NAs from dataframe (for use in Vioplot)

2016-05-02 Thread Bert Gunter
Martin et. al.: na.omit(frame) will remove all rows/cases in which an NA occurs. I'm not sure that this is what the OP wanted, which seemed to be to separately remove NA's from each column and plot the resulting column. This is what the lapply (and the OP's provided code) does, anyway. Also,

[R] Rserve() error in the first instance of running a Java application

2016-05-02 Thread Purva Kulkarni
Hi, I am writing a Java GUI application which uses Rserve(). I have a java script which sends a command to the shell to start Rserve(). When I run the Java main method for the very first time, it calls this script to invoke Rserve() and starts Rserve(). But, in this first run the Java GUI

Re: [R] Create a new variable and concatenation inside a "for" loop

2016-05-02 Thread Tom Wright
As pointed out somewhere in the replies to this you can always use the exists() function. for(i in 1:5){ if(exists(output)){ output <- c(output, i ) }else{ output <- i } } On Wed, Apr 27, 2016, 11:15 AM Gordon, Fabiana < fabiana.gor...@imperial.ac.uk> wrote: > Hello, >

Re: [R] Create a new variable and concatenation inside a "for" loop

2016-05-02 Thread Rolf Turner
You are quite wrong. This is not "nonsense"; it is sound advice. It is true that R is capable of distinguishing between a function and a non-function object with the same name. However there are many circumstances in which using a function's name for the name of a data object will lead

Re: [R] How to print the frequency table (produced by the command "table" to Excel

2016-05-02 Thread Jim Lemon
Hi jpm miao, After a fair stretch of fooling around with it, I can't see any way to add the variable names ("varnames") to the output of delim.table without breaking it for things other than table objects. You can probably do this as a one-off hack by setting the names of the dimnames of the

Re: [R] how to use AND in grepl

2016-05-02 Thread ch.elahe via R-help
Thanks for your reply tom. After using Subset(df,grepl("(.*t2.*pd.*)|(.*pd.*t2.*)"),df$Command) I get this error: Argument "x" is missing, with no default. Actually I don't know how to fix this. Do you have any idea? Thanks, Elahe On Saturday, April 30, 2016 7:35 PM, Tom Wright

Re: [R] Retrieving response variable in the probit

2016-05-02 Thread Achim Zeileis
On Mon, 2 May 2016, Steven Yen wrote: Can anyone tell me how to retrieve the response (dependent) variable from a probit regression object (as much as model.matrix(obj) retrieves the data matrix). Below is a self-runnable set of codes. Thank you! library(sampleSelection)

Re: [R] Order of bars w geom_errorbarh ??

2016-05-02 Thread Jeff Newmiller
Ordering of any discrete values in ggplot goes according to the levels of the factor. As a convenience, ggplot will convert character values into factor for you according to the default order alphabetical). To take control of this you have to convert your discrete columns to factors yourself

[R-es] Script sin resultados (SOLUCIONADO)

2016-05-02 Thread Manuel Máquez
Carlos: Muchísimas gracias nuevamente, en mi anterior había dicho que te comentaría, y, ahora lo hago. Quería 'comerme el pastel con una mordida', era necesario tomar un vector y 'exprimirlo' quedando finalmente así: library(ggplot2) ogl <- read.csv('T06.csv') re <- ogl[ogl[,3] <= 9,]#