[R] create dataframe using structure ()

Luigi Marongiu marongiu.luigi at gmail.com
Sun May 11 13:58:36 CEST 2014


Dear all,
there was indeed a misplaced parenthesis, so the last line runs as:

  .Names = c("row", "stimulation", "positivity", "group", "copy")),
row.names = c(NA, -120L),  class = "data.frame")

with two )) at the end of .Names.

problem solved,
thank you
Luigi


On Thu, Mar 13, 2014 at 7:29 PM, Rui Barradas <ruipbarradas at sapo.pt> wrote:
> Hello,
>
> You're misplacing one close parenthesis. See the commented lines below.
>
>
>
> structure(list(
> column_1 = 1:32,
> column_2 = structure(c(1, 2, 3, 4, 5, 6, 7, 8,
> 1, 2, 3, 4, 5, 6, 7, 8,
> 1, 2, 3, 4, 5, 6, 7, 8,
> 1, 2, 3, 4, 5, 6, 7, 8),
> .Label =
> c("Unstimulated", "ESAT6", "CFP10", "Rv3615c", "Rv2654", "Rv3879",
> "Rv3873", "PHA"),
> class = "factor"),
> column_3 =
> structure(c(1, 1, 1, 1, 1, 1, 1, 1, 2, 2, 2, 2, 2, 2, 2, 2, 3, 3, 3,
> 3, 3, 3, 3, 3, 4, 4, 4, 4, 4, 4, 4, 4), .Label = c("bd", "2m", "1m",
> "0.5m"), class = "factor"),
> column_4 =
> c(71.62097178, 2.892223468, 144.8618621, 40.90079262, 37.0516856,
> 32.78206822, 72.44424152, 1512.516293, 3164.748333, 1092.634557,
> 28733.20269, 1207.87783, 729.6090973, 151.8706088, 241.2466141,
> 9600.963594, 682.865522, 5869.375226, 554.8924896, 2982.759858,
> 7690.028092, 40.37298719, 942.3549279, 3403.679967, 103.9862389,
> 35.28562613, 321.5985377, 0.274424607, 3352.874906, 93.76421187,
> 21.3709382, 4193.183281)),  # close 2 )) here
> .Names = c("row", "stimulation", "type", "copy"), row.names = c(NA,
> -32L), class = "data.frame")  # and only one ) after df
>
>
> Hope this helps,
>
> Rui Barradas
>
> Em 13-03-2014 18:58, Luigi Marongiu escreveu:
>>
>> dear all,
>> I have tried to create a dataframe using the structure() function, but it
>> did not really work. In column 1 i have the row number, in column 2 and 3
>> factors (8 and 4 levels respectively) and in column 4 the actual data.
>> any clue on what went wrong?
>> best regards
>> luigi
>>
>> my.data<-structure(list(
>> column_1 = 1:32,
>> column_2 = structure(c(1, 2, 3, 4, 5, 6, 7, 8,
>> 1, 2, 3, 4, 5, 6, 7, 8,
>> 1, 2, 3, 4, 5, 6, 7, 8,
>> 1, 2, 3, 4, 5, 6, 7, 8),
>> .Label =
>> c("Unstimulated", "ESAT6", "CFP10", "Rv3615c", "Rv2654", "Rv3879",
>> "Rv3873", "PHA"),
>> class = "factor"),
>> column_3 =
>> structure(c(1, 1, 1, 1, 1, 1, 1, 1, 2, 2, 2, 2, 2, 2, 2, 2, 3, 3, 3,
>> 3, 3, 3, 3, 3, 4, 4, 4, 4, 4, 4, 4, 4), .Label = c("bd", "2m", "1m",
>> "0.5m"), class = "factor"),
>> column_4 =
>> c(71.62097178, 2.892223468, 144.8618621, 40.90079262, 37.0516856,
>> 32.78206822, 72.44424152, 1512.516293, 3164.748333, 1092.634557,
>> 28733.20269, 1207.87783, 729.6090973, 151.8706088, 241.2466141,
>> 9600.963594, 682.865522, 5869.375226, 554.8924896, 2982.759858,
>> 7690.028092, 40.37298719, 942.3549279, 3403.679967, 103.9862389,
>> 35.28562613, 321.5985377, 0.274424607, 3352.874906, 93.76421187,
>> 21.3709382, 4193.183281),
>> .Names = c("row", "stimulation", "type", "copy"), class = "data.frame"))
>> attach(my.data)
>>
>>         [[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.
>>
>



More information about the R-help mailing list