Re: [R] Use or ??

2012-08-28 Thread David Winsemius
On Aug 28, 2012, at 9:54 PM, arun wrote: HI, If I understand your question correctly, this should give the result: dat1<-read.table(text=" A B C a b a x y z ",sep="",header=TRUE,stringsAsFactors=FALSE) within(dat1,{new_column<-ifelse(A==C|B==C,"y","n")}) # A B C new_column #1 a b a y

Re: [R] Use or ??

2012-08-28 Thread McGuire, Rhydwyn
Have a look at the documentation for ifelse() http://stat.ethz.ch/R-manual/R-devel/library/base/html/ifelse.html that should do what you need. Rhydwyn -Original Message- From: r-help-boun...@r-project.org [mailto:r-help-boun...@r-project.org] On Behalf Of Sapana Lohani Sent: Wednesda

Re: [R] Help on calculating spearman rank correlation for a data frame with conditions

2012-08-28 Thread arun
Hi, Try this: dat1<-read.table(text=" id  price  distance 1  2    4 1  3    5 2  4  8 2  5  9 3  6  3 3  4  8 ",sep="",header=TRUE) dat2<-split(dat1,dat1$id)  lapply(dat2,function(x) cor(x[2],x[3],method="spearman")) A.K. - Original Message - From: Yi To: R-help@r-project.org Cc: Sen

[R] Saving a Stata file with labels that are not just a copy of the variable name

2012-08-28 Thread McGuire, Rhydwyn
Hi I am trying to export dataframes to Stata with stata's labels, I have looked though the documentation for the foreign library and code for write.dta, (but not the complied code) and I can't find anything. Ideally what I want is something like write.dta(myDataFrame, labels = listOfLabels, fi

Re: [R] Use or ??

2012-08-28 Thread arun
HI, If I understand your question correctly, this should give the result: dat1<-read.table(text=" A B C a b a x y z ",sep="",header=TRUE,stringsAsFactors=FALSE) within(dat1,{new_column<-ifelse(A==C|B==C,"y","n")})  # A B C new_column #1 a b a  y #2 x y z  n A.K. - Original M

Re: [R] Help on calculating spearman rank correlation for a data frame with conditions

2012-08-28 Thread David Winsemius
On Aug 28, 2012, at 9:20 PM, R. Michael Weylandt wrote: On Tue, Aug 28, 2012 at 9:01 PM, Yi wrote: Dear all, Suppose my data frame is as follows: id price distance 1 2 4 1 35 ... 2 4 8 2 5 9 ... n 3 7 n 8 9 I would like to calculate the rank-order correlation betw

Re: [R] variable scope

2012-08-28 Thread Sam Steingold
> * Duncan Murdoch [2012-08-28 21:06:33 -0400]: > > On 12-08-28 5:55 PM, Sam Steingold wrote: >>> * R. Michael Weylandt [2012-08-28 13:45:35 >>> -0500]: >>> always you shouldn't need manual garbage collection. >> >> my observation is that gc in R sucks. >> (it cannot release small objects).

Re: [R] write.matrix.csr data conversion

2012-08-28 Thread R. Michael Weylandt
On Tue, Aug 28, 2012 at 11:39 PM, Sam Steingold wrote: >> * R. Michael Weylandt [2012-08-28 17:16:35 >> -0500]: >> >> install.packages by default goes to CRAN (the stable repository): > > how often are stable released made? > weekly? monthly? > At the discretion of the package maintainers and t

Re: [R] variable scope

2012-08-28 Thread Sam Steingold
> * Jeff Newmiller [2012-08-28 15:21:39 -0700]: > > Sam Steingold wrote: > >>> * R. Michael Weylandt [2012-08-28 >>13:45:35 -0500]: >>> always you shouldn't need manual garbage collection. >> >>my observation is that gc in R sucks. >>(it cannot release small objects). >>this is not specific

Re: [R] variable scope

2012-08-28 Thread Sam Steingold
> * R. Michael Weylandt [2012-08-28 17:30:06 > -0500]: > >> In my experience, the one point I've needed it was after freeing >> multiple very large objects when hitting memory limits. that's what I am doing. >> Rewriting that code to use functions rather than as one long >> imperative slog was

Re: [R] write.matrix.csr data conversion

2012-08-28 Thread Sam Steingold
> * R. Michael Weylandt [2012-08-28 17:16:35 > -0500]: > > install.packages by default goes to CRAN (the stable repository): how often are stable released made? weekly? monthly? > if you want the bleeding edge, install e1071 from R-forge (note you > might need a source install if the build bot

Re: [R] Estimation parameters of lognormal censored data

2012-08-28 Thread R. Michael Weylandt
On Tue, Aug 28, 2012 at 9:58 PM, Salma Wafi wrote: > Hi, I am trying to get the maximum likelihood estimator for lognormal > distribution with censored data;when we have left, interval and right > censord. I built my code in R, by writing the deriving of log likelihood > function and using newt

Re: [R] Help on calculating spearman rank correlation for a data frame with conditions

2012-08-28 Thread R. Michael Weylandt
On Tue, Aug 28, 2012 at 9:01 PM, Yi wrote: > Dear all, > > Suppose my data frame is as follows: > > id price distance > 1 2 4 > 1 35 > ... > 2 4 8 > 2 5 9 > ... > n 3 7 > n 8 9 > > I would like to calculate the rank-order correlation between price and > distance for each

Re: [R] Use or ??

2012-08-28 Thread R. Michael Weylandt
Suppose your data is called dfs: dfs$NEW_COLUMN <- ifelse(dfs$A == dfs$C | dfs$B == dfs$C, "y", "n") which says if dfs column A equals dfs column C or dfs column B equals dfs column C, put "y" else put "n"; then put the resulting vector into NEW_COLUMN of dfs. Note that if your data are factors

Re: [R] Get variable data Reading from the list

2012-08-28 Thread R. Michael Weylandt
On Tue, Aug 28, 2012 at 8:19 AM, Rantony wrote: > Here i have a variable > > MyVar <- data.frame(read.csv("D:\\Doc.csv")) read.csv() returns a data.frame so the outer call to data.frame() is superfluous. > > And now i am storing this variable name into a list. > > MyList <- list() > MyList [len

Re: [R] Inexplicably different results using subset vs bracket notation on logical variable

2012-08-28 Thread David Winsemius
On Aug 28, 2012, at 11:52 AM, Mauricio Cornejo wrote: Peter, You're right ... and I do think I've finally understood the help file on this. I somehow missed the connection between my variable's values, which include NAs, and the fact that those returned values are in turn indices for '[

[R] Help on calculating spearman rank correlation for a data frame with conditions

2012-08-28 Thread Yi
Dear all, Suppose my data frame is as follows: id price distance 1 2 4 1 35 ... 2 4 8 2 5 9 ... n 3 7 n 8 9 I would like to calculate the rank-order correlation between price and distance for each id. cor(price,distance,method = "spearman") calculate a correlation for

Re: [R] return first index for each unique value in a vector

2012-08-28 Thread arun
HI, Replacing seq_along() with which() slightly improved CPU time.   system.time({  set.seed(1)  A<-sample(1:5,1e6,replace=TRUE)  which(!duplicated(A))  A[which(!duplicated(A))]  }) #   user  system elapsed   #0.040   0.012   0.052  A.K. - Original Message - From: Bronwyn Rayfield T

[R] Estimation parameters of lognormal censored data

2012-08-28 Thread Salma Wafi
Hi, I am trying to get the maximum likelihood estimator for lognormal distribution with censored data;when we have left, interval and right censord. I built my code in R, by writing the deriving of log likelihood function and using newton raphson method but my estimators were too high " overest

[R] Get variable data Reading from the list

2012-08-28 Thread Rantony
Here i have a variable MyVar <- data.frame(read.csv("D:\\Doc.csv")) And now i am storing this variable name into a list. MyList <- list() MyList [length(MyList )+1]<- "MyVar" Now what is the requirement is, i need to call the variable name "MyVar" from the list "MyList " and get the data. ---

[R] Use or ??

2012-08-28 Thread Sapana Lohani
Hi, My data frame looks like A B C a b a x y z I want to add a new column which says "y" if either A or B matches with C and "n" if there is no match. How can I do that? Thanks [[alternative HTML version deleted]] __ R-help@r-project.o

Re: [R] return first index for each unique value in a vector

2012-08-28 Thread arun
HI, I was thinking about duplicated().  But, Bert already posted the solution.  The solution below is not very efficient. A<-c(9,2,9,5) unik<-as.numeric(names(table(A))) match(unik,A) #[1] 2 4 1 #Bert's solution wins here. system.time({ set.seed(1) A<-sample(1:5,1e6,replace=TRUE) unik <- !duplic

Re: [R] Error in ops.factor: check and verify

2012-08-28 Thread arun
HI, I just answered to one with similar contents but with a different title.  I guess both are the same. A.K. - Original Message - From: Sapana Lohani To: R help Cc: Sent: Tuesday, August 28, 2012 5:41 PM Subject: [R] Error in ops.factor: check and verify Hi, may be i was not clear

Re: [R] variable scope

2012-08-28 Thread Jeff Newmiller
--- Jeff NewmillerThe . . Go Live... DCN:Basics: ##.#. ##.#. Live Go... Live: OO#.. Dead: OO#.. Playing Research Engineer (Sola

[R] predict.lm(...,type="terms") question

2012-08-28 Thread John Thaden
Hello all, How do I actually use the output of predict.lm(..., type="terms") to predict new term values from new response values? I'm a chromatographer trying to use R (2.15.1) for one of the most common calculations in that business: - Given several chromatographic peak areas measured for

Re: [R] return first index for each unique value in a vector

2012-08-28 Thread William Dunlap
Here are two methods: > A<-c(9,2,9,5) > f1 <- function(x) { d <- !duplicated(x) ; data.frame(uniqueValue=x[d], > firstIndex=which(d)) } > f2 <- function(x) { u <- unique(x) ; data.frame(uniqueValue=u, > firstIndex=match(u, x))} > f1(A) uniqueValue firstIndex 1 9 1 2

Re: [R] [netcdfgroup] [ncdf4] error converting GEIA data to netCDF

2012-08-28 Thread Tom Roche
Tom Roche Tue, Aug 28, 2012 at 4:23 PM >> Can ncdf4 be made to fail more helpfully? E.g., to fail immediately >> on nc_open without assignment? David W. Pierce Tue, 28 Aug 2012 13:23:53 -0700 > I'll see if there exists some way to do a better check for this. TIA. > One of the many great things

Re: [R] How to average time series data around regular intervals

2012-08-28 Thread Jim Holtman
your specification was to have the data centered at 15 minute intervals and extend 7.5 minutes on either side. on my output you see the time of the lower value of the interval. 11:52:30 is the lower value of the 12:00:00 time. so you can just add back the 7.5 minutes to the time value to get

Re: [R] Search for locations of subsequences?

2012-08-28 Thread Duncan Murdoch
On 12-08-28 5:45 PM, Rui Barradas wrote: Hello, Try the following. occur1 <- function(pat, vec){ m <- length(pat) n <- length(vec) candidate <- seq.int(length=n-m+1) for (i in seq.int(length=m)) candidate <- candidate[pat[i] == vec[candidate + i - 1]] can

Re: [R] variable scope

2012-08-28 Thread Duncan Murdoch
On 12-08-28 5:55 PM, Sam Steingold wrote: * R. Michael Weylandt [2012-08-28 13:45:35 -0500]: always you shouldn't need manual garbage collection. my observation is that gc in R sucks. (it cannot release small objects). this is not specific to R; ocaml suffers too. Sorry, I didn't realize y

Re: [R] Search for locations of subsequences?

2012-08-28 Thread Duncan Murdoch
On 12-08-28 5:32 PM, Marc Schwartz wrote: On Aug 28, 2012, at 4:05 PM, Duncan Murdoch wrote: Is there a function to efficiently search for a subsequence within a vector? For example, with x <- 1:100 I'd like to search for the sequence c(49,50,51), and be told that it occurs exactly once, s

Re: [R] [netcdfgroup] [ncdf4] error converting GEIA data to netCDF

2012-08-28 Thread Pascal Oettli
De rien. You're welcome. Pascal Le 12/08/29 5:23, Tom Roche a écrit : Pascal Oettli: MERCI BEAUCOUP! (though I would have thanked you earlier if I hadn't had to dig through the r-help digest first :-) Tom Roche Mon, 27 Aug 2012 23:31:23 -0400 summary: I can successfully ncvar_put(...) data

Re: [R] Lattice graphics adding abline line (1:1 line) ???

2012-08-28 Thread Peter Ehlers
On 2012-08-27 15:49, iwaite wrote: I have read multiple books and looked at many posts online and can't seem to figure out how to add a 1:1 line in lattice xyplot. I've tried multiple versions of getting this to work, including trying "panel.abline(h=0,v=1), panel=function and others. Second que

Re: [R] return first index for each unique value in a vector

2012-08-28 Thread Robert Baer
On 8/28/2012 5:52 PM, Bert Gunter wrote: Sheesh! I would have thought that someone would have noticed that on the ?unique Help page there is a link to ?duplicated, which gives a _logical_ vector of the duplicates. From this, everything else can be quickly derived -- and packaged in a simple Matl

Re: [R] return first index for each unique value in a vector

2012-08-28 Thread Bert Gunter
Sheesh! I would have thought that someone would have noticed that on the ?unique Help page there is a link to ?duplicated, which gives a _logical_ vector of the duplicates. From this, everything else can be quickly derived -- and packaged in a simple Matlab like function, if you insist on that. e.

Re: [R] return first index for each unique value in a vector

2012-08-28 Thread Noia Raindrops
Hi, Try this: order(A)[!duplicated(sort(A))] -- Noia Raindrops noia.raindr...@gmail.com __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and

Re: [R] Error message

2012-08-28 Thread R. Michael Weylandt
It all looks up to date to me. The only one we can't see is lme4 (because it won't load) so could you also give us installed.packages()[c("lme4","nlme","Matrix"),c(2,3,12)] Beyond that, can you give your linux distro and installation details? It might be necessary to punt this to the R-Debian or

Re: [R] return first index for each unique value in a vector

2012-08-28 Thread R. Michael Weylandt
On Tue, Aug 28, 2012 at 2:58 PM, Bronwyn Rayfield wrote: > I would like to efficiently find the first index of each unique value in a > very large vector. > > For example, if I have a vector > > A<-c(9,2,9,5) > > I would like to return not only the unique values (2,5,9) but also their > first indi

Re: [R] variable scope

2012-08-28 Thread R. Michael Weylandt
On Tue, Aug 28, 2012 at 5:13 PM, R. Michael Weylandt wrote: > On Tue, Aug 28, 2012 at 4:55 PM, Sam Steingold wrote: >>> * R. Michael Weylandt [2012-08-28 13:45:35 >>> -0500]: >>> always you shouldn't need manual garbage collection. >> >> my observation is that gc in R sucks. >> (it cannot

Re: [R] variable scope

2012-08-28 Thread R. Michael Weylandt
On Tue, Aug 28, 2012 at 4:55 PM, Sam Steingold wrote: >> * R. Michael Weylandt [2012-08-28 13:45:35 >> -0500]: >> >>> always you shouldn't need manual garbage collection. > > my observation is that gc in R sucks. > (it cannot release small objects). > this is not specific to R; ocaml suffers too

Re: [R] write.matrix.csr data conversion

2012-08-28 Thread R. Michael Weylandt
install.packages by default goes to CRAN (the stable repository): if you want the bleeding edge, install e1071 from R-forge (note you might need a source install if the build bot hasn't gotten to it since the update) https://r-forge.r-project.org/R/?group_id=786 Cheers, Michael On Tue, Aug 28, 2

Re: [R] check and verify

2012-08-28 Thread arun
HI, If you wish to keep it as factors (A-D), then try this: test<-read.table(text="  A B C D E F  a b c d 40 30  a f a b 20 10  x m y m 50 30 ",sep="",header=TRUE) str(test) #'data.frame':    3 obs. of  6 variables: # $ A: Factor w/ 2 levels "a","x": 1 1 2 # $ B: Factor w/ 3 levels "b","f","m":

[R] Error in ops.factor: check and verify

2012-08-28 Thread Sapana Lohani
Hi, may be i was not clear when I made this query before. I have 6 columns in my dataframe (test) A B C D E F a b c d 40 30 a f a b 20 10 x m y m 50 30 I want a new column which gets value in E if character value in column A matches with that in column C. One more column comparing B and D. It

Re: [R] Inexplicably different results using subset vs bracket notation on logical variable

2012-08-28 Thread Mauricio Cornejo
Peter, You're right ... and I do think I've finally understood the help file on this.  I somehow missed the connection between my variable's values, which include NAs, and the fact that those returned values are in turn indices for '['. OK ... I'm all straight on this now.  (I lost count of how

Re: [R] barchart with 3 Arguments

2012-08-28 Thread David
The listserver is very good about passing on attachments IF AND ONLY IF they are text or an acceptable image format. -- David Sent from my iPhone On Aug 28, 2012, at 11:17 AM, John Kane wrote: > No data is attached. The R-help list usually strips out attachments to > prevent viruses or malw

[R] K-Means clustering Algorithm

2012-08-28 Thread olemissrebs1123
I was wondering if there was an R equivalent to the two phased approach that MATLAB uses in performing the Kmeans algorithm. If not is there away that I can determine if the kmeans in R and the kmeans in MATLAB are essentially giving me the same clustering information within a small amount of erro

Re: [R] check and verify

2012-08-28 Thread arun
HI, Try this: test<-read.table(text="  A B C D E F  a b c d 40 30  a f a b 20 10  x m y m 50 30 ",sep="",header=TRUE,stringsAsFactors=FALSE) #Here, stringsAsFactors=FALSE is the key here.  If you did not add that (or =TRUE) , by default, A-D columns will be factors and you will get the error mess

[R] return first index for each unique value in a vector

2012-08-28 Thread Bronwyn Rayfield
I would like to efficiently find the first index of each unique value in a very large vector. For example, if I have a vector A<-c(9,2,9,5) I would like to return not only the unique values (2,5,9) but also their first indices (2,4,1). I tried using a for loop with which(A==unique(A)[i])[1] to

Re: [R] Error message

2012-08-28 Thread Scott Raynaud
Here's the sessinoInfo().  I didn't do the upgrade and I don't know how to interpret the output. > sessionInfo() R version 2.15.1 (2012-06-22) Platform: x86_64-pc-linux-gnu (64-bit) locale:  [1] LC_CTYPE=en_US.UTF-8  LC_NUMERIC=C  [3] LC_TIME=en_US.UTF-8   LC_COL

Re: [R] find and replace

2012-08-28 Thread arun
HI, You can also try this: Students1<-data.frame(ID=c(101,201,303,304),Name=c("Andrew","John","Julie","Monica"),Fav_Place=c("Phoenix AZ","San Francisco","California/New York","New York"))   gsubfun<-function(pattern,replacement,x, ...){  for(i in seq_along(pattern))  x<-gsub(pattern[i],replacement

Re: [R] [netcdfgroup] [ncdf4] error converting GEIA data to netCDF

2012-08-28 Thread Tom Roche
Roy Mendelssohn Tue, 28 Aug 2012 09:07:32 -0700 > here is the relevant section from your code: > > netcdf.file <- nc_create( > > filename=netcdf.fn, > > # vars=list(emis.var), > > # verbose=TRUE) > > vars=list(emis.var)) > > # Write data to data variable: gotta have file first. > > # Gotta

Re: [R] Standard deviation from MANOVA??

2012-08-28 Thread BrutishFruit
Thanks for all help so far! And I seems as you are correct Peter (and Jean too). And I have now investigated and found how it is connected with the standard errors: If use the following code (taking from Jeans example code), where we have one manova and two individual models (continue read comment

Re: [R] write.matrix.csr data conversion

2012-08-28 Thread Sam Steingold
Thanks, when will I be able to use the new code? I just did install.packages("e1071") + library(e1071). no good. do I need to restart R? thanks! > * David Meyer [2012-08-27 22:57:17 +0200]: > > done, thanks for the suggestion. > > On 2012-08-27 21:15, Sam Steingold wrote: >> >> David, could you p

Re: [R] variable scope

2012-08-28 Thread Sam Steingold
> * R. Michael Weylandt [2012-08-28 13:45:35 > -0500]: > >> always you shouldn't need manual garbage collection. my observation is that gc in R sucks. (it cannot release small objects). this is not specific to R; ocaml suffers too. > since a loop doesn't define its own scope like some languages

Re: [R] Search for locations of subsequences?

2012-08-28 Thread Rui Barradas
Hello, Try the following. occur1 <- function(pat, vec){ m <- length(pat) n <- length(vec) candidate <- seq.int(length=n-m+1) for (i in seq.int(length=m)) candidate <- candidate[pat[i] == vec[candidate + i - 1]] candidate } patrn <- c(1,2,3,4) exmpl <- c(3,3,4,2,3,1,2

Re: [R] Search for locations of subsequences?

2012-08-28 Thread Marc Schwartz
On Aug 28, 2012, at 4:05 PM, Duncan Murdoch wrote: > Is there a function to efficiently search for a subsequence within a vector? > > For example, with > > x <- 1:100 > > I'd like to search for the sequence c(49,50,51), and be told that it occurs > exactly once, starting at location 49. (The

[R] Search for locations of subsequences?

2012-08-28 Thread Duncan Murdoch
Is there a function to efficiently search for a subsequence within a vector? For example, with x <- 1:100 I'd like to search for the sequence c(49,50,51), and be told that it occurs exactly once, starting at location 49. (The items in the vectors might be numeric or character, and there migh

Re: [R] [netcdfgroup] [ncdf4] error converting GEIA data to netCDF

2012-08-28 Thread David W. Pierce
> > - Nothing about the error text (IMHO) would lead one to the fix. > > (Note also that neither ncvar_put or nc_close appear to require > assignment, which is probably what made me think I could nc_open > without assignment.) > > Can ncdf4 be made to fail more helpfully? E.g., to fail immediately

Re: [R] [netcdfgroup] [ncdf4] error converting GEIA data to netCDF

2012-08-28 Thread Tom Roche
Pascal Oettli: MERCI BEAUCOUP! (though I would have thanked you earlier if I hadn't had to dig through the r-help digest first :-) Tom Roche Mon, 27 Aug 2012 23:31:23 -0400 >> summary: I can successfully ncvar_put(...) data to a file, but when >> I try to ncvar_get(...) the same data I get >> >

Re: [R] [netcdfgroup] [ncdf4] error converting GEIA data to netCDF

2012-08-28 Thread Roy Mendelssohn
On Aug 28, 2012, at 12:24 PM, Tom Roche wrote: > > Roy Mendelssohn Tue, 28 Aug 2012 09:07:32 -0700 >> here is the relevant section from your code: > >>> netcdf.file <- nc_create( >>> filename=netcdf.fn, >>> # vars=list(emis.var), >>> # verbose=TRUE) >>> vars=list(emis.var)) > >>> # Write d

Re: [R] Package cwhmisc and problems

2012-08-28 Thread William Dunlap
You could try running the dependency checker function directly and then using the usual R debugging tools to start tracking down the problem. E.g., I have a package in ~/packages/foo with a bogus entry in the Depends line of DESCRIPTION: > tools:::.check_package_depends(dir="~/packages/foo") Packa

Re: [R] Font size in geom_dl (using ggplot2)

2012-08-28 Thread John Kane
Sample data? Some representative sample data really is needed to see what you are doing. Have a look at dput() for a handy way to present data. Also where did theme_complete_bw come from? Is it a special formattng function? John Kane Kingston ON Canada > -Original Message- > F

[R] Package cwhmisc and problems

2012-08-28 Thread Christian Hoffmann
Hi, I have revised my package cwhmisc and want to re-submit it (meeting a deadline soon). One big stumbling stone is the 'sudden' appearance of > sessionInfo() R version 2.15.1 (2012-06-22) Platform: x86_64-apple-darwin9.8.0/x86_64 (64-bit) locale: [1] C attached base packages: [1] tools

Re: [R] corrgram

2012-08-28 Thread Rui Barradas
Hello, You should say which package you are getting 'corrgram' from. I'll assume it's from package corrgram. The answer to your question is not in the help page but part of it is, it says it calls function 'col.corrgram'. And R is open source so a quick look at the package *.R sources (only

Re: [R] don't print object attributes

2012-08-28 Thread Duncan Murdoch
On 28/08/2012 2:16 PM, Liviu Andronic wrote: On Tue, Aug 28, 2012 at 7:34 PM, Duncan Murdoch wrote: > Assign a class to the object, and write a print method for it. > > For example, this doesn't quite do what you want, but it's a start: > > print.noattributes <- function(x, ...) { >attribute

Re: [R] variable scope

2012-08-28 Thread Duncan Murdoch
On 28/08/2012 2:29 PM, Sam Steingold wrote: At the end of a for loop its variables are still present: for (i in 1:10) { x <- vector(length=1) } ls() will print "i" and "x". this means that at the end of the for loop body I have to write rm(x) gc() is there a more elegant way

Re: [R] variable scope

2012-08-28 Thread Marc Schwartz
On Aug 28, 2012, at 1:29 PM, Sam Steingold wrote: > At the end of a for loop its variables are still present: > > for (i in 1:10) { > x <- vector(length=1) > } > ls() > > will print "i" and "x". > this means that at the end of the for loop body I have to write > > rm(x) > gc() > >

Re: [R] variable scope

2012-08-28 Thread R. Michael Weylandt
On Tue, Aug 28, 2012 at 1:37 PM, R. Michael Weylandt wrote: > On Tue, Aug 28, 2012 at 1:29 PM, Sam Steingold wrote: >> At the end of a for loop its variables are still present: >> >> for (i in 1:10) { >> x <- vector(length=1) >> } >> ls() >> >> will print "i" and "x". >> this means that

Re: [R] variable scope

2012-08-28 Thread Bert Gunter
Perhaps I'm dense, but huh*? -- Bert *e.g. What are you trying to do? R does it's own garbage collection -- why do you think you need it? And, as a general comment which may or may not be applicable, if you create variables in a function they are local only to the function -- they disappear once t

Re: [R] variable scope

2012-08-28 Thread Rui Barradas
Hello, Maybe local(). Continue your example with #?local local(for (i in 1:10) { x <- vector(length=1) }) ls() # not 'i' nor 'x' Hope this helps, Rui Barradas Em 28-08-2012 19:29, Sam Steingold escreveu: At the end of a for loop its variables are still present: for (i in 1:10) {

Re: [R] variable scope

2012-08-28 Thread R. Michael Weylandt
On Tue, Aug 28, 2012 at 1:29 PM, Sam Steingold wrote: > At the end of a for loop its variables are still present: > > for (i in 1:10) { > x <- vector(length=1) > } > ls() > > will print "i" and "x". > this means that at the end of the for loop body I have to write > > rm(x) > gc() >

[R] variable scope

2012-08-28 Thread Sam Steingold
At the end of a for loop its variables are still present: for (i in 1:10) { x <- vector(length=1) } ls() will print "i" and "x". this means that at the end of the for loop body I have to write rm(x) gc() is there a more elegant way to handle this? Thanks. -- Sam Steingold (http

Re: [R] don't print object attributes

2012-08-28 Thread R. Michael Weylandt
On Tue, Aug 28, 2012 at 1:16 PM, Liviu Andronic wrote: > On Tue, Aug 28, 2012 at 7:34 PM, Duncan Murdoch > wrote: >> Assign a class to the object, and write a print method for it. >> >> For example, this doesn't quite do what you want, but it's a start: >> >> print.noattributes <- function(x, ...

Re: [R] don't print object attributes

2012-08-28 Thread Liviu Andronic
On Tue, Aug 28, 2012 at 7:34 PM, Duncan Murdoch wrote: > Assign a class to the object, and write a print method for it. > > For example, this doesn't quite do what you want, but it's a start: > > print.noattributes <- function(x, ...) { >attributes(x) <- NULL >print(x) > } > > class(x) <-

Re: [R] date in plot, can't add regression line

2012-08-28 Thread Rui Barradas
Hello, Inline. Em 28-08-2012 18:23, Nordlund, Dan (DSHS/RDA) escreveu: -Original Message- From: r-help-boun...@r-project.org [mailto:r-help-bounces@r- project.org] On Behalf Of Norbert Skalski Sent: Tuesday, August 28, 2012 9:49 AM To: r-help@r-project.org Subject: [R] date in plot, can'

Re: [R] Inexplicably different results using subset vs bracket notation on logical variable

2012-08-28 Thread Peter Ehlers
On 2012-08-28 07:44, Mauricio Cornejo wrote: William, David, and Peter, Thank you all so much for your help on this. Though I had read the help files on 'subset' and '[', I had not been able to discern from that text what the problem was. I could not have solved it without your help. The

Re: [R] date in plot, can't add regression line

2012-08-28 Thread John Kane
First of all, a practical way to supply data is to use the function dput() Just do dput(mydata) and copy and paste the results into your email. The reader can copy and paste into R and have an identical data set. I am not sure I have followed exactly what you are doing but here is something th

Re: [R] don't print object attributes

2012-08-28 Thread Peter Ehlers
On 2012-08-28 10:34, Duncan Murdoch wrote: On 28/08/2012 1:12 PM, Liviu Andronic wrote: Dear all Suppose the object below: require(Hmisc) require(plyr) x <- dlply(iris, .(Species), describe) How can I print the object without displaying the attributes? I inspected ?print and ?print.default wi

Re: [R] don't print object attributes

2012-08-28 Thread Duncan Murdoch
On 28/08/2012 1:12 PM, Liviu Andronic wrote: Dear all Suppose the object below: > require(Hmisc) > require(plyr) > x <- dlply(iris, .(Species), describe) How can I print the object without displaying the attributes? I inspected ?print and ?print.default with no luck. Assign a class to the obje

Re: [R] date in plot, can't add regression line

2012-08-28 Thread Nordlund, Dan (DSHS/RDA)
> -Original Message- > From: r-help-boun...@r-project.org [mailto:r-help-bounces@r- > project.org] On Behalf Of Norbert Skalski > Sent: Tuesday, August 28, 2012 9:49 AM > To: r-help@r-project.org > Subject: [R] date in plot, can't add regression line > > Hello all, > > I have been using R

Re: [R] barchart with 3 Arguments

2012-08-28 Thread John Kane
No data is attached. The R-help list usually strips out attachments to prevent viruses or malware spreading. Use dput to include the data . Just do : dput(mydata) and copy the results into your email. Also it is a good idea to include the code that you are using. John Kane Kingston ON Canad

[R] don't print object attributes

2012-08-28 Thread Liviu Andronic
Dear all Suppose the object below: > require(Hmisc) > require(plyr) > x <- dlply(iris, .(Species), describe) How can I print the object without displaying the attributes? I inspected ?print and ?print.default with no luck. > x $setosa x[, "Sepal.Length"] n missing uniqueMean .05

Re: [R] Standard deviation from MANOVA??

2012-08-28 Thread peter dalgaard
On Aug 27, 2012, at 19:15 , BrutishFruit wrote: > Hi David. > I mean that I want to get the *standard error of the predicted means* (which > is a type standard deviation, if I have understand everything right), which > the se.fit switch mentioned above should require from the "predict()" > functi

Re: [R] Course

2012-08-28 Thread Duncan Murdoch
On 28/08/2012 9:42 AM, Pedro Henrique Lamarão Souza wrote: Hello, I am a student of Materials Engineering and I want to minister an introductory course of R at the university I study here in Brazil. I know R is a free software, but I just want to know if I do need a special authorization for

Re: [R] Create and Assign value into a variable from Another variable

2012-08-28 Thread arun
HI, Try this:  Variable_1<-"MyDataFrame"  set.seed(1)   assign(Variable_1,sample(1:5,replace=TRUE))  assign(Variable_1,rbind(get(Variable_1),1:5))  get(Variable_1) # [,1] [,2] [,3] [,4] [,5] #[1,]    2    2    3    5    2 #[2,]    1    2    3    4    5 A.K. - Original Message - From

Re: [R] Course

2012-08-28 Thread R. Michael Weylandt
Though, for the record, it is perfectly legal and rather common to charge for _instruction_ in R, just not for R itself.[1] This is done, inter alia, at the UserR conferences. Similarly, one could charge for books on R (physical or digital), for code deliverables in R, etc. Cheers, Michael [1] Ac

[R] barchart with 3 Arguments

2012-08-28 Thread Geophagus
Hi @ all, I have a problem concerning the barplot (barchart lattice) of a dataframe. I work with the attached dataframe. When I try to plot this dataframe I only get two rows plottet. When I try to plot the whole dataframe, there is message, that it is 'height' must be a vector or a matrix. On the

Re: [R] Create and Assign value into a variable from Another variable

2012-08-28 Thread Greg Snow
Others have mentioned assign and get, but generally when the answer to a question is "assign" it means that you are asking the wrong question (see fortune(236)). This is actually FAQ 7.21, the most useful part of the answer in the FAQ is the last few lines. If you tell us more about what you are

[R] date in plot, can't add regression line

2012-08-28 Thread Norbert Skalski
Hello all, I have been using R for about 3 weeks and I am frustrated by a problem. I have read R in a nutshell, scoured the internet for help but I either am not understanding examples or am missing something completely basic. Here is the problem: I want to plot data that contains dates on t

Re: [R] R Download 'Permission Denied'

2012-08-28 Thread TwistedSkies
Ahhh that makes sense now. I figured that the name would be that of the file you were downloading. Feel a bit stupid now, many thanks! -- View this message in context: http://r.789695.n4.nabble.com/R-Download-Permission-Denied-tp4641568p4641582.html Sent from the R help mailing list archiv

Re: [R] [netcdfgroup] [ncdf4] error converting GEIA data to netCDF

2012-08-28 Thread Roy Mendelssohn
Hi Tom: Sorry for top-posting. My bad etiquette for the day. The order that you do things when you create nercdf files matters a lot. Here is a section from the help for ncdf4: > If you want to WRITE data to a new netCDF file, the procedure is to first > define the dimensions your data arra

Re: [R] Create and Assign value into a variable from Another variable

2012-08-28 Thread S Ellison
> > Now, " MyDataFrame " is a variable and containing some > values in that. > > And Now, the problem what is I need to do "rbind" into the > variable " > > MyDataFrame ". > > > > I tried to do, > > rbind(as.character(Variable_1), > > data.frame(read.csv("c:\\My2ndData.csv"))) > > The above

Re: [R] Course

2012-08-28 Thread Jeff Newmiller
I am not a lawyer, and you should not ask for such advice on the Web. However, if you read the GNU license, it does not mention such activities. Money is not traditionally the issue with free software... the obligation to pass the source along if you change it is. I have personally taken a cours

Re: [R] Error message

2012-08-28 Thread Duncan Murdoch
On 28/08/2012 10:31 AM, Scott Raynaud wrote: I suddenly started getting the error message below. Not sure why. If I type intalled.packages() it shows Matrix and lme4 installed. Can someone tell what's going on and what I need to do to remedy the problem? I'm running on a Linux box.

Re: [R] Course

2012-08-28 Thread Albyn Jones
Dear Pedro in your R session, enter the commands license() RShowDoc("COPYING") "R is free software and comes with ABSOLUTELY NO WARRANTY. You are welcome to redistribute it under certain conditions." Those imply no restriction on charging a fee for presenting courses in R. albyn

Re: [R] R Download 'Permission Denied'

2012-08-28 Thread Berend Hasselman
On 28-08-2012, at 16:57, TwistedSkies wrote: > Hello, > > I am receiving a 'Permission Denied' error when trying to use the R Download > funtion. > > I am wondering if this is a: > > - Error in the code > - Permissions issue at source > - Permissions issue at destination. > > If you could she

[R] Course

2012-08-28 Thread Pedro Henrique Lamarão Souza
Hello, I am a student of Materials Engineering and I want to minister an introductory course of R at the university I study here in Brazil. I know R is a free software, but I just want to know if I do need a special authorization for doing it. The course will be totaly free and I also will not

Re: [R] Unzip files from the given path to the destination path

2012-08-28 Thread R. Michael Weylandt
googling "R unzip files" gives this as the first hit: http://stackoverflow.com/questions/3053833/using-r-to-download-zipped-data-file-extract-and-import-data Dirk's answer should get you started, but note that there are different zip protocols, so you might need to modify for your data. Cheers,

Re: [R] find and replace

2012-08-28 Thread arun
Hi, Try this: dat1<-readLines(textConnection(  "ID Name Fav_Place  101 Andrew  Phoenix,AZ  201 John SanFrancisco  303 Julie California/New York  304 Monica  New York"))  gsub("Phoenix","Tucson",gsub("New York","New York City",dat1)) #[1] "ID Name Fav_Place"  "101 Andrew  Tucson,AZ

Re: [R] find and replace

2012-08-28 Thread arun
Hi, Try this: set.seed(1)  dat1<-data.frame(A=sample(letters[20:25],replace=TRUE),B=sample(letters[1:6],replace=TRUE),C=c(letters[1:3],letters[3:1]),D=sample(letters[2:7],replace=TRUE),E=sample(letters[21:26],replace=TRUE))  newdat<-list()  for(i in 1:ncol(dat1)){  newdat[[i]]<-list()  newdat[[i]]<

  1   2   >