plot - Scatterplot with R from text file with log scale -


i have data saved in text file couple thousands line. each line has 1 value. this

52312 2 3 4 5 7 9 4 5 3 

the first value 10.000 times bigger other values.

i can read in data data<-read.table("data.txt")

when use plot(data) data have same y-value, resulting in line, x values represent values given data.

what want, however, x-value represents linenumber , y-value actual data. above example values (1,52312), (2,2), (3,3), (4,4), (5,5), (6,7), (7,9), (8,4), (9,5), (10,3).

also, since first value way higher other values, i'd use log scale y-axis.

sorry, new r.

set.seed(1000)     df = data.frame(a=c(9999999,sample(2:78,77,replace = f))) plot(x=1:nrow(df), y=log(df$a)) 

i) set.seed(1000) helps reproduce same random numbers sample() each time run code. makes code reproducible.

ii) type ?sample in r console documentation. iii) since wanted x-axis linenumber - create using ":" operator. 1:3 = 1,2,3. similarily created "id" index using 1:nrow(df) create based on dimension of data.

iv) log ,just use simple :). read more ?plot , parameters


Comments

Popular posts from this blog

asynchronous - C# WinSCP .NET assembly: How to upload multiple files asynchronously -

aws api gateway - SerializationException in posting new Records via Dynamodb Proxy Service in API -

asp.net - Problems sending emails from forum -