Re: [R] Building factors across two columns, is this possible?

2012-11-23 Thread Brian Feeny
To clarify on my previous post, here is a representation of what I am trying to accomplish: I would like every unique value in either column to be assigned a number so like so: V1V2 V3 1 sun moonstars 2 stars moon sun 3 cat dog catdog 4 dog moon sun 5

Re: [R] function call from another r file

2012-11-23 Thread Jeff Newmiller
It is straightforward to load function definitions into memory using the source() function. --- Jeff NewmillerThe . . Go Live... DCN:Basics: ##.#. ##.#. Live Go...

[R] function call from another r file

2012-11-23 Thread sheenmaria
How to call a function from another r file ? Anyone can help me . Having a function named like fun1 which is saved in r file file1.r and i have another r file like file2.r, and i need to call the fun1 (which is in file1) within file2. Thank you -- View this message in context: http://r.789

Re: [R] subsetting - questions

2012-11-23 Thread arun
HI, This should work: df[df$X1>=8,][-which(names(df)%in% c("X3","X4","X5"))] #   X1 X2 #1   8  2 #5  10  1 #8   8  5 #9   9  4 #12  9  5 #13  9 10 #19  9  8  df[df$X1>=8,][,!names(df)%in%drop_var] #   X1 X2 #1   8  2 #5  10  1 #8   8  5 #9   9  4 #12  9  5 #13  9 10 #19  9  8 A.K. - Origina

Re: [R] R help..subsetting data frame that meeting multiple criteria

