Archive | Software RSS for this section

R: read.delim2 .txt file and calulate mean of 5 classes

################################################################################
# MC TEST data set by H.Wright                                                 |
#                                                                              |
#                                                                              | 
################################################################################
# set working directory file path
setwd("D:\\Projects\\R_analysis\\mc_30.12.2010\\")
# load the test marechiara dataset 
read.delim2 (file="D:\\Projects\\R_analysis\\mc_30.12.2010\\mc_test1.txt", 
          na.strings = "NA", 
          nrows = -1,
          skip = 0, 
          check.names = TRUE, 
          strip.white = FALSE, 
          blank.lines.skip = TRUE)
# assign data table to object 'mc' 
mc<-(read.delim2  (file="D:\\Projects\\R_analysis\\mc_30.12.2010\\mc_test1.txt", 
          na.strings = "NA", 
          nrows = -1, 
          skip = 0, 
          check.names = TRUE, 
          strip.white = FALSE, 
          blank.lines.skip = TRUE))
# obtain the data table column variables
names(mc)
#[1] "year"    "Acartia.clausi"     "Acartia.danae"      "Acartia.discaudata" "Acartia.longiremis" "Acartia.margalefi"      
 
#define variables in object mc
  col2 <-mc$Acartia.clausi
  col3 <-mc$Acartia.danae
  col4 <-mc$Acartia.discaudata
  col5 <-mc$Acartia.longiremis
  col6 <-mc$Acartia.margalefi
#take the mean of each variable
     mean(col2)
          mean(col3)
               mean(col4)
                    mean(col5)
                         mean(col6)

Created by Pretty R at inside-R.org

R: read.delim2 .txt file and calulate mean of 5 classes

################################################################################
# MC TEST data set by H.Wright                                                 |
#                                                                              |
#                                                                              | 
################################################################################
# set working directory file path
setwd("D:\Projects\R_analysis\mc_30.12.2010\")
# load the test marechiara dataset 
read.delim2 (file="D:\Projects\R_analysis\mc_30.12.2010\mc_test1.txt", 
          na.strings = "NA", 
          nrows = -1,
          skip = 0, 
          check.names = TRUE, 
          strip.white = FALSE, 
          blank.lines.skip = TRUE)
# assign data table to object 'mc' 
mc<-(read.delim2  (file="D:\Projects\R_analysis\mc_30.12.2010\mc_test1.txt", 
          na.strings = "NA", 
          nrows = -1, 
          skip = 0, 
          check.names = TRUE, 
          strip.white = FALSE, 
          blank.lines.skip = TRUE))
# obtain the data table column variables
names(mc)
#[1] "year"    "Acartia.clausi"     "Acartia.danae"      "Acartia.discaudata" "Acartia.longiremis" "Acartia.margalefi"      
 
#define variables in object mc
  col2 <-mc$Acartia.clausi
  col3 <-mc$Acartia.danae
  col4 <-mc$Acartia.discaudata
  col5 <-mc$Acartia.longiremis
  col6 <-mc$Acartia.margalefi
#take the mean of each variable
     mean(col2)
          mean(col3)
               mean(col4)
                    mean(col5)
                         mean(col6)

Created by Pretty R at inside-R.org

%d bloggers like this: