Hi everybody, If I've a data frame like this: dataframe a X0 X2 X4 X6 X8 X10 X12 X14 X16 1957 0 0 0 0 0 0 0 0 0 1958 0 0 0 0 0 0 0 0 0 1959 831 0 0 0 0 0 0 0 0 1960 544 282 0 0 0 0 0 0 0 1961 446 365 0 0 0 0 0 0 0 1962 442 473 0 0 0 0 0 0 0 1963 595 468 0 0 0 0 0 0 0 1964 400 397 516 0 0 0 0 0 0 1965 417 382 401 0 0 0 0 0 0 1966 642 518 509 453 0 0 0 0 0 1967 505 340 621 458 0 0 0 0 0 1968 451 383 428 318 339 0 0 0 0> length (a)[1] 9 I've a questions... There is a function for show the lenght of single observation?> ???? (a)[1] 12 Best Wishes, Alfredo [[alternative HTML version deleted]]
Ciao, do you mean the number of records? something like nrow(a) I would also suggest ncol(a) instad of length, which would work for a matrix as well. [Italian] E' quello che cercavi? [/Italian] Ciao Stefano On Mon, Sep 17, 2007 at 06:05:58PM +0200, Alfredo Alessandrini wrote: <Alfredo>Hi everybody, <Alfredo> <Alfredo>If I've a data frame like this: <Alfredo> <Alfredo>dataframe a <Alfredo> <Alfredo> X0 X2 X4 X6 X8 X10 X12 X14 X16 <Alfredo>1957 0 0 0 0 0 0 0 0 0 <Alfredo>1958 0 0 0 0 0 0 0 0 0 <Alfredo>1959 831 0 0 0 0 0 0 0 0 <Alfredo>1960 544 282 0 0 0 0 0 0 0 <Alfredo>1961 446 365 0 0 0 0 0 0 0 <Alfredo>1962 442 473 0 0 0 0 0 0 0 <Alfredo>1963 595 468 0 0 0 0 0 0 0 <Alfredo>1964 400 397 516 0 0 0 0 0 0 <Alfredo>1965 417 382 401 0 0 0 0 0 0 <Alfredo>1966 642 518 509 453 0 0 0 0 0 <Alfredo>1967 505 340 621 458 0 0 0 0 0 <Alfredo>1968 451 383 428 318 339 0 0 0 0 <Alfredo> <Alfredo>> length (a) <Alfredo>[1] 9 <Alfredo> <Alfredo>I've a questions... <Alfredo> <Alfredo>There is a function for show the lenght of single observation? <Alfredo> <Alfredo>> ???? (a) <Alfredo>[1] 12 <Alfredo> <Alfredo> <Alfredo> <Alfredo>Best Wishes, <Alfredo> <Alfredo>Alfredo <Alfredo> <Alfredo> [[alternative HTML version deleted]] <Alfredo> <Alfredo>______________________________________________ <Alfredo>R-help a r-project.org mailing list <Alfredo>https://stat.ethz.ch/mailman/listinfo/r-help <Alfredo>PLEASE do read the posting guide http://www.R-project.org/posting-guide.html <Alfredo>and provide commented, minimal, self-contained, reproducible code.
?str On 9/17/07, Alfredo Alessandrini <alfreale74 at gmail.com> wrote:> Hi everybody, > > If I've a data frame like this: > > dataframe a > > X0 X2 X4 X6 X8 X10 X12 X14 X16 > 1957 0 0 0 0 0 0 0 0 0 > 1958 0 0 0 0 0 0 0 0 0 > 1959 831 0 0 0 0 0 0 0 0 > 1960 544 282 0 0 0 0 0 0 0 > 1961 446 365 0 0 0 0 0 0 0 > 1962 442 473 0 0 0 0 0 0 0 > 1963 595 468 0 0 0 0 0 0 0 > 1964 400 397 516 0 0 0 0 0 0 > 1965 417 382 401 0 0 0 0 0 0 > 1966 642 518 509 453 0 0 0 0 0 > 1967 505 340 621 458 0 0 0 0 0 > 1968 451 383 428 318 339 0 0 0 0 > > > length (a) > [1] 9 > > I've a questions... > > There is a function for show the lenght of single observation? > > > ???? (a) > [1] 12 > > > > Best Wishes, > > Alfredo > > [[alternative HTML version deleted]] > > ______________________________________________ > R-help at 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. >-- Jim Holtman Cincinnati, OH +1 513 646 9390 What is the problem you are trying to solve?
I believe you're looking for: dim(a) dim(a)[1] # Number of observations, in your example, 12 dim(a)[2] # Number of variables per observation, in your example, 9 --Jeff. On Sep 17, 2007, at 12:05 PM, Alfredo Alessandrini wrote:> Hi everybody, > > If I've a data frame like this: > > dataframe a > > X0 X2 X4 X6 X8 X10 X12 X14 X16 > 1957 0 0 0 0 0 0 0 0 0 > 1958 0 0 0 0 0 0 0 0 0 > 1959 831 0 0 0 0 0 0 0 0 > 1960 544 282 0 0 0 0 0 0 0 > 1961 446 365 0 0 0 0 0 0 0 > 1962 442 473 0 0 0 0 0 0 0 > 1963 595 468 0 0 0 0 0 0 0 > 1964 400 397 516 0 0 0 0 0 0 > 1965 417 382 401 0 0 0 0 0 0 > 1966 642 518 509 453 0 0 0 0 0 > 1967 505 340 621 458 0 0 0 0 0 > 1968 451 383 428 318 339 0 0 0 0 > >> length (a) > [1] 9 > > I've a questions... > > There is a function for show the lenght of single observation? > >> ???? (a) > [1] 12 > > > > Best Wishes, > > Alfredo > > [[alternative HTML version deleted]] > > ______________________________________________ > R-help at 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.