Hi list, I am looking at the data yarn in package, I don't understand what is dimension of this data set. I did the following:> library(pls)> data(yarn)> dim(yarn)[1] 28 3> head(yarn)NIR.1 NIR.2 NIR.3 NIR.4 NIR.5 NIR.6 NIR.7 NIR.8 NIR.9 NIR.10 NIR.11 1 3.06630 3.08610 3.10790 3.09720 2.99790 2.82730 2.62330 2.40390 2.19310 2.00580 1.83790 2 3.06750 3.08570 3.09580 3.06920 2.98180 2.84080 2.67600 2.50590 2.35060 2.22300 2.11920 3 3.07500 3.09660 3.09160 3.02880 2.88490 2.68850 2.47640 2.26940 2.08240 1.91950 1.77470 4 3.08280 3.09730 3.10100 3.07350 2.99130 2.87090 2.73920 2.61020 2.50000 2.42370 2.37740 5 3.10290 3.10340 3.08480 3.02280 2.89270 2.71590 2.53840 2.37640 2.23970 2.13460 2.05340 6 3.08150 3.08490 3.04870 2.93050 2.73230 2.50890 2.29440 2.09950 1.93280 1.79250 1.66930 There were 270 columns, I only copy pasted the first 11 columns. But either way, this is NOT 3 columns. Could anyone let me know what is wrong here? Thanks in advance, Mike [[alternative HTML version deleted]]
I just looked at it again, and I did:> is.list(yarn)[1] TRUE So, I guess it's a list with data inside. M On Sat, Oct 6, 2012 at 9:44 PM, C W <tmrsg11@gmail.com> wrote:> Hi list, > I am looking at the data yarn in package, I don't understand what is > dimension of this data set. > > I did the following: > > library(pls) > > > data(yarn) > > > dim(yarn) > > [1] 28 3 > > > head(yarn) > > NIR.1 NIR.2 NIR.3 NIR.4 NIR.5 NIR.6 NIR.7 NIR.8 NIR.9 > NIR.10 NIR.11 > > 1 3.06630 3.08610 3.10790 3.09720 2.99790 2.82730 2.62330 2.40390 2.19310 > 2.00580 1.83790 > > 2 3.06750 3.08570 3.09580 3.06920 2.98180 2.84080 2.67600 2.50590 2.35060 > 2.22300 2.11920 > > 3 3.07500 3.09660 3.09160 3.02880 2.88490 2.68850 2.47640 2.26940 2.08240 > 1.91950 1.77470 > > 4 3.08280 3.09730 3.10100 3.07350 2.99130 2.87090 2.73920 2.61020 2.50000 > 2.42370 2.37740 > > 5 3.10290 3.10340 3.08480 3.02280 2.89270 2.71590 2.53840 2.37640 2.23970 > 2.13460 2.05340 > > 6 3.08150 3.08490 3.04870 2.93050 2.73230 2.50890 2.29440 2.09950 1.93280 > 1.79250 1.66930 > > There were 270 columns, I only copy pasted the first 11 columns. But > either way, this is NOT 3 columns. > > Could anyone let me know what is wrong here? > > Thanks in advance, > Mike >[[alternative HTML version deleted]]
Jeff Newmiller
2012-Oct-07 01:57 UTC
[R] what exactly is the dim of data set yarn in package "pls"?
Perhaps what is wrong is that you need to learn when to use the str() function. str(yarn) --------------------------------------------------------------------------- Jeff Newmiller The ..... ..... Go Live... DCN:<jdnewmil at dcn.davis.ca.us> Basics: ##.#. ##.#. Live Go... Live: OO#.. Dead: OO#.. Playing Research Engineer (Solar/Batteries O.O#. #.O#. with /Software/Embedded Controllers) .OO#. .OO#. rocks...1k --------------------------------------------------------------------------- Sent from my phone. Please excuse my brevity. C W <tmrsg11 at gmail.com> wrote:>Hi list, >I am looking at the data yarn in package, I don't understand what is >dimension of this data set. > >I did the following: >> library(pls) > >> data(yarn) > >> dim(yarn) > >[1] 28 3 > >> head(yarn) > > NIR.1 NIR.2 NIR.3 NIR.4 NIR.5 NIR.6 NIR.7 NIR.8 NIR.9 >NIR.10 NIR.11 > >1 3.06630 3.08610 3.10790 3.09720 2.99790 2.82730 2.62330 2.40390 >2.19310 >2.00580 1.83790 > >2 3.06750 3.08570 3.09580 3.06920 2.98180 2.84080 2.67600 2.50590 >2.35060 >2.22300 2.11920 > >3 3.07500 3.09660 3.09160 3.02880 2.88490 2.68850 2.47640 2.26940 >2.08240 >1.91950 1.77470 > >4 3.08280 3.09730 3.10100 3.07350 2.99130 2.87090 2.73920 2.61020 >2.50000 >2.42370 2.37740 > >5 3.10290 3.10340 3.08480 3.02280 2.89270 2.71590 2.53840 2.37640 >2.23970 >2.13460 2.05340 > >6 3.08150 3.08490 3.04870 2.93050 2.73230 2.50890 2.29440 2.09950 >1.93280 >1.79250 1.66930 > >There were 270 columns, I only copy pasted the first 11 columns. But >either way, this is NOT 3 columns. > >Could anyone let me know what is wrong here? > >Thanks in advance, >Mike > > [[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.
William Dunlap
2012-Oct-07 02:06 UTC
[R] what exactly is the dim of data set yarn in package "pls"?
Start by using str() to get an idea of the structure of this dataset > str(pls::yarn) 'data.frame': 28 obs. of 3 variables: $ NIR : num [1:28, 1:268] 3.07 3.07 3.08 3.08 3.1 ... ..- attr(*, "dimnames")=List of 2 .. ..$ : NULL .. ..$ : NULL $ density: num 100 80.2 79.5 60.8 60 ... $ train : logi TRUE TRUE TRUE TRUE TRUE TRUE ... I.e., it contains 3 things, each with 28 observations: a 268-column matrix of numbers, NIR, a numeric vector, density, and a logical vector, train. data.frames can contain matrices. They are not common, but can be used for grouping purposes or because it is easier to refer to NIR[,j] than paste(NIR, j, sep="."). help(yarn) tells about the meaning of the components. Bill Dunlap Spotfire, TIBCO Software wdunlap tibco.com> -----Original Message----- > From: r-help-bounces at r-project.org [mailto:r-help-bounces at r-project.org] On Behalf > Of C W > Sent: Saturday, October 06, 2012 6:45 PM > To: r-help > Subject: [R] what exactly is the dim of data set yarn in package "pls"? > > Hi list, > I am looking at the data yarn in package, I don't understand what is > dimension of this data set. > > I did the following: > > library(pls) > > > data(yarn) > > > dim(yarn) > > [1] 28 3 > > > head(yarn) > > NIR.1 NIR.2 NIR.3 NIR.4 NIR.5 NIR.6 NIR.7 NIR.8 NIR.9 > NIR.10 NIR.11 > > 1 3.06630 3.08610 3.10790 3.09720 2.99790 2.82730 2.62330 2.40390 2.19310 > 2.00580 1.83790 > > 2 3.06750 3.08570 3.09580 3.06920 2.98180 2.84080 2.67600 2.50590 2.35060 > 2.22300 2.11920 > > 3 3.07500 3.09660 3.09160 3.02880 2.88490 2.68850 2.47640 2.26940 2.08240 > 1.91950 1.77470 > > 4 3.08280 3.09730 3.10100 3.07350 2.99130 2.87090 2.73920 2.61020 2.50000 > 2.42370 2.37740 > > 5 3.10290 3.10340 3.08480 3.02280 2.89270 2.71590 2.53840 2.37640 2.23970 > 2.13460 2.05340 > > 6 3.08150 3.08490 3.04870 2.93050 2.73230 2.50890 2.29440 2.09950 1.93280 > 1.79250 1.66930 > > There were 270 columns, I only copy pasted the first 11 columns. But > either way, this is NOT 3 columns. > > Could anyone let me know what is wrong here? > > Thanks in advance, > Mike > > [[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.