Hello,
On Tue, Aug 13, 2019 at 01:59:56PM -0400, Christopher W Ryan wrote:
> But this assumes that all files have column names in their first row. In
> this case, some don't. Any advice how to handle it so that those with
> column names and those without are read in and combined properly?
It obvo
Yes. Also, the original poster said that the files had the same column
structure, so there may be stronger heuristics to see whether the first line is
a header line. E.g., assuming that the first column is called "ID" (and doesn't
have ID as a possible value) use
first <- readLines(file, 1)
if
If the data are numeric (or at least some columns are numeric), a
brute force solution is to read a file once with header = FALSE, check
the relevant column(s) for being numeric, and if they are not numeric,
re-read with header = TRUE. Alternatively, if you know the column
names (headers) beforehan
Like Bert, I can't see an easy approach for datasets that have
character rather than numeric data. But here's a simple approach for
distinguishing files that have possible character headers but numeric
data.
readheader <- function(filename) {
possibleheader <- read.table(filename, nrows=1, sep=
Are these files of numerics? In other words, how would one know whether the
first line of a file of alpha data are headers or not? read.table's Help
file contains some info that may or may not be relevant for your files also.
Assuming a criterion for distinction, one could simply read the first l
Alas, we spend so much time and energy on data wrangling . . . .
I'm given a collection of csv files to work with---"found data". They arose
via saving Excel files to csv format. They all have the same column
structure, except that some were saved with column names and some were not.
I have a cod
Chapeau Ista :-)
On Tue, Aug 13, 2019 at 4:22 PM Ista Zahn wrote:
> How about
>
> > library(tidyr)
> > separate_rows(d, Col2)
> Col1 Col2
> 1 Agency A Function1
> 2 Agency A Function2
> 3 Agency A Function3
> 4 Agency A Function4
> 5 Agency B Function2
> 6 Agency B Function4
> 7 Agenc
Hi
I does not use Deducer so I do not know if it has some features for such task
In plain R instead
file.names <- dir(pattern = "*.txt")
use
file.names <- list.files(pattern = "*.txt")
for(i in 1:length(file.names)){file <-
> read.table(file.names[i],header=TRUE) #
Here you want to change zero
How about
> library(tidyr)
> separate_rows(d, Col2)
Col1 Col2
1 Agency A Function1
2 Agency A Function2
3 Agency A Function3
4 Agency A Function4
5 Agency B Function2
6 Agency B Function4
7 Agency C Function1
8 Agency C Function3
9 Agency C Function4
On Mon, Aug 12, 2019 at 11:06 PM
Hi all,
I am having an issue with trying to run iterations for the same analysis
with a list of data sets. I am assuming I am missing a basic step here.
Code I am trying is below. Not certain if a NEXT call needs to be
included somewhere or not.
This is run under the Deducer GUI. I would a
Hello,
Though good answers were already given, I would like to say something.
1.
If you are lazy (typing), use with, if you prefer to play safe, don't.
I am lazy many times, but in interactive mode only.
2.
I find it better in the long run *not* to take advantage of R's
one-liners, they tend t
11 matches
Mail list logo