[R] Shifting cells and removing blanks

Nordlund, Dan (DSHS/RDA) NordlDJ at dshs.wa.gov
Tue Mar 26 18:34:50 CET 2013


> -----Original Message-----
> From: r-help-bounces at r-project.org [mailto:r-help-bounces at r-
> project.org] On Behalf Of ankur verma
> Sent: Tuesday, March 26, 2013 10:22 AM
> To: r-help at r-project.org
> Subject: [R] Shifting cells and removing blanks
> 
> Hi ,
> 
> I've been struggling with this problem. Initially I thought something
> like
> a na.locf would help but I'm at a dead end. I have a data set like
> this:
> 
>  ID  Prod1  Prod2  Prod3  Prod4  Prod5
> 01    A             -           B        -           C
> 02      -           F           -           G        -
> 03      H         -             -           -         J


What does "like this" mean?  Is this a text file, or a list, or a dataframe, or a matrix, or ...?  You say you want to remove all blanks.  Are the hyphens your attempt to represent blanks in the email, or do they actually exist?


> 
> 
> And I would like to remove all the blanks and get a aggregated list
> against
> each ID like so:
> 
> 01 A B C
> 02 F G
> 03 H J

Again, do you want this output in a text file or some R structure?  If an R structure, which one?

> 
> Can anyone suggest a function or a package on how to achieve this ?
> 

Not until you provide a reproducible example as the posting guide asks.


Dan

Daniel J. Nordlund
Washington State Department of Social and Health Services
Planning, Performance, and Accountability
Research and Data Analysis Division
Olympia, WA 98504-5204



More information about the R-help mailing list