Hi

Structure is usefull for exchanging information and it is result of ?dput 
function. I wonder if anybody would like to use it for **creating** data frames.

For creating data frames see functions like

?read.table,
?read.delim,
or other ?read.* functions.

Your questions are mainly adressed in R-intro which should be part of your R 
installation.

Cheers
Petr

> -----Original Message-----
> From: R-help <r-help-boun...@r-project.org> On Behalf Of Drake Gossi
> Sent: Saturday, April 20, 2019 1:40 AM
> To: r-help@r-project.org
> Subject: [R] creating a data.frame from scratch
>
> Hello everyone,
>
> Is there any way to create a data.frame from scratch? other than, say, this?
>
> > structure(list(Fruit = structure(c(1L, 2L, 5L, 4L, 3L), .Label =
> c("apple",
> "banana", "kiwi", "orange", "pear"), class = "factor"), Color = 
> structure(c(3L, 4L,
> 1L, 2L, 1L), .Label = c("green", "orange", "red", "yellow"
> ), class = "factor"), Shape = structure(c(3L, 1L, 2L, 3L, 3L), .Label = 
> c("oblong",
> "pear", "round"), class = "factor"), Juice = c(1, 0, 0.5, 1, 0)), class =
> "data.frame", row.names = c("1", "2", "3", "4",
> "5"))
>
>
> which yields
>
>    Fruit  Color  Shape  Juice
> 1  apple    red  round  1.0
> 2 banana yellow oblong   0.0
> 3   pear  green   pear   0.5
> 4 orange orange  round   1.0
> 5   kiwi  green  round   0.0
>
>
> I get *that* it works. I just don't know *how* it works, and whether or not
> there is another, easier way...
>
> For example,
>
> > structure(list(Fruit = structure(c(1L, 2L, 5L, 4L, 3L), .Label =
> c("apple", "banana", "kiwi", "orange", "pear") ...
>
>
> What on earth are these numbers? c(1L, 2L, 5L, 4L, 3L)? and why are they out
> of order?
>
> And then why put the fruits out of order? c("apple", "banana", "kiwi",
> "orange", "pear")? since that's not a descending order?
> since, in the final data.frame, it goes apple, banana, *pear*, *orange*, kiwi?
>
> So many questions!
>
> Drake
>
> [[alternative HTML version deleted]]
>
> ______________________________________________
> R-help@r-project.org mailing list -- To UNSUBSCRIBE and more, see
> 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.
Osobní údaje: Informace o zpracování a ochraně osobních údajů obchodních 
partnerů PRECHEZA a.s. jsou zveřejněny na: 
https://www.precheza.cz/zasady-ochrany-osobnich-udaju/ | Information about 
processing and protection of business partner’s personal data are available on 
website: https://www.precheza.cz/en/personal-data-protection-principles/
Důvěrnost: Tento e-mail a jakékoliv k němu připojené dokumenty jsou důvěrné a 
podléhají tomuto právně závaznému prohláąení o vyloučení odpovědnosti: 
https://www.precheza.cz/01-dovetek/ | This email and any documents attached to 
it may be confidential and are subject to the legally binding disclaimer: 
https://www.precheza.cz/en/01-disclaimer/

______________________________________________
R-help@r-project.org mailing list -- To UNSUBSCRIBE and more, see
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.

Reply via email to