2012-11-23 Thread arun
Hi David, Tried the solution on a slightly different data: dat <- read.table(text=" value class percent 15526 36 4.6875 15527 62 85.9375 15527 82 32.4564 15528 36 70.3125 15528 62 9.375 15528 82 74.6875 15529 72 50. 15530 72 50. ", header = TRUE) dat.a <- dat[ dat[["class"]] %in% dat[ dat[[

Re: [R] R help..subsetting data frame that meeting multiple criteria

2012-11-23 Thread arun
HI, You could also try this: dat <- read.table(text=" value class percent 15526 36 4.6875 15527 62 85.9375 15527 82 32.4564 15528 36 70.3125 15528 62 9.375 15528 82 74.6875 15529 72 50. 15530 72 50. ", header = TRUE) mat1<-as.matrix(dat) row.names(mat1)<-paste(dat$class,ave(dat$percent,dat$

Re: [R] R help..subsetting data frame that meeting multiple criteria

2012-11-23 Thread David Winsemius
On Nov 23, 2012, at 6:32 PM, arun wrote: Hi David, Tried the solution on a slightly different data: dat <- read.table(text=" value class percent 15526 36 4.6875 15527 62 85.9375 15527 82 32.4564 15528 36 70.3125 15528 62 9.375 15528 82 74.6875 15529 72 50. 15530 72 50. ", header = TRUE)

Re: [R] subsetting - questions

2012-11-23 Thread Muhuri, Pradip (SAMHSA/CBHSQ)
Hello Peter, 1. -c("X3", "X4", "X5") For the above variables, class is integer. Arun has suggested the following: df[df$X1>=8,][-which(names(df)%in% c("X3","X4","X5"))] 2.df[df$X1>=8,] [, !names(df) %in% drop_var] I agree - Arun has also suggested the same. Thanks and regards, Pra

Re: [R] subsetting - questions

2012-11-23 Thread Muhuri, Pradip (SAMHSA/CBHSQ)
Hi Jorge, I could use subset(). But, I wanted to minimize coding. Thanks, Pradip From: Jorge I Velez [jorgeivanve...@gmail.com] Sent: Friday, November 23, 2012 10:02 PM To: Muhuri, Pradip (SAMHSA/CBHSQ) Cc: r-help@r-project.org Subject: Re: [R] subsetting

[R] Building factors across two columns, is this possible?

2012-11-23 Thread Brian Feeny
I am trying to make it so two columns with similar data use the same internal numbers for same factors, here is the example: > read.csv("test.csv",header =FALSE,sep=",") V1V2 V3 1 sun moonstars 2 stars moon sun 3 cat dog catdog 4 dog moon sun 5 bird pla

Re: [R] subsetting - questions

2012-11-23 Thread Peter Ehlers
On 2012-11-23 18:55, Muhuri, Pradip (SAMHSA/CBHSQ) wrote: Hello, I have two very basic questions (console attached): 1) What am I getting an error message for # 5 and # 7 ? 2) How to fix the code? I would appreciate receiving your help. Thanks, Pradip Muhuri ## Reproducible Example

Re: [R] subsetting - questions

2012-11-23 Thread Muhuri, Pradip (SAMHSA/CBHSQ)
Hi Arun, Thank you so much for your help. Pradip From: arun [smartpink...@yahoo.com] Sent: Friday, November 23, 2012 10:15 PM To: Muhuri, Pradip (SAMHSA/CBHSQ) Cc: R help Subject: Re: [R] subsetting - questions HI, This should work: df[df$X1>=8,][-which(n

Re: [R] subsetting - questions

2012-11-23 Thread Jorge I Velez
Hi Pradip, It is easier to use subset(). Check ?subset for some examples and pay special attention to the "select" parameter. By the way, do not call your data "df" as it is already a function. Best, Jorge.- On Sat, Nov 24, 2012 at 1:55 PM, Muhuri, Pradip (SAMHSA/CBHSQ) <> wrote: > > Hello,

[R] subsetting - questions

2012-11-23 Thread Muhuri, Pradip (SAMHSA/CBHSQ)
Hello, I have two very basic questions (console attached): 1) What am I getting an error message for # 5 and # 7 ? 2) How to fix the code? I would appreciate receiving your help. Thanks, Pradip Muhuri ## Reproducible Example # N <- 100 set.seed(13) df<-data.frame(matrix(sample(c

Re: [R] R lapack routines cannot be loaded

2012-11-23 Thread Martin Morgan
On 11/23/2012 08:05 AM, arysar wrote: I usually ran different statistical analysis in R with routines that use lapack like gam() lm(), etc but after several updates of libraries the following error appears: library(mgcv) This is mgcv 1.7-22. For overview type 'help("mgcv-package")'. model <- wi

Re: [R] Problems with weight

2012-11-23 Thread Anthony Damico
from your stata output, it looks like you need to use the survey package in R for step-by-step instructions about how to do this (and comparisons to stata), see http://journal.r-project.org/archive/2009-2/RJournal_2009-2_Damico.pdf once you're ready to run the regression, use svyglm() instead of

Re: [R] R help..subsetting data frame that meeting multiple criteria

2012-11-23 Thread Rui Barradas
Hello, Like the following? dat <- read.table(text=" value class percent 15526 36 4.6875 15527 62 85.9375 15527 82 32.4564 15528 36 70.3125 15528 62 9.375 15528 82 74.6875 ", header = TRUE) per70 <- dat$percent > 70 split(dat, list(dat$class, per70)) Hope this helps, Rui Barradas Em 23-11-2012

Re: [R] R help..subsetting data frame that meeting multiple criteria

2012-11-23 Thread David Winsemius
On Nov 23, 2012, at 1:14 PM, prasmas wrote: Hi, I am new to R. I am trying to regroup data frame using multiple constrains. for example data frame: data value class percent 15526 36 4.6875 15527 62 85.9375 15527 82 32.4564 15528 36 70.3125 15528 62 9.

Re: [R] Spatstat: Mark correlation function

2012-11-23 Thread Rolf Turner
On 24/11/12 06:36, AMFTom wrote: I normally use the following code to create a figure displaying the mark correlation function for the point pattern process "A": M<-markcorr(A) plot(M) I have now started to use the following code to perform 1000 Monte Carlo simulations of Complete Spatial Rand

Re: [R] characters, mathematical expressions and computed values

2012-11-23 Thread David Winsemius
On Nov 23, 2012, at 12:20 PM, mee1d3hs wrote: The code hist(new, main=bquote("Heart Attack (" * bar(X)==.(round(mean(new), 1)) * ")")) does not work on 2.15.2 on OSX. the histogram is generated, but the title does show at all, which kind of tells me the bquote expression is failing Wo

[R] Results displayed in Console

2012-11-23 Thread cavan
General question concerning summary results of a linear model. I've tried to look in help and search online but I either don't understand it or I can't find the answer. I've defined a model with a really large number of variables and levels. The summary results are so big that not all of the coeff

[R] R help..subsetting data frame that meeting multiple criteria

2012-11-23 Thread prasmas
Hi, I am new to R. I am trying to regroup data frame using multiple constrains. for example data frame: data value class percent 15526 36 4.6875 15527 62 85.9375 15527 82 32.4564 15528 36 70.3125 15528 62 9.375 15528 82 74.6875 I need to regroup each

Re: [R] Summary statistics for matrix columns

2012-11-23 Thread arun
Hi, No problem. There are a couple of other libraries which deal with summary statistics: library(pastecs) ?stat.desc() # library(matrixStats) #Using the functions from package: matrixStats fun1<-function(x){ res<-rbind(colMins(x),colQuantiles(x)[,2],colMedians(x),colMeans(x),colSds(x),colQuant

[R] Problems with weight

2012-11-23 Thread Pablo Menese
Until a weeks ago I used stata for everything. Now I'm learning R and trying to move. But, in this stage I'm testing R trying to do the same things than I used to do in stata whit the same outputs. I have a problem with the logit, applying weights. in stata I have this output . svy: logit bach job

Re: [R] characters, mathematical expressions and computed values

2012-11-23 Thread mee1d3hs
The code hist(new, main=bquote("Heart Attack (" * bar(X)==.(round(mean(new),1)) * ")")) does not work on 2.15.2 on OSX. the histogram is generated, but the title does show at all, which kind of tells me the bquote expression is failing I would appreciate any help in making this work, it seems i

Re: [R] caret train and trainControl

2012-11-23 Thread Brian Feeny
Max, Thanks, I do understand that the final model is fitted. I think I was not clear in my posting. I am changing datasets between tuning and real training. So maybe I tune on "trainset" but its only 5000 rows, doing my gridsearch and all that, and then once I have the hyper parameters, I

Re: [R] Barplot with lines

2012-11-23 Thread Jim Lemon
On 11/24/2012 02:21 AM, skanap wrote: Hi Jim, Thank you for the reply. But, when I use Barpos I get this error. plot(mydata$score,barpos) Error in xy.coords(x, y, xlabel, ylabel, log) : 'x' and 'y' lengths differ I need all the points in x-axis that are in 'days' column. If I'm selecting o

Re: [R] caret train and trainControl

2012-11-23 Thread Max Kuhn
Brian, This is all outlined in the package documentation. The final model is fit automatically. For example, using 'verboseIter' provides details. From ?train > knnFit1 <- train(TrainData, TrainClasses, + method = "knn", + preProcess = c("center", "scale"), +

[R] caret train and trainControl

2012-11-23 Thread Brian Feeny
I am used to packages like e1071 where you have a tune step and then pass your tunings to train. It seems with caret, tuning and training are both handled by train. I am using train and trainControl to find my hyper parameters like so: MyTrainControl=trainControl( method = "cv", number=5,

Re: [R] daily maximum temperature

2012-11-23 Thread arun
Hi, Since you mentioned filtering the daily maximum temperature, this may help: datos<-read.table(text=" X, Ta, HR, RS, v 1/1/2010 1:00:00,5.28,100,0,2.3 1/1/2010 6:00:00,5.45,100,0,2.5 1/1/2010 11:00:00,5.51,100,0,1.1 2/1/2010 1:00:00,5.33,100,0,2.1 2/1/2010 6:00:00,5.48,100,0,2.3 2/1/2010 11:00

Re: [R] read.csv.sql() to select from a large csv file

2012-11-23 Thread Juliane Struve
Rui, Anthony, and Gabor,   I got this to work in the end:   for(i in length(Names_EastCoast){ name <- Names_EastCoast[i] sql <- paste("select * from file where ID = '",name,"'",sep = "") Data <- read.csv.sql("filename",sql = sql) }   loops through all individuals in the csv file.   Thanks a lot

Re: [R] Add column index number to str() output

2012-11-23 Thread David L Carlson
You could create a simple function using this as a starting point: str.ext <- function(x) { if(!is.data.frame(x)) stop("No data frame!") st <- gsub(" \\$", "", capture.output(str(x))) nm <- prettyNum(0:length(x), width=3) cat("\n", paste(nm, st, "\n", sep=" ")) } str.ext(iris)

Re: [R] printing difftime summary

2012-11-23 Thread David Winsemius
On Nov 23, 2012, at 12:35 PM, Sam Steingold wrote: * R. Michael Weylandt [2012-11-23 09:13:36 +]: 2. because difftime.summary returns a data.frame and not a "Classes 'summaryDefault', 'table'" as I assume summary must return. See http://cran.r-project.org/doc/FAQ/R-FAQ.html#How-shou

Re: [R] Add column index number to str() output

2012-11-23 Thread David Winsemius
On Nov 23, 2012, at 12:40 PM, Peter Ehlers wrote: On 2012-11-23 08:54, seth.fore wrote: I often find it would be very useful when inspecting a data structure using str() to know the column index number in order to rearrange the data in a manner amenable to my purpose. Is there a way to mo

Re: [R] lines()

2012-11-23 Thread Duncan Murdoch
On 23/11/2012 11:56 AM, wdmc2012 wrote: I have some latitude and longitudes that I am trying to plot on an image with the lines() command like this: image(seq(-98, -93, 0.1), seq(28.5, 32.5, 0.1), z, xlab= "Longitude", ylab= "Latitude", main= "Temperature") for (i in 2:length(subset(geo, Featu

Re: [R] problem with svyglm

2012-11-23 Thread David Winsemius
On Nov 23, 2012, at 12:08 PM, Pablo Menese wrote: I have this problem. test <- svydesign(id=~1,weights=~peso) logit <- svyglm(bach ~ job2 + mujer + egp4 + programa + delay + mdeo + str + evprivate, family=binomial,design=test) then appear: Error in svyglm.survey.design(bach ~ job2 + muje

Re: [R] daily maximum temperature

2012-11-23 Thread David Winsemius
On Nov 23, 2012, at 10:04 AM, Dominic Roye wrote: Hello, I want to filter the daily maximum temperature. For this i made this skript, but it come out wrong results. Can anybody help me? Thanks for your help! Best regards datos$X <- as.POSIXct(strptime(datos$X, "%d/%m/%Y %H:%M:%S")) z <- ag

Re: [R] Add column index number to str() output

2012-11-23 Thread Peter Ehlers
On 2012-11-23 08:54, seth.fore wrote: I often find it would be very useful when inspecting a data structure using str() to know the column index number in order to rearrange the data in a manner amenable to my purpose. Is there a way to modify the display options of the str() function to add c

Re: [R] printing difftime summary

2012-11-23 Thread Sam Steingold
> * R. Michael Weylandt [2012-11-23 09:13:36 > +]: > >> 2. because difftime.summary returns a data.frame and not a >> "Classes 'summaryDefault', 'table'" as I assume summary must return. > > See > http://cran.r-project.org/doc/FAQ/R-FAQ.html#How-should-I-write-summary-methods_003f what are

[R] problem with svyglm

2012-11-23 Thread Pablo Menese
I have this problem. test <- svydesign(id=~1,weights=~peso) logit <- svyglm(bach ~ job2 + mujer + egp4 + programa + delay + mdeo + str + evprivate, family=binomial,design=test) then appear: Error in svyglm.survey.design(bach ~ job2 + mujer + egp4 + programa + : all variables must be in desig

[R] Spatstat: Mark correlation function

2012-11-23 Thread AMFTom
I normally use the following code to create a figure displaying the mark correlation function for the point pattern process "A": M<-markcorr(A) plot(M) I have now started to use the following code to perform 1000 Monte Carlo simulations of Complete Spatial Randomness (CSR). It is a Monte Carlo t

Re: [R] Adding two different factors to one observation?

2012-11-23 Thread Florian Ahrweiler
On 16.11.2012 01:19, arun wrote: Hi, If you want to convert from the first way to the second way suggested by Jean: [...] A.K. - Original Message - From: Jean V Adams To: Florian Ahrweiler Cc: r-help@r-project.org Sent: Thursday, November 15, 2012 2:50 PM Subject: Re: [R] Add

Re: [R] Odp: Object Browser

2012-11-23 Thread jverzaniNWBKZ
If gvarbrowser isn't quite to your liking, it isn't so hard to build your own variable browser. This uses a slight modification of Petr's function and wraps in a gWidgets interface. Modify his function to display what info you want and add a handler to the tbl object to have some action associated

[R] lines()

2012-11-23 Thread wdmc2012
I have some latitude and longitudes that I am trying to plot on an image with the lines() command like this: image(seq(-98, -93, 0.1), seq(28.5, 32.5, 0.1), z, xlab= "Longitude", ylab= "Latitude", main= "Temperature") for (i in 2:length(subset(geo, Feature=="Coast")[,1])) { lines(x=geo[(i-1),2]:

[R] Add column index number to str() output

2012-11-23 Thread seth.fore
I often find it would be very useful when inspecting a data structure using str() to know the column index number in order to rearrange the data in a manner amenable to my purpose. Is there a way to modify the display options of the str() function to add column index? I know this is really a tri

[R] Why do i get "Error: unexpected input in "A<-lm(GandW ~ Authocracy, Data)"

2012-11-23 Thread F86
Every time i insert : A<-lm(GandW ~ Authocracy;Data) i get this Error. Iam using Mac. And i have checked that "Data" has been read correctly. The same command with the same Data has been used by a friend who is using Linux. Thanks for help! Stockholm university Faradj -- View this m

Re: [R] How to override gWidgets:gvarbrowser_classes

2012-11-23 Thread jverzaniNWBKZ
Try this: library(gWidgets) options(guiToolkit="RGtk2") mydefaultclasses <- list("Data sets1"=c("data.frame") ) w <- gwindow() vb <- gvarbrowser(cont=w, knownTypes=mydefaultclasses) This could be done better, but I think the above does what you want. -- View this message in context: http:

Re: [R] Summary statistics for matrix columns

2012-11-23 Thread arun
HI, You are right. It is slower when compared to Pete's solution: set.seed(125) x <- matrix(sample(1:80),nrow=1000) colnames(x)<- paste("Col",1:ncol(x),sep="") system.time({ res<-sapply(data.frame(x),function(x) c(summary(x),sd=sd(x),IQR=IQR(x)))  res1<-as.matrix(res) res2<-res1[c(1:4,7,5,8,6

[R] R lapack routines cannot be loaded

2012-11-23 Thread arysar
I usually ran different statistical analysis in R with routines that use lapack like gam() lm(), etc but after several updates of libraries the following error appears: library(mgcv) This is mgcv 1.7-22. For overview type 'help("mgcv-package")'. model <- with(chlaR,gam(ClorMAX ~ s(DegDay_NM))) Er

Re: [R] Using cumsum with 'group by' ?

2012-11-23 Thread arun
HI, If that is the case, this should work: dat1<-read.table(text=" id,  x,  date 1,  5,  2012-06-05 12:01 1,  10,    2012-06-05 12:02 1,  45,    2012-06-05 12:03 2,  5,  2012-06-05 12:01 2,  3,  2012-06-05 12:0

Re: [R] Barplot with lines

2012-11-23 Thread skanap
Hi Jim, Thank you for the reply. But, when I use Barpos I get this error. plot(mydata$score,barpos) Error in xy.coords(x, y, xlabel, ylabel, log) : 'x' and 'y' lengths differ I need all the points in x-axis that are in 'days' column. If I'm selecting only points in val1 and val2 I'm missing

Re: [R] Why do i get "Error: unexpected input in "A<-lm(GandW ~ Authocracy, Data)"

2012-11-23 Thread brunosm
Use "," instead of ";" It should work now... Regards, Bruno -- View this message in context: http://r.789695.n4.nabble.com/Why-do-i-get-Error-unexpected-input-in-A-lm-GandW-Authocracy-Data-tp4650559p4650566.html Sent from the R help mailing list archive at Nabble.com. __

Re: [R] Student-t distributed random value generation within a confidence interval?

2012-11-23 Thread Ben Bolker
Thomas Schu gmx.de> writes: > I´m faced with following problem: > Given is a sample where the sample size is 12, the sample mean is 30, and > standard deviation is 4.1. > Based on a Student-t distribution i´d like to simulate randomly 500 possible > mean values within a two-tailed 95% confidence

Re: [R] Barplot with lines

2012-11-23 Thread Greg Snow
Look at the updateusr function in the TeachingDemos package. One of the examples shows adding lines to a barplot. On Fri, Nov 23, 2012 at 12:33 AM, Ripples <9ripp...@gmail.com> wrote: > Hi, > > I'm trying to plot stacked barplot with lines on it. Here is the data. > > emp days val1 val2 score

[R] r cloud computing

2012-11-23 Thread ya
Dear list, I am trying to find some place on internet for R cloud computing.I have some questions about it. I followed this webpage: http://www.r-bloggers.com/crdata-org-to-shut-down/ trying to gain some knowledge about where I can find free cloud computing service for R. It looks like there

Re: [R] Joining two files

2012-11-23 Thread Rui Barradas
Hello, So you need a function that can rbind and also return the total unique columns. It's a bit more complicated but I think this does what you want. ADD <- function(x, y){ cx <- colnames(x) cy <- colnames(y) if(is.null(cx) || is.null(cy)){ d <- length(cx) - length(cy)

Re: [R] Joining two files

2012-11-23 Thread David L Carlson
Arun's solution can be modified slightly to be more general: r1<-c(1,1,2,3) r2<-c(2,1,2,2) r3<-c(2,1,4,1) r4<-c(3,4,1,2) r5<-c(3,1,2,2) data1<-data.frame(r1,r2,r4) data2<-data.frame(r1,r3,r5) data1[,setdiff(names(data2), names(data1))] <- NA data2[,setdiff(names(data1), names(data2))] <- NA data3

Re: [R] Joining two files

2012-11-23 Thread Virgile Capo-Chichi
All, thanks so much for your suggestions. both rbind.fill and creating NA where necessary worked. I think rbind.fill is much easier and quite elegant. Have a great weekend, V 2012/11/23 arun > Hi, > Try this: > > r1<-c(1,1,2,3) > r2<-c(2,1,2,2) > r3<-c(2,1,4,1) > data1<-data.frame(r1,r2) > d

Re: [R] read.csv.sql() to select from a large csv file

2012-11-23 Thread Rui Barradas
Hello, Try forming the sql statement with paste(). Name <- "Bobby" sqlstatement <- paste("select * from file where ID = '", Name, "'", sep = "") read.csv.sql("filename", sql = sqlstatement) Note the opening and closing quotes around the name. Hope this helps, Rui Barradas Em 23-11-2012 16:12,

Re: [R] Joining two files

2012-11-23 Thread arun
Hi, Try this: r1<-c(1,1,2,3)  r2<-c(2,1,2,2)  r3<-c(2,1,4,1)  data1<-data.frame(r1,r2)  data2<-data.frame(r1,r3) data1$r3<-NA  data2$r2<-NA  merge(data1,data2,all=TRUE,sort=FALSE) #  r1 r2 r3 #1  1  2 NA #2  1  1 NA #3  2  2 NA #4  3  2 NA #5  1 NA  2 #6  1 NA  1 #7  2 NA  4 #8  3 NA  1 A.K. --

Re: [R] read.csv.sql() to select from a large csv file

2012-11-23 Thread Anthony Damico
you need to construct the character string. here's what you want to give to the sql argument -- paste( 'select * from file where ID = ' , Name ) so try Name <- "Bobby" read.csv.sql("filename",sql = paste( 'select * from file where ID = ' , Name ) ) On Fri, Nov 23, 2012 at 11:12 AM, Juliane St

Re: [R] read.csv.sql() to select from a large csv file

2012-11-23 Thread Gabor Grothendieck
On Fri, Nov 23, 2012 at 11:12 AM, Juliane Struve wrote: > Dear list, > > Dear list, > I am using read.csv.sql() from the sqldf package to read > individual-based data from a csv file that is too large for R. > My original file contains a column called “ID” that > identifies the individual. I would

Re: [R] Joining two files

2012-11-23 Thread Anthony Damico
library(reshape) ?rbind.fill On Fri, Nov 23, 2012 at 10:57 AM, Virgile Capo-Chichi wrote: > Thanks Jim for your help. Your results are not what I wanted. I would like > to see something like the matrix below. This is what I would get if I used > the ADD Files command in SPSS. V > > r1 r2 r3 >

Re: [R] Function storing error messages in 32 bit R-2.15.2 version

2012-11-23 Thread David Winsemius
On Nov 23, 2012, at 2:21 AM, Paarkhi wrote: I am working with Maulik on this. We installed a 64-bit version of R 2.15.1 now but the ltm package is under version 2.15.2 The same problem is occurring even with this version. You and Maulik are posting messages without context and without the

[R] read.csv.sql() to select from a large csv file

2012-11-23 Thread Juliane Struve
Dear list,   Dear list, I am using read.csv.sql() from the sqldf package to read individual-based data from a csv file that is too large for R. My original file contains a column called “ID” that identifies the individual. I would like to read in data for only one individual at a time, for e

Re: [R] Adding a function with default parameters into the Rcmdr menu

2012-11-23 Thread vincent guyader
I will try this. thank you. 2012/11/23 Milan Bouchet-Valat > Le vendredi 23 novembre 2012 à 03:17 +0100, vincent guyader a écrit : > > Hi everyone, > > > > I made some tests with Rcmdr, to add a function with default parameters : > > > > For example (very simple): > > > > myfunction<-function(v

Re: [R] Joining two files

2012-11-23 Thread Virgile Capo-Chichi
Thanks Jim for your help. Your results are not what I wanted. I would like to see something like the matrix below. This is what I would get if I used the ADD Files command in SPSS. V r1 r2 r3 1 2 NA 1 1 NA 2 2 NA 3 2 NA 1 NA 2 1 NA 1 2 NA 4 3 NA 1 2012/11/23 jim holtman > You

Re: [R] Joining two files

2012-11-23 Thread Rui Barradas
Hello, I don't believe there's an R function that does what you want, but you can write one. myrbind <- function(x, y){ cx <- colnames(x) cy <- colnames(y) if(is.null(cx) || is.null(cy)){ result <- rbind(x, y) }else{ ox <- order(cx) oy <- order(cy)

[R] Student-t distributed random value generation within a confidence interval?

2012-11-23 Thread Thomas Schu
Dear R-users! I´m faced with following problem: Given is a sample where the sample size is 12, the sample mean is 30, and standard deviation is 4.1. Based on a Student-t distribution i´d like to simulate randomly 500 possible mean values within a two-tailed 95% confidence interval. Calculation of

Re: [R] Summary statistics for matrix columns

2012-11-23 Thread Fares Said
Thank you all Sent from my iPhone On 2012-11-23, at 10:19, "arun" wrote: > HI, > You are right. > It is slower when compared to Pete's solution: > set.seed(125) > x <- matrix(sample(1:80),nrow=1000) > colnames(x)<- paste("Col",1:ncol(x),sep="") > > system.time({ > res<-sapply(data.frame(x

Re: [R] Joining two files

2012-11-23 Thread jim holtman
You did not specify what you were expecting as output. Here is one way of using 'merge', but I am not sure if this is what you were after: > r1<-c(1,1,2,3) > r2<-c(2,1,2,2) > r3<-c(2,1,4,1) > data1<-data.frame(r1,r2) > data2<-data.frame(r1,r3) > data1 r1 r2 1 1 2 2 1 1 3 2 2 4 3 2 > dat

Re: [R] Using cumsum with 'group by' ?

2012-11-23 Thread Pete Brecknock
TheRealJimShady wrote > Hi Peter, > > Yes, I did miss an e from the first 'not' in the brackets at the end > of the message, sorry. > > Thanks for that code, but when I use it, it creates a new column > called csum which simply contains the values of the variable x . i.e. > it just duplicates the

Re: [R] Joining two files

2012-11-23 Thread Virgile Capo-Chichi
Hi Jim, I did not try merge because I thought it only adds variables instead of cases. Below is what I am trying to do. When I joined data1 and data2, I was was expecting three variables: r1, r2 and r3 with r2 and r3 presenting missing values where they did not exist in the first place. V > r1<-c(

Re: [R] Joining two files

2012-11-23 Thread jim holtman
Have you tried 'merge'? You did not provide any sample data (use 'dput' if you do) so that we could show a possible solution. On Fri, Nov 23, 2012 at 9:56 AM, Virgile Capo-Chichi wrote: > Hello all, > I al trying to join (ADD FILES in SPSS) two files using the rbind() > function. However, with r

[R] Joining two files

2012-11-23 Thread Virgile Capo-Chichi
Hello all, I al trying to join (ADD FILES in SPSS) two files using the rbind() function. However, with rbind() R does not behave the same way as SPSS. I mean, it just concatenates the two blocs with no consideration for same variables if these are not in the same position in the two files. Anyone k

Re: [R] Failed to install RMySQL,help!

2012-11-23 Thread Gabor Grothendieck
On Fri, Nov 23, 2012 at 3:29 AM, li1127217ye wrote: > I had installed R and MySQL ,then I input : >> install.packages('RMySQL',type='source') > show the message below, Why? Why shows "ERROR: configuration failed for > package 'RMySQL'"? > > 试开URL’http://mirrors.xmu.edu.cn/CRAN/src/contrib/RMySQL

Re: [R] Using cumsum with 'group by' ?

2012-11-23 Thread peter dalgaard
On Nov 23, 2012, at 12:04 , TheRealJimShady wrote: > Hi Arun & everyone, > > Thank you very much for your helpful suggestions. I've been working > through them, but have realised that my data is a little more > complicated than I said and that the solutions you've kindly provided > don't work. T

Re: [R] error in IF condition with factor evaluation

2012-11-23 Thread PIKAL Petr
Hi > -Original Message- > From: r-help-boun...@r-project.org [mailto:r-help-bounces@r- > project.org] On Behalf Of Rui Barradas > Sent: Friday, November 23, 2012 2:37 PM > To: edoardo baldoni > Cc: R-help@r-project.org > Subject: Re: [R] error in IF condition with factor evaluation > > He

Re: [R] Summary statistics for matrix columns

2012-11-23 Thread Pete Brecknock
frespider wrote > Hi, > > it is possible. but don't you think it will slow the code if you convert > to data.frame? > > Thanks > > Date: Thu, 22 Nov 2012 18:31:35 -0800 > From: > ml-node+s789695n4650500h51@.nabble > To: > frespider@ > Subject: RE: Summary statistics for matrix columns >

Re: [R] invalid colour name 'rgb(1.000,0,0)' error

2012-11-23 Thread Rui Barradas
Hello, Why paste? rgb() is a function, you need its return value, not a character string. r <- rgb(1.000,0,0) And the rest plots a graph in red. Hope this helps, Rui Barradas Em 23-11-2012 09:06, Manish Gupta escreveu: Hi, I m working on latex and R and i need to dynamically generate colo

Re: [R] error in IF condition with factor evaluation

2012-11-23 Thread Rui Barradas
Hello, Try if (!is.na(x[i]) && x[i] == "DISCONECTED") Hope this helps, Rui Barradas Em 23-11-2012 09:42, edoardo baldoni escreveu: Cam anyone tell me why the condition x[i] == "DISCONECTED" looks like producing an NA instead of TRUE/FALSE I would like to rename "DISCONNECTED" those factors

Re: [R] error in IF condition with factor evaluation

2012-11-23 Thread Eik Vettorazzi
Hi Edoardo, there is a difference between comparisons and assignments, both semantically as well as in R syntax: "==" vs "=" or "<-", latter being more obvious an assignment. This is the source of your error. But to change the labels of a factor object, it is easier to do sth like at<-factor(1:5,l

Re: [R] Function storing error messages in 32 bit R-2.15.2 version

2012-11-23 Thread Paarkhi
I am working with Maulik on this. We installed a 64-bit version of R 2.15.1 now but the ltm package is under version 2.15.2 The same problem is occurring even with this version. -- View this message in context: http://r.789695.n4.nabble.com/Function-storing-error-messages-in-32-bit-R-2-15-2-ver

Re: [R] Function storing error messages in 32 bit R-2.15.2 version

2012-11-23 Thread Paarkhi
The data we used for testing is pasted below - Note that our objective is to analyse a dataset with 60 items and about 25,000 candidates but we used the above to test if we get desired result and the two versions gave different results.

Re: [R] ROC Curve: negative AUC

2012-11-23 Thread brunosm
Thanks, Do you know how to correct it? Cheers, Bruno -- View this message in context: http://r.789695.n4.nabble.com/ROC-Curve-negative-AUC-tp4650469p4650530.html Sent from the R help mailing list archive at Nabble.com. __ R-help@r-project.org mail

[R] error in IF condition with factor evaluation

2012-11-23 Thread edoardo baldoni
Cam anyone tell me why the condition x[i] == "DISCONECTED" looks like producing an NA instead of TRUE/FALSE I would like to rename "DISCONNECTED" those factors inside the variable "dataset$STATUS.x" that are named "DISCONECTED" thank you > summary(dataset$STATUS.x) ACTIVE DISCONECTED P

[R] Failed to install RMySQL,help!

2012-11-23 Thread li1127217ye
I had installed R and MySQL ,then I input : > install.packages('RMySQL',type='source') show the message below, Why? Why shows "ERROR: configuration failed for package 'RMySQL'"? 试开URL’http://mirrors.xmu.edu.cn/CRAN/src/contrib/RMySQL_0.9-3.tar.gz' Content type 'application/x-gzip' length 165363

[R] invalid colour name 'rgb(1.000,0,0)' error

2012-11-23 Thread Manish Gupta
Hi, I m working on latex and R and i need to dynamically generate colors. r<-paste("rgb(1.000,",0,",",0,")",sep="") # i m generating dynamically by paste command cars <- c(1, 3, 6, 4, 9) plot(cars, type="o", col=r) *Error in plot.xy(xy, type, ...) : invalid colour name 'r

Re: [R] SEM raw moment matrix

2012-11-23 Thread John Fox
Dear Maya, sem() computes the fit statistics that I know how to compute for a model fit to a raw moment matrix. If you know how to compute the others (and if they're defined), then you could do that youself using the object returned by sem(). I'm not sure why you want the likelihood under the m

Re: [R] Adding a function with default parameters into the Rcmdr menu

2012-11-23 Thread Milan Bouchet-Valat
Le vendredi 23 novembre 2012 à 03:17 +0100, vincent guyader a écrit : > Hi everyone, > > I made some tests with Rcmdr, to add a function with default parameters : > > For example (very simple): > > myfunction<-function(var="314"){ > print("hello") > print(var) > } > > if I run myfunction() dire

Re: [R] Constant (= wrong) historical quotes via get.hist.quote() from yahoo.finance

2012-11-23 Thread Marius Hofert
Dear Achim, Thanks a lot for your quick help. Indeed, I did not realize that the "Download to Spreadsheet" gives the wrong result, so it's really a Yahoo! Finance issue (too bad, an R issue would have been easier to fix :-) ). Thanks again, Marius Achim Zeileis writes: > On Fri, 23 Nov 2012

Re: [R] Odp: Object Browser

2012-11-23 Thread Liviu Andronic
On Fri, Nov 23, 2012 at 6:44 AM, wampeh wrote: > How do I get gvarbrowser to display only data.frame named, say "atab1" or > "atab2" or "atab*"? > > Also, how do I turn off the selection pull down box? > Two remarks. If you hope to get an answer it would be a good idea to CC John Verzani, maintain

Re: [R] column name prefix 'x' after data import via read.delim

2012-11-23 Thread Gerrit Eichner
Hello, "e-letter", check ?read.delim and look for the argument check.names and from there you'll should end up reading ?make.names Hth -- Gerrit On Fri, 23 Nov 2012, e-letter wrote: Readers, The function 'read.delim' was used to import data into R: columnnamea columnnameb columnn

[R] column name prefix 'x' after data import via read.delim

2012-11-23 Thread e-letter
Readers, The function 'read.delim' was used to import data into R: columnnamea columnnameb columnnamec 1 2 3 2 3 4 3 4 5 After import, the column names were: X.columnnamea columnnameb columnnamec Why did this occur? -- r2151 __ R-help@r-project.org

Re: [R] help in M-estimator by R

2012-11-23 Thread S Ellison
> -Original Message- > i have to do something in robust regression by R programm , > and i have some problems as following: > > *the first :* Afte loading MAS, type 'hubers' (without brackets) and look at the code. That should give you a clue. > new psi ( psi.a=r/(1+(r/k)^2)) ,k=1.34

Re: [R] Constant (= wrong) historical quotes via get.hist.quote() from yahoo.finance

2012-11-23 Thread Achim Zeileis
On Fri, 23 Nov 2012, Marius Hofert wrote: Dear expeRts, I would like to download a time series of historical data from the ticker with symbol "ROG.VX". Interestingly, I obtain constant values (138.3 for each day in the chosen period) although the yahoo.finance website tells me that the time

Re: [R] printing difftime summary

2012-11-23 Thread R. Michael Weylandt
On Thu, Nov 22, 2012 at 5:49 PM, Sam Steingold wrote: >> * R. Michael Weylandt [2012-11-22 12:11:55 >> +]: >> >>> I now think that what I want is >>> --8<---cut here---start->8--- >>> difftime.summary <- function (v) { >>> s <- summary(as.numeric(v)) >>>

Re: [R] What is the . in formula ~. syntax?

2012-11-23 Thread Prof Brian Ripley
On 23/11/2012 08:16, Brian Feeny wrote: Thank you! I searched in the manual, but I did not see where this is mentioned, I looked under operators and in some of the formula documentation. It *is* documented on the help page for formula (and it is not an operator, so should not be in the docu

Re: [R] Sentiment analysis in R

2012-11-23 Thread Milan Bouchet-Valat
Le vendredi 23 novembre 2012 à 10:47 +0530, sushobhan just says"I QUIT" a écrit : > Hi All, > I am trying to perform sentiment analysis using R with the > help of the library(sentiment). I am using the function > classify_emotions(sentiment). It is basically selecting a particular

Re: [R] Factor function for coded numerical values

2012-11-23 Thread Milan Bouchet-Valat
Le jeudi 22 novembre 2012 à 13:12 -0800, maths123 a écrit : > I have s data set where 2 of the columns give the coded versions of the > factors A and B. Factor A is coded with 1, 2, 3. Factor B is coded with 1,2. > > How do use the factor function to convert these variables into factors, and > a

  1   2   >