Re: [R] help with data layout

From: Mike Lawrence <Mike.Lawrence_at_dal.ca>
Date: Thu, 17 Jul 2008 13:58:21 -0300

Nice tip on filling missing col1 values. I've always just done the filling in excel by hand. I then use that same hand to smack the person that gave me data in excel format :Op

On 17-Jul-08, at 1:19 PM, Erik Iverson wrote:

> Iain Gallagher wrote:
>> Hello list
>> I have been given some Excel sheets with data laid like this:
>> Col1 Col2 A 3 2 3 B 4 5 4 C 1 4 3
>> I was hoping to import this into R as a csv and then get the mean and
>> SD for each letter in column 1.
>> Could someone give me some guidance on best to approach this?
>
> Sure. Reading in Excel sheets can be done at least a few ways, see
> the R Data Import/Export manual on CRAN. The only way I have done
> it is to save the Excel sheet as a CSV file, and then use read.csv
> in R to get a data.frame. One note here is that sometimes the Excel
> sheet has 'missing' cells where someone has inserted blanks. These
> may get written out to the CSV file, you'll have to check. For
> example, I've seen an Excel sheet with something like 10 rows of
> data that outputs about 100 to the CSV file, mostly all missing.
>
> Anyway, once you have the data.frame, I'd use na.locf from the zoo
> package to 'fill' in the missing Col1 values, and then use an R
> function such as ave, tapply, aggregate, or by to do whatever you'd
> like.
>
>
>> Thanks
>> Iain
>> [[alternative HTML version deleted]]
>> ______________________________________________ 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.
>
> ______________________________________________
> 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.

--
Mike Lawrence
Graduate Student, Department of Psychology, Dalhousie University

www.memetic.ca

"The road to wisdom? Well, it's plain and simple to express:
Err and err and err again, but less and less and less."
	- Piet Hein

______________________________________________
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.
Received on Thu 17 Jul 2008 - 17:01:31 GMT

Archive maintained by Robert King, hosted by the discipline of statistics at the University of Newcastle, Australia.
Archive generated by hypermail 2.2.0, at Thu 17 Jul 2008 - 17:31:49 GMT.

Mailing list information is available at https://stat.ethz.ch/mailman/listinfo/r-help. Please read the posting guide before posting to the list.

list of date sections of archive