Sei sulla pagina 1di 3

Pre-formatted files :: Tutorials for quanteda https://tutorials.quanteda.

io/import-data/pre-formatted/

 quanteda tutorials > Data Import > Pre-formatted �les

 Search... 

PRE-
1. Introduction 

2. Data Import 
FORMATTED
Pre-formatted �les 

Multiple text �les

Different encodings
FILES
3. Basic Operations 

require(quanteda)
4. Statistical Analysis 
require(readtext)

5. Advanced Operations

6. Scaling and First, we show how to import pre-formatted
Classi�cation  �les that come in a “spreadsheet format”.
path_data is the location of sample �les on
7. Different Languages
your computer that come with the readtext
package.
More
 Github repo
path_data <-
 Website system.file("extdata/", package =
 Clear History "readtext")

If your text data is stored in a pre-formatted


�le where one column contains the text and
additional columns might store document-

1 of 3 3/7/19, 3:42 PM
Pre-formatted files :: Tutorials for quanteda https://tutorials.quanteda.io/import-data/pre-formatted/

level variables (e.g. year, author, or language),


you can use read.csv() to import.

dat_inaug <-
  read.csv(paste0(path_data,
"/csv/inaugCorpus.csv"))

1. Introduction 

Alternatively, you can use the readtext


2. Data Import 
package to import character (comma- or tab-
Pre-formatted �les 
separated) values. readtext reads �les
Multiple text �les containing text, along with any associated

Different encodings
document-level variables.

3. Basic Operations 
dat_inaug <-
4. Statistical Analysis  readtext(paste0(path_data,
"/tsv/dailsample.tsv"),
text_field = "speech")
5. Advanced Operations

6. Scaling and
Classi�cation   Warning

7. Different Languages The most common problem in loading


data into R is misspeci�ng locations of

More �les or directories. If a path is relative,


check where you are using getwd() and
 Github repo set the root directory of your project
 Website using setwd() . On Windows, you also
 Clear History have to replace all \ in a path with / .

 Tip

If you have more than a few R �les in a

2 of 3 3/7/19, 3:42 PM
Pre-formatted files :: Tutorials for quanteda https://tutorials.quanteda.io/import-data/pre-formatted/

project, you should create a RStudio


Project to better manage �les and
settings. You can create a RStudio project
from the menu (File > New Project).

 

1. Introduction 

2. Data Import 

Pre-formatted �les 
 
Multiple text �les

Different encodings

3. Basic Operations 

4. Statistical Analysis 

5. Advanced Operations

6. Scaling and
Classi�cation 

7. Different Languages

More
 Github repo
 Website
 Clear History

3 of 3 3/7/19, 3:42 PM

Potrebbero piacerti anche