It would help if you placed r <- 0; s <- 0 etc. outside the loop. Same
goes for cat(...). And get rid of the sum(r), sum(s) and so on, that's
doing nothing (r,s,... are single numbers)
This said :
See Peter Langfelder's response.
Cheers
Joris
> # see ?table for a better approach
> r<-0
> s<-0
>
On average, any data manipulation that can be described in a sentence or two of
English can be programmed in one line in R. If you find yourself writing a long
'for' loop to do something that sounds simple, take a step back and research if
an existing combination of functions can easily handle y
On Thu, Jun 24, 2010 at 3:16 PM, john polo wrote:
> Dear R users,
>
> I have a list of numbers such as
>
>> n
> [1] 3000 4000 5000 3000 5000 6000 4000 5000 7000 5000 6000 7000
>
> and i'd like to set up a loop that will keep track of the number of
> occurences of each of the values that occur in t
Dear R users,
I have a list of numbers such as
> n
[1] 3000 4000 5000 3000 5000 6000 4000 5000 7000 5000 6000 7000
and i'd like to set up a loop that will keep track of the number of
occurences of each of the values that occur in the list, e.g.
3000: 2
4000: 2
5000: 4
I came up with the fol
4 matches
Mail list logo