[R] Error occurred during mean calculation of a column of a data frame, which is apparently contents numeric data

2012-02-29 Thread Aniruddha Mukherjee
Hello R people, How can I compute the mean of the Pulse_rate column of the data frame or matrix from the following character object called str_got. It has 14 entries and each entry has 8 values, separated by commas. Please go thru the following R commands to know how I tried to unstring and

Re: [R] Error occurred during mean calculation of a column of a data frame, which is apparently contents numeric data

2012-02-29 Thread Berend Hasselman
On 29-02-2012, at 09:45, Aniruddha Mukherjee wrote: Hello R people, How can I compute the mean of the Pulse_rate column of the data frame or matrix from the following character object called str_got. It has 14 entries and each entry has 8 values, separated by commas. Please go thru the

Re: [R] Error occurred during mean calculation of a column of a data frame, which is apparently contents numeric data

2012-02-29 Thread Berend Hasselman
On 29-02-2012, at 11:49, Aniruddha Mukherjee wrote: Hello Berend. Many thanks for your prompt reply and that helped me a lot. One more thing, if you please explain, I shall be highly obliged. Why in my case (i.e. when stringsAsFactors was TRUE by default),

Re: [R] Error occurred during mean calculation of a column of a data frame, which is apparently contents numeric data

2012-02-29 Thread Aniruddha Mukherjee
Hello Berend. Many thanks for your prompt reply and that helped me a lot. One more thing, if you please explain, I shall be highly obliged. Why in my case (i.e. when stringsAsFactors was TRUE by default), as.numeric(matr1$Pulse_rate) displays the following [1] 4 5 7 5 9 8 6 10 3 2

Re: [R] Error occurred during mean calculation of a column of a data frame, which is apparently contents numeric data

2012-02-29 Thread R. Michael Weylandt
Factors are internally stored as integers (enums if you have used other programming languages) with a special label set -- it's more memory efficient than storing the whole string over and over. Michael On Wed, Feb 29, 2012 at 5:49 AM, Aniruddha Mukherjee aniruddha.mukher...@tcs.com wrote:

Re: [R] Error occurred during mean calculation of a column of a data frame, which is apparently contents numeric data

2012-02-29 Thread Duncan Murdoch
On 12-02-29 8:16 AM, R. Michael Weylandt wrote: Factors are internally stored as integers (enums if you have used other programming languages) with a special label set -- it's more memory efficient than storing the whole string over and over. That was one of the original justifications, but

Re: [R] Error occurred during mean calculation of a column of a data frame, which is apparently contents numeric data

2012-02-29 Thread Prof Brian Ripley
On 29/02/2012 13:41, Duncan Murdoch wrote: On 12-02-29 8:16 AM, R. Michael Weylandt wrote: Factors are internally stored as integers (enums if you have used other programming languages) with a special label set -- it's more memory efficient than storing the whole string over and over. That