Corpus Linguistics with R, Day 1
Want to share your content on R-bloggers? click here if you have a blog, or here if you don't.
(This post documents the first day of a class on R that I took at ESU C&T. I is posted here purely for my own use.)
R Lesson 1
> 2+3; 2/3; 2^3
[1] 5
[1] 0.6666667
[1] 8
---
Fundamentals - Functions
> log(x=1000, base=10)
[1] 3
---
(Formals describes the syntax of other functions)
formals(sample)
---
Variables
( a a
[1] 5
# is for comments
whitespace doesn't matter
---
# Pick files
file.choose()
# Get working dir
getwd()
# Set working dir
setwd("..")
# Save
> save(VARIABLE_NAME, file=file.choose())
Fehler in save(test, file = file.choose()) : Objekt ‘test’ nicht gefunden
> save.image("FILE_NAME")
---
> setwd("/home/cornelius/Code/samples/Brown_95perc")
> getwd()
[1] "/home/cornelius/Code/samples/Brown_95perc"
> dir()
> my_array my_array
[1] 1 2 3 4
> my_array my_array2 c(my_array, my_array2)
[1] "lalala" "lululu" "bla" "1" "2" "3" "4"
>
# it is possible to add something to ALL values in a vector, i.e.
my_array2 + 10
# c (conc) makes a list
stuff1 my_corpus
R-bloggers.com offers daily e-mail updates about R news and tutorials about learning R and many other topics. Click here if you're looking to post or find an R/data-science job.
Want to share your content on R-bloggers? click here if you have a blog, or here if you don't.