Solved
I am very new to R. I am having difficulties understanding how resolve a couple of error messages.
Warning messages:
1: In if (!header) rlabp <- FALSE :
the condition has length > 1 and only the first element will be used
2: In if (header) { :
the condition has length > 1 and only the first element will be used
and
Error in scan(file, what = "", sep = sep, quote = quote, nlines = 1, quiet = TRUE, :
invalid 'sep' value: must be one byte
I need to save both matrix1 and matrix2 to separate text files. For matrix1 use commas to delimit the data values and for matrix2 use tabs.
below is what I have entered into R thus far.
v1 <- (-5:10)
v2 <- seq(from=pi, to=2*pi)
v3 <- seq(5, -1, -0.35)
myData <- c(v1,v2,v3)
n <- max(length(v3))
length(v3) <- n
length(v2) <- n
length(v1) <- n
rbind(v1,v2,v3)
matrix1 <- rbind(v1,v2,v3)
write.csv(matrix1, file="matrix1.csv", row.names=TRUE, na="NA")
read.csv(matrix1, file="matrix1.csv", sep=",")
n <- max(length(v3))
length(v3) <- n
length(v2) <- n
length(v1) <- n
cbind(v1,v2,v3)
matrix2 <- cbind(v1,v2,v3)
write.csv(matrix2, file="matrix2.csv", row.names=TRUE, na="NA")
read.csv(matrix2, file="matrix2.csv", sep="/tab")
I am very new to R. I am having difficulties understanding how resolve a couple of error messages.
Warning messages:
1: In if (!header) rlabp <- FALSE :
the condition has length > 1 and only the first element will be used
2: In if (header) { :
the condition has length > 1 and only the first element will be used
and
Error in scan(file, what = "", sep = sep, quote = quote, nlines = 1, quiet = TRUE, :
invalid 'sep' value: must be one byte
I need to save both matrix1 and matrix2 to separate text files. For matrix1 use commas to delimit the data values and for matrix2 use tabs.
below is what I have entered into R thus far.
v1 <- (-5:10)
v2 <- seq(from=pi, to=2*pi)
v3 <- seq(5, -1, -0.35)
myData <- c(v1,v2,v3)
n <- max(length(v3))
length(v3) <- n
length(v2) <- n
length(v1) <- n
rbind(v1,v2,v3)
matrix1 <- rbind(v1,v2,v3)
write.csv(matrix1, file="matrix1.csv", row.names=TRUE, na="NA")
read.csv(matrix1, file="matrix1.csv", sep=",")
n <- max(length(v3))
length(v3) <- n
length(v2) <- n
length(v1) <- n
cbind(v1,v2,v3)
matrix2 <- cbind(v1,v2,v3)
write.csv(matrix2, file="matrix2.csv", row.names=TRUE, na="NA")
read.csv(matrix2, file="matrix2.csv", sep="/tab")
Last edited: