[R] suppress output of makeCluster()
I'm trying to suppress the output of: makeCluster(detectCores()) and haven't had luck. So far, I've tried invisible, sink, and capture.output. Any ideas are appreciated. Thanks. -- View this message in context: http://r.789695.n4.nabble.com/suppress-output-of-makeCluster-tp4632904.html Sent from the R help mailing list archive at Nabble.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 provide commented, minimal, self-contained, reproducible code.
[R] Multivariate Laplace density
Can anyone show how to calculate a multivariate Laplace density? Thanks. -- View this message in context: http://r.789695.n4.nabble.com/Multivariate-Laplace-density-tp3864072p3864072.html Sent from the R help mailing list archive at Nabble.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 provide commented, minimal, self-contained, reproducible code.
Re: [R] Multivariate normal density in C for R
Dimitris, Thanks for the great code. When the number of rows of X and mu are large, it is probably faster due to R's vectorization. Thanks again. -- View this message in context: http://r.789695.n4.nabble.com/Multivariate-normal-density-in-C-for-R-tp3624602p3625857.html Sent from the R help mailing list archive at Nabble.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 provide commented, minimal, self-contained, reproducible code.
Re: [R] Multivariate normal density in C for R
IIRC, package mvtnorm will allow an X matrix, but requires mu to be a vector, so although it's close, it won't do it all...but all suggestions are well received. Dimitrius, you don't happen to have the multivariate t form of that function, do you? -- View this message in context: http://r.789695.n4.nabble.com/Multivariate-normal-density-in-C-for-R-tp3624602p3626127.html Sent from the R help mailing list archive at Nabble.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 provide commented, minimal, self-contained, reproducible code.
[R] Multivariate normal density in C for R
Does anyone know of a package that uses C code to calculate a multivariate normal density? My goal is to find a faster way to calculate MVN densities and avoid R loops or apply functions, such as when X and mu are N x K matrices, as opposed to vectors, and in this particular case, speed really matters. I would like to be able to use .C or .Call to pass X, mu, Sigma, and N to a C program and have it return a vector of log densities to R. I'm new to putting C in R, but am sure I'll figure it out. Thanks for any suggestions. -- View this message in context: http://r.789695.n4.nabble.com/Multivariate-normal-density-in-C-for-R-tp3624602p3624602.html Sent from the R help mailing list archive at Nabble.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 provide commented, minimal, self-contained, reproducible code.
[R] How would you avoid loops in this simple example?
I'm trying to code more R-like and avoid loops. Here is an example I'm having a hard time getting away from loops with, and the real matrices are rather large, and the computation is too time-consuming. ### Dimensions N - 2 M - 3 P - 4 ### Array and Matrices nu - array(NA,dim=c(N,M,P)) Lambda - matrix(1:12,P,M) F - matrix(1:8,N,P) ### Loop to avoid for (i in 1:N) {for (m in 1:M) {for (p in 1:P) { nu[i,m,p] - Lambda[p,m] * F[i,p] }}} Any help is appreciated. Thanks. -- View this message in context: http://r.789695.n4.nabble.com/How-would-you-avoid-loops-in-this-simple-example-tp3390017p3390017.html Sent from the R help mailing list archive at Nabble.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 provide commented, minimal, self-contained, reproducible code.
Re: [R] How would you avoid loops in this simple example?
Thanks for the help, and now I have some functions to learn. Both suggestions work great, really appreciate it. -- View this message in context: http://r.789695.n4.nabble.com/How-would-you-avoid-loops-in-this-simple-example-tp3390017p3390549.html Sent from the R help mailing list archive at Nabble.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 provide commented, minimal, self-contained, reproducible code.
Re: [R] Sweave: \Sexpr{} inside ?
Thanks Duncan, that helps. It successfully displays what I'm looking for, but it is not executing it. In a previous code chunk, it notes the time it took to run something, and in the successive code chunk, it runs something else where the previous time is now a parameter, but I'd like it to numerically display that previous time in the new chunk, rather than a variable name I create for it behind the scenes. Is this possible? Many thanks. -- View this message in context: http://r.789695.n4.nabble.com/Sweave-Sexpr-inside-tp3237313p3238764.html Sent from the R help mailing list archive at Nabble.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 provide commented, minimal, self-contained, reproducible code.
[R] Sweave: \Sexpr{} inside ?
Hi, Is it possible in Sweave to put \Sexpr{} inside ? This is a bad example, but here goes: results=hide Age - 5 @ x - \Sexpr{Age} @ I'm trying to get it to display x - 5, rather than x - Age. It's probably so obvious I'm going to feel sorry for having to ask, just the same, I'm stumped. Any ideas? Thanks. -- View this message in context: http://r.789695.n4.nabble.com/Sweave-Sexpr-inside-tp3237313p3237313.html Sent from the R help mailing list archive at Nabble.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 provide commented, minimal, self-contained, reproducible code.
[R] Referring to an object name from within a function
Can anyone show me how to refer to an object name that is passed to a function, from within the function? For example: MyModel - 1 test - function(x) { if(x == 1) {cat(x is a valid object.\n)} } test(x) What I would like this to do is pass MyModel to function test, and if it passes a test, be able to print MyModel is a valid object. Thanks. -- View this message in context: http://r.789695.n4.nabble.com/Referring-to-an-object-name-from-within-a-function-tp3167147p3167147.html Sent from the R help mailing list archive at Nabble.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 provide commented, minimal, self-contained, reproducible code.
Re: [R] Referring to an object name from within a function
Excellent, thanks, and sorry about the test(x) goof. -- View this message in context: http://r.789695.n4.nabble.com/Referring-to-an-object-name-from-within-a-function-tp3167147p3167174.html Sent from the R help mailing list archive at Nabble.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 provide commented, minimal, self-contained, reproducible code.
[R] Laplace Approximation
Does anyone have any R code that shows how to do a Laplace Approximation? I know there are a variety of these numerical approximation algorithms and I'm pretty open at this point, I'm just curious how it's approximated in R code. I have seen some functions in packages, but I think they all call C code, and am looking for an example in R only. Thanks. -- View this message in context: http://r.789695.n4.nabble.com/Laplace-Approximation-tp3058004p3058004.html Sent from the R help mailing list archive at Nabble.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 provide commented, minimal, self-contained, reproducible code.
[R] WhisperStation R
What do you think of this: http://www.microway.com/whisperstation/whisperstation-r.html I'm considering ditching my Windows Vista 2 GB RAM computer for WhisperStation R using Debian 64-bit Linux with 32 GB RAM and setting the whole thing up for R and WinBUGS. I put in a price request, but I know nothing about Linux, or WhisperStation R for that matter, and am really curious what you think? -- View this message in context: http://www.nabble.com/WhisperStation-R-tp21678280p21678280.html Sent from the R help mailing list archive at Nabble.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 provide commented, minimal, self-contained, reproducible code.
Re: [R] Help with maps
I'm brand new to the map function too, here's my attempt at coloring a map of the states according to a rate (rather than count): map('state')$names MyCount - c(1:63); MyRate - runif(63, 0, 1) map('state', fill=TRUE, col=rgb((1-MyRate),MyRate,0,1)) Seeing that there are 63 states, means you'll have to adjust your data to fit. For example, look at Washington. I think the effect of MyRate on color is that as it approaches 1, rgb produces green, and as it approaches 0, rgb produces red. I know you were asking for counts, but I just had this handy, and I'm learning too. Cheers. -- View this message in context: http://www.nabble.com/Help-with-maps-tp20804115p20874881.html Sent from the R help mailing list archive at Nabble.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 provide commented, minimal, self-contained, reproducible code.
Re: [R] What's the BEST way in R to adapt this vector?
Thanks for the help, I've a few more functions to get familiar with. Those are definitely concise ways to do this! :) -- View this message in context: http://www.nabble.com/What%27s-the-BEST-way-in-R-to-adapt-this-vector--tp20638991p20647978.html Sent from the R help mailing list archive at Nabble.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 provide commented, minimal, self-contained, reproducible code.
[R] What's the BEST way in R to adapt this vector?
Goal: Suppose you have a vector that is a discrete variable with values ranging from 1 to 3, and length of 10. We'll use this as the example: y - c(1,2,3,1,2,3,1,2,3,1) ...and suppose you want your new vector (y.new) to be equal in length to the possible discrete values (3) times the length (10), and formatted in such a way that if y[1] == 1, then y.new[1:3] == c(1,0,0), and if y[2] == 2, then y.new[4:6] == c(0,1,0). For example, the final goal should be: y.new - c(1,0,0,0,1,0,0,0,1,1,0,0,0,1,0,0,0,1,1,0,0,0,1,0,0,0,1,1,0,0) Note: I know how to do this with loops, but that's not taking advantage of R's capabilities with vectors and, I suspect, matrices. So far, my best guess would be to start as follows: y1 - ifelse(y == 1, 1, 0) y2 - ifelse(y == 2, 1, 0) y3 - ifelse(y == 3, 1, 0) From here, maybe put these into a 10x3 matrix, and read them out by row into y.new? Is that even the most efficient way? If it is, I'm sure I can get them into a matrix, but how do I read them out correctly? Thanks for any input. -- View this message in context: http://www.nabble.com/What%27s-the-BEST-way-in-R-to-adapt-this-vector--tp20638991p20638991.html Sent from the R help mailing list archive at Nabble.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 provide commented, minimal, self-contained, reproducible code.
[R] How do you apply a function to each variable in a data frame?
I want to apply a more complicated function than what I use in my example, but the idea is the same: Suppose you have a data frame named x and you want to a function applied to each variable, we'll just use the quantile function for this example. I'm trying all sorts of apply functions, but not having luck. My best guess would be: sapply(x, FUN=quantile) -- View this message in context: http://www.nabble.com/How-do-you-apply-a-function-to-each-variable-in-a-data-frame--tp20304332p20304332.html Sent from the R help mailing list archive at Nabble.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 provide commented, minimal, self-contained, reproducible code.
Re: [R] How do you apply a function to each variable in a data frame?
Thank you all for the help, sometime soon I'll know enough to be able to help others who are learning this. Thanks. -- View this message in context: http://www.nabble.com/How-do-you-apply-a-function-to-each-variable-in-a-data-frame--tp20304332p20308611.html Sent from the R help mailing list archive at Nabble.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 provide commented, minimal, self-contained, reproducible code.
Re: [R] Dealing With Extremely Large Files
Thank you Gabor, this is fantastic, easy to use and so powerful. I was instantly able to many things with .csv files that are much too large for my PC's memory. This is clearly my new favorite way to read in data, I love it! Is it possible to use sqldf with a fixed width format that requires a file layout? For example, let's say you have a .dat file called madeup.dat, without a header row. The hypothetical file madeup.dat for discussion has 3 variables (state, zipcode, and score), is 10 characters wide, and has 20 rows (again, just a made-up file). Here is my fumbling attempt at code that will read in only state and score, and randomly select 10 obs: library(sqldf) # Source pulls in the development version of sqldf. source(http://sqldf.googlecode.com/svn/trunk/R/sqldf.R;) #Open a connection to that file. MyConnection - file(madeup.dat) # Read in only state and score variables, and randomly select only 10 rows. MyData - sqldf(select state,score from MyConnection order by random(*) limit 10) # I think everything about this would work, except it should not currently know which # columns are to be brought in for the state variable (which would be 1-2), and that # the text columns for zipcode (3-7) should be ignored, and finally that score (text # columns 8-10) should be included again. If I have overlooked this, I apologize. # Thank you. -- View this message in context: http://www.nabble.com/Dealing-With-Extremely-Large-Files-tp19695311p19750580.html Sent from the R help mailing list archive at Nabble.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 provide commented, minimal, self-contained, reproducible code.
[R] Dealing With Extremely Large Files
Hi, I'm sure that a large fixed width file, such as 300 million rows and 1,000 columns, is too large for R to handle on a PC, but are there ways to deal with it? For example, is there a way to combine some sampling method with read.fwf so that you can read in a sample of 100,000 records, for example? Something like this may make analysis possible. Once analyzed, is there a way to, say, read in only x rows at a time, save and score each subset separately, and finally append them back together? I haven't seen any information on this, if it is possible. Thank you for reading, and sorry if the information was easily available and I simply didn't find it. -- View this message in context: http://www.nabble.com/Dealing-With-Extremely-Large-Files-tp19695311p19695311.html Sent from the R help mailing list archive at Nabble.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 provide commented, minimal, self-contained, reproducible code.
Re: [R] Legality Question about R's Open Source GNU GPL License
I just wanted to let everyone know the good news, that I was approved to use R at work by legal and compliance. Now to begin learning here. Speaking of, is there anyone who is an expert at R and would be willing to have our company pay them as a consultant to come to my place of work (in Connecticut) and tutor me (and possibly others), to pass off some R wisdom? I have learned a lot of basics from free online R manuals, but would like human instruction as well, if possible. There are no specific things I'm looking to learn at the moment, other than to gain a broader, basic working knowledge with R. I work in a marketing department for an insurance company, and even though I don't have specific questions on methods in R, here is a little background. We use multinomial logit (and have attempted some discrete choice methods) regarding mailing campaigns. There is also a departmental push toward optimization methods, segmentation, as well as refining the forecasting of call volume (those who respond to mailings). Of course, there are many more statistical things we do, but this should give an idea. If anyone is interested, please call 860-276-2731. Thanks. PS I apologize if I shouldn't have posted that here for any reason. -- View this message in context: http://www.nabble.com/Legality-Question-about-R%27s-Open-Source-GNU-GPL-License-tp18696623p18837036.html Sent from the R help mailing list archive at Nabble.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 provide commented, minimal, self-contained, reproducible code.
[R] Legality Question about R's Open Source GNU GPL License
Hi, I use R at home, and am interested in using it at my work company (which is in the Fortune 100). I began the request, and our legal team has given some gruff about the open source license. Not boring you with the details here, but I used some info on gnu.org as a rebuttal, and someone at the company replied that the generalities of GNU GPL may differ from R's specific GNU GPL license, and that I should refer specifically to it, and it should be on the CRAN website. I may be blind, but haven't seen such a document. Does one exist, and how may I obtain it? I believe they are wrong. Our legal team is notorious for being overly conservative, and I'm personally betting they think I won't look into it, and then they won't have to deal with it. But I will, and I want to use R. Thanks. PS Sorry if the document was posted and obvious, and I simply couldn't find it. Thanks. -- View this message in context: http://www.nabble.com/Legality-Question-about-R%27s-Open-Source-GNU-GPL-License-tp18696623p18696623.html Sent from the R help mailing list archive at Nabble.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 provide commented, minimal, self-contained, reproducible code.
Re: [R] Legality Question about R's Open Source GNU GPL License
Thanks to each of you for your excellent input. I have copied the file and will read it tonight. I haven't run into any heat from IT, but if I do, it will be in the near future. The exact legal issue was touched upon. There was a concern that anything associated with R (my code, etc.) would have to be made public, legally, if demanded. I thought that was absurd. Before I came to this company a few years ago, I interviewed at Amazon.com in Seattle, and in that interview, it was explained to me that their entire computer network, at least as far as I would be concerned, was all Linux. Well, that's open source as well. But of course there could be fine legal differences. Gnu.org said the same thing, under its FAQ, that there is no legal risk to use it at work, in the sense that you'd have to divulge anything. It even said you could modify source code and use it at work. No problems. But, like was said, there could be a problem if you distribute it. But I'm just a simple user, looking for a much better range of statistical, mathematical, and optimization methods than SAS STAT and SAS ETS offer. For me, I will slowly try to convert my SAS code at work to R script. I've seen the light. Cheers and thanks for the good feedback. -- View this message in context: http://www.nabble.com/Legality-Question-about-R%27s-Open-Source-GNU-GPL-License-tp18696623p18698452.html Sent from the R help mailing list archive at Nabble.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 provide commented, minimal, self-contained, reproducible code.
[R] Errors using nlme's gls with autocorrelation
Hi, I am trying out a generalized least squares method of forecasting that corrects for autocorrelation. I downloaded daily stock data from Yahoo Finance, and am trying to predict Close (n=7903). I have learned to use date functions to extract indicator variables for Monday - Friday (and Friday is missing in the model to prevent it from becoming full rank). When I run the following code... library(nlme) MyModel - gls(Close ~ Monday + Tuesday + Wednesday + Thursday, correlation=corARMA(p=2), data=MyData, method=ML) ...I get the following error... Error in corFactor.corARMA(object) : Calloc could not allocate (62457409 of 8) memory ...Does anybody know what I'm doing wrong? I appreciate any help. Thanks. -- View this message in context: http://www.nabble.com/Errors-using-nlme%27s-gls-with-autocorrelation-tp17026417p17026417.html Sent from the R help mailing list archive at Nabble.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 provide commented, minimal, self-contained, reproducible code.
[R] How to extract vectors from an arima() object and into a data frame?
This should be very easy, but alas, I'm very new to R. My end goal is to calculate p-values from arima(). Let's say I just ran this: MyModel - arima(y[1:58], order=c(1,0,0), xreg=MyData[1:58,7:14], method=ML) MyModel And I see: arima(x = y[1:58], order = c(1, 0, 0), xreg = MyData[1:58, 7:14], method = ML) Coefficients: ar1 intercept x1 x2 x3 x4x5 x6 0.5812 -52.7725 -0.0270 -6.3467 2.8435 4.3727 -14.9045 -3e-04 s.e. 0.132816.6182 0.0212 3.6454 1.5571 0.56412.4294 2e-04 x7 x8 2.4094 1.0823 s.e. 0.5134 0.3093 sigma^2 estimated as 1.223: log likelihood = -88.35, aic = 198.71 To calculate a p-value, all I have to do is: 1. Let z = parameter / s.e. 2. Let abs_z = abs(z) 3. Let p = 1 minus the integral of a normal distribution from -z to z How do I extract the coefficients and standard errors out of the MyModel object, place them in their own data frame? From there, I'm sure I could calculate the p-value. I have found that: coef(MyModel) ...shows the coefficients, but I'm unable to get them into a data frame. I tried: parameters$coef - coef(MyModel) But when I try... parameters - edit(parameters) ...I don't see what I would expect, a column of coefficients. And I don't know how to refer to the standard errors. Help? Thanks. -- View this message in context: http://www.nabble.com/How-to-extract-vectors-from-an-arima%28%29-object-and-into-a-data-frame--tp16757321p16757321.html Sent from the R help mailing list archive at Nabble.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 provide commented, minimal, self-contained, reproducible code.
Re: [R] How to extract vectors from an arima() object and into a data frame?
This has been solved, and I'm thankful for the help. The solution is: z = MyModel$coef/diag(MyModel$var.coef) ...and from there I will use a for loop and pnorm to get the p-values. Thanks again! Byron zerfetzen wrote: This should be very easy, but alas, I'm very new to R. My end goal is to calculate p-values from arima(). Let's say I just ran this: MyModel - arima(y[1:58], order=c(1,0,0), xreg=MyData[1:58,7:14], method=ML) MyModel And I see: arima(x = y[1:58], order = c(1, 0, 0), xreg = MyData[1:58, 7:14], method = ML) Coefficients: ar1 intercept x1 x2 x3 x4x5 x6 0.5812 -52.7725 -0.0270 -6.3467 2.8435 4.3727 -14.9045 -3e-04 s.e. 0.132816.6182 0.0212 3.6454 1.5571 0.56412.4294 2e-04 x7 x8 2.4094 1.0823 s.e. 0.5134 0.3093 sigma^2 estimated as 1.223: log likelihood = -88.35, aic = 198.71 To calculate a p-value, all I have to do is: 1. Let z = parameter / s.e. 2. Let abs_z = abs(z) 3. Let p = 1 minus the integral of a normal distribution from -abs_z to abs_z How do I extract the coefficients and standard errors out of the MyModel object, and place them in their own data frame? From there, I'm sure I could calculate the p-value. I have found that: coef(MyModel) ...shows the coefficients, but I'm unable to get them into a data frame. I tried: MyParameters$coef - coef(MyModel) But when I try... MyParameters - edit(MyParameters) ...I don't see what I would expect: a column of coefficients. And I don't know how to refer to the standard errors. Help? Thanks. -- View this message in context: http://www.nabble.com/How-to-extract-vectors-from-an-arima%28%29-object-and-into-a-data-frame--tp16757321p16758220.html Sent from the R help mailing list archive at Nabble.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 provide commented, minimal, self-contained, reproducible code.
Re: [R] Equivalent to a BY command in SAS
Thanks all. I will try to use both tapply and by, and have no idea how I missed the by function. Thanks again. -- View this message in context: http://www.nabble.com/Equivalent-to-a-BY-command-in-SAS-tp16670452p16676280.html Sent from the R help mailing list archive at Nabble.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 provide commented, minimal, self-contained, reproducible code.
[R] Equivalent to a BY command in SAS
Hi, I'm very new to R and absolutely love it. Does anyone know how to use something in R that functions like a BY command in SAS? For example, let's say you have a variable x, and you want to see the mean. Easy... mean(x) But what if you want to see the mean of x conditional on another discrete variable? My best attempts so far are something like... mean(x, y_cat=1) ...which of course doesn't work. I have downloaded plenty of R user guides that are very informative, but am not seeing much on detailed descriptives or data manipulation (for my life, I can't figure out how to sort an attached data frame, but that's another issue). Thanks. -- View this message in context: http://www.nabble.com/Equivalent-to-a-BY-command-in-SAS-tp16670452p16670452.html Sent from the R help mailing list archive at Nabble.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 provide commented, minimal, self-contained, reproducible code.