column

  1. D

    Remove part of the values in a column

    Probably this is an easy question for experienced R-users, so hopefully you can help me. In my dataframe, I have the following kind of values in my 'RSID'- and 'ALLELE'-columns: RSID ALLELE rs12345. A. rs3984. C. rs12398432. G. etc. Now I need to remove the...
  2. P

    Programming Beginner

    Hi, Can i get some help in writing a code. I have 3 csv files, 6 columns in each file. 1) I need to take average of each column in each file separately. ~ 6 values per file 2) find minimum average value for each column across all 3 files (min value of average across the three...
  3. S

    Medical Audit New Column based off three other columns

    Hello I'm Sean a final year medical student doing an audit on some ultrasound data. I'm new to programming and R. What I want to do is create a column of data based off the values in three other columns. I have attached a picture to refer to because its a bit difficult to describe So I...
  4. F

    Group Like Columns In Data Frame

    I have a data frame takes the following form. Type| val1 | val2 | val3 | Type | val1 | val2 | val3 | Type | val1 | val2 | val3 | --------------------------------------------------------------------------------------- A | 3 | 2 | 4 | A | 3 | 2 | 4 |...
  5. L

    Help please with a tricky problem: compare one element to a row in a table

    Hi Please help I am stuck with a really tricky problem: Hi I have a really tricky problem. I tried several approaches and so far I got lost. I have a table with one column which contains 9 and 2. This is the second table: > my_crazy_data V1 V2 V3 V4 V5 V6 V7 1 1 a 2.0...
  6. T

    How to define a field inside a dataframe based on the columnname and the rowname ?

    I have a dataframe called HMDAYTIME with the columnname "A" and the rownames "2" and "3", and based on a raw data csv called "DATA". My question is (i didn´t found anything about that on the internet), if i want to do a for loop to change each value of the "A" column, how can I make the...
  7. E

    Adding a new column in R data frame with values conditional on another column

    Suppose I have the data frame: table<- data.frame(population=c(100, 300, 5000, 2000, 900, 2500), habitat=c(1,2,3,4,5,6)) Now I want to add a new column table$size with the values 1 if population< 500, 2 if 500<=population<1000, 3 if 1000<=population<2000, 4 if 2000<=population<3000, 5 if...
  8. M

    Expand Observations in New Column Based on Two Columns

    Hi I have read a csv file using the read.table function into R. It contains a list of variables which are numeric in class. I would like to create a new column based on two columns. Se example below, where C is my desired output. A B C 1 4 4 2 3 3 3 4 3 2 5 4 - - 4 - - 4 - -...
  9. G

    sum in column by date

    Hi all, I have a small problem which is holding me back and I cannot figure it out. In a dataset I need to calculate the sum of variable "value" and put the result in a new variable "result". The problem is, that the calculation needs to be done by id and date. Every id can have multiple...