Re: [R] list of vectors which are part of an initial vector

2015-01-12 Thread Jeff Newmiller
library(gtools) running(1:5, fun=I, align=center, width=3, allow.fewer=TRUE)[c(-1,-7)] Clue found at http://stackoverflow.com/questions/1311920/lagging-variables-in-r --- Jeff NewmillerThe .

[R] Suggestions for workaround for R Markdown problem with data() ?

2015-01-12 Thread Molly Elliott
R version: 3.1.2 (2014-10-31) RStudio version: 0.98.1091 MacOS X Yosemite v. 10.10.1 When I run the following in the console, all is well: data(IlluminaHumanMethylation450kanno.ilmn12.hg19) Yet, when I compile in my .Rmd file, in RStudio (knit to PDF), I get the following error: Error in

[R] Need help on Support. CEs

2015-01-12 Thread 朴美艳
Hi, I am a student from Korea. Currently I use Support. CEs package to conduct a choice-based conjoint analysis, but encounter some problems.I hope I can get a solution here. Here's my problem.I 've done the design matrix data set, and have a respondent data set. But when I try to use the

Re: [R] R vs. RStudio?

2015-01-12 Thread peter dalgaard
On 11 Jan 2015, at 11:30 , Duncan Murdoch murdoch.dun...@gmail.com wrote: - I don't like the tiled display. I find it doesn't give me enough space. This is a mixed blessing. For teaching purposes, it helps avoid shuffling windows to uncover the editor, graph window, and terminal in

Re: [R] Suggestions for workaround for R Markdown problem with data() ?

2015-01-12 Thread ONKELINX, Thierry
Dear Molly, Is the package in which the data is stored loaded in the Rmd? If not try library(yourPackage) data(yourData) or data(yourData, package = yourPackage) If this doesn't solve your problem, please provide a minimal reproducible example of the problem. Best regards, Thierry ir.

Re: [R] R vs. RStudio?

2015-01-12 Thread Jeff Newmiller
If you have two screens the zoom plot window can fill the second screen. Some laptops can handle a second external screen if you use a docking station. --- Jeff NewmillerThe . . Go

Re: [R] Suggestions for workaround for R Markdown problem with data() ?

2015-01-12 Thread Jeff Newmiller
When you start off by saying it works fine in the console, it starts sounding like not a question that belongs here. It actually is possible to run knitr/rmarkdown in the console without RStudio, so you could try that but to me it sounds suspiciously like a bug in RStudio. Ask on their support

Re: [R] Calculate the median age interval

2015-01-12 Thread Jose Iparraguirre
Dear Erik, There may be more elegant solutions, but try this: a. Create a data frame with your data, for example data - data.frame(agegrp, y1994, y1995, y1996) b. Then use the which function: as.character(aa$agegrp[which(aa$y1994==23)]) Hope it helps, José Prof. José Iparraguirre Chief

Re: [R] Calculate the median age interval

2015-01-12 Thread Ted Harding
Sorry, a typo in my reply below. See at ###. On 12-Jan-2015 11:12:43 Ted Harding wrote: On 12-Jan-2015 10:32:41 Erik B Svensson wrote: Hello I've got a problem I don't know how to solve. I have got a dataset that contains age intervals (age groups) of people and the number of persons in

[R] ggplot barchart: bars don't stock on breaks

2015-01-12 Thread najuzz
Hi guys, I have the following weired problem. I just want a simple barchart, but the visuals are different from what I expect. xx-as.vector(xx) xx[1:4852]-0 xx[4853:5941]-1 table(xx) x-data.frame(xx) ggplot(x,aes(xx))+geom_bar(binwidth = 0.5)

[R] rename columns with pattern

2015-01-12 Thread Kuma Raj
I want to rename columns 1 to 6 in the sample data set as bp_1 to bp_6. How could I do that in R? Thanks dput(dff) structure(list(one = c(1.00027378507871, 0.982313483915127, 1.1531279945243, 1.07400410677618, 1.22710472279261, 1.19762271047046, 1.10904859685147, 1.32060232717317), two =

Re: [R] rename columns with pattern

2015-01-12 Thread Jeff Newmiller
Read the help page for the names function: ?names ... note particularly the examples section. You might also find the fact that the paste0 function works on vectors to be helpful: paste0( bp_, 1:6 ) --- Jeff Newmiller

Re: [R] ggplot barchart: bars don't stock on breaks

2015-01-12 Thread Boris Steipe
Barcharts are for categorical data, the axis only serves to organize the category labels. From the sound of it, you are looking for a histogram. Hope this helps, Boris On Jan 12, 2015, at 8:31 AM, najuzz mj...@gmx.de wrote: Hi guys, I have the following weired problem. I just want a simple

Re: [R] rename columns with pattern

2015-01-12 Thread Ivan Calandra
Hi! Nice example! You just need to learn about the functions names() and paste(): names(dff)[1:6] - paste(bp, 1:6, sep=_) HTH, Ivan -- Ivan Calandra, ATER University of Reims Champagne-Ardenne GEGENAA - EA 3795 CREA - 2 esplanade Roland Garros 51100 Reims, France +33(0)3 26 77 36 89

Re: [R] nonmonotonic glm?

2015-01-12 Thread Vito M. R. Muggeo
dear Stanislav, Your data show two slopes with a kink at around 0. Thus, yet another approach would be to use segmented regression to fit a piecewise linear relationship with unknown breakpoint (being estimated as part of model fitting). While the resulting fitting is likely to be (slightly)

Re: [R] R vs. RStudio?

2015-01-12 Thread peter dalgaard
On 12 Jan 2015, at 09:28 , Jeff Newmiller jdnew...@dcn.davis.ca.us wrote: If you have two screens the zoom plot window can fill the second screen. Some laptops can handle a second external screen if you use a docking station. Unfortunately, such luxury is not available in the classroom. All

Re: [R] two-sample KS test: data becomes significantly different after normalization

2015-01-12 Thread Andrews, Chris
The main issue is that the original distributions are the same, you shift the two samples *by different amounts* (about 0.01 SD), and you have a large (n=1000) sample size. Thus the new distributions are not the same. This is a problem with testing for equality of distributions. With large

Re: [R] R vs. RStudio?

2015-01-12 Thread Hadley Wickham
On Mon, Jan 12, 2015 at 2:01 AM, peter dalgaard pda...@gmail.com wrote: On 11 Jan 2015, at 11:30 , Duncan Murdoch murdoch.dun...@gmail.com wrote: - I don't like the tiled display. I find it doesn't give me enough space. This is a mixed blessing. For teaching purposes, it helps avoid

Re: [R] Calculate the median age interval

2015-01-12 Thread Ted Harding
On 12-Jan-2015 10:32:41 Erik B Svensson wrote: Hello I've got a problem I don't know how to solve. I have got a dataset that contains age intervals (age groups) of people and the number of persons in each age group each year (y1994-y1996). The number of persons varies each year. I only have

Re: [R] Change of locale

2015-01-12 Thread Prof Brian Ripley
You don't want to change the locale, rather the message language. That is not a locale, and e.g. LANGUAGE=en is the correct form. See http://cran.r-project.org/doc/manuals/r-patched/R-admin.html#Localization-of-messages for what may be possible during a session: nothing is guaranteed.

Re: [R] nonmonotonic glm?

2015-01-12 Thread Stanislav Aggerwal
Thanks very much Marc and Ben for the helpful suggestions Stan On Sun, Jan 11, 2015 at 10:28 PM, Ben Bolker bbol...@gmail.com wrote: If you're going to use splines, another possibility is mgcv::gam (also part of standard R installation) require(mgcv) gam(DV ~ s(IV), data=

[R] Calculate the median age interval

2015-01-12 Thread Erik B Svensson
Hello I've got a problem I don't know how to solve. I have got a dataset that contains age intervals (age groups) of people and the number of persons in each age group each year (y1994-y1996). The number of persons varies each year. I only have access to the age intervals, not the age of each

Re: [R] nonmonotonic glm?

2015-01-12 Thread Michael Dewey
Comments in line On 12/01/2015 13:13, Vito M. R. Muggeo wrote: dear Stanislav, Your data show two slopes with a kink at around 0. Thus, yet another approach would be to use segmented regression to fit a piecewise linear relationship with unknown breakpoint (being estimated as part of model

Re: [R] R vs. RStudio?

2015-01-12 Thread Hadley Wickham
Is there a reason you don't just click the zoom button? Hadley On Mon, Jan 12, 2015 at 8:22 AM, John Fox j...@mcmaster.ca wrote: Dear Peter and Jeff, I've used RStudio in teaching for quite some time now. For displaying graphics, I open a windows() graphics device on a Windows PC or a

Re: [R] Suggestions for workaround for R Markdown problem with data() ?

2015-01-12 Thread Yihui Xie
Can you try to compile your .Rmd file in the R console (instead of clicking the button in RStudio)? rmarkdown::render('your.Rmd') If it gives the same error, please post the traceback() information. I just tried the following minimal example, and I was unable to reproduce your problem. You may

Re: [R] R console colours (R profile)

2015-01-12 Thread Sarah Goslee
I think you're setting the colors incorrectly. My understanding from reading the package docs is that you use setOutputColors to do so, and not the options() approach. There are no options for background etc that I'm aware of. Does that work if you run it in an interactive session instead? See

Re: [R] regular expression question

2015-01-12 Thread John McKown
No HTML please. it makes me itchy! grin/ s - c(lngimbintrhofixed,lngimbnointnorhofixed,test) sub('(no)?rhofixed$','',s) [1] lngimbint lngimbnoint test On Mon, Jan 12, 2015 at 1:37 PM, Mark Leeds marklee...@gmail.com wrote: Hi All: I have a regular expression problem. If a character

[R] R console colours (R profile)

2015-01-12 Thread Ingrid Charvet
Hello R users, I would like to set defaults text and background colours of my R console using R profile (to load automatically each time I start a new session) So far my R profile is set up like this: if(interactive()) { suppressWarnings(require(colorout,quietly=T)) message(successfully loaded

Re: [R] Reading large data matrix in R

2015-01-12 Thread Sarah Goslee
I'm not at all clear on what you want your plots to look like, but I would recommend reading the help for xyplot and trying out the examples. In general, you need to pass xyplot() a formula that describes what you want your plots to contain, and then a data argument with the data for doing so.

Re: [R] R vs. RStudio?

2015-01-12 Thread Fraser D. Neiman
In my experience, another negative to RStudio is its performance when trying to access code or data files on a remote server over a VPN connection -- even modest files can take minutes to load and sometimes crash the session. The native R GUI seems to handle this better and I often am

[R] regular expression question

2015-01-12 Thread Mark Leeds
Hi All: I have a regular expression problem. If a character string ends with rhofixed or norhofixed, I want that part of the string to be removed. If it doesn't end with either of those two endings, then the result should be the same as the original. Below doesn't work for the second case. I know

[R] Tomorrow Webinar: Enter a KDD Cup or Kaggle Competition without being an expert!

2015-01-12 Thread Lisa Solomon
Webinar: Enter a KDD Cup or Kaggle Competition, You don't need to be an expert! Tomorrow, January 13, 2015 from 10am-11am PDT * If inconvenient time, please register and we will send you a recording. Click to Register: http://hubs.ly/y0q_jf0 Abstract: * Quickly achieve a

Re: [R] R vs. RStudio?

2015-01-12 Thread C W
I use R on Mac, and I use RStudio on Windows. That's my opinion. I have one problem. When I use R on Mac. The function plot() gives a graph that's cut off. For example, try plot(rnorm(100) I believe there should be space below index on x-axis. Why is that? Thanks, Mike On Mon, Jan 12,

Re: [R] Showing error when trying to open a netcdf file using 'ncdf' package in R

2015-01-12 Thread David W. Pierce
Hi, *library(ncdf)* *f-open.ncdf('Acc.nc')* *Error in R_nc_inq_dim: NetCDF: Invalid dimension ID or nameError in dim.inq.ncdf(nc, i) : using ncid 65536 dimid 1* I've fixed this error, and put a new source package (version 1.8.6) up on ncdf's home page at:

Re: [R] R vs. RStudio?

2015-01-12 Thread Duncan Murdoch
On 12/01/2015 12:00 PM, C W wrote: I use R on Mac, and I use RStudio on Windows. That's my opinion. I have one problem. When I use R on Mac. The function plot() gives a graph that's cut off. For example, try plot(rnorm(100) I believe there should be space below index on x-axis.

Re: [R] R vs. RStudio?

2015-01-12 Thread Richard M. Heiberger
I have this in my .Rprofile setHook(packageEvent(grDevices, onLoad), function(...) grDevices::quartz.options(height=6.7)) ## for the MacBook Air, the default height=7 puts the legend below the bottom of the screen On Mon, Jan 12, 2015 at 4:31 PM, Duncan Murdoch murdoch.dun...@gmail.com

Re: [R] Suggestions for workaround for R Markdown problem with data() ?

2015-01-12 Thread Molly Elliott
My apologies to everyone who offered assistance here. I broke my code chunks up some more, and further isolated the problem line to a different function. Yihui, Thank you for the information for running the .Rmd file within R itself, rather than RStudio. I have installed pandoc and like

[R] Saving an edited function in R Studio

2015-01-12 Thread Tae J. Kwon
Hello, I am trying to modify a few functions in a specific R package that I installed. I am using a simple edit function to edit the function and override the exisiting using the same function name. For instance, if the function is named as aaaMap then I do: aaaMap = edit(aaaMap) so other

Re: [R] any r package can handle factor levels not in the test set

2015-01-12 Thread Richard M. Heiberger
You need to define the levels of the training set to include all levels that you might see. Something like this A - factor(letters[1:5]) B - factor(letters[c(1,3,5,7,9)]) A [1] a b c d e Levels: a b c d e B [1] a c e g i Levels: a c e g i training - factor(A, levels=unique(c(levels(A),

Re: [R] two-sample KS test: data becomes significantly different after normalization

2015-01-12 Thread Monnand
Thank you, Chris! I think it is exactly the problem you mentioned. I did consider 1000-point data is a large one at first. I down-sampled the data from 1000 points to 100 points and ran KS test again. It worked as expected. Is there any typical method to compare two large samples? I also tried

Re: [R] R vs. RStudio?

2015-01-12 Thread C W
Thanks, Duncan and Richard. This graphing being cut off problem is very subtle, I can live with it. It is usually the white spaces that's cut off. Thanks for addressing this. Please continue with your original discussion, didn't mean to divert your attention. On Mon, Jan 12, 2015 at 5:08 PM,

[R] any r package can handle factor levels not in the test set

2015-01-12 Thread HelponR
It looks like gbm, glm all has this issue I wonder if any R package is immune of this? In reality, it is very normal that test data has data unseen in training data. It looks like I have to give up R? Thanks! [[alternative HTML version deleted]]

Re: [R] global environment

2015-01-12 Thread Matt Warpinski
Rewrite it with spaces between your assigns and numbers. This line is unclear to me: if(rst[i]-3 rst[i]=-3) Is it supposed to be rst[i] - 3, or rst[i] -3? R might be misinterpreting what you're trying to get it to do. On Mon, Jan 12, 2015 at 1:18 AM, Methekar, Pushpa (GE Transportation,

Re: [R] Saving an edited function in R Studio

2015-01-12 Thread Jeff Newmiller
The usual answer is don't do that. Always use a text editor to change your code on disk and re-load it by sourcing it or building it into a package. This makes sure your changes make it back to the hard disk where they came from to begin with, since the edit function only saves them back into

[R] Complex merging problems

2015-01-12 Thread npretnar
Hello, I have two data frames structured as follows: df1 v1 v2 1 83 1 83 1 84 1 84 1 85 1 85 2 90 2 91 2 91 2 91 2 92 4 89 4 89 4 90 4 90 df2 v1 v2 1 83 2 83 3

Re: [R] Showing error when trying to open a netcdf file using 'ncdf' package in R

2015-01-12 Thread കുഞ്ഞായി kunjaai
On Tue, Jan 13, 2015 at 2:17 AM, David W. Pierce dpie...@ucsd.edu wrote: Hi, *library(ncdf)* *f-open.ncdf('Acc.nc')* *Error in R_nc_inq_dim: NetCDF: Invalid dimension ID or nameError in dim.inq.ncdf(nc, i) : using ncid 65536 dimid 1* I've fixed this error, and put a new source

[R] Help reading multiple ts objects

2015-01-12 Thread stamos
Hello R team, I am currently exploring the R functionality for time series forecasting. My set of data consists of 4y monthly data sales per sku. Each sku spans across 4 lines - one for each year - and the respective periods of time are in columns P1 to P12. The .txt file (assume tab sep)

Re: [R] rename columns with pattern

2015-01-12 Thread Alain Guillet
Dear Raj, names(dff)[1:6] - paste(bp,1:6,sep=_) Alain On 2015-01-12 15:17, Kuma Raj wrote: I want to rename columns 1 to 6 in the sample data set as bp_1 to bp_6. How could I do that in R? Thanks dput(dff) structure(list(one = c(1.00027378507871, 0.982313483915127, 1.1531279945243,

Re: [R] ggplot barchart: bars don't stock on breaks

2015-01-12 Thread Jeff Newmiller
xx-as.vector(xx) Error in as.vector(xx) : object 'xx' not found I do not think as.vector does what you think it does... all data in R is some kind of vector. xx-rep(0,5941) # make the whole vector xx[4853:5941]-1 # change part of it table(xx) # review the data xx 01 4852 1089

Re: [R] R vs. RStudio?

2015-01-12 Thread John Fox
Dear Peter and Jeff, I've used RStudio in teaching for quite some time now. For displaying graphics, I open a windows() graphics device on a Windows PC or a quartz() device on a Mac. I explain to the students that they don't have to do this, but I'm doing it so that I can make the graphs larger.

Re: [R] Change of locale

2015-01-12 Thread Chel Hee Lee
Thank you so much. Your explanation is very clear and helpful to understand. Thank you, again. Chel Hee Lee On 1/12/2015 5:56 AM, Prof Brian Ripley wrote: You don't want to change the locale, rather the message language. That is not a locale, and e.g. LANGUAGE=en is the correct form.

Re: [R] Question about package principal

2015-01-12 Thread William Revelle
As David suggests, look at your data. For instance, there seems to be only 1 case (#2) for seat.width.club with non-zero data. I find it hard to believe that the other planes have seat.widths of 0! I think you probably want to code the 0s as missing, rather than 0. You also want to rethink

[R] global environment

2015-01-12 Thread Methekar, Pushpa (GE Transportation, Non-GE)
Hi I am trying to make some changes in data frame and return it to function .this is my function rm.outliers = function(model,xsys) { rst = rstudent(model) outliers-vector(numeric,10) xsys-xsys for(i in 1:length(rst)) { if(rst[i]-3 rst[i]=-3) { #print(this is not

Re: [R] R package creation: Confused about how to handle text data

2015-01-12 Thread Marine Rohmer
Hi Uwe and Hadley, Thank you a lot for your answer. The ./inst/extdata folder seems to work fine, accessing my text files in this way : myFile=system.file(extdata, myFile.csv, package=MyPackage) I've read the Writing R Extension so many times without understanding well the 1.1.6 section, so

Re: [R] R vs. RStudio?

2015-01-12 Thread peter dalgaard
On 12 Jan 2015, at 17:24 , Hadley Wickham h.wick...@gmail.com wrote: Is there a reason you don't just click the zoom button? Hadley Two, I think. One may be a version issue. 1. Some plots will fail if done on the unzoomed device. 2. The zoom featur has a bug (at least on OSX) where it

[R] overlapping coefficient bidimensional distribution

2015-01-12 Thread Meli Massimiliano
Hello All, I have two set of data (A and B) and i would calculate the percentage of superimposition of these two set. Or the number of point that belong to the intersection A ∩ B of these two sets. How i can measure it ? thanks a lot, max __

Re: [R] R vs. RStudio?

2015-01-12 Thread John Fox
Dear Hadley, On Mon, 12 Jan 2015 10:24:35 -0600 Hadley Wickham h.wick...@gmail.com wrote: Is there a reason you don't just click the zoom button? Hadley Yes: To have enough room for the console and script panes, I often have to make the graphics pane too small to display a graph in the first

Re: [R] Reading large data matrix in R

2015-01-12 Thread Bert Gunter
You really need to read ?xyplot and probaby also an R tutorial such as cran.r-project.org/doc/manuals/R-intro.pdf (which also ships with R) to learn about S3 methods. R is a language that requires an investment in time and effort to learn. If you are unwilling to make that investment, use other

[R] Showing error when trying to open a netcdf file using 'ncdf' package in R

2015-01-12 Thread കുഞ്ഞായി kunjaai
Dear all, I am tried to open an netcdf file in R, *library(ncdf)* *f-open.ncdf('Acc.nc')* *Error in R_nc_inq_dim: NetCDF: Invalid dimension ID or nameError in dim.inq.ncdf(nc, i) : using ncid 65536 dimid 1* But I can open this same nc file using other software tool like UVCDAT. I have

Re: [R] overlapping coefficient bidimensional distribution

2015-01-12 Thread Bert Gunter
?intersect or, more generally, ?match Cheers, Bert Bert Gunter Genentech Nonclinical Biostatistics (650) 467-7374 Data is not information. Information is not knowledge. And knowledge is certainly not wisdom. Clifford Stoll On Mon, Jan 12, 2015 at 5:09 AM, Meli Massimiliano

Re: [R] nonmonotonic glm?

2015-01-12 Thread Bert Gunter
... but do realize that after you have looked at the data to determine the appropriate modeling approach, no statistical inference (significance tests, confidence intervals, etc.) should be done on the model used. Or more precisely, any that is done is wrong. Cheers, Bert Bert Gunter Genentech

[R-es] VI Jornadas de Usuarios de R (Compostela, Oct2014)

2015-01-12 Thread miguel.angel.rodriguez.muinos
Hola a todos. Revolution Analytics ha publicado en su blog el artículo de Emilio L. Cano sobre las VI Jornadas de Usuarios de R, celebradas en Santiago de Compostela en Octubre del pasado año. http://blog.revolutionanalytics.com/2014/12/the-6th-spanish-r-users-conference.html Muchas gracias a

[R-es] Abreviar nombres ciéntificos

2015-01-12 Thread JC Arronte
Hola a tod@s, Estoy tratando de abreviar nombres ci�ntificos pero no me gusta c�mo queda usando make.cepnames de la librer�a vegan. Me gustar�a poderlos abreviar as�, Hymenocephalus italicus -- H.italicus Merluccius merluccius -- M.merluccius He probado con varias opciones y no consigo dar con

Re: [R-es] Abreviar nombres ciéntificos

2015-01-12 Thread Jorge I Velez
Hola Juan Carlos, Quizas lo siguiente pueda serte util: # test R s - Merluccius merluccius R strsplit(s, ) [[1]] [1] Merluccius merluccius R strsplit(s, )[[1]] [1] Merluccius merluccius R s - strsplit(s, )[[1]] R paste0(substr(s[1], 1, 1), ., s[2]) [1] M.merluccius # funcion convertir -

Re: [R-es] Abreviar nombres ciéntificos

2015-01-12 Thread Marcuzzi, Javier Rubén
Estimado Juan Carlos Nuca use make.cepnames, pero creo que el problema o solución depende de como tenga los datos, pienso en lo siguiente, el nombre es una cadena, busca la separación (espacio en blanco), a partir de este toma las dos palabras en forma separadas, a al primera le toma el primer

Re: [R-es] Abreviar nombres ciéntificos

2015-01-12 Thread Francisco Rodríguez
En la linea de lo que comenta Javier, hay una librería que permite el tratamiento de string de modo bastante sencillo y aporta muchas funciones, es la stringr si tienes los datos más o menos adecuadamente dispuestos. Puede que en tu caso funciones como la de str_extract(string, pattern) sea