Used unique() function to extract unique timestamps from a large electrophysiology dataset. As per my knowledge, the value of length(unique(dataset$time) should have been 201; however, I am getting 1321.
Desired output:
unique(dataset$time)
[1] -1.00 -0.99 -0.98 -0.97 -0.96 -0.95 -0.94 -0.93 -0.92 -0.91 -0.90 -0.89 -0.88 -0.87 -0.86
[16] -0.85 -0.84 -0.83 -0.82 -0.81 -0.80 -0.79 -0.78 -0.77 -0.76 -0.75 -0.74 -0.73 -0.72 -0.71
[31] -0.70 -0.69 -0.68 -0.67 -0.66 -0.65 -0.64 -0.63 -0.62 -0.61 -0.60 -0.59 -0.58 -0.57 -0.56
[46] -0.55 -0.54 -0.53 -0.52 -0.51 -0.50 -0.49 -0.48 -0.47 -0.46 -0.45 -0.44 -0.43 -0.42 -0.41
[61] -0.40 -0.39 -0.38 -0.37 -0.36 -0.35 -0.34 -0.33 -0.32 -0.31 -0.30 -0.29 -0.28 -0.27 -0.26
[76] -0.25 -0.24 -0.23 -0.22 -0.21 -0.20 -0.19 -0.18 -0.17 -0.16 -0.15 -0.14 -0.13 -0.12 -0.11
[91] -0.10 -0.09 -0.08 -0.07 -0.06 -0.05 -0.04 -0.03 -0.02 -0.01 0.00 0.01 0.02 0.03 0.04
[106] 0.05 0.06 0.07 0.08 0.09 0.10 0.11 0.12 0.13 0.14 0.15 0.16 0.17 0.18 0.19
[121] 0.20 0.21 0.22 0.23 0.24 0.25 0.26 0.27 0.28 0.29 0.30 0.31 0.32 0.33 0.34
[136] 0.35 0.36 0.37 0.38 0.39 0.40 0.41 0.42 0.43 0.44 0.45 0.46 0.47 0.48 0.49
[151] 0.50 0.51 0.52 0.53 0.54 0.55 0.56 0.57 0.58 0.59 0.60 0.61 0.62 0.63 0.64
[166] 0.65 0.66 0.67 0.68 0.69 0.70 0.71 0.72 0.73 0.74 0.75 0.76 0.77 0.78 0.79
[181] 0.80 0.81 0.82 0.83 0.84 0.85 0.86 0.87 0.88 0.89 0.90 0.91 0.92 0.93 0.94
[196] 0.95 0.96 0.97 0.98 0.99 1.00
The current output replicates this exact pattern and starts repeating the -1, -0.9 etc after reaching 1.0.
Any ideas on why this would happen?
Related
data("Auto")
mpg01 <- rep(0, length(Auto$mpg))
mpg01[Auto$mpg > median(Auto$mpg)] <- 1
Auto <- data.frame(Auto, mpg01)
summary(Auto)
cor(Auto[, -9])
Error in cor(Auto[, -9]) : 'x' must be numeric
I don't know how deal with this error
I think you are not referencing the columns correctly. Try -
data <- ISLR::Auto
data$mpg01 <- as.integer(data$mpg > median(data$mpg))
cor(data[, -9])
# mpg cylinders displacement horsepower weight acceleration year origin mpg01
#mpg 1.00 -0.78 -0.81 -0.78 -0.83 0.42 0.58 0.57 0.84
#cylinders -0.78 1.00 0.95 0.84 0.90 -0.50 -0.35 -0.57 -0.76
#displacement -0.81 0.95 1.00 0.90 0.93 -0.54 -0.37 -0.61 -0.75
#horsepower -0.78 0.84 0.90 1.00 0.86 -0.69 -0.42 -0.46 -0.67
#weight -0.83 0.90 0.93 0.86 1.00 -0.42 -0.31 -0.59 -0.76
#acceleration 0.42 -0.50 -0.54 -0.69 -0.42 1.00 0.29 0.21 0.35
#year 0.58 -0.35 -0.37 -0.42 -0.31 0.29 1.00 0.18 0.43
#origin 0.57 -0.57 -0.61 -0.46 -0.59 0.21 0.18 1.00 0.51
#mpg01 0.84 -0.76 -0.75 -0.67 -0.76 0.35 0.43 0.51 1.00
I have a huge dataframe (>1,000,000 rows) like this.
term estimate st.error statistic p.value SNP
(Intercept) 7.68 0.17 44.64 0 rs1406947
GT 0.01 0.01 0.07 0.19 rs1406947
SEX 1.52 0.14 10.87 0.1 rs1406947
M 0.12 0.29 0.41 0.67 rs1406947
N -0.06 0.12 -0.48 0.63 rs1406947
GT:SEX -0.03 0.08 -0.44 0.65 rs1406947
GT:N -0.00 0.06 -0.08 0.93 rs1406947
(Intercept) 9.23 0.20 34.64 0 rs25904
GT 0.05 0.04 0.12 0.22 rs25904
SEX 1.67 0.76 10.34 0.1 rs25904
M 0.14 0.39 0.51 0.55 rs25904
N -0.08 0.05 -0.46 0.55 rs25904
GT:SEX -0.19 0.11 -0.34 0.44 rs25904
GT:N -0.22 0.33 -0.44 0.55 rs25904
(Intercept) 7.99 0.66 44.44 0 rs7133579
GT 0.01 0.3 0.04 0.33 rs7133579
SEX 1.22 0.22 10.44 0.15 rs7133579
M 0.88 0.22 0.33 0.44 rs7133579
N -0.5 0.5 -0.5 0.6 rs7133579
GT:N -0.00 0.03 -0.04 0.78 rs7133579
It is composed by blocks of 7 observations: (Intercept), GT, SEX, M, N, GT:SEX and GT:N. However, a few blocks lack one or more of the observations (e.g. the third block lacks GT:SEX). Using R, I want to remove these blocks. In this toy example I would get:
term estimate st.error statistic p.value SNP
(Intercept) 7.68 0.17 44.64 0 rs1406947
GT 0.01 0.01 0.07 0.19 rs1406947
SEX 1.52 0.14 10.87 0.1 rs1406947
M 0.12 0.29 0.41 0.67 rs1406947
N -0.06 0.12 -0.48 0.63 rs1406947
GT:SEX -0.03 0.08 -0.44 0.65 rs1406947
GT:N -0.00 0.06 -0.08 0.93 rs1406947
(Intercept) 9.23 0.20 34.64 0 rs25904
GT 0.05 0.04 0.12 0.22 rs25904
SEX 1.67 0.76 10.34 0.1 rs25904
M 0.14 0.39 0.51 0.55 rs25904
N -0.08 0.05 -0.46 0.55 rs25904
GT:SEX -0.19 0.11 -0.34 0.44 rs25904
GT:N -0.22 0.33 -0.44 0.55 rs25904
I think you'd want to group by SNP and check those blocks for whether they comply with your expectations:
library(dplyr)
expected_terms <- c("(Intercept)", "GT", "SEX", "M", "N", "GT:SEX", "GT:N")
df %>%
group_by(SNP) %>%
filter(
all(expected_terms %in% term)
)
Stricter than that, if you need to make sure that each of your terms exist only once or no other terms appear:
df %>%
group_by(SNP) %>%
filter(
# use `table` to count occurrence of terms, keep only if all are counted exactly once
all(table(term)[expected_terms] == 1),
# keep only if no terms remain after removing your expected set
length(setdiff(term, expected_terms)) == 0
)
Assuming that (Intercept) is present everytime, you can test if the length of each block is 7.
x[unlist(lapply(split(seq_len(nrow(x)), cumsum(x$term == "(Intercept)")),
function(y) {if(length(y) == 7) y else NULL})), ]
# term estimate st.error statistic p.value SNP
#1 (Intercept) 7.68 0.17 44.64 0.00 rs1406947
#2 GT 0.01 0.01 0.07 0.19 rs1406947
#3 SEX 1.52 0.14 10.87 0.10 rs1406947
#4 M 0.12 0.29 0.41 0.67 rs1406947
#5 N -0.06 0.12 -0.48 0.63 rs1406947
#6 GT:SEX -0.03 0.08 -0.44 0.65 rs1406947
#7 GT:N 0.00 0.06 -0.08 0.93 rs1406947
#8 (Intercept) 9.23 0.20 34.64 0.00 rs25904
#9 GT 0.05 0.04 0.12 0.22 rs25904
#10 SEX 1.67 0.76 10.34 0.10 rs25904
#11 M 0.14 0.39 0.51 0.55 rs25904
#12 N -0.08 0.05 -0.46 0.55 rs25904
#13 GT:SEX -0.19 0.11 -0.34 0.44 rs25904
#14 GT:N -0.22 0.33 -0.44 0.55 rs25904
Data:
x <- read.table(header=TRUE, text="term estimate st.error statistic p.value SNP
(Intercept) 7.68 0.17 44.64 0 rs1406947
GT 0.01 0.01 0.07 0.19 rs1406947
SEX 1.52 0.14 10.87 0.1 rs1406947
M 0.12 0.29 0.41 0.67 rs1406947
N -0.06 0.12 -0.48 0.63 rs1406947
GT:SEX -0.03 0.08 -0.44 0.65 rs1406947
GT:N -0.00 0.06 -0.08 0.93 rs1406947
(Intercept) 9.23 0.20 34.64 0 rs25904
GT 0.05 0.04 0.12 0.22 rs25904
SEX 1.67 0.76 10.34 0.1 rs25904
M 0.14 0.39 0.51 0.55 rs25904
N -0.08 0.05 -0.46 0.55 rs25904
GT:SEX -0.19 0.11 -0.34 0.44 rs25904
GT:N -0.22 0.33 -0.44 0.55 rs25904
(Intercept) 7.99 0.66 44.44 0 rs7133579
GT 0.01 0.3 0.04 0.33 rs7133579
SEX 1.22 0.22 10.44 0.15 rs7133579
M 0.88 0.22 0.33 0.44 rs7133579
N -0.5 0.5 -0.5 0.6 rs7133579
GT:N -0.00 0.03 -0.04 0.78 rs7133579")
I have a list of all files (dataframes) within a directory:
library("plyr")
library("dplyr")
library("broom")
library("tidyr")
snp_list <- list.files(pattern="*.txt", all.files = T,full.names = F)
I also have a dataframe A obtained through the following function:
pv1= lapply(snp_list, function(x) tidy(lm(PV ~ GT*SEX + M + GT*N,read.table(x,header=TRUE)))) %>%
bind_rows()
Dataframe A has 7 rows ((Intercept), GT, SEX, M, N, GT:SEX, GT:N) for each element in list snp_list. In this toy example the list has 3 elements (rs1406947.txt rs25904.txt rs7133579.txt), but in reality there are 1,200,000 elements
A:
term estimate st.error statistic p.value
(Intercept) 7.68 0.17 44.64 0
GT 0.01 0.01 0.07 0.19
SEX 1.52 0.14 10.87 0.1
M 0.12 0.29 0.41 0.67
N -0.06 0.12 -0.48 0.63
GT:SEX -0.03 0.08 -0.44 0.65
GT:N -0.00 0.06 -0.08 0.93
(Intercept) 9.23 0.20 34.64 0
GT 0.05 0.04 0.12 0.22
SEX 1.67 0.76 10.34 0.1
M 0.14 0.39 0.51 0.55
N -0.08 0.05 -0.46 0.55
GT:SEX -0.19 0.11 -0.34 0.44
GT:N -0.22 0.33 -0.44 0.55
(Intercept) 7.99 0.66 44.44 0
GT 0.01 0.3 0.04 0.33
SEX 1.22 0.22 10.44 0.15
M 0.88 0.22 0.33 0.44
N -0.5 0.5 -0.5 0.6
GT:SEX -0.06 0.09 -0.74 0.35
GT:N -0.00 0.03 -0.04 0.78
I want to add a new column "SNP" to A, where each row has the name of the element the rows belongs to (nrows = 7*1,200,000). I would get this:
term estimate st.error statistic p.value SNP
(Intercept) 7.68 0.17 44.64 0 rs1406947
GT 0.01 0.01 0.07 0.19 rs1406947
SEX 1.52 0.14 10.87 0.1 rs1406947
M 0.12 0.29 0.41 0.67 rs1406947
N -0.06 0.12 -0.48 0.63 rs1406947
GT:SEX -0.03 0.08 -0.44 0.65 rs1406947
GT:N -0.00 0.06 -0.08 0.93 rs1406947
(Intercept) 9.23 0.20 34.64 0 rs25904
GT 0.05 0.04 0.12 0.22 rs25904
SEX 1.67 0.76 10.34 0.1 rs25904
M 0.14 0.39 0.51 0.55 rs25904
N -0.08 0.05 -0.46 0.55 rs25904
GT:SEX -0.19 0.11 -0.34 0.44 rs25904
GT:N -0.22 0.33 -0.44 0.55 rs25904
(Intercept) 7.99 0.66 44.44 0 rs7133579
GT 0.01 0.3 0.04 0.33 rs7133579
SEX 1.22 0.22 10.44 0.15 rs7133579
M 0.88 0.22 0.33 0.44 rs7133579
N -0.5 0.5 -0.5 0.6 rs7133579
GT:SEX -0.06 0.09 -0.74 0.35 rs7133579
GT:N -0.00 0.03 -0.04 0.78 rs7133579
Here's how to do what you asked:
A$SNP=rep(0,nrow(A))
for (i in 1:nrow(A)){
A$SNP[i]=snp_list[(i%/%8)+1]
}
Using integer division, you can generate an index for 7 elements to map to each element in snp_list.
In particular, I'd like to subset the temperature measurements from 1960 onwards in the time series gtemp in the package astsa:
require(astsa)
gtemp
Time Series:
Start = 1880
End = 2009
Frequency = 1
[1] -0.28 -0.21 -0.26 -0.27 -0.32 -0.32 -0.29 -0.36 -0.27 -0.17 -0.39 -0.27 -0.32
[14] -0.33 -0.33 -0.25 -0.14 -0.11 -0.25 -0.15 -0.07 -0.14 -0.24 -0.30 -0.34 -0.24
[27] -0.19 -0.39 -0.33 -0.35 -0.33 -0.34 -0.32 -0.30 -0.15 -0.10 -0.30 -0.39 -0.33
[40] -0.20 -0.19 -0.14 -0.26 -0.22 -0.22 -0.17 -0.02 -0.15 -0.12 -0.26 -0.08 -0.02
[53] -0.08 -0.19 -0.07 -0.12 -0.05 0.07 0.10 0.01 0.04 0.10 0.03 0.09 0.19
[66] 0.06 -0.05 0.00 -0.04 -0.07 -0.16 -0.04 0.03 0.11 -0.10 -0.10 -0.17 0.08
[79] 0.08 0.06 -0.01 0.07 0.04 0.08 -0.21 -0.11 -0.03 -0.01 -0.04 0.08 0.03
[92] -0.10 0.00 0.14 -0.08 -0.05 -0.16 0.12 0.01 0.08 0.18 0.26 0.04 0.26
[105] 0.09 0.05 0.12 0.26 0.31 0.19 0.37 0.35 0.12 0.13 0.23 0.37 0.29
[118] 0.39 0.56 0.32 0.33 0.48 0.56 0.55 0.48 0.62 0.54 0.57 0.43 0.57
The individual time points are not labeled in years, so although I can do gtemp[3] [1] -0.26, I can't do gtemp[as.date(1960)], for instance to get the value in 1960.
How can I bring out the correspondence between year and measurements, so as to later subset values?
We can make use of the window function
gtemp1 <- window(gtemp, start = 1960)
gtemp1
#Time Series:
#Start = 1960
#End = 2009
#Frequency = 1
#[1] -0.01 0.07 0.04 0.08 -0.21 -0.11 -0.03 -0.01 -0.04 0.08 0.03
#[12]-0.10 0.00 0.14 -0.08 -0.05 -0.16 0.12 0.01 0.08 0.18 0.26
#[23] 0.04 0.26 0.09 0.05 0.12 0.26 0.31 0.19 0.37 0.35 0.12
#[34] 0.13 0.23 0.37 0.29 0.39 0.56 0.32 0.33 0.48 0.56 0.55
#[45] 0.48 0.62 0.54 0.57 0.43 0.57
Function time can also help to answer your question
How can I bring out the correspondence between year and measurements, so as to later subset values?
head(time(gtemp))
[1] 1880 1881 1882 1883 1884 1885
If you want the value that corresponds to 1961, you can write
gtemp[time(gtemp) == 1961]
[1] 0.07
As mentioned in the first answer, you can also use the function window
window(gtemp, start = 1961, end = 1961)
Time Series:
Start = 1961
End = 1961
Frequency = 1
[1] 0.07
that returns the result as one point time series. You can convert it into a number by
as.numeric(window(gtemp, start = 1961, end = 1961))
[1] 0.07
I have a large txt file. As listed in the txt listed at the end of this question. There are three columns, and 677 rows
How to read in the txt below to R, and sum all the numbers in the cells in the row 1-2 and column 300-400.
1.00 0.90 0.76 0.61 0.52 0.36 0.33 0.28 0.18 0.21 0.17 0.12 0.08 0.08 0.00 -0.05 -0.11 -0.09 -0.07 -0.12 -0.15 -0.19 -0.16 -0.05 0.07 0.18 0.26 0.25 0.31 0.36 0.40 0.41 0.53 0.59 0.66 0.72 -0.16 -0.19 -0.20 -0.18 -0.19 -0.22 -0.25 -0.20 -0.22 -0.23 -0.27 -0.29 -0.27 -0.28 -0.30 -0.29 -0.28 -0.28 -0.32 -0.32 -0.35 -0.36 -0.32 -0.27 -0.26 -0.23 -0.20 -0.19 -0.21 -0.16 -0.06 0.00 0.05 0.08 0.15 0.15 0.18 0.24 0.24 0.26 0.22 0.23 0.11 0.06 0.01 -0.01 -0.04 -0.06 -0.16 -0.20 -0.27 -0.26 -0.28 -0.29 -0.30 -0.26 -0.20 -0.24 -0.22 -0.16 -0.14 -0.15 -0.12 -0.07 -0.07 -0.06 -0.03 -0.02 0.02 0.03 0.09 0.01 -0.07 -0.02 -0.16 -0.10 -0.07 -0.01 -0.00 0.01 -0.07 -0.14 -0.00 -0.05 -0.03 0.01 0.06 0.08 0.13 0.10 0.05 -0.06 -0.07 -0.05 -0.03 -0.08 -0.17 -0.07 0.08 0.14 0.10 0.15 0.22 0.19 0.17 0.12 0.08 0.13 0.12 0.08 0.05 -0.07 -0.07 -0.09 -0.11 -0.14 -0.11 -0.13 -0.12 -0.13 -0.18 -0.14 -0.11 -0.02 -0.02 0.00 -0.10 -0.15 -0.25 -0.23 -0.20 -0.22 -0.20 -0.20 -0.22 -0.18 -0.13 -0.09 -0.04 -0.02 0.02 0.02 0.04 0.02 0.04 0.09 0.04 -0.03 -0.11 -0.14 -0.09 -0.07 -0.03 -0.07 -0.09 -0.15 -0.20 -0.27 -0.28 -0.28 -0.25 -0.28 -0.24 -0.14 -0.05 0.05 0.15 0.19 0.18 0.28 0.20 0.38 0.36 0.33 0.32 0.25 0.12 -0.00 -0.09 -0.10 -0.13 -0.06 -0.07 -0.01 -0.12 -0.17 -0.14 -0.07 -0.03 0.07 0.14 -0.00 -0.06 -0.12 -0.18 -0.22 -0.27 -0.25 -0.26 -0.23 -0.18 -0.19 -0.13 -0.15 -0.14 -0.08 -0.07 -0.19 -0.23 -0.29 -0.28 -0.28 -0.27 -0.26 -0.30 -0.27 -0.26 -0.20 -0.18 -0.18 -0.20 -0.20 -0.23 -0.24 -0.23 -0.20 -0.22 -0.25 -0.29 -0.29 -0.28 -0.31 -0.26 -0.22 -0.21 -0.22 -0.23 -0.20 -0.17 -0.16 -0.12 -0.09 -0.06 -0.07 -0.07 -0.05 -0.03 -0.04 -0.06 -0.09 -0.07 -0.12 -0.18 -0.16 -0.16 -0.17 -0.15 -0.14 0.00 0.04 -0.03 -0.08 -0.06 -0.08 -0.10 -0.08 -0.13 -0.13 -0.15 -0.14 -0.07 -0.08 -0.06 -0.03 0.01 0.05 0.07 0.10 0.07 0.03 -0.00 -0.02 -0.04 0.03 0.03 -0.05 -0.03 -0.01 -0.05 -0.07 -0.08 -0.09 -0.08 -0.07 -0.05 -0.07 -0.05 -0.08 0.08 0.12 0.14 -0.02 -0.13 0.01 0.04 -0.10 -0.16 -0.26 -0.27 -0.25 -0.25 -0.26 -0.29 -0.29 -0.34 -0.34 -0.34 -0.29 -0.32 -0.29 -0.27 -0.18 -0.20 -0.17 -0.15 -0.21 -0.25 -0.22 -0.19 -0.23 -0.22 -0.22 -0.16 -0.14 -0.06 0.02 0.05 0.15 0.20 0.23 0.30 0.32 0.25 0.23 0.17 0.14 0.09 0.08 -0.03 -0.02 -0.14 -0.20 -0.19 -0.16 -0.12 -0.10 -0.17 -0.19 -0.18 -0.16 -0.14 -0.08 -0.12 -0.11 -0.06 -0.08 0.00 0.08 0.03 0.08 -0.01 0.01 -0.06 -0.14 -0.06 -0.06 -0.01 0.10 0.09 0.13 0.12 0.09 0.10 0.06 0.07 0.02 -0.00 0.02 0.04 0.08 0.08 0.11 0.10 0.06 0.04 0.01 0.01 -0.02 -0.05 -0.07 -0.11 -0.14 -0.23 -0.28 -0.29 -0.26 -0.14 -0.20 -0.20 -0.27 -0.29 -0.30 -0.16 -0.07 -0.03 -0.05 -0.06 -0.03 -0.01 0.02 0.06 0.10 0.06 0.08 0.11 0.02 0.20 0.22 0.21 0.21 0.20 0.17 0.20 0.19 0.22 0.25 0.29 0.31 0.29 0.31 0.34 0.35 0.29 0.34 0.37 0.37 0.38 0.37 0.37 0.36 0.36 0.37 0.35 0.34 0.34 0.33 0.32 0.30 0.27 0.27 0.18 0.19 0.17 0.18 0.14 0.12 0.12 0.20 0.23 0.29 0.30 0.27 0.30 0.35 0.33 0.30 0.34 0.37 0.37 0.38 0.38 0.36 0.34 0.36 0.34 0.28 0.27 0.28 0.25 0.20 0.22 0.23 0.18 0.20 0.14 0.14 0.10 0.11 0.05 0.02 0.03 0.09 0.15 0.23 0.21 0.13 0.21 0.27 0.16 0.17 0.26 0.24 0.31 0.27 0.28 0.33 0.26 0.26 0.31 0.27 0.24 0.28 0.27 0.22 0.17 0.08 0.02 -0.06 0.01 -0.01 -0.00 -0.03 -0.09 -0.09 -0.07 -0.01 0.07 -0.02 -0.09 -0.04 -0.01 -0.13 -0.16 -0.05 -0.11 0.01 -0.03 0.07 0.09 -0.02 0.01 0.11 0.07 -0.01 0.06 0.11 0.02 -0.02 -0.13 -0.20 -0.22 -0.17 -0.17 -0.15 -0.15 -0.20 -0.21 -0.22 -0.21 -0.19 -0.23 -0.25 -0.24 -0.24 -0.26 -0.26 -0.25 -0.24 -0.21 -0.22 -0.17 -0.16 -0.21 -0.18 -0.13 -0.17 -0.19 -0.14 -0.11 -0.16 -0.19 -0.21 -0.24 -0.25 -0.24 -0.26 -0.25 -0.25 -0.28 -0.28 -0.29 -0.29 -0.28 -0.29 -0.30 -0.29 -0.30 -0.30 -0.30 -0.28 -0.27 -0.27 -0.26 -0.23 -0.26 -0.28 -0.26 -0.26 -0.27 -0.26 -0.23 -0.22 -0.20 -0.21 -0.05 0.25 0.25 0.24 0.21 0.21 0.26 0.20 0.15 0.12 0.10 0.07 -0.01 -0.04 -0.06 -0.09 -0.09
0.90 1.00 0.92 0.77 0.63 0.39 0.36 0.28 0.16 0.19 0.20 0.16 0.13 0.11 0.03 -0.04 -0.11 -0.08 -0.06 -0.10 -0.11 -0.16 -0.12 -0.01 0.15 0.26 0.31 0.31 0.33 0.35 0.35 0.35 0.52 0.61 0.72 0.76 -0.19 -0.22 -0.25 -0.18 -0.17 -0.19 -0.21 -0.17 -0.19 -0.21 -0.23 -0.24 -0.22 -0.24 -0.26 -0.25 -0.23 -0.22 -0.28 -0.27 -0.30 -0.32 -0.28 -0.24 -0.24 -0.20 -0.19 -0.17 -0.19 -0.14 -0.02 0.05 0.11 0.13 0.23 0.24 0.28 0.34 0.33 0.35 0.28 0.27 0.15 0.06 -0.00 -0.01 -0.02 -0.05 -0.14 -0.18 -0.25 -0.24 -0.25 -0.26 -0.28 -0.25 -0.20 -0.23 -0.22 -0.18 -0.14 -0.14 -0.11 -0.08 -0.07 -0.05 -0.03 -0.02 0.02 0.03 0.08 0.02 -0.04 -0.01 -0.11 -0.06 -0.04 0.03 0.04 0.06 -0.01 -0.11 0.07 0.01 0.02 0.08 0.10 0.13 0.18 0.14 0.06 -0.03 -0.01 -0.03 -0.00 -0.07 -0.15 -0.07 0.06 0.11 0.12 0.18 0.27 0.26 0.25 0.21 0.17 0.22 0.22 0.16 0.09 -0.03 -0.03 -0.05 -0.06 -0.10 -0.05 -0.07 -0.07 -0.08 -0.13 -0.08 -0.07 0.02 0.03 0.06 -0.02 -0.06 -0.20 -0.18 -0.14 -0.16 -0.15 -0.16 -0.19 -0.15 -0.09 -0.05 -0.00 0.02 0.07 0.04 0.04 0.04 0.03 0.08 0.02 -0.04 -0.12 -0.16 -0.09 -0.08 -0.04 -0.09 -0.13 -0.20 -0.26 -0.34 -0.36 -0.35 -0.30 -0.33 -0.29 -0.18 -0.10 0.01 0.11 0.14 0.10 0.22 0.18 0.38 0.35 0.32 0.27 0.22 0.09 -0.04 -0.13 -0.15 -0.19 -0.12 -0.13 -0.07 -0.16 -0.22 -0.18 -0.11 -0.06 0.06 0.15 -0.02 -0.09 -0.17 -0.22 -0.29 -0.34 -0.33 -0.34 -0.32 -0.27 -0.28 -0.22 -0.25 -0.24 -0.20 -0.19 -0.29 -0.31 -0.36 -0.37 -0.37 -0.35 -0.35 -0.37 -0.34 -0.33 -0.27 -0.25 -0.24 -0.27 -0.29 -0.32 -0.32 -0.31 -0.28 -0.30 -0.32 -0.34 -0.32 -0.33 -0.36 -0.32 -0.29 -0.27 -0.29 -0.29 -0.29 -0.26 -0.23 -0.18 -0.13 -0.08 -0.07 -0.09 -0.04 -0.05 -0.07 -0.08 -0.10 -0.10 -0.17 -0.25 -0.20 -0.21 -0.22 -0.17 -0.15 -0.01 0.00 -0.10 -0.14 -0.11 -0.17 -0.18 -0.17 -0.24 -0.24 -0.24 -0.22 -0.15 -0.17 -0.15 -0.12 -0.05 0.00 0.05 0.09 0.04 -0.02 -0.07 -0.09 -0.12 -0.04 -0.04 -0.11 -0.07 -0.01 -0.06 -0.08 -0.06 -0.08 -0.08 -0.07 -0.06 -0.07 -0.05 -0.09 0.07 0.16 0.14 -0.07 -0.12 -0.06 -0.01 -0.14 -0.18 -0.29 -0.28 -0.26 -0.24 -0.24 -0.25 -0.24 -0.28 -0.28 -0.28 -0.23 -0.27 -0.26 -0.27 -0.22 -0.21 -0.17 -0.14 -0.17 -0.18 -0.16 -0.14 -0.17 -0.16 -0.17 -0.10 -0.10 -0.03 0.05 0.10 0.21 0.22 0.24 0.32 0.32 0.24 0.24 0.18 0.16 0.12 0.12 0.01 0.02 -0.10 -0.16 -0.16 -0.14 -0.12 -0.13 -0.18 -0.17 -0.17 -0.13 -0.10 -0.03 -0.06 -0.05 -0.01 -0.07 0.00 0.06 0.02 0.04 -0.04 -0.02 -0.07 -0.11 -0.00 -0.04 0.02 0.10 0.10 0.14 0.14 0.11 0.12 0.08 0.09 0.04 0.03 0.04 0.06 0.10 0.10 0.13 0.11 0.07 0.08 0.05 0.05 0.03 0.01 -0.02 -0.04 -0.08 -0.18 -0.23 -0.25 -0.22 -0.10 -0.17 -0.15 -0.20 -0.23 -0.24 -0.08 -0.01 0.05 0.02 0.00 0.02 0.03 0.05 0.09 0.13 0.08 0.09 0.15 0.08 0.24 0.25 0.25 0.23 0.22 0.17 0.22 0.22 0.25 0.30 0.33 0.35 0.33 0.34 0.37 0.37 0.31 0.35 0.37 0.38 0.38 0.38 0.38 0.38 0.37 0.39 0.37 0.36 0.35 0.36 0.34 0.33 0.30 0.30 0.25 0.23 0.19 0.20 0.16 0.14 0.15 0.23 0.27 0.32 0.33 0.30 0.33 0.37 0.34 0.32 0.35 0.36 0.37 0.37 0.37 0.37 0.35 0.36 0.36 0.30 0.29 0.30 0.28 0.22 0.23 0.26 0.22 0.24 0.18 0.19 0.14 0.14 0.09 0.07 0.07 0.13 0.18 0.26 0.22 0.16 0.23 0.27 0.15 0.16 0.25 0.21 0.28 0.22 0.25 0.32 0.25 0.22 0.29 0.27 0.23 0.26 0.26 0.22 0.18 0.10 0.04 -0.02 0.05 0.03 0.04 0.02 -0.04 -0.05 -0.04 0.02 0.07 -0.03 -0.09 -0.05 -0.04 -0.16 -0.18 -0.12 -0.17 -0.05 -0.08 0.03 0.06 -0.05 -0.02 0.10 0.07 -0.02 0.06 0.11 0.03 -0.01 -0.11 -0.19 -0.18 -0.15 -0.16 -0.14 -0.13 -0.19 -0.20 -0.22 -0.20 -0.19 -0.24 -0.25 -0.24 -0.27 -0.28 -0.28 -0.28 -0.27 -0.26 -0.26 -0.22 -0.21 -0.25 -0.23 -0.17 -0.19 -0.22 -0.17 -0.13 -0.18 -0.20 -0.21 -0.25 -0.25 -0.23 -0.25 -0.25 -0.23 -0.28 -0.27 -0.29 -0.29 -0.29 -0.31 -0.32 -0.31 -0.32 -0.32 -0.32 -0.31 -0.30 -0.30 -0.30 -0.28 -0.30 -0.31 -0.30 -0.28 -0.29 -0.29 -0.27 -0.26 -0.24 -0.24 -0.05 0.22 0.24 0.22 0.18 0.18 0.24 0.17 0.10 0.08 0.06 0.01 -0.06 -0.08 -0.09 -0.12 -0.10
0.76 0.92 1.00 0.88 0.74 0.47 0.42 0.33 0.19 0.21 0.24 0.21 0.17 0.15 0.04 -0.05 -0.14 -0.10 -0.07 -0.09 -0.10 -0.16 -0.11 0.03 0.21 0.34 0.38 0.39 0.37 0.37 0.37 0.37 0.56 0.65 0.73 0.74 -0.20 -0.22 -0.26 -0.18 -0.17 -0.18 -0.19 -0.15 -0.17 -0.19 -0.22 -0.22 -0.20 -0.23 -0.24 -0.22 -0.21 -0.21 -0.27 -0.27 -0.30 -0.30 -0.28 -0.24 -0.24 -0.20 -0.20 -0.18 -0.19 -0.15 -0.01 0.08 0.15 0.18 0.29 0.31 0.35 0.43 0.41 0.43 0.35 0.33 0.19 0.07 -0.01 -0.00 -0.01 -0.04 -0.13 -0.18 -0.25 -0.24 -0.26 -0.26 -0.27 -0.24 -0.20 -0.22 -0.20 -0.17 -0.14 -0.12 -0.09 -0.08 -0.06 -0.02 -0.01 0.00 0.03 0.04 0.08 0.04 -0.01 0.01 -0.08 -0.02 0.00 0.07 0.08 0.10 0.03 -0.08 0.10 0.04 0.06 0.14 0.15 0.18 0.23 0.19 0.09 -0.01 0.00 -0.01 0.01 -0.06 -0.15 -0.07 0.07 0.12 0.14 0.22 0.33 0.32 0.32 0.28 0.25 0.30 0.29 0.22 0.14 0.00 -0.00 -0.03 -0.03 -0.07 -0.01 -0.04 -0.04 -0.03 -0.08 -0.03 -0.03 0.05 0.07 0.11 0.03 -0.00 -0.15 -0.14 -0.10 -0.13 -0.12 -0.15 -0.20 -0.15 -0.07 -0.03 0.03 0.05 0.11 0.08 0.06 0.06 0.04 0.07 0.01 -0.06 -0.15 -0.19 -0.10 -0.10 -0.06 -0.11 -0.14 -0.23 -0.30 -0.39 -0.43 -0.41 -0.35 -0.38 -0.33 -0.22 -0.14 -0.01 0.09 0.14 0.08 0.23 0.21 0.42 0.40 0.36 0.29 0.23 0.09 -0.05 -0.16 -0.18 -0.23 -0.15 -0.16 -0.10 -0.20 -0.25 -0.20 -0.13 -0.06 0.07 0.17 -0.02 -0.11 -0.20 -0.26 -0.34 -0.40 -0.39 -0.41 -0.39 -0.34 -0.35 -0.27 -0.32 -0.31 -0.25 -0.25 -0.34 -0.37 -0.43 -0.44 -0.44 -0.43 -0.42 -0.44 -0.39 -0.38 -0.33 -0.30 -0.29 -0.33 -0.35 -0.38 -0.39 -0.38 -0.34 -0.36 -0.37 -0.38 -0.35 -0.37 -0.41 -0.38 -0.35 -0.32 -0.35 -0.35 -0.35 -0.33 -0.30 -0.23 -0.18 -0.11 -0.09 -0.09 -0.04 -0.05 -0.09 -0.11 -0.13 -0.12 -0.21 -0.29 -0.23 -0.26 -0.26 -0.19 -0.16 -0.01 -0.01 -0.12 -0.17 -0.16 -0.23 -0.24 -0.24 -0.30 -0.30 -0.30 -0.27 -0.21 -0.23 -0.21 -0.19 -0.09 -0.02 0.04 0.08 0.02 -0.05 -0.12 -0.14 -0.17 -0.09 -0.09 -0.14 -0.10 -0.02 -0.07 -0.09 -0.06 -0.08 -0.09 -0.08 -0.07 -0.07 -0.04 -0.10 0.06 0.18 0.12 -0.10 -0.13 -0.09 -0.03 -0.17 -0.21 -0.31 -0.30 -0.28 -0.26 -0.24 -0.25 -0.24 -0.27 -0.26 -0.26 -0.22 -0.24 -0.25 -0.27 -0.23 -0.21 -0.17 -0.14 -0.15 -0.14 -0.13 -0.13 -0.14 -0.13 -0.13 -0.05 -0.06 0.00 0.08 0.13 0.25 0.25 0.26 0.34 0.33 0.26 0.26 0.20 0.18 0.15 0.16 0.04 0.06 -0.06 -0.12 -0.13 -0.13 -0.12 -0.15 -0.19 -0.17 -0.16 -0.10 -0.07 0.00 -0.02 -0.02 0.01 -0.04 0.02 0.06 0.01 0.02 -0.05 -0.04 -0.08 -0.09 0.04 -0.02 0.04 0.12 0.12 0.16 0.16 0.13 0.14 0.11 0.11 0.06 0.05 0.06 0.08 0.12 0.12 0.15 0.13 0.09 0.11 0.08 0.08 0.06 0.04 0.03 0.00 -0.03 -0.13 -0.19 -0.23 -0.20 -0.09 -0.16 -0.14 -0.18 -0.20 -0.21 -0.04 -0.00 0.09 0.06 0.04 0.05 0.06 0.08 0.11 0.16 0.12 0.13 0.16 0.10 0.28 0.29 0.29 0.28 0.26 0.21 0.26 0.26 0.30 0.34 0.37 0.38 0.37 0.38 0.40 0.40 0.35 0.38 0.39 0.40 0.39 0.40 0.41 0.40 0.40 0.42 0.40 0.38 0.39 0.39 0.38 0.36 0.34 0.35 0.31 0.28 0.23 0.25 0.21 0.18 0.19 0.27 0.32 0.37 0.37 0.34 0.37 0.40 0.35 0.33 0.37 0.37 0.39 0.38 0.39 0.39 0.38 0.38 0.38 0.33 0.33 0.34 0.31 0.25 0.26 0.30 0.25 0.27 0.21 0.23 0.18 0.19 0.13 0.11 0.11 0.17 0.22 0.28 0.24 0.18 0.26 0.28 0.14 0.14 0.25 0.19 0.29 0.22 0.25 0.32 0.24 0.21 0.29 0.28 0.23 0.25 0.27 0.23 0.20 0.12 0.06 0.00 0.08 0.06 0.08 0.07 -0.02 -0.03 -0.03 0.03 0.07 -0.03 -0.10 -0.06 -0.07 -0.19 -0.21 -0.17 -0.23 -0.11 -0.14 -0.02 0.02 -0.09 -0.06 0.07 0.05 -0.03 0.04 0.10 0.03 -0.00 -0.10 -0.18 -0.16 -0.15 -0.16 -0.14 -0.13 -0.19 -0.20 -0.23 -0.20 -0.21 -0.27 -0.28 -0.26 -0.31 -0.33 -0.32 -0.32 -0.32 -0.31 -0.32 -0.28 -0.26 -0.30 -0.29 -0.22 -0.23 -0.26 -0.22 -0.17 -0.22 -0.22 -0.24 -0.28 -0.27 -0.25 -0.26 -0.25 -0.22 -0.28 -0.28 -0.31 -0.32 -0.32 -0.35 -0.35 -0.34 -0.36 -0.36 -0.35 -0.36 -0.35 -0.36 -0.35 -0.34 -0.35 -0.36 -0.35 -0.33 -0.33 -0.34 -0.33 -0.32 -0.30 -0.29 -0.08 0.19 0.23 0.23 0.15 0.14 0.22 0.15 0.05 0.03 0.01 -0.05 -0.13 -0.12 -0.12 -0.15 -0.09
0.61 0.77 0.88 1.00 0.87 0.59 0.53 0.41 0.26 0.28 0.31 0.27 0.24 0.21 0.08 -0.04 -0.15 -0.12 -0.08 -0.11 -0.12 -0.16 -0.08 0.08 0.29 0.42 0.47 0.47 0.44 0.44 0.45 0.46 0.65 0.66 0.70 0.71 -0.20 -0.24 -0.28 -0.21 -0.20 -0.21 -0.22 -0.17 -0.17 -0.20 -0.24 -0.22 -0.20 -0.23 -0.25 -0.22 -0.21 -0.22 -0.29 -0.29 -0.33 -0.33 -0.30 -0.26 -0.25 -0.20 -0.21 -0.18 -0.20 -0.16 0.01 0.12 0.20 0.24 0.37 0.39 0.44 0.52 0.50 0.52 0.43 0.41 0.25 0.11 0.02 0.04 0.02 -0.03 -0.12 -0.19 -0.27 -0.27 -0.29 -0.29 -0.28 -0.25 -0.22 -0.23 -0.21 -0.18 -0.15 -0.13 -0.10 -0.08 -0.06 -0.02 -0.01 0.01 0.05 0.06 0.11 0.07 0.00 0.04 -0.07 0.01 0.05 0.13 0.14 0.16 0.08 -0.08 0.10 0.07 0.09 0.19 0.22 0.26 0.31 0.25 0.13 0.00 -0.01 -0.01 0.01 -0.06 -0.16 -0.07 0.09 0.15 0.18 0.30 0.41 0.40 0.39 0.34 0.32 0.37 0.35 0.28 0.19 0.04 0.03 -0.00 -0.00 -0.05 0.01 -0.01 -0.02 0.01 -0.05 -0.00 -0.01 0.07 0.10 0.12 0.05 0.02 -0.14 -0.13 -0.08 -0.12 -0.11 -0.15 -0.21 -0.15 -0.06 -0.01 0.07 0.09 0.16 0.13 0.09 0.09 0.07 0.09 0.03 -0.05 -0.16 -0.19 -0.09 -0.08 -0.04 -0.07 -0.12 -0.23 -0.32 -0.43 -0.48 -0.46 -0.40 -0.42 -0.36 -0.24 -0.15 -0.00 0.11 0.17 0.11 0.28 0.27 0.50 0.47 0.42 0.34 0.28 0.10 -0.05 -0.18 -0.20 -0.25 -0.18 -0.20 -0.11 -0.22 -0.28 -0.23 -0.15 -0.07 0.08 0.18 -0.02 -0.12 -0.22 -0.30 -0.39 -0.46 -0.45 -0.46 -0.45 -0.40 -0.40 -0.31 -0.35 -0.34 -0.27 -0.27 -0.38 -0.44 -0.51 -0.51 -0.51 -0.49 -0.48 -0.50 -0.45 -0.43 -0.37 -0.34 -0.32 -0.37 -0.39 -0.44 -0.44 -0.44 -0.39 -0.42 -0.44 -0.45 -0.42 -0.45 -0.48 -0.44 -0.40 -0.37 -0.41 -0.42 -0.41 -0.38 -0.35 -0.28 -0.21 -0.13 -0.10 -0.07 -0.04 -0.04 -0.11 -0.13 -0.15 -0.12 -0.23 -0.32 -0.26 -0.28 -0.29 -0.20 -0.15 0.02 0.02 -0.10 -0.19 -0.19 -0.28 -0.28 -0.28 -0.34 -0.34 -0.34 -0.30 -0.22 -0.27 -0.25 -0.22 -0.12 -0.04 0.03 0.10 0.02 -0.07 -0.14 -0.17 -0.21 -0.13 -0.10 -0.17 -0.13 -0.03 -0.08 -0.11 -0.06 -0.09 -0.10 -0.09 -0.09 -0.08 -0.05 -0.11 0.06 0.19 0.12 -0.13 -0.15 -0.09 -0.01 -0.17 -0.21 -0.33 -0.32 -0.30 -0.28 -0.25 -0.27 -0.26 -0.30 -0.29 -0.28 -0.25 -0.27 -0.28 -0.30 -0.25 -0.25 -0.20 -0.15 -0.15 -0.16 -0.14 -0.14 -0.15 -0.16 -0.12 -0.04 -0.04 0.02 0.10 0.15 0.28 0.28 0.30 0.39 0.38 0.30 0.29 0.25 0.22 0.18 0.18 0.04 0.06 -0.05 -0.14 -0.17 -0.17 -0.17 -0.19 -0.24 -0.21 -0.17 -0.08 -0.04 0.03 0.01 0.01 0.04 -0.02 0.05 0.08 0.01 0.01 -0.08 -0.07 -0.13 -0.14 0.04 -0.03 0.01 0.13 0.15 0.20 0.21 0.18 0.18 0.16 0.15 0.09 0.09 0.11 0.11 0.16 0.17 0.21 0.18 0.14 0.15 0.12 0.11 0.10 0.08 0.06 0.03 -0.00 -0.11 -0.19 -0.25 -0.24 -0.12 -0.20 -0.16 -0.22 -0.23 -0.24 -0.05 -0.03 0.09 0.07 0.05 0.08 0.10 0.12 0.16 0.21 0.17 0.17 0.18 0.10 0.31 0.35 0.34 0.33 0.32 0.25 0.31 0.31 0.35 0.39 0.42 0.44 0.42 0.43 0.45 0.45 0.40 0.43 0.44 0.45 0.45 0.45 0.46 0.46 0.45 0.47 0.46 0.44 0.44 0.45 0.43 0.42 0.39 0.40 0.34 0.33 0.28 0.29 0.26 0.22 0.23 0.31 0.36 0.42 0.41 0.38 0.42 0.45 0.39 0.36 0.41 0.40 0.43 0.43 0.44 0.45 0.43 0.43 0.43 0.39 0.37 0.40 0.36 0.28 0.30 0.34 0.29 0.31 0.24 0.26 0.21 0.22 0.16 0.13 0.13 0.19 0.24 0.31 0.25 0.18 0.28 0.29 0.13 0.12 0.25 0.19 0.33 0.27 0.28 0.35 0.26 0.24 0.32 0.31 0.25 0.28 0.30 0.25 0.22 0.13 0.05 -0.01 0.08 0.06 0.08 0.08 -0.02 -0.04 -0.05 0.01 0.06 -0.07 -0.14 -0.09 -0.12 -0.25 -0.27 -0.22 -0.30 -0.17 -0.20 -0.07 -0.03 -0.14 -0.11 0.04 0.02 -0.08 0.00 0.08 0.01 -0.03 -0.13 -0.23 -0.20 -0.18 -0.19 -0.17 -0.15 -0.22 -0.23 -0.26 -0.24 -0.25 -0.32 -0.33 -0.32 -0.37 -0.39 -0.38 -0.38 -0.38 -0.38 -0.39 -0.35 -0.33 -0.37 -0.35 -0.28 -0.29 -0.32 -0.28 -0.23 -0.28 -0.28 -0.29 -0.34 -0.33 -0.29 -0.31 -0.29 -0.26 -0.32 -0.33 -0.36 -0.37 -0.38 -0.41 -0.41 -0.40 -0.42 -0.42 -0.41 -0.41 -0.41 -0.42 -0.42 -0.40 -0.42 -0.43 -0.42 -0.41 -0.40 -0.40 -0.39 -0.38 -0.36 -0.34 -0.13 0.18 0.24 0.25 0.14 0.12 0.22 0.14 0.03 0.00 -0.02 -0.09 -0.17 -0.15 -0.16 -0.19 -0.10
Given that your pasted data doesn't match your description I'm going to go with the last part of your question... the sum of rows 1-2 and columns 300-400.
datf <- read.table('myGreatDataFile')
sum( datf[1:2, 300:400] )
You should look in help at all the features of read.table (help(read.table)) and also for indexing data frames, which are the type returned by read.table (help('[')).
But what you really need to do is go through one of the introductory manuals for R. Judging by your question I suggest that you DO NOT attempt to read any of the R manuals at the main site except "An Introduction to R". If you get through that and need more help your next best step is go back to the manuals section but go to the contributed documentation linked near the bottom.
(and also read the FAQ about asking questions which was a link to the right of the page when you were editing your question)