Questions tagged [s]

S is a statistical programming language

S is a statistical programming language. The aim of the language, as expressed by its creators, is "to turn ideas into software, quickly and faithfully."

The two modern implementations of S are and .

Resources

27 questions
84
votes
12 answers

How to get summary statistics by group

I'm trying to get multiple summary statistics in R/S-PLUS grouped by categorical column in one shot. I found couple of functions, but all of them do one statistic per call, like aggregate(). data <- c(62, 60, 63, 59, 63, 67, 71, 64, 65, 66, 68, 66,…
user1289220
  • 841
  • 1
  • 7
  • 3
44
votes
4 answers

Why are there two assignment operators, `<-` and `->` in R?

I know how to use <- and ->, and there are several writeups on the difference between equals assignment & arrow assignment, but I don't know when to prefer -> over <-. It seems the community has coalesced around using <- for assignment. Neither the…
Haleemur Ali
  • 20,742
  • 3
  • 37
  • 68
22
votes
4 answers

What are the major differences between the R and S programming languages?

What are the differences between R and S?
Sauron
  • 15,788
  • 40
  • 119
  • 171
5
votes
0 answers

Reproduce S-plus result in R

I have an old S-plus script, and I would like to reproduce the results in R. The only issue I'm having is the random seed. I know they use different algorithms for the pseudo-random number generation. In the S-plus file the seed was set…
bdeonovic
  • 3,890
  • 7
  • 35
  • 67
4
votes
2 answers

How to get the value of list(...) in R and S functions

I am confused by how list(...) works in R and S-plus. For following code pp <- function(x, ...) { print( length( list(...)))} pp(1,,,1) In S-Plus, it works, but in R, it gives "Error in print(length(list(...))) : argument is missing, with no…
Ossifragus
  • 43
  • 2
4
votes
1 answer

How to count and test for the sum and repeat the action

I need to test the value of'peso'(see replication code below) for each factor. Whether a factor reaches 50% of the overall sum for 'peso', the values of each factor should be paste into a new object 'results', otherwise, R should evaluate which…
daniel
  • 1,096
  • 2
  • 12
  • 20
3
votes
3 answers

How to lag date-index in a time-series in R?

REWRITTEN QUESTION HERE: I've made some progress but am getting odd behaviour from R... Here's the xts I'm starting with Value Value2 Value3 2002-08-21 21 2 27 2003-09-10 22 42 87 2004-02-12 23 62 …
Bit Rocker
  • 737
  • 1
  • 7
  • 13
2
votes
1 answer

What was a For loop? Why isn't it needed in R?

In the R FAQ's section about comparing S and R, we find the following: In R, For() loops are not necessary and hence not supported. What was a For() loop and why does R not need it?
J. Mini
  • 1,288
  • 4
  • 23
2
votes
1 answer

Function can't "see" other functions defined in global environment

fa <- function(x){x+1} fb <- function(x){x-1} f1 <- function(x, y){f(x)^y} f2 <- function(x, ab, y){ if(ab == 'a'){ f <- fa } else { f <- fb } f1(x, y) } f2(0, 'a', .5) Error in f1(x, y) : could not find function "f" The…
generic_user
  • 3,051
  • 2
  • 25
  • 43
2
votes
0 answers

Calling predict after training with polr on multicollinear data problematic

Take a look at the code below. This question has been asked before but shut down - presumably for lack of R code to reproduce the problem. Basically, when there is multicollinearity in the data, using Polr-trained model is problematic during the…
Navneet
  • 8,012
  • 9
  • 31
  • 50
2
votes
1 answer

Calling R from S-Plus?

Does anyone have any suggestions for a good way to call R from S-Plus? Ideally I would like to just pass code to R and get data back without having to write anything too elaborate to integrate them. I should add that I'm familiar with the RinS…
Shane
  • 92,684
  • 33
  • 219
  • 216
1
vote
2 answers

lm()$assign: what is it?

What is the assign attribute of a linear model fit? It's supposed to somehow provide the position of the response term, but in practice it seems to enumerate all coefficients in the model. It's my understanding that assign is a carryover from S…
rimorob
  • 582
  • 1
  • 3
  • 15
1
vote
2 answers

Create a matrix with gradually changing values without a for loop

In R, I am building a matrix M that stores 4 changing weights for each of 20 rounds of a game. I start with the weight vector W1 (4x1) and end game with weight vector W2 (4x1). The weight values remain constant until the change initiation round C1…
inarts
  • 49
  • 7
1
vote
1 answer

Design matrix for MLM from library(lme4) with fixed and random effects

Context of application I have a model with random slopes and intercepts. There are numerous levels of the random effects. The new data (to be predicted) may or may not have all of these levels. To make this more concrete, I am working with music…
Alex W
  • 4,489
  • 4
  • 26
  • 52
0
votes
1 answer

Nonlinear regression in R / S

I have a R / S / Nonlinear regression related issue and i am not a R programmer, so i kinda need help. I have two arrays - tt and td. I need to find the parameters a,b and c so the sum of least squares is minimal for a non linear function: td / tt…
Nemanja
  • 1,325
  • 11
  • 24
1
2