社区!
我想这是我在这个网站上的第一个问题的时候了。希望我能清楚地描述一下:
背景:目前,我正在尝试编写一个脚本,用于清理,子集化和绘制.csv文件中的数据。一个专业"关于原始数据是每个时间点有4种不同的测量值,数据分类为" O分钟...... 30分钟..... 49分30秒..... 0分钟。 ...... 30分钟......"直到整个时间跨度完成4次。
install.packages("ggplot2")
library(ggplot2)
results<-read.csv(file="Rnase alert _Ecoli target_20170906_afternoon1.csv", header = FALSE, stringsAsFactors = FALSE, sep = ";")
rownames(results)<-results[,3] #set column with samplenames as rownames and remove unneccessary columns
results<-results[,-(1:3)]
colnames(results)<-results[2,] #same for colnames, now rownames = samples and colnames= timepoints
results<-results[-(1:2),]
starts<-as.vector(col(results)[which(results == "0 min ")]) #check the start timepoints (there is multiple datasets in the one file)
starts #there are 4 starts-->4 different sets in the file
results1<-subset(results,select = (starts[1]:(starts[2]-1) )) #create subsets each going from "0 min" to latest timepoint
results2<-subset(results,select = (starts[2]:(starts[3]-1) ))
results3<-subset(results,select = (starts[3]:(starts[4]-1) ))
results4<-subset(results,select = (starts[4]:ncol(results)))
results1<-data.frame(t(results1)) #change rows and columns for easier plotting
results2<-data.frame(t(results2))
results3<-data.frame(t(results3))
results4<-data.frame(t(results4))
View(results4) #everything looks perfect
timeinseconds<-seq(0,2970,30) #create a vector with timeponts from 0 sec to 49min30sec in seconds because timepoints in original dataset contain text
从现在开始,事情发生了变化:
par(mfrow=c(1,1))
plot(timeinseconds,results1$Sample.X1,type = "l") #result: instead of 80,000, the max. Y-value is 100, while the timepoints are correctly scaled; overay of graphs is intended
lines(timeinseconds,results1$Sample.X2,type = "l")
lines(timeinseconds,results1$Sample.X3,type = "l")
lines(timeinseconds,results1$Sample.X4,type = "l")
lines(timeinseconds,results1$Sample.X5,type = "l")
lines(timeinseconds,results1$Sample.X6,type = "l")
lines(timeinseconds,results1$Sample.X7,type = "l")
lines(timeinseconds,results1$Sample.X8,type = "l")
lines(timeinseconds,results1$Sample.X9,type = "l")
lines(timeinseconds,results1$Sample.X10,type = "l")
当值范围从30,000到80,0000时,Y轴显示从0到100的范围.X轴的尺寸正确,符合&#34; timeinseconds&#34;。并且没有错误消息。
以前尝试过这样做:
results1$Sample.X1<-as.numeric(results1$Sample.X1) #manually setting the first column from factor to numeric: no change
此外,将表与&#34; timeinseconds&#34; -vector与colbind合并并不会改变事物。使用&#34; results1&#34;检查子集时或&#34;查看(results1)&#34;每个值都是正确的。
在寻找最后6小时的解决方案后,我很无知出了什么问题,但我觉得这是一个小错误,你们马上就能看到错误^^。
提前致谢!