[R] Transpose a dataset
jim holtman
jholtman at gmail.com
Tue Aug 18 13:50:27 CEST 2009
Is this what you want:
> x
mean sd X0. X25. X50.
X75. X100. n
BODY_TEMPERATURE 36.41099 0.4015699 35.1 36.22222 36.5
36.66667 37.1 89
DIASTOLIC_BLOOD_PRESSURE 73.60079 9.4656186 50.0 67.00000 73.0
80.00000 95.0 253
HEIGHT 171.94000 9.2011670 153.5 166.50000 173.0
176.25000 190.0 20
PULSE_RATE 67.48221 11.7657645 40.0 60.00000 68.0
75.00000 97.0 253
SYSTOLIC_BLOOD_PRESSURE 131.91700 14.4986667 97.0 122.00000 132.0
140.00000 185.0 253
WEIGHT 85.17079 17.3150434 57.3 70.90000 83.1
100.00000 122.5 89
> t(x)
BODY_TEMPERATURE DIASTOLIC_BLOOD_PRESSURE HEIGHT PULSE_RATE
SYSTOLIC_BLOOD_PRESSURE WEIGHT
mean 36.4109900 73.600790 171.940000 67.48221
131.91700 85.17079
sd 0.4015699 9.465619 9.201167 11.76576
14.49867 17.31504
X0. 35.1000000 50.000000 153.500000 40.00000
97.00000 57.30000
X25. 36.2222200 67.000000 166.500000 60.00000
122.00000 70.90000
X50. 36.5000000 73.000000 173.000000 68.00000
132.00000 83.10000
X75. 36.6666700 80.000000 176.250000 75.00000
140.00000 100.00000
X100. 37.1000000 95.000000 190.000000 97.00000
185.00000 122.50000
n 89.0000000 253.000000 20.000000 253.00000
253.00000 89.00000
>
Also when sending example data, used 'dput'; makes it easier to access it:
> dput(x)
structure(list(mean = c(36.41099, 73.60079, 171.94, 67.48221,
131.917, 85.17079), sd = c(0.4015699, 9.4656186, 9.201167, 11.7657645,
14.4986667, 17.3150434), X0. = c(35.1, 50, 153.5, 40, 97, 57.3
), X25. = c(36.22222, 67, 166.5, 60, 122, 70.9), X50. = c(36.5,
73, 173, 68, 132, 83.1), X75. = c(36.66667, 80, 176.25, 75, 140,
100), X100. = c(37.1, 95, 190, 97, 185, 122.5), n = c(89L, 253L,
20L, 253L, 253L, 89L)), .Names = c("mean", "sd", "X0.", "X25.",
"X50.", "X75.", "X100.", "n"), class = "data.frame", row.names =
c("BODY_TEMPERATURE",
"DIASTOLIC_BLOOD_PRESSURE", "HEIGHT", "PULSE_RATE", "SYSTOLIC_BLOOD_PRESSURE",
"WEIGHT"))
>
On Tue, Aug 18, 2009 at 12:00 AM, rajclinasia<raj at clinasia.com> wrote:
>
> Hi Everyone,
>
> I have a dataset like this
>
> mean sd 0% 25% 50%
> 75% 100% n
> BODY TEMPERATURE 36.41099 0.4015699 35.1 36.22222 36.5
> 36.66667 37.1 89
> DIASTOLIC BLOOD PRESSURE 73.60079 9.4656186 50.0 67.00000 73.0
> 80.00000 95.0 253
> HEIGHT 171.94000 9.2011670 153.5 166.50000 173.0
> 176.25000 190.0 20
> PULSE RATE 67.48221 11.7657645 40.0 60.00000 68.0
> 75.00000 97.0 253
> SYSTOLIC BLOOD PRESSURE 131.91700 14.4986667 97.0 122.00000 132.0
> 140.00000 185.0 253
> WEIGHT 85.17079 17.3150434 57.3 70.90000 83.1
> 100.00000 122.5 89
>
> now i want to transpose this dataset like
>
> BODY TEMPERATURE mean 36.41099
> sd 0.4015699
> 0% 35.1
> 25% 36.222
> 50% 36.5
> 75% 36.667
> 100% 37.1
> n 89
>
> DIASTOLIC BLOOD PRESSURE mean
> sd
> 0%
> 25%
> 50%
> 75%
> 100%
> n
> etc.
> if possible please send me the code. it will be very helpful us.
>
> Thanks in Advance.
>
> --
> View this message in context: http://www.nabble.com/Transpose-a-dataset-tp25018071p25018071.html
> Sent from the R help mailing list archive at Nabble.com.
>
> ______________________________________________
> 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.
>
--
Jim Holtman
Cincinnati, OH
+1 513 646 9390
What is the problem that you are trying to solve?
More information about the R-help
mailing list