# ds.dataFrame - Accessing variables

**URL:** <https://datashield.discourse.group/t/ds-dataframe-accessing-variables/199>\
**Category:** Analyst Support\
**Created:** [8 April 2020 10:53 UTC](https://datashield.discourse.group/t/ds-dataframe-accessing-variables/199 "2020-04-08T10:53:50Z")\
**Posts on this page:** 6\
**Page:** 1

<div class="post-metadata">

**Author:** ![daniela.zoeller](https://yyz2.discourse-cdn.com/free1/user_avatar/datashield.discourse.group/daniela.zoeller/32/16_2.png) [@daniela.zoeller](https://datashield.discourse.group/u/daniela.zoeller)\
**Post date:** [8 April 2020 10:53 UTC](https://datashield.discourse.group/t/ds-dataframe-accessing-variables/199/1 "2020-04-08T10:53:50Z")

</div>

Dear all,

when I build a dataframe using ds.dataFrame with e.g.

```
ds.dataFrame(x= c("D$age","D$sex","D$bmi"), newobj = "T")

```

I do not know how to extract the variables in the dataframe T. The variables are called “D$age” and so on, but e.g.

```
ds.mean("T$D$bmi")

```

does not work.

Best wishes, Daniela

---

<div class="post-metadata">

**Author:** ![swheater](https://yyz2.discourse-cdn.com/free1/user_avatar/datashield.discourse.group/swheater/32/182_2.png) [@swheater](https://datashield.discourse.group/u/swheater)\
**Post date:** [8 April 2020 14:38 UTC](https://datashield.discourse.group/t/ds-dataframe-accessing-variables/199/2 "2020-04-08T14:38:37Z")

</div>

Daniela,

This is an issue I have had to deal with a number of times.

My personal workaround is to use ‘ds.assign’. So I would do (or something like):

```
ds.assign("D$age", "age")
ds.assign("D$sex", "sex")
ds.assign("D$bmi", "bmi")

```

ds.dataFrame(x= c(“age”,“sex”,“bmi”), newobj = “T”) Then the following should work (I think):

`ds.mean("T$bmi")`

Stuart

---

<div class="post-metadata">

**Author:** ![daniela.zoeller](https://yyz2.discourse-cdn.com/free1/user_avatar/datashield.discourse.group/daniela.zoeller/32/16_2.png) [@daniela.zoeller](https://datashield.discourse.group/u/daniela.zoeller)\
**Post date:** [8 April 2020 14:44 UTC](https://datashield.discourse.group/t/ds-dataframe-accessing-variables/199/3 "2020-04-08T14:44:38Z")

</div>

Thanks Stuart!

Unfortunately, this is not an option here for me, as I am working with high-dimensional data and instead of

`c("age","sex","bmi")`

I actually have a vector with a high number of variables. It would be very great if a dataframe is part of the name of an input variable, this would just be removed or if new names could be provided for a given dataframe or as an input for the ds.dataFrame funciton.

---

<div class="post-metadata">

**Author:** ![tombishop](https://yyz2.discourse-cdn.com/free1/user_avatar/datashield.discourse.group/tombishop/32/23_2.png) [@tombishop](https://datashield.discourse.group/u/tombishop)\
**Post date:** [14 April 2020 10:48 UTC](https://datashield.discourse.group/t/ds-dataframe-accessing-variables/199/4 "2020-04-14T10:48:31Z")

</div>

Hi,

In the past I ran into trouble using T as a name for a variable because it is shorthand for TRUE in R. The same goes for F for FALSE.

Perhaps if you try a different name it might work better?

Tom

---

<div class="post-metadata">

**Author:** ![daniela.zoeller](https://yyz2.discourse-cdn.com/free1/user_avatar/datashield.discourse.group/daniela.zoeller/32/16_2.png) [@daniela.zoeller](https://datashield.discourse.group/u/daniela.zoeller)\
**Post date:** [16 April 2020 15:02 UTC](https://datashield.discourse.group/t/ds-dataframe-accessing-variables/199/5 "2020-04-16T15:02:50Z")

</div>

Hi,

this is of course true, but I just wrote T here to shorten what I had to write, I used another name…

Best Daniela

---

<div class="post-metadata">

**Author:** ![demetris.avraam](https://avatars.discourse-cdn.com/v4/letter/d/439d5e/32.png) [@demetris.avraam](https://datashield.discourse.group/u/demetris.avraam)\
**Post date:** [25 May 2020 13:12 UTC](https://datashield.discourse.group/t/ds-dataframe-accessing-variables/199/6 "2020-05-25T13:12:28Z")

</div>

Hi Daniela,

We have updated the ds.dataFrame function and now removes directly any “D$” parts from the column names of the assigned data frames. The new version will be included in v6.0 of DataSHIELD.
