Re: [R] small negative values instead of zeros in nested loop

2012-09-26 Thread Daniel Nordlund
-Original Message- From: r-help-boun...@r-project.org [mailto:r-help-boun...@r-project.org] On Behalf Of Cristina Fdez. Aragón Sent: Tuesday, September 25, 2012 4:40 PM To: r-help@r-project.org Subject: [R] small negative values instead of zeros in nested loop Hi,I am

[R] Ask for help - how to change WHIRR.117.csv to WHIRR_117.csv

2012-09-26 Thread s.s.m. fauzi
Hi, I have a script below. dat - read.table(file=pt.csv, header=T, sep=,, row.names=1, col.names=1) dat for(which_col in seq_len(ncol(dat))) { subset_data - dat[,which_col:ncol(dat)] file_name - sprintf('%s.csv', colnames(dat)[which_col]) write.csv(subset_data, file_name)

Re: [R] Memory usage in R grows considerably while calculating word frequencies

2012-09-26 Thread Rainer M Krug
-BEGIN PGP SIGNED MESSAGE- Hash: SHA1 On 25/09/12 01:29, mcelis wrote: I am working with some large text files (up to 16 GBytes). I am interested in extracting the words and counting each time each word appears in the text. I have written a very simple R program by following

Re: [R] Help needed on parallel processing

2012-09-26 Thread Milan Bouchet-Valat
Le mercredi 26 septembre 2012 à 13:04 +0530, Anindya Sankar Dey a écrit : Hi All, If i have a vector say x-1:10 and then use parLapply(cl,x,function(k){k=k*2; return(k);} it works and will also parallel process depending on the number of cores and the number of clusters I've built in

Re: [R] Simulating from probit

2012-09-26 Thread Duncan Murdoch
On 12-09-25 10:16 PM, Tjun Kiat Teo wrote: Is there anyway to simulate random deviates from probit ? Use pnorm() to calculate the probabilities, and rbinom() to simulate the random values. Duncan Murdoch __ R-help@r-project.org mailing list

[R] Broken Links on http://www.r-project.org

2012-09-26 Thread Viechtbauer Wolfgang (STAT)
I was not sure who I should contact about this, so I am posting this here. There are a few broken links on the R website. 1) http://www.r-project.org/search.html - link to the Nabble R Forum. I belive the correct/new URL should be: http://r.789695.n4.nabble.com/ 2)

[R] map two names into one

2012-09-26 Thread Tammy Ma
Dear R user: I have got the following problem: I have imported two data sets into R: one set includes price information, another one includes volume information. but I noticed the wrong data order problem in the product name, for instance, in one data set, GALAXY ACE S 5830 in another

Re: [R] map two names into one

2012-09-26 Thread Kenn Konstabel
It may be easy or difficult depending on what your data are like. GALAXY ACE S 5830 vs S 5830 GALAXY ACE One easy and reasonably general way would be to divide each such bit into 4 words and then compare if set 2 contains exactly all words in set 1 but possibly in different order. x1 - GALAXY

Re: [R] map two names into one

2012-09-26 Thread Sarah Goslee
Hi Tammy, I think we need more information. Are the names always four parts? Does the fix always involve moving two parts from the back to the front? For that matter, which of the two you gave is correct? Or does it matter what order the parts are in as long as it's consistent? Sorting them

Re: [R] Ask for help - how to change WHIRR.117.csv to WHIRR_117.csv

2012-09-26 Thread Rui Barradas
Hello, Maybe the code below answers to both your questions (Q1 and Q2) cnames - colnames(dat) cnames - sub(WHIRR\\., WHIRR_, cnames) for(which_col in seq_len(ncol(dat))) { subset_data - dat[which_col:ncol(dat)] # change 1, Q2 file_name - sprintf('%s.csv', cnames[which_col]) #

[R] create new column in a DF according to values from another column

2012-09-26 Thread jeff6868
Hi everyone, I have a small problem in my R-code. Imagine this DF for example: DF - data.frame(number=c(1,4,7,3,11,16,14,17,20,19),data=c(1:10)) I would like to add a new column Station in this DF. This new column must be automatically filled with: V1 or V2 or V3. The choice must be done on

Re: [R] R for commercial use

2012-09-26 Thread kk414
cool, im none the wiser now, but thanks anyway -- View this message in context: http://r.789695.n4.nabble.com/R-for-commercial-use-tp4644027p4644204.html Sent from the R help mailing list archive at Nabble.com. __ R-help@r-project.org mailing list

[R] Running different Regressions using for loops

2012-09-26 Thread Krunal Nanavati
Hi, I am trying to run many different regressions using a FOR Loop. The input data that is read into R has the following variables · Volume · Price1 · Price2 · Price3 · Price4 · Price5 · Trend · Seasonality I want

Re: [R] lattice dotplot reorder contiguous levels

2012-09-26 Thread maxbre
sorry for my slow reply, this is what I worked out so far… my reproducible example and the code test-structure(list(site = structure(c(1L, 1L, 1L, 1L, 1L, 1L, 2L, 2L, 2L, 2L, 2L, 2L, 2L, 2L, 2L, 2L, 2L, 2L, 2L, 2L, 2L, 2L, 3L, 3L, 3L, 3L, 3L, 3L, 4L, 4L, 4L, 4L, 4L, 4L, 4L, 4L, 4L, 4L, 4L,

Re: [R] add a data frame to my data frame

2012-09-26 Thread Tagmarie
Thanks to all of you. The three advices helped me a lot - solved my problem and thank you Sarah for the hint with rseek.org. Didn't know that one. Have a great day, Tagmarie -- View this message in context:

[R] average environmental data if AnimalID and Time is duplicated

2012-09-26 Thread Tagmarie
Hello, I tried for about three hours now to solve this problem but I can't figure it out. I am sure someone knows how do it. At least I hope so. I have a data frame somewhat like this: myframe - data.frame (ID=c(Ernie, Ernie, Bert, Bert), Timestamp=c(24.09.2012 09:00, 24.09.2012 09:00,

[R] Change in order of names after applying plyr package

2012-09-26 Thread Vincy Pyne
Dear R helpers I have following two data.frames viz. equity_data and param. equity_data = data.frame(security_id = c(Air, Air, Air, Air, Air, Air, Air, Air, Air, Air, Air, Air, AB, AB, AB, AB, AB, AB, AB, AB, AB, AB, AB, AB, AD,  AD, AD, AD, AD, AD, AD, AD, AD, AD, AD, AD), ason_date =

Re: [R] create new column in a DF according to values from another column

2012-09-26 Thread Berend Hasselman
On 26-09-2012, at 12:49, jeff6868 geoffrey_kl...@etu.u-bourgogne.fr wrote: Hi everyone, I have a small problem in my R-code. Imagine this DF for example: DF - data.frame(number=c(1,4,7,3,11,16,14,17,20,19),data=c(1:10)) I would like to add a new column Station in this DF. This new

Re: [R] lattice dotplot reorder contiguous levels

2012-09-26 Thread Deepayan Sarkar
On Wed, Sep 26, 2012 at 3:36 PM, maxbre mbres...@arpa.veneto.it wrote: sorry for my slow reply, this is what I worked out so far… my reproducible example and the code test-structure(list(site = structure(c(1L, 1L, 1L, 1L, 1L, 1L, 2L, 2L, 2L, 2L, 2L, 2L, 2L, 2L, 2L, 2L, 2L, 2L, 2L, 2L, 2L,

Re: [R] average environmental data if AnimalID and Time is duplicated

2012-09-26 Thread Jim Lemon
On 09/26/2012 08:53 PM, Tagmarie wrote: Hello, I tried for about three hours now to solve this problem but I can't figure it out. I am sure someone knows how do it. At least I hope so. I have a data frame somewhat like this: myframe- data.frame (ID=c(Ernie, Ernie, Bert, Bert),

Re: [R] Running different Regressions using for loops

2012-09-26 Thread Rui Barradas
Hello, Try the following. #cnames - names(tryout) # in your code, use this one cnames - c(Volume, Price1, Price2, Price3, Price4, Price5, Trend, Seasonaliy) price - cnames[grep(Price, cnames)] resp - cnames[1] regr - cnames[7:8] #lm.list - vector(list, 5) for(i in 1:5){ regress -

Re: [R] Creating x*y different contigency tables

2012-09-26 Thread Berend Hasselman
On 26-09-2012, at 09:59, Loukia Spineli spinelilouki...@gmail.com wrote: Dear all, I am trying to construct 25x31 different matrices of 2x2 dimension. Here is the problem: we have the following matrix matrix(c(54+s0, 43+s1, 56-s0,

Re: [R] average environmental data if AnimalID and Time is duplicated

2012-09-26 Thread Rui Barradas
Hello, Why do you have Hunger and Temp recorded as characters? Between double quotes? myframe - data.frame (ID=c(Ernie, Ernie, Bert, Bert), Timestamp=c(24.09.2012 09:00, 24.09.2012 09:00, 24.09.2012 10:00, 25.09.2012 10:00), Hunger=c(1,5,2,2), Temp=c(25,30,27,28) ) str(myframe)

Re: [R] create new column in a DF according to values from another column

2012-09-26 Thread jim holtman
Here is another technique to use, especially if you have a long list of replacement values: DF - data.frame(number=c(1,4,7,3,11,16,14,17,20,19),data=c(1:10)) # create a list of replacement values; if you have a lot and # you can create them automagically, then it is easier replace -

Re: [R] Change in order of names after applying plyr package

2012-09-26 Thread jim holtman
Here is one of the places that you need a 'factor' to create the ordering you want; notice the statement that I added: equity_data = data.frame(security_id = c(Air, Air, Air, Air + , Air, Air, Air, Air, Air, Air, Air, Air, AB + , AB, AB, AB, AB, AB, AB, AB, AB, AB, AB + ,

Re: [R] Extrapolating Cox predicted risk

2012-09-26 Thread Terry Therneau
On 09/26/2012 05:00 AM, r-help-requ...@r-project.org wrote: I generated predicted risk of death for each subject in the study by means of Cox proportional hazards model at 8 year of follow-up, a time point at which follow-up was more than 90% complete. It is possible to extrapolate to 10-year

[R] RV: problems for making grids from lmer models

2012-09-26 Thread MARIA OLGA VIEDMA SILLERO
Dear colleagues: I am working with binary mixed models using lme4 package and everything works fine until I try to spatialize the fitted models using grids predictors. I have used the predict function from RASTER package and the RSAGA functionalities, but always I have the same error: Error

Re: [R] create new column in a DF according to values from another column

2012-09-26 Thread jeff6868
Yes this is it! Thank you for your help Berend! -- View this message in context: http://r.789695.n4.nabble.com/create-new-column-in-a-DF-according-to-values-from-another-column-tp4644217p4644225.html Sent from the R help mailing list archive at Nabble.com.

[R] Jointly distributed random variables in R

2012-09-26 Thread Kizito Omala
Dear all, is there a specific package and reference book for plotting Jointly distributed random variables? Kindly help. Kizito. __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide

[R] gbinom function

2012-09-26 Thread Kizito Omala
Dear all, I have just downloaded a package 'prob' and also loaded it using library(prob). Whereas function 'tosscoin' works very well the other functions like 'gbinom' for graphing density functions does not work. I get the message: gbinom(20,0.3) Error: could not find function gbinom How do

Re: [R] create new column in a DF according to values from another column

2012-09-26 Thread Rui Barradas
Hello, 'if' is not vectorized, it only uses the first value of the multiple condition. 'ifelse' is vectorized and in your case use nested ifelses. DF - data.frame(number=c(1,4,7,3,11,16,14,17,20,19),data=c(1:10)) v1 - c(1,7,11,16) v2 - c(4,14,20) v3 - c(3,17,19) DF$Station -

Re: [R] average environmental data if AnimalID and Time is duplicated

2012-09-26 Thread arun
HI, Just to add to Jim's solution with data.table() myframe- data.frame (ID=c(Ernie, Ernie, Bert, Bert),  Timestamp=c(24.09.2012 09:00, 24.09.2012 09:00, 24.09.2012 10:00,  25.09.2012 10:00), Hunger=c(1,5,2,2), Temp=c(25,30,27,28)  ) library(data.table) myframe1-data.table(myframe)  

[R] RCURL ftp upload - ASCII or Binary type?

2012-09-26 Thread Magnus Eriksson
I'm trying to upload a file using RCURL:s ftpUpload() to a ftp-server using the following command: ftpUpload('VERY.ODD.FILE.NAME(+1)',to=ftp://x.x.x.x/,;' VERY.ODD.FILE.NAME(+1)',userpwd=USER:PASSWORD) OK 0 The file I'm trying to upload is a very simple text-file but with a bit weird

Re: [R] create new column in a DF according to values from another column

2012-09-26 Thread arun
HI, Try this:  DF$Station[DF$number%in%c(1,7,11,16)]-V1  DF$Station[DF$number%in%c(4,14,20)]-V2  DF$Station[DF$number%in%c(3,17,19)]-V3  DF #   number data Station #1   1    1  V1 #2   4    2  V2 #3   7    3  V1 #4   3    4  V3 #5  11    5  V1 #6  16   

Re: [R] average environmental data if AnimalID and Time is duplicated

2012-09-26 Thread Tagmarie
Thank you! Am 26.09.2012 13:31, schrieb Jim Lemon [via R]: On 09/26/2012 08:53 PM, Tagmarie wrote: Hello, I tried for about three hours now to solve this problem but I can't figure it out. I am sure someone knows how do it. At least I hope so. I have a data frame somewhat like this:

Re: [R] gbinom function

2012-09-26 Thread Berend Hasselman
On 26-09-2012, at 13:24, Kizito Omala kizrom...@gmail.com wrote: Dear all, I have just downloaded a package 'prob' and also loaded it using library(prob). Whereas function 'tosscoin' works very well the other functions like 'gbinom' for graphing density functions does not work. I get the

Re: [R] calculation of diversity confidence interval

2012-09-26 Thread Jean V Adams
Mike, You could use bootstrapping. See for example the function boot() in pacakge boot. library(boot) ?boot Jean Michael Eisenring michael.eisenr...@gmx.ch wrote on 09/25/2012 04:54:29 AM: Dear R-help members. Maybe this is not the right platform to ask this, but I'm looking

[R] Interaction scatterplots in ggplot with multiple regression lines

2012-09-26 Thread Isaac Petersen
I'm trying to treat a continuous variable as discrete for plotting multiple regression lines in a scatterplot as a function of the level on the moderating variable. In the example below, there is only one regression line plotted to the whole data. I would like a separate regression line for each

Re: [R] gbinom function

2012-09-26 Thread Berend Hasselman
I have forwarded your message to the R-help list. You should also send your replies to the R-help list and not just to the person(s) who replied. Berend On 26-09-2012, at 15:44, Kizito Omala kizrom...@gmail.com wrote: Hello Berend, I got the code from google, pasted in the script editor

Re: [R] RCURL ftp upload - ASCII or Binary type?

2012-09-26 Thread Ben Tupper
Hi, On Sep 26, 2012, at 8:07 AM, Magnus Eriksson wrote: I'm trying to upload a file using RCURL:s ftpUpload() to a ftp-server using the following command: ftpUpload('VERY.ODD.FILE.NAME(+1)',to=ftp://x.x.x.x/,;' VERY.ODD.FILE.NAME(+1)',userpwd=USER:PASSWORD) OK 0 The file I'm trying

[R] Retrieve regression summary results after rq

2012-09-26 Thread Camila Mendes
Hi all, I am using quantile regression with svy design. I want to retrieve summary regression statistics (std error, p-value), since I don't have any in my output: Commands: clus1_d- svydesign(id=~cd002_co, weights=~wtper, strata=~str, data=data)

Re: [R] Interaction scatterplots in ggplot with multiple regression lines

2012-09-26 Thread John Kane
Some like this help? mydata$modnew - cut(mydata$moderator, 7) ggplot(mydata, aes(x=predictor, y=outcome, color=modnew)) + geom_point() + stat_smooth(method=lm, se=TRUE, fullrange=T) John Kane Kingston ON Canada -Original Message- From: dadr...@gmail.com Sent: Wed, 26 Sep 2012

Re: [R] Plotting of regsubsets adjr2 values not correct

2012-09-26 Thread Greg Snow
Does your dataset have any missing data? (without a reproducible example we can only guess). If it does then you may be fitting the same model to different subsets of the data between the 2 methods. On Tue, Sep 25, 2012 at 9:03 AM, Maximilian Lklweryc maxlklwe...@gmail.com wrote: Hi, I want to

Re: [R] Retrieve regression summary results after rq

2012-09-26 Thread John Kane
summary(fit1) perhaps/ John Kane Kingston ON Canada -Original Message- From: cacamende...@gmail.com Sent: Wed, 26 Sep 2012 11:39:30 -0300 To: r-help@r-project.org Subject: [R] Retrieve regression summary results after rq Hi all, I am using quantile regression with svy design.

Re: [R] rows extraction

2012-09-26 Thread David L Carlson
subtest - subset(test, Name. %in% c(PKB123, PKB22, PKB23, PKB32, CTV19, CTV20, PKB11, PKB11)) subtest Name. Score performance Environment. 10 CTV19 2 0.52740797 0.53639048 11 CTV20 3 0.05298615 0.04856818 12 PKB11 4 0.90037809 0.79427806 13 PKB11 5

Re: [R] geom_line: How to plot two data sets having different maximum X-axis values in a single plot?

2012-09-26 Thread John Kane
Clumsy but this should do it. aa$set - rep(a, length(aa$position)) bb$set - rep(b, length(bb$position)) (mydata - rbind(aa,bb)) p - ggplot( mydata , aes( position, count, colour = set )) + geom_line() p John Kane Kingston ON Canada -Original Message- From:

Re: [R] Retrieve regression summary results after rq

2012-09-26 Thread Camila Mendes
This does not work at all... On Wed, Sep 26, 2012 at 12:04 PM, John Kane jrkrid...@inbox.com wrote: summary(fit1) perhaps/ John Kane Kingston ON Canada -Original Message- From: cacamende...@gmail.com Sent: Wed, 26 Sep 2012 11:39:30 -0300 To: r-help@r-project.org Subject: [R]

Re: [R] Retrieve regression summary results after rq

2012-09-26 Thread John Kane
Strange, I have never used it but presumably you are using the package ‘survey’? The manual suggests summary(xx) should work. What results or error messages do you get? John Kane Kingston ON Canada -Original Message- From: cacamende...@gmail.com Sent: Wed, 26 Sep 2012 12:39:46

Re: [R] boxplot of different colors

2012-09-26 Thread John Kane
Shamelessly stealling Richard Heiberger's data set I'd suggest another way using ggplot2 which you would need to install library(ggplot2) dataN - data.frame(GE_distance=rnorm(260), Diet_B=factor(rep(1:13, each=20))) p - ggplot(dataN , aes(Diet_B, GE_distance, colour =

Re: [R] Latitude Longitude to SPDF

2012-09-26 Thread John Kane
I think I know considerably less than you do but have a look as the sp package. I think you are referring to and object type SpatialPolygonsDataFrame from the package sp or which that package will produce. Good luck. Now to install rgdal. John Kane Kingston ON Canada -Original

Re: [R] rows extraction

2012-09-26 Thread Jeff Newmiller
You need to use the match function if you want to specify result sort order or duplication. test[ match(c( PKB123, PKB22, PKB23,PKB32, CTV19, CTV20, PKB11, PKB11 ),test$Name.), ] --- Jeff Newmiller

[R] Removing duplicates without a for loop

2012-09-26 Thread wwreith
I have several thousand rows of shipment data imported into R as a data frame, with two columns of particular interest, col 1 is the entry date, and col 2 is the tracking number (colname is REQ.NR). Tracking numbers should be unique but on occassion aren't because they get entered more than once.

[R] specifying arguments in functions and calling functions, within functions

2012-09-26 Thread K. Brand
Esteemed R UseRs, Regarding specifying arguments in functions and calling functions within functions: ## beginning ## ## some data ex - rnorm(10) ex[5] - NA ## example function Scale - function(x, method=c(mean, median)) { scl - method scl(x) } ## both return NA Scale(ex, method=median)

Re: [R] map two names into one

2012-09-26 Thread arun
HI, Try this: vec1-GALAXY ACE S 5830 vec2-S 5830 GALAXY ACE vec3-R GALAXY 5812 ACE  vec11-paste(sort(unlist(strsplit(vec2, ))),collapse=_)  vec22-paste(sort(unlist(strsplit(vec2, ))),collapse=_)  vec11 #[1] 5830_ACE_GALAXY_S  vec22 #[1] 5830_ACE_GALAXY_S  identical(vec11,vec22) #[1] TRUE  

[R] Reading multiple files

2012-09-26 Thread Silvano Cesar da Costa
Hi, I have 35 data files for reading. I would like get a program for performing reading of 35 files at once. All are of the type: Dados1.raw, Dados2.raw and so on. If the files have the same number of columns, I can read with the following commands: rm(list=ls()) filenames =

[R] averageif and looping

2012-09-26 Thread Eko andryanto Prakasa
 haiii i want to know, is there any script in R to measure looping averageif (like in the excel) ... for example: i have a vector rowvalue 10 22 3-3 4-2 51 6-2 i want to measure the average of the vector for negative value with window

[R] Help with R invoking

2012-09-26 Thread Li, Jianying (NIH/NIEHS) [C]
Hi, I encountered a very strange error with R (2.14.1). I tried to build an R package and eventually worked (passing all the checks etc.). Then, I tried this command R CMD INSTALL --binary pkg, which supposedly installs and produce a binary source archive (*.zip) for use on Windows only.

[R] Submit a new script after all parallel jobs have completed

2012-09-26 Thread francesca casalino
Dear R experts, I have an R script that creates multiple scripts and submits these simultaneously to a computer cluster, and after all of the multiple scripts have completed and the output has been written in the respective folders, I would like to automatically launch another R script that works

Re: [R] factor expansion

2012-09-26 Thread Jose Bustos Melo
Thank you PIKAL Petr, This is used when you have a big data base of a national sample. So, this factor is a variable that uses the sample in order to obtain information about all the people of the country.  Similar of getting a real approach about what's going on in the total population. I

[R] Create an error logging text file

2012-09-26 Thread Sam Sturge
Hi, I am looking to run a script which calls other functions from other scripts. Such as in script 1 I may have function f1 which then calls functions f2, f3, f4 which are found in script 3 and then f4 also calls function f6 which can be found in script 3 etc. What I am looking to do is to

[R] Specifying a response variable in a Bayesian network

2012-09-26 Thread Abraham Mathew
I'm trying to teach myself about Bayesian Networks and am working with the following data and the bnlearn package. I understand the conceptual aspects of BNs, but I'm not sure how to specify the response variables in R when constructing a dag plot. I've cecked ?hc and done numerous google searches

[R] lme(y ~ ns(x, df=splineDF)) error

2012-09-26 Thread Jacob Wegelin
I would like to fit regression models of the form y ~ ns(x, df=splineDF) where splineDF is passed as an argument to a wrapper function. This works fine if the regression function is lm(). But with lme(), I get two different errors, depending on how I handle splineDF inside the wrapper

Re: [R] specifying arguments in functions and calling functions, within functions

2012-09-26 Thread Sarah Goslee
Hi, You have some basic confusion here, and a problem likely caused by an object named scl that exists in your global environment. On Wed, Sep 26, 2012 at 11:56 AM, K. Brand k.br...@erasmusmc.nl wrote: Esteemed R UseRs, Regarding specifying arguments in functions and calling functions within

Re: [R] Help with R invoking

2012-09-26 Thread Duncan Murdoch
On 26/09/2012 11:03 AM, Li, Jianying (NIH/NIEHS) [C] wrote: Hi, I encountered a very strange error with R (2.14.1). I tried to build an R package and eventually worked (passing all the checks etc.). Then, I tried this command R CMD INSTALL --binary pkg, which supposedly installs and produce a

[R] how to know where you've been sourced from

2012-09-26 Thread Alexander Shenkin
Hello All, I need a script to perform different actions depending on the file from which it was source()'d. Thus, my script needs a way to figure out from whence it was sourced. There seems to be some relevant information in sys.calls() (see below). However, I need to get at the name of the

Re: [R] rows extraction

2012-09-26 Thread David Winsemius
On Sep 26, 2012, at 8:28 AM, David L Carlson wrote: subtest - subset(test, Name. %in% c(PKB123, PKB22, PKB23, PKB32, CTV19, CTV20, PKB11, PKB11)) subtest Name. Score performance Environment. 10 CTV19 2 0.52740797 0.53639048 11 CTV20 3 0.05298615 0.04856818 12

Re: [R] how to know where you've been sourced from

2012-09-26 Thread Duncan Murdoch
On 26/09/2012 2:39 PM, Alexander Shenkin wrote: Hello All, I need a script to perform different actions depending on the file from which it was source()'d. Thus, my script needs a way to figure out from whence it was sourced. There seems to be some relevant information in sys.calls() (see

Re: [R] specifying arguments in functions and calling functions, within functions

2012-09-26 Thread Rui Barradas
Hello, You define a 2nd version of Scale with the dots argument but do not use it. Scale2 - function(x, method=c(mean, median),...) { scl - match.fun(method) scl(x, ...) # Here! } Scale2(ex, method=median, na.rm=TRUE) # both return Scale2(ex, method=median, na.rm=TRUE) # the median

Re: [R] Retrieve regression summary results after rq

2012-09-26 Thread David Winsemius
On Sep 26, 2012, at 8:50 AM, John Kane wrote: Strange, I have never used it but presumably you are using the package ‘survey’? The manual suggests summary(xx) should work. What results or error messages do you get? She didn't return a model object as fit1. She return only the results of

Re: [R] specifying arguments in functions and calling functions, within functions

2012-09-26 Thread David L Carlson
Adding on to what Sarah has said, your function appears to limit the functions that can be passed to it, but it does not. The character strings mean and median will fail, but passing the function name directly will work: Scale - function(x, method=mean,...) { scl - method scl(x, ...) }

Re: [R] Removing duplicates without a for loop

2012-09-26 Thread Jean V Adams
This might be quicker. Para.5C.sorted - Para.5C[order(Para.5C[, 1]), ] Para.5C.final - Para.5C.sorted[!duplicated(Para.5C.sorted$REQ.NR), ] If your data are already sorted by date, then you can skip the first step and just run Para.5C.final - Para.5C[!duplicated(Para.5C$REQ.NR), ] Jean

Re: [R] Reading multiple files

2012-09-26 Thread Jean V Adams
Will your data be read in correctly if you do away with the colClasses argument to read.delim (or read.table)? Jean Silvano Cesar da Costa silv...@uel.br wrote on 09/26/2012 09:11:33 AM: Hi, I have 35 data files for reading. I would like get a program for performing reading of 35 files

[R] R and sell buy stock

2012-09-26 Thread baycan global
Hi all, I have seen that R can be switched on to a Broker called IB. There is another one similar to IB that permits to make a code and send orders to broker to buy or sell stocks? Can be done trough R, writte in excel and trough API sell/buy to the broker? Can someone send me an example (easy

Re: [R] Removing duplicates without a for loop

2012-09-26 Thread Rui Barradas
Sorry, but in my previous post I've confused the columns. It's by REQ.NR, not by date REQ.NR - 1:4 REQ.NR - c(REQ.NR, sample(REQ.NR, 2)) dat - data.frame(date = Sys.Date() + 1:6, REQ.NR = REQ.NR, value = rnorm(6)) aggregate(dat, by = list(dat$REQ.NR), FUN = tail, 1) Rui Barradas Em

[R] Help with invoking R

2012-09-26 Thread Li, Jianying (NIH/NIEHS) [C]
Hi, I encountered a very strange error with R (2.14.1). I tried to build an R package and eventually worked (passing all the checks etc.). Then, I tried this command R CMD INSTALL --binary pkg, which supposedly installs and produce a binary source archive (*.zip) for use on Windows only.

Re: [R] Removing duplicates without a for loop

2012-09-26 Thread Rui Barradas
Hello, If I understand it correctly, something like this will get you what you want. d - Sys.Date() + 1:4 d2 - sample(d, 2) dat - data.frame(id = 1:6, date = c(d, d2), value = rnorm(6)) aggregate(dat, by = list(dat$date), FUN = tail, 1) Hope this helps, Rui Barradas Em 26-09-2012 16:19,

[R] replace string values with numbers

2012-09-26 Thread JiangZhengyu
Hi everyone, I have a data frame Gene with SNPs eg. P1 P2 P3 CG CG GG -- -- AC -- AC CC AC -- AC I tried to replace all the GG with a value 3.Gene[Gene==GG]-3 It always give me: Warning in `[-.factor`(`*tmp*`, thisvar, value = 3) : invalid factor level, NAs generated Does any

Re: [R] Background color in a grid plot seems to interfere with plot()

2012-09-26 Thread Marius Hofert
Dear Paul, Many thanks, that solved it. Cheers, Marius Paul Murrell p.murr...@auckland.ac.nz writes: Hi On 25/09/2012 6:10 p.m., Marius Hofert wrote: Dear Paul, Thanks. Redrawing the points solves it for the minimal example, but what happens if you have plot(.., type=b) like below?

Re: [R] Removing duplicates without a for loop

2012-09-26 Thread Clint Bowman
?duplicated Clint BowmanINTERNET: cl...@ecy.wa.gov Air Quality Modeler INTERNET: cl...@math.utah.edu Department of Ecology VOICE: (360) 407-6815 PO Box 47600FAX:(360) 407-7534 Olympia, WA 98504-7600

[R] Simple Question About Exporting Back to Excel

2012-09-26 Thread RCar
All, Relatively new R user so this is probably an easy question to answer. I am able to generate a cluster for my dataset using hclust() then ploting the data with plot(). This results in an image with a dendrogram with my sample names along the bottom. Great! However, I now need a way to get

Re: [R] Removing duplicates without a for loop

2012-09-26 Thread David Winsemius
On Sep 26, 2012, at 11:23 AM, Rui Barradas wrote: Hello, If I understand it correctly, something like this will get you what you want. d - Sys.Date() + 1:4 d2 - sample(d, 2) dat - data.frame(id = 1:6, date = c(d, d2), value = rnorm(6)) aggregate(dat, by = list(dat$date), FUN =

Re: [R] replace string values with numbers

2012-09-26 Thread David Winsemius
On Sep 26, 2012, at 12:52 PM, JiangZhengyu wrote: Hi everyone, I have a data frame Gene with SNPs eg. P1 P2 P3 CG CG GG -- -- AC -- AC CC AC -- AC I tried to replace all the GG with a value 3. Gene[Gene==GG]-3 It always give me: Warning in `[-.factor`(`*tmp*`,

Re: [R] replace string values with numbers

2012-09-26 Thread David Winsemius
On Sep 26, 2012, at 2:27 PM, David Winsemius wrote: On Sep 26, 2012, at 12:52 PM, JiangZhengyu wrote: Hi everyone, I have a data frame Gene with SNPs eg. P1 P2 P3 CG CG GG -- -- AC -- AC CC AC -- AC I tried to replace all the GG with a value 3. Gene[Gene==GG]-3 It always

Re: [R] Reading multiple files

2012-09-26 Thread Bretschneider SIG-R
On 26 Sep 2012, at 16:11 , Silvano Cesar da Costa wrote: Hi, I have 35 data files for reading. I would like get a program for performing reading of 35 files at once. All are of the type: Dados1.raw, Dados2.raw and so on. If the files have the same number of columns, I can read with the

Re: [R] Reading multiple files

2012-09-26 Thread Jean V Adams
If your previously posted code worked with files all having the same number of columns, and if your data is read in correctly without the colClasses argument, then I think the following code should work. for(i in names){ filepath = file.path(~/Silvano/Dados, paste(i, .raw, sep=))

Re: [R] averageif and looping

2012-09-26 Thread Rui Barradas
Hello, Try the following. sapply(seq_len(nrow(dat) - 4), function(i){ w - window(dat$value, start = i, end = i + 4) mean(w[w 0])}) Hope this helps, Rui Barradas Em 26-09-2012 16:38, Eko andryanto Prakasa escreveu: haiii i want to know, is there any script in R to measure looping

Re: [R] averageif and looping

2012-09-26 Thread William Dunlap
You could use filter(..., filter=rep(1,5)) to get running sums of length 5 to get your answer. The following calls filter once to get the sum of the negative values in each window and once to get the number of negative values in each window, then divides to get the means. f - function(x, n=5) {

[R] Is there a way to source from a specific Git repository without hardcoding the location everywhere?

2012-09-26 Thread Curt Seeliger
Folks, A small group of us are working together to develop a set of R functions to support data management and analysis using Eclipse/StatET in a Windows environment. We are using Git/EGit for version control. We work within our own repository and occasionally push to a common remote

Re: [R] Is there a way to source from a specific Git repository without hardcoding the location everywhere?

2012-09-26 Thread Duncan Murdoch
On 12-09-26 8:25 PM, Curt Seeliger wrote: Folks, A small group of us are working together to develop a set of R functions to support data management and analysis using Eclipse/StatET in a Windows environment. We are using Git/EGit for version control. We work within our own repository and

[R] Mac Text editors

2012-09-26 Thread Steven Wolf
Hi everyone, I've recently moved from using a windows machine to a Mac (some might call it an upgrade, others not…I'll let you be the judge). Once I started using Notepad ++ on my windows machine, I really began to like it. Unfortunately, I'm not sure what the free text editor options are

Re: [R] Is there a way to source from a specific Git repository without hardcoding the location everywhere?

2012-09-26 Thread Curt Seeliger
Duncan Murdoch murdoch.dun...@gmail.com wrote on 09/26/2012 05:35:00 PM: ... I'd like to have the code source files from the 'local' git repository without modification, where 'local' could mean c:\yada\ for one person, m:\my documents\wetlands\ for another, and

[R] Comparing density plots using same axes or same axes scale

2012-09-26 Thread Meredith Ballard LaBeau
Good Evening- I have a set of nine scenarios I want to plot to see how the distribution is changing, if one tail is getting larger in certain scenario, currently I am using this code colnames-dimnames(sag_pdfs)[[2]] par(mfrow=c(3,3)) for(i in 1:9) { d-density(sag[,i]) plot(d,type=n,

Re: [R] Mac Text editors

2012-09-26 Thread Albyn Jones
Have you looked at aquamacs? (emacs for the mac). its at aquamacs.org. albyn On 2012-09-26 17:48, Steven Wolf wrote: Hi everyone, I've recently moved from using a windows machine to a Mac (some might call it an upgrade, others not…I'll let you be the judge). Once I started using Notepad ++

Re: [R] Mac Text editors

2012-09-26 Thread David Winsemius
On Sep 26, 2012, at 5:48 PM, Steven Wolf wrote: Hi everyone, I've recently moved from using a windows machine to a Mac (some might call it an upgrade, others not…I'll let you be the judge). Once I started using Notepad ++ on my windows machine, I really began to like it. Unfortunately,

[R] Random Forest - Extract

2012-09-26 Thread Lopez, Dan
Hello, I have two Random Forest (RF) related questions. 1. How do I view the classifications for the detail data of my training data (aka trainset) that I used to build the model? I know there is an object called predicted which I believe is a vector. To view the detail for my testset

Re: [R] Mac Text editors

2012-09-26 Thread David Winsemius
On Sep 26, 2012, at 5:48 PM, Steven Wolf wrote: Hi everyone, I've recently moved from using a windows machine to a Mac (some might call it an upgrade, others not…I'll let you be the judge). Once I started using Notepad ++ on my windows machine, I really began to like it. Unfortunately,

Re: [R] Comparing density plots using same axes or same axes scale

2012-09-26 Thread Rui Barradas
Hello, Something like this? sag - matrix(rnorm(1e3 * 9), ncol = 9) d.list - apply(sag, 2, density) xrange - range(sapply(d.list, function(d) range(d$x))) ymax - max(sapply(d.list, function(d) max(d$y))) op - par(mfrow=c(3,3)) for(i in 1:9) plot(d.list[[i]], xlim = xrange, ylim = c(0,

Re: [R] Mac Text editors

2012-09-26 Thread David Winsemius
On Sep 26, 2012, at 6:06 PM, David Winsemius wrote: On Sep 26, 2012, at 5:48 PM, Steven Wolf wrote: Hi everyone, I've recently moved from using a windows machine to a Mac (some might call it an upgrade, others not…I'll let you be the judge). Once I started using Notepad ++ on my

Re: [R] Comparing density plots using same axes or same axes scale

2012-09-26 Thread Rui Barradas
Hello, again. I forgot, but the subject line also says same axes, not just same axes scale. If you want all densities on the same graph, use ?matplot (matrix plot). Rui Barradas Em 27-09-2012 02:08, Rui Barradas escreveu: Hello, Something like this? sag - matrix(rnorm(1e3 * 9), ncol = 9)

Re: [R] Mac Text editors

2012-09-26 Thread Bhupendrasinh Thakre
My vote for R-Studio. Very elegant design and great functionality. However if coming from languages like Java and others then eclipse is better. R-Studio have dedicated section for Mac user which you will find useful. Best Regards, Bhupendrasinh Thakre Sent from my iPhone On Sep 26, 2012,

  1   2   >