[R] the first name of the first column

Bert Gunter bgunter@4567 @end|ng |rom gm@||@com
Fri May 11 01:39:05 CEST 2018


1. My name is Bert, not Brent;

2. I am not your private consultant -- always cc the list unless you have
good reason not to. I have done that here.

It looks like this is what you want; if so, you really need to go through
an R tutorial or two to learn the basics:

d <-
structure(list(region = structure(c(1L, 1L, 1L, 1L), .Label = "zilan",
class = "factor"),
    Fe_ppmtp = c(8.36, 8.78, 16.52, 42.22), Zn.ppmtp = c(0.44,
    0.58, 2.28, 14.22), Mn_tp = c(6.9, 21.16, 27.58, 34.7), Cu_tp = c(0.5,
    0.24, 0.8, 31.9)), class = "data.frame", row.names = c(NA,
-4L))

> md <- as.matrix(d[,-1])  ## knowledge of indexing is essential in R !
> md
     Fe_ppmtp Zn.ppmtp Mn_tp Cu_tp
[1,]     8.36     0.44  6.90  0.50
[2,]     8.78     0.58 21.16  0.24
[3,]    16.52     2.28 27.58  0.80
[4,]    42.22    14.22 34.70 31.90
> is.numeric(md)
[1] TRUE

## to get rid of the column names:

> dimnames(md)[[2]] <- NULL
> md
      [,1]  [,2]  [,3]  [,4]
[1,]  8.36  0.44  6.90  0.50
[2,]  8.78  0.58 21.16  0.24
[3,] 16.52  2.28 27.58  0.80
[4,] 42.22 14.22 34.70 31.90


Bert Gunter

"The trouble with having an open mind is that people keep coming along and
sticking things into it."
-- Opus (aka Berkeley Breathed in his "Bloom County" comic strip )

On Thu, May 10, 2018 at 3:13 PM, greg holly <mak.hholly using gmail.com> wrote:

> Brent;
>
> I am sorry. Her is the reproducible data
>
> structure(list(region = structure(c(1L, 1L, 1L, 1L), .Label = "zilan",
> class = "factor"),
>     Fe_ppmtp = c(8.36, 8.78, 16.52, 42.22), Zn.ppmtp = c(0.44,
>     0.58, 2.28, 14.22), Mn_tp = c(6.9, 21.16, 27.58, 34.7), Cu_tp = c(0.5,
>     0.24, 0.8, 31.9)), class = "data.frame", row.names = c(NA,
> -4L))
>
>
> On Fri, May 11, 2018 at 1:10 AM, greg holly <mak.hholly using gmail.com> wrote:
>
>> Hi Brent;
>>
>> Thanks so much, fore writing. It is much appreciated. Here is a small
>> example from my data
>>
>> Bolge Fe_ppmtp Zn ppmtp Mn_tp Cu_tp
>> zilan
>> zilan 8.36 0.44 6.9 0.5
>> zilan 8.78 0.58 21.16 0.24
>> zilan 16.52 2.28 27.58 0.8
>> zilan 42.22 14.22 34.7 31.9
>>
>> On Fri, May 11, 2018 at 12:55 AM, Bert Gunter <bgunter.4567 using gmail.com>
>> wrote:
>>
>>> Clarification needed.
>>>
>>> Are your data in a data frame or an alphanumeric matrix? What does it
>>> look like?
>>>
>>> A small reproducible example would be very useful here I think!
>>>
>>>
>>> [1] http://stackoverflow.com/questions/5963269/how-to-make-a-gre
>>> at-r-reproducible-example
>>> [2] http://adv-r.had.co.nz/Reproducibility.html
>>>
>>> Also, is this relevant:
>>>
>>> > d <- matrix(1:12,ncol = 4)
>>> > d
>>>      [,1] [,2] [,3] [,4]
>>> [1,]    1    4    7   10
>>> [2,]    2    5    8   11
>>> [3,]    3    6    9   12
>>> > dd <- d[,c(3,1,2,4)]
>>> > dd
>>>      [,1] [,2] [,3] [,4]
>>> [1,]    7    1    4   10
>>> [2,]    8    2    5   11
>>> [3,]    9    3    6   12
>>>
>>> Perhaps you neeed to spend time with an R tutorial that covers indexing
>>> of data frames and matrices, an absolutely basic R operation? (I am not
>>> clear from your question if this is your problem).
>>>
>>>
>>> Cheers,
>>> Bert
>>>
>>>
>>>
>>> Bert Gunter
>>>
>>> "The trouble with having an open mind is that people keep coming along
>>> and sticking things into it."
>>> -- Opus (aka Berkeley Breathed in his "Bloom County" comic strip )
>>>
>>> On Thu, May 10, 2018 at 2:36 PM, greg holly <mak.hholly using gmail.com>
>>> wrote:
>>>
>>>> Dear all;
>>>>
>>>> I need to run heatmap. Because my first column in my data is
>>>> alphanumeric,
>>>> I can not run as.matrix(scale(my_data)). So I need to make my data
>>>> readable
>>>> as in data(mtcars). In *mtcars *data the first column is alphanumeric
>>>> and
>>>> has no  name.
>>>>
>>>> Thanks,
>>>>
>>>> Greg
>>>>
>>>>         [[alternative HTML version deleted]]
>>>>
>>>> ______________________________________________
>>>> R-help using 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/posti
>>>> ng-guide.html
>>>> and provide commented, minimal, self-contained, reproducible code.
>>>>
>>>
>>>
>>
>

	[[alternative HTML version deleted]]




More information about the R-help mailing